[PATCH] malloc: Cleanup warnings
Wilco Dijkstra
Wilco.Dijkstra@arm.com
Wed Mar 11 17:30:27 GMT 2026
Cleanup warnings - malloc builds with -Os and -Og without needing any
complex warning avoidance defines.
---
diff --git a/malloc/malloc-check.c b/malloc/malloc-check.c
index fba7242190813d3b905d006fe039d2b6a22126b6..a78d79b6bde6ad113e3d6494bb296cb45f2541e1 100644
--- a/malloc/malloc-check.c
+++ b/malloc/malloc-check.c
@@ -314,12 +314,6 @@ realloc_check (void *oldmem, size_t bytes)
newmem = _int_realloc (&main_arena, oldp, chunksize (oldp), chnb);
}
- DIAG_PUSH_NEEDS_COMMENT;
-#if __GNUC_PREREQ (7, 0)
- /* GCC 7 warns about magic_p may be used uninitialized. But we never
- reach here if magic_p is uninitialized. */
- DIAG_IGNORE_NEEDS_COMMENT_GCC (7, "-Wmaybe-uninitialized");
-#endif
/* mem2chunk_check changed the magic byte in the old chunk.
If newmem is NULL, then the old chunk will still be used though,
so we need to invert that change here. */
diff --git a/malloc/malloc.c b/malloc/malloc.c
index 4aac196533d896353e3a32e34fa143d03eb82627..6455a1b0e0b85da0caaba4a5d922e1660fab5bb5 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -233,9 +233,6 @@
/* For ALIGN_UP et. al. */
#include <libc-pointer-arith.h>
-/* For DIAG_PUSH/POP_NEEDS_COMMENT et al. */
-#include <libc-diag.h>
-
/* For memory tagging. */
#include <libc-mtag.h>
@@ -3099,7 +3096,7 @@ tcache_get_align (size_t nb, size_t alignment)
tcache_entry **tep = & tcache->entries[tc_idx];
tcache_entry *te = *tep;
bool mangled = false;
- size_t csize;
+ size_t csize = 0;
while (te != NULL
&& ((csize = chunksize (mem2chunk (te))) < nb
@@ -3111,16 +3108,10 @@ tcache_get_align (size_t nb, size_t alignment)
mangled = true;
}
- /* GCC compiling for -Os warns on some architectures that csize may be
- uninitialized. However, if 'te' is not NULL, csize is always
- initialized in the loop above. */
- DIAG_PUSH_NEEDS_COMMENT;
- DIAG_IGNORE_Os_NEEDS_COMMENT (12, "-Wmaybe-uninitialized");
if (te != NULL
&& csize == nb
&& PTR_IS_ALIGNED (te, alignment))
return tag_new_usable (tcache_get_n (tc_idx, tep, mangled));
- DIAG_POP_NEEDS_COMMENT;
}
return NULL;
}
More information about the Libc-alpha
mailing list