From: Philippe Mathieu-Daudé Date: Wed, 8 Oct 2025 06:14:37 +0000 (+0200) Subject: hw/loongarch/boot: Remove unnecessary cast to target_ulong X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=faf1fae7645303180b1404716cb2e9d740f0eb2e;p=thirdparty%2Fqemu.git hw/loongarch/boot: Remove unnecessary cast to target_ulong Reduce initrd_size scope. It is already of signed type (ssize_t), no need to cast to unsigned for the comparison. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Message-Id: <20251009201947.34643-2-philmd@linaro.org> --- diff --git a/hw/loongarch/boot.c b/hw/loongarch/boot.c index a516415822..3dd48cb8aa 100644 --- a/hw/loongarch/boot.c +++ b/hw/loongarch/boot.c @@ -306,7 +306,7 @@ static ram_addr_t alloc_initrd_memory(struct loongarch_boot_info *info, static int64_t load_kernel_info(struct loongarch_boot_info *info) { uint64_t kernel_entry, kernel_low, kernel_high, initrd_offset = 0; - ssize_t kernel_size, initrd_size; + ssize_t kernel_size; kernel_size = load_elf(info->kernel_filename, NULL, cpu_loongarch_virt_to_phys, NULL, @@ -328,7 +328,8 @@ static int64_t load_kernel_info(struct loongarch_boot_info *info) } if (info->initrd_filename) { - initrd_size = get_image_size(info->initrd_filename); + ssize_t initrd_size = get_image_size(info->initrd_filename); + if (initrd_size > 0) { initrd_offset = ROUND_UP(kernel_high + 4 * kernel_size, 64 * KiB); initrd_offset = alloc_initrd_memory(info, initrd_offset, @@ -337,7 +338,7 @@ static int64_t load_kernel_info(struct loongarch_boot_info *info) initrd_offset, initrd_size); } - if (initrd_size == (target_ulong)-1) { + if (initrd_size == -1) { error_report("could not load initial ram disk '%s'", info->initrd_filename); exit(1);