summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2021-04-18 21:18:00 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2021-04-18 21:18:21 -0700
commit9b8db75dbe7c33d5dc7eccee84f80c17c18223c1 (patch)
treeb519dc980b4aab645f6c452c4551c565b693eb0c /tests
parent5d5120d76b6e540c7e78332aa8302b3244b9ea02 (diff)
downloadgnulib-9b8db75dbe7c33d5dc7eccee84f80c17c18223c1.tar.gz
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=]”.
Diffstat (limited to 'tests')
-rw-r--r--tests/test-malloc-gnu.c6
-rw-r--r--tests/test-realloc-gnu.c6
2 files changed, 6 insertions, 6 deletions
diff --git a/tests/test-malloc-gnu.c b/tests/test-malloc-gnu.c
index ce7e4fec2a..e1dfde452c 100644
--- a/tests/test-malloc-gnu.c
+++ b/tests/test-malloc-gnu.c
@@ -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;
}
diff --git a/tests/test-realloc-gnu.c b/tests/test-realloc-gnu.c
index 9c7344f151..b62ee6badc 100644
--- a/tests/test-realloc-gnu.c
+++ b/tests/test-realloc-gnu.c
@@ -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;
}