From 9626d20f0151c1b34d511c82796d7b34aabc5939 Mon Sep 17 00:00:00 2001 From: Paul Floyd Date: Sat, 28 Sep 2024 08:20:25 +0200 Subject: [PATCH] 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. --- coregrind/m_debuginfo/readelf.c | 2 ++ 1 file changed, 2 insertions(+) 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; -- 2.47.2