On Mon, Mar 18, 2019 at 11:19 AM Ian Lance Taylor <i...@google.com> wrote:
>
> On Sun, Mar 17, 2019 at 6:22 PM <james.hillia...@gmail.com> wrote:
> >
> > From: James Hilliard <james.hillia...@gmail.com>
> >
> > Fixes error: ‘st.st_mode’ may be used uninitialized in this function
> > ---
> >  libbacktrace/elf.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/libbacktrace/elf.c b/libbacktrace/elf.c
> > index f3988ec02a0..714bfec965d 100644
> > --- a/libbacktrace/elf.c
> > +++ b/libbacktrace/elf.c
> > @@ -765,7 +765,7 @@ elf_syminfo (struct backtrace_state *state, uintptr_t 
> > addr,
> >  static int
> >  elf_is_symlink (const char *filename)
> >  {
> > -  struct stat st;
> > +  struct stat st={0};
> >
> >    if (lstat (filename, &st) < 0)
> >      return 0;
>
> I can't see why that is needed.  The variable is initialized right
> there on the next non-blank line.  If the compiler is giving a
> warning, then we need to fix the compiler.
This is the message I get:
../../../../libsanitizer/libbacktrace/../../libbacktrace/elf.c: In
function ‘elf_is_symlink’:
../../../../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);
                     ^
>
> Ian

Reply via email to