]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Fix malloc tests build with GCC 10.
authorJoseph Myers <joseph@codesourcery.com>
Mon, 10 Jun 2019 22:12:08 +0000 (22:12 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Mon, 10 Jun 2019 22:12:08 +0000 (22:12 +0000)
GCC mainline has recently added warn_unused_result attributes to some
malloc-like built-in functions, where glibc previously had them in its
headers only for __USE_FORTIFY_LEVEL > 0.  This results in those
attributes being newly in effect for building the glibc testsuite, so
resulting in new warnings that break the build where tests
deliberately call such functions and ignore the result.  Thus patch
duly adds calls to DIAG_* macros around those calls to disable the
warning.

Tested with build-many-glibcs.py for aarch64-linux-gnu.

* malloc/tst-calloc.c: Include <libc-diag.h>.
(null_test): Ignore -Wunused-result around calls to calloc.
* malloc/tst-mallocfork.c: Include <libc-diag.h>.
(do_test): Ignore -Wunused-result around call to malloc.

ChangeLog
malloc/tst-calloc.c
malloc/tst-mallocfork.c

index 55afdcbfbda07feadf403ed8c7e9ef18947053da..e3f60702ea278c3cee1aa774b1bb6cc6ca410424 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2019-06-10  Joseph Myers  <joseph@codesourcery.com>
+
+       * malloc/tst-calloc.c: Include <libc-diag.h>.
+       (null_test): Ignore -Wunused-result around calls to calloc.
+       * malloc/tst-mallocfork.c: Include <libc-diag.h>.
+       (do_test): Ignore -Wunused-result around call to malloc.
+
 2019-06-07  Florian Weimer  <fweimer@redhat.com>
 
        Linux: Add getdents64 system call.
index 1eac6aecfc618e7a631a6cdd66799d3d3e0a1037..aa3f26d7d7cc6e8d01b01cfa05486f0929ce416f 100644 (file)
@@ -22,6 +22,7 @@
 #include <malloc.h>
 #include <stdlib.h>
 #include <stdio.h>
+#include <libc-diag.h>
 
 
 /* Number of samples per size.  */
@@ -95,12 +96,16 @@ static void
 null_test (void)
 {
   /* If the size is 0 the result is implementation defined.  Just make
-     sure the program doesn't crash.  */
+     sure the program doesn't crash.  The result of calloc is
+     deliberately ignored, so do not warn about that.  */
+  DIAG_PUSH_NEEDS_COMMENT;
+  DIAG_IGNORE_NEEDS_COMMENT (10, "-Wunused-result");
   calloc (0, 0);
   calloc (0, UINT_MAX);
   calloc (UINT_MAX, 0);
   calloc (0, ~((size_t) 0));
   calloc (~((size_t) 0), 0);
+  DIAG_POP_NEEDS_COMMENT;
 }
 
 
index 4ff6ec09f4446ed3388011421a1bf6b3afcafddb..00851a16c3f15a5f30be1bda42677dad3d3e3f4b 100644 (file)
@@ -7,6 +7,7 @@
 #include <unistd.h>
 #include <sys/types.h>
 #include <sys/wait.h>
+#include <libc-diag.h>
 
 static void
 sig_handler (int signum)
@@ -25,7 +26,12 @@ do_test (void)
   struct sigaction action = { .sa_handler = sig_handler };
   sigemptyset (&action.sa_mask);
 
+  DIAG_PUSH_NEEDS_COMMENT;
+  DIAG_IGNORE_NEEDS_COMMENT (10, "-Wunused-result");
+  /* The result of malloc is deliberately ignored, so do not warn
+     about that.  */
   malloc (sizeof (int));
+  DIAG_POP_NEEDS_COMMENT;
 
   if (sigaction (SIGALRM, &action, NULL) != 0)
     {