]> www.infradead.org Git - users/dwmw2/qemu.git/commitdiff
hw/loader: Clarify local variable name in load_elf_ram_sym()
authorPhilippe Mathieu-Daudé <philmd@linaro.org>
Sun, 26 Jan 2025 13:54:00 +0000 (14:54 +0100)
committerPhilippe Mathieu-Daudé <philmd@linaro.org>
Fri, 31 Jan 2025 18:36:44 +0000 (19:36 +0100)
load_elf_ram_sym() compares target_data_order versus
host data_order. Rename 'data_order' -> 'host_data_order'
to ease code review. Avoid the preprocessor by directly
checking HOST_BIG_ENDIAN.

Reviewed-by: BALATON Zoltan <balaton@eik.bme.hu>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20250127113824.50177-4-philmd@linaro.org>

hw/core/loader.c

index ead10fb6cb51888a8a08e4bf16dd6fc1563342f8..de6b173f4a1fd7e95923de69198794a7e0f1d42f 100644 (file)
@@ -443,7 +443,8 @@ ssize_t load_elf_ram_sym(const char *filename,
                          int clear_lsb, int data_swab,
                          AddressSpace *as, bool load_rom, symbol_fn_t sym_cb)
 {
-    int fd, data_order, target_data_order, must_swab;
+    const int host_data_order = HOST_BIG_ENDIAN ? ELFDATA2MSB : ELFDATA2LSB;
+    int fd, target_data_order, must_swab;
     ssize_t ret = ELF_LOAD_FAILED;
     uint8_t e_ident[EI_NIDENT];
 
@@ -461,12 +462,7 @@ ssize_t load_elf_ram_sym(const char *filename,
         ret = ELF_LOAD_NOT_ELF;
         goto fail;
     }
-#if HOST_BIG_ENDIAN
-    data_order = ELFDATA2MSB;
-#else
-    data_order = ELFDATA2LSB;
-#endif
-    must_swab = data_order != e_ident[EI_DATA];
+    must_swab = host_data_order != e_ident[EI_DATA];
     if (big_endian) {
         target_data_order = ELFDATA2MSB;
     } else {