]> git.ipfire.org Git - thirdparty/elfutils.git/commit
stacktrace: Init elf_fd in sysprof_init_dwfl
authorMark Wielaard <mark@klomp.org>
Thu, 24 Oct 2024 09:06:08 +0000 (11:06 +0200)
committerMark Wielaard <mark@klomp.org>
Thu, 24 Oct 2024 16:37:30 +0000 (18:37 +0200)
commitdce324303198545e1c5484d912e5f259b1d4953d
treed93223b4cc3b594fcbed555a4c33f08c9f34f60a
parent42b19e54393f031e6355cf0658e9518571e85ed3
stacktrace: Init elf_fd in sysprof_init_dwfl

When building with LTO gcc believes elf_fd can be used uninitialized:

In function ‘sysprof_init_dwfl’,
    inlined from ‘sysprof_unwind_cb’ at stacktrace.c:1235:16:
stacktrace.c:1087:7: error: ‘elf_fd’ may be used uninitialized [-Werror=maybe-uninitialized]
 1087 |       close (elf_fd);
      |       ^

This code won't be reached because if find_procfile doesn't initialize
elf_fd, it will return an error. But help the compiler by initializing
elf_fd to -1.

* src/stacktrace.c (sysprof_init_dwfl): Init elf_fd to -1.

Signed-off-by: Mark Wielaard <mark@klomp.org>
src/stacktrace.c