summary refs log tree commit diff stats
path: root/dump/dump.c
diff options
context:
space:
mode:
authorJanosch Frank <frankja@linux.ibm.com>2022-03-30 12:35:58 +0000
committerMarc-André Lureau <marcandre.lureau@redhat.com>2022-04-22 13:36:03 +0400
commit344107e07bd81546474a54ab83800158ca953059 (patch)
treead583d4f2e2242f1d902c9dcf2a5041c1e7dc73e /dump/dump.c
parent862a395858e5a302ed5921487777acdc95a3a31b (diff)
downloadfocaccia-qemu-344107e07bd81546474a54ab83800158ca953059.tar.gz
focaccia-qemu-344107e07bd81546474a54ab83800158ca953059.zip
dump: Remove the section if when calculating the memory offset
When s->shdr_num is 0 we'll add 0 bytes of section headers which is
equivalent to not adding section headers but with the multiplication
we can remove a if/else.

Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20220330123603.107120-5-frankja@linux.ibm.com>
Diffstat (limited to 'dump/dump.c')
-rw-r--r--dump/dump.c24
1 files changed, 8 insertions, 16 deletions
diff --git a/dump/dump.c b/dump/dump.c
index 285ed4475b..9c80680eb2 100644
--- a/dump/dump.c
+++ b/dump/dump.c
@@ -1817,23 +1817,15 @@ static void dump_init(DumpState *s, int fd, bool has_format,
     }
 
     if (s->dump_info.d_class == ELFCLASS64) {
-        if (s->shdr_num) {
-            s->memory_offset = sizeof(Elf64_Ehdr) +
-                               sizeof(Elf64_Phdr) * s->phdr_num +
-                               sizeof(Elf64_Shdr) * s->shdr_num + s->note_size;
-        } else {
-            s->memory_offset = sizeof(Elf64_Ehdr) +
-                               sizeof(Elf64_Phdr) * s->phdr_num + s->note_size;
-        }
+        s->memory_offset = sizeof(Elf64_Ehdr) +
+                           sizeof(Elf64_Phdr) * s->phdr_num +
+                           sizeof(Elf64_Shdr) * s->shdr_num +
+                           s->note_size;
     } else {
-        if (s->shdr_num) {
-            s->memory_offset = sizeof(Elf32_Ehdr) +
-                               sizeof(Elf32_Phdr) * s->phdr_num +
-                               sizeof(Elf32_Shdr) * s->shdr_num + s->note_size;
-        } else {
-            s->memory_offset = sizeof(Elf32_Ehdr) +
-                               sizeof(Elf32_Phdr) * s->phdr_num + s->note_size;
-        }
+        s->memory_offset = sizeof(Elf32_Ehdr) +
+                           sizeof(Elf32_Phdr) * s->phdr_num +
+                           sizeof(Elf32_Shdr) * s->shdr_num +
+                           s->note_size;
     }
 
     return;