Use the function argument "name" instead of hardcoded
"VMCOREINFO". All callers use "VMCOREINFO" as argument, so this isn't
an exposed bug, thankfully.
Simplify a little bit the code while touching this.
Suggested-by: Andrew Jones <drjones@redhat.com>
Reported-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
dump.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/dump.c b/dump.c
index d4a8c942eb..e9dfed060a 100644
--- a/dump.c
+++ b/dump.c
@@ -788,12 +788,7 @@ static bool note_name_equal(DumpState *s,
get_note_sizes(s, note, &head_size, &name_size, NULL);
head_size = ROUND_UP(head_size, 4);
- if (name_size != len ||
- memcmp(note + head_size, "VMCOREINFO", len)) {
- return false;
- }
-
- return true;
+ return name_size == len && memcmp(note + head_size, name, len) == 0;
}
/* write common header, sub header and elf note to vmcore */
--
2.15.1.355.g36791d7216
On 12/12/17 16:09, Marc-André Lureau wrote: > Use the function argument "name" instead of hardcoded > "VMCOREINFO". All callers use "VMCOREINFO" as argument, so this isn't > an exposed bug, thankfully. > > Simplify a little bit the code while touching this. > > Suggested-by: Andrew Jones <drjones@redhat.com> > Reported-by: Laszlo Ersek <lersek@redhat.com> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> > --- > dump.c | 7 +------ > 1 file changed, 1 insertion(+), 6 deletions(-) > > diff --git a/dump.c b/dump.c > index d4a8c942eb..e9dfed060a 100644 > --- a/dump.c > +++ b/dump.c > @@ -788,12 +788,7 @@ static bool note_name_equal(DumpState *s, > get_note_sizes(s, note, &head_size, &name_size, NULL); > head_size = ROUND_UP(head_size, 4); > > - if (name_size != len || > - memcmp(note + head_size, "VMCOREINFO", len)) { > - return false; > - } > - > - return true; > + return name_size == len && memcmp(note + head_size, name, len) == 0; > } > > /* write common header, sub header and elf note to vmcore */ > Reviewed-by: Laszlo Ersek <lersek@redhat.com>
On Tue, Dec 12, 2017 at 04:09:09PM +0100, Marc-André Lureau wrote: > Use the function argument "name" instead of hardcoded > "VMCOREINFO". All callers use "VMCOREINFO" as argument, so this isn't > an exposed bug, thankfully. > > Simplify a little bit the code while touching this. > > Suggested-by: Andrew Jones <drjones@redhat.com> > Reported-by: Laszlo Ersek <lersek@redhat.com> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> > --- > dump.c | 7 +------ > 1 file changed, 1 insertion(+), 6 deletions(-) > > diff --git a/dump.c b/dump.c > index d4a8c942eb..e9dfed060a 100644 > --- a/dump.c > +++ b/dump.c > @@ -788,12 +788,7 @@ static bool note_name_equal(DumpState *s, > get_note_sizes(s, note, &head_size, &name_size, NULL); > head_size = ROUND_UP(head_size, 4); > > - if (name_size != len || > - memcmp(note + head_size, "VMCOREINFO", len)) { > - return false; > - } > - > - return true; > + return name_size == len && memcmp(note + head_size, name, len) == 0; > } > > /* write common header, sub header and elf note to vmcore */ > -- > 2.15.1.355.g36791d7216 > Reviewed-by: Andrew Jones <drjones@redhat.com>
© 2016 - 2024 Red Hat, Inc.