This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] elf.c: initialize st_mode member


From: Mingli Yu <Mingli.Yu@windriver.com>

Initialize st_mode member to fix the below
build failure when -Og included in compiler flag.
| ./../../../../../../../../work-shared/gcc-8.3.0-r0/gcc-8.3.0/libsanitizer/libbacktrace/../../libbacktrace/elf.c: In function 'elf_is_symlink':
| ../../../../../../../../../work-shared/gcc-8.3.0-r0/gcc-8.3.0/libsanitizer/libbacktrace/../../libbacktrace/elf.c:772:21: error: 'st.st_mode' may be used uninitialized in this function [-Werror=maybe-uninitialized]
   return S_ISLNK (st.st_mode);

Signed-off-by: Mingli Yu <Mingli.Yu@windriver.com>
---
 libbacktrace/elf.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libbacktrace/elf.c b/libbacktrace/elf.c
index f4863f0..561bdc2 100644
--- a/libbacktrace/elf.c
+++ b/libbacktrace/elf.c
@@ -766,6 +766,7 @@ static int
 elf_is_symlink (const char *filename)
 {
   struct stat st;
+  st.st_mode = 0;
 
   if (lstat (filename, &st) < 0)
     return 0;
-- 
2.7.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]