[glibc/azanella/clang] elf: Supress clang -Wsometimes-uninitialized on _dl_debug_initialize
Adhemerval Zanella
azanella@sourceware.org
Thu Apr 10 18:12:38 GMT 2025
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=a3ccba50e36f29383cf2af8147e17c347426e1f5
commit a3ccba50e36f29383cf2af8147e17c347426e1f5
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Wed Aug 24 12:25:05 2022 -0300
elf: Supress clang -Wsometimes-uninitialized on _dl_debug_initialize
clang issues an warning where variable 'r' is used uninitialized
whenever 'if' condition is false. The _dl_debug_initialize is called
for static case always with LM_ID_BASE (csu/libc-start.c and
elf/dl-reloc-static-pie.c) and DL_NSS will be always larger than 1
for shared case.
Diff:
---
elf/dl-debug.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/elf/dl-debug.c b/elf/dl-debug.c
index 5ff1460ab7..5a4c0613f7 100644
--- a/elf/dl-debug.c
+++ b/elf/dl-debug.c
@@ -17,6 +17,7 @@
<https://www.gnu.org/licenses/>. */
#include <ldsodefs.h>
+#include <libc-diag.h>
/* These are the members in the public `struct link_map' type.
@@ -54,7 +55,15 @@ _dl_debug_update (Lmid_t ns)
struct r_debug *
_dl_debug_initialize (ElfW(Addr) ldbase, Lmid_t ns)
{
- struct r_debug_extended *r, **pp = NULL;
+ /* clang issues an warning where variable 'r' is used uninitialized whenever
+ 'if' condition is false. The _dl_debug_initialize is called for static
+ case always with LM_ID_BASE (csu/libc-start.c and
+ elf/dl-reloc-static-pie.c) and DL_NSS will be always larger than 1 for
+ shared case. */
+ DIAG_PUSH_NEEDS_COMMENT_CLANG;
+ DIAG_IGNORE_NEEDS_COMMENT_CLANG (18, "-Wsometimes-uninitialized");
+ struct r_debug_extended *r;
+ struct r_debug_extended **pp = NULL;
if (ns == LM_ID_BASE)
{
@@ -81,6 +90,7 @@ _dl_debug_initialize (ElfW(Addr) ldbase, Lmid_t ns)
r->base.r_version = 2;
}
}
+ DIAG_POP_NEEDS_COMMENT_CLANG;
if (r->base.r_brk == 0)
{
More information about the Glibc-cvs
mailing list