From: Paul Floyd Date: Sat, 28 Sep 2024 06:20:25 +0000 (+0200) Subject: Compiler warning in ML_(check_elf_and_get_rw_loads) X-Git-Tag: VALGRIND_3_24_0~61 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9626d20f0151c1b34d511c82796d7b34aabc5939;p=thirdparty%2Fvalgrind.git Compiler warning in ML_(check_elf_and_get_rw_loads) GCC 12.2 complains that previous_rw_a_phdr.p_vaddr + previous_rw_a_phdr.p_filesz may be using p_filesz uninitialized That's only possible if ML_(img_get) somehow fails to read all of a program header such that p_memsz is greater than 0 but p_filesz remains uninitialized. Hardly likely since p_memsz comes after p_filesz in the structure. --- diff --git a/coregrind/m_debuginfo/readelf.c b/coregrind/m_debuginfo/readelf.c index b037b9201..1d6ec55a0 100644 --- a/coregrind/m_debuginfo/readelf.c +++ b/coregrind/m_debuginfo/readelf.c @@ -3902,6 +3902,8 @@ Bool ML_(check_elf_and_get_rw_loads) ( Int fd, const HChar* filename, /* Sets p_memsz to 0 to indicate we have not yet a previous a_phdr. */ previous_rw_a_phdr.p_memsz = 0; + /* and silence compiler warnings */ + previous_rw_a_phdr.p_filesz = 0; for (i = 0U; i < phdr_mnent; i++) { ElfXX_Phdr a_phdr;