about summary refs log tree commit diff
path: root/stdio-common/tst-vfprintf-width-prec.c
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2021-10-04 19:10:43 +0000
committerJoseph Myers <joseph@codesourcery.com>2021-10-04 19:10:43 +0000
commita312e8fe6d89f5eae6a4583d5db577121e61c0b5 (patch)
tree605d1a7e39fa68c3e4f74024787b7c5adba6dfca /stdio-common/tst-vfprintf-width-prec.c
parentde0a7c5a0b2061c86441a1822d6c3a898b0b6ba2 (diff)
downloadglibc-a312e8fe6d89f5eae6a4583d5db577121e61c0b5.tar.gz
glibc-a312e8fe6d89f5eae6a4583d5db577121e61c0b5.tar.xz
glibc-a312e8fe6d89f5eae6a4583d5db577121e61c0b5.zip
Fix stdio-common tests for GCC 12 -Waddress
My glibc bot shows failures building the testsuite with GCC mainline
across all architectures:

tst-vfprintf-width-prec.c: In function 'do_test':
tst-vfprintf-width-prec.c:90:16: error: the comparison will always evaluate as 'false' for the address of 'result' will never be NULL [-Werror=address]
   90 |     if (result == NULL)
      |                ^~
tst-vfprintf-width-prec.c:89:13: note: 'result' declared here
   89 |     wchar_t result[100];
      |             ^~~~~~

This is clearly a correct warning; the comparison against NULL is
clearly a cut-and-paste mistake from an earlier case in the test that
does use calloc.  Thus, remove the unnecessary check for NULL shown up
by the warning.

Similarly, two other tests have bogus comparisons against NULL; remove
those as well:

scanf14a.c:95:13: error: the comparison will always evaluate as 'false' for the address of 'fname' will never be NULL [-Werror=address]
   95 |   if (fname == NULL)
      |             ^~
scanf14a.c:93:8: note: 'fname' declared here
   93 |   char fname[strlen (tmpdir) + sizeof "/tst-scanf14.XXXXXX"];
      |        ^~~~~

scanf16a.c:125:13: error: the comparison will always evaluate as 'false' for the address of 'fname' will never be NULL [-Werror=address]
  125 |   if (fname == NULL)
      |             ^~
scanf16a.c:123:8: note: 'fname' declared here
  123 |   char fname[strlen (tmpdir) + sizeof "/tst-scanf16.XXXXXX"];
      |        ^~~~~

Tested with build-many-glibcs.py (GCC mainline) for aarch64-linux-gnu.
Diffstat (limited to 'stdio-common/tst-vfprintf-width-prec.c')
-rw-r--r--stdio-common/tst-vfprintf-width-prec.c6
1 files changed, 0 insertions, 6 deletions
diff --git a/stdio-common/tst-vfprintf-width-prec.c b/stdio-common/tst-vfprintf-width-prec.c
index 3192fd797a..278d57f739 100644
--- a/stdio-common/tst-vfprintf-width-prec.c
+++ b/stdio-common/tst-vfprintf-width-prec.c
@@ -87,12 +87,6 @@ do_test (void)
   }
   {
     wchar_t result[100];
-    if (result == NULL)
-      {
-        printf ("error: calloc (%d, %zu): %m", ret + 1, sizeof (wchar_t));
-        return 1;
-      }
-
     ret = swprintf (result, 100, L"%133000.999999999x", 17);
     if (ret >= 0)
       {