]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
malloc-gnu-tests: pacify -Walloc-size-larger-than
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 19 Apr 2021 04:18:00 +0000 (21:18 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 19 Apr 2021 04:18:21 +0000 (21:18 -0700)
* tests/test-malloc-gnu.c (main):
* tests/test-realloc-gnu.c (main): Hide true intentions from GCC,
to prevent diagnostics like “warning: argument 1 value
9223372036854775808’ exceeds maximum object size
9223372036854775807 [-Walloc-size-larger-than=]”.

ChangeLog
tests/test-malloc-gnu.c
tests/test-realloc-gnu.c

index 2c7edd59ab681a85fd5f68c66460b7be66f1fd83..0146e159442427daf0cc81f9b0d94857dcb5dda6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2021-04-18  Paul Eggert  <eggert@cs.ucla.edu>
 
+       malloc-gnu-tests: pacify -Walloc-size-larger-than
+       * tests/test-malloc-gnu.c (main):
+       * tests/test-realloc-gnu.c (main): Hide true intentions from GCC,
+       to prevent diagnostics like “warning: argument 1 value
+       ‘9223372036854775808’ exceeds maximum object size
+       9223372036854775807 [-Walloc-size-larger-than=]”.
+
        safe-alloc: fix pointer implementation
        The old implementation assumed that all pointers use the same
        internal representation, but the C standard doesn’t guarantee
index ce7e4fec2a0e810fb858dd6250519f0f18a5e338..e1dfde452c3d13466112d4b2ed9b08148844ed29 100644 (file)
@@ -20,7 +20,7 @@
 #include <stdint.h>
 
 int
-main ()
+main (int argc, char **argv)
 {
   /* Check that malloc (0) is not a NULL pointer.  */
   char *p = malloc (0);
@@ -31,8 +31,8 @@ main ()
   /* Check that malloc (n) fails when n exceeds PTRDIFF_MAX.  */
   if (PTRDIFF_MAX < SIZE_MAX)
     {
-      size_t n = PTRDIFF_MAX, n1 = n + 1;
-      if (malloc (n1) != NULL)
+      size_t one = argc != 12345;
+      if (malloc (PTRDIFF_MAX + one) != NULL)
         return 1;
     }
 
index 9c7344f15101b67bc8fa4b29d9745b9637f5fa31..b62ee6badc4f5c13e3f603d4b2ce8d277c76bd42 100644 (file)
@@ -20,7 +20,7 @@
 #include <stdint.h>
 
 int
-main ()
+main (int argc, char **argv)
 {
   /* Check that realloc (NULL, 0) is not a NULL pointer.  */
   char *p = realloc (NULL, 0);
@@ -31,8 +31,8 @@ main ()
      PTRDIFF_MAX.  */
   if (PTRDIFF_MAX < SIZE_MAX)
     {
-      size_t n = PTRDIFF_MAX, n1 = n + 1;
-      if (realloc (p, n1) != NULL)
+      size_t one = argc != 12345;
+      if (realloc (p, PTRDIFF_MAX + one) != NULL)
         return 1;
     }