]> git.ipfire.org Git - thirdparty/glibc.git/commit
Fix stdio-common tests for GCC 12 -Waddress
authorJoseph Myers <joseph@codesourcery.com>
Mon, 4 Oct 2021 19:10:43 +0000 (19:10 +0000)
committerFlorian Weimer <fweimer@redhat.com>
Wed, 11 Jan 2023 13:12:05 +0000 (14:12 +0100)
commit6ff61a51459d141782fbcc32ae81c0ef1954dad6
tree51657e4364fd8e4e66dc19f97390e63c5c8ee7b5
parent26c7c6bac9da305b634a661aa491dae2756581ec
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.

(cherry picked from commit a312e8fe6d89f5eae6a4583d5db577121e61c0b5)
stdio-common/scanf14a.c
stdio-common/scanf16a.c
stdio-common/tst-vfprintf-width-prec.c