On 3/10/22 03:08, Janosch Frank wrote:
Checking d_class in dump_info leads to lengthy conditionals so let's
shorten things a bit by introducing a helper function.

Signed-off-by: Janosch Frank <fran...@linux.ibm.com>
---
  dump/dump.c | 19 ++++++++++++-------
  1 file changed, 12 insertions(+), 7 deletions(-)

Reviewed-by: Richard Henderson <richard.hender...@linaro.org>

@@ -1007,7 +1012,7 @@ out:
static void write_dump_header(DumpState *s, Error **errp)
  {
-    if (s->dump_info.d_class == ELFCLASS32) {
+    if (!dump_is_64bit(s)) {
          create_header32(s, errp);
      } else {
          create_header64(s, errp);
@@ -1697,7 +1702,7 @@ static void dump_init(DumpState *s, int fd, bool 
has_format,
          uint32_t size;
          uint16_t format;
- note_head_size = s->dump_info.d_class == ELFCLASS32 ?
+        note_head_size = !dump_is_64bit(s) ?
              sizeof(Elf32_Nhdr) : sizeof(Elf64_Nhdr);

It would be nice to standardize on positive tests, which in this case would reverse these two conditionals.


r~

Reply via email to