|
|
6ca6e8 |
commit 6ff61a51459d141782fbcc32ae81c0ef1954dad6
|
|
|
6ca6e8 |
Author: Joseph Myers <joseph@codesourcery.com>
|
|
|
6ca6e8 |
Date: Mon Oct 4 19:10:43 2021 +0000
|
|
|
6ca6e8 |
|
|
|
6ca6e8 |
Fix stdio-common tests for GCC 12 -Waddress
|
|
|
6ca6e8 |
|
|
|
6ca6e8 |
My glibc bot shows failures building the testsuite with GCC mainline
|
|
|
6ca6e8 |
across all architectures:
|
|
|
6ca6e8 |
|
|
|
6ca6e8 |
tst-vfprintf-width-prec.c: In function 'do_test':
|
|
|
6ca6e8 |
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]
|
|
|
6ca6e8 |
90 | if (result == NULL)
|
|
|
6ca6e8 |
| ^~
|
|
|
6ca6e8 |
tst-vfprintf-width-prec.c:89:13: note: 'result' declared here
|
|
|
6ca6e8 |
89 | wchar_t result[100];
|
|
|
6ca6e8 |
| ^~~~~~
|
|
|
6ca6e8 |
|
|
|
6ca6e8 |
This is clearly a correct warning; the comparison against NULL is
|
|
|
6ca6e8 |
clearly a cut-and-paste mistake from an earlier case in the test that
|
|
|
6ca6e8 |
does use calloc. Thus, remove the unnecessary check for NULL shown up
|
|
|
6ca6e8 |
by the warning.
|
|
|
6ca6e8 |
|
|
|
6ca6e8 |
Similarly, two other tests have bogus comparisons against NULL; remove
|
|
|
6ca6e8 |
those as well:
|
|
|
6ca6e8 |
|
|
|
6ca6e8 |
scanf14a.c:95:13: error: the comparison will always evaluate as 'false' for the address of 'fname' will never be NULL [-Werror=address]
|
|
|
6ca6e8 |
95 | if (fname == NULL)
|
|
|
6ca6e8 |
| ^~
|
|
|
6ca6e8 |
scanf14a.c:93:8: note: 'fname' declared here
|
|
|
6ca6e8 |
93 | char fname[strlen (tmpdir) + sizeof "/tst-scanf14.XXXXXX"];
|
|
|
6ca6e8 |
| ^~~~~
|
|
|
6ca6e8 |
|
|
|
6ca6e8 |
scanf16a.c:125:13: error: the comparison will always evaluate as 'false' for the address of 'fname' will never be NULL [-Werror=address]
|
|
|
6ca6e8 |
125 | if (fname == NULL)
|
|
|
6ca6e8 |
| ^~
|
|
|
6ca6e8 |
scanf16a.c:123:8: note: 'fname' declared here
|
|
|
6ca6e8 |
123 | char fname[strlen (tmpdir) + sizeof "/tst-scanf16.XXXXXX"];
|
|
|
6ca6e8 |
| ^~~~~
|
|
|
6ca6e8 |
|
|
|
6ca6e8 |
Tested with build-many-glibcs.py (GCC mainline) for aarch64-linux-gnu.
|
|
|
6ca6e8 |
|
|
|
6ca6e8 |
(cherry picked from commit a312e8fe6d89f5eae6a4583d5db577121e61c0b5)
|
|
|
6ca6e8 |
|
|
|
6ca6e8 |
diff --git a/stdio-common/scanf14a.c b/stdio-common/scanf14a.c
|
|
|
6ca6e8 |
index 12adcff5a4970da1..b37712d1c673fa3a 100644
|
|
|
6ca6e8 |
--- a/stdio-common/scanf14a.c
|
|
|
6ca6e8 |
+++ b/stdio-common/scanf14a.c
|
|
|
6ca6e8 |
@@ -92,8 +92,6 @@ main (void)
|
|
|
6ca6e8 |
|
|
|
6ca6e8 |
char fname[strlen (tmpdir) + sizeof "/tst-scanf14.XXXXXX"];
|
|
|
6ca6e8 |
sprintf (fname, "%s/tst-scanf14.XXXXXX", tmpdir);
|
|
|
6ca6e8 |
- if (fname == NULL)
|
|
|
6ca6e8 |
- FAIL ();
|
|
|
6ca6e8 |
|
|
|
6ca6e8 |
/* Create a temporary file. */
|
|
|
6ca6e8 |
int fd = mkstemp (fname);
|
|
|
6ca6e8 |
diff --git a/stdio-common/scanf16a.c b/stdio-common/scanf16a.c
|
|
|
6ca6e8 |
index 400d85a54e81c3cb..74d0295c97f73b14 100644
|
|
|
6ca6e8 |
--- a/stdio-common/scanf16a.c
|
|
|
6ca6e8 |
+++ b/stdio-common/scanf16a.c
|
|
|
6ca6e8 |
@@ -122,8 +122,6 @@ main (void)
|
|
|
6ca6e8 |
|
|
|
6ca6e8 |
char fname[strlen (tmpdir) + sizeof "/tst-scanf16.XXXXXX"];
|
|
|
6ca6e8 |
sprintf (fname, "%s/tst-scanf16.XXXXXX", tmpdir);
|
|
|
6ca6e8 |
- if (fname == NULL)
|
|
|
6ca6e8 |
- FAIL ();
|
|
|
6ca6e8 |
|
|
|
6ca6e8 |
/* Create a temporary file. */
|
|
|
6ca6e8 |
int fd = mkstemp (fname);
|
|
|
6ca6e8 |
diff --git a/stdio-common/tst-vfprintf-width-prec.c b/stdio-common/tst-vfprintf-width-prec.c
|
|
|
6ca6e8 |
index 3192fd797ad4ea90..278d57f739f576e9 100644
|
|
|
6ca6e8 |
--- a/stdio-common/tst-vfprintf-width-prec.c
|
|
|
6ca6e8 |
+++ b/stdio-common/tst-vfprintf-width-prec.c
|
|
|
6ca6e8 |
@@ -87,12 +87,6 @@ do_test (void)
|
|
|
6ca6e8 |
}
|
|
|
6ca6e8 |
{
|
|
|
6ca6e8 |
wchar_t result[100];
|
|
|
6ca6e8 |
- if (result == NULL)
|
|
|
6ca6e8 |
- {
|
|
|
6ca6e8 |
- printf ("error: calloc (%d, %zu): %m", ret + 1, sizeof (wchar_t));
|
|
|
6ca6e8 |
- return 1;
|
|
|
6ca6e8 |
- }
|
|
|
6ca6e8 |
-
|
|
|
6ca6e8 |
ret = swprintf (result, 100, L"%133000.999999999x", 17);
|
|
|
6ca6e8 |
if (ret >= 0)
|
|
|
6ca6e8 |
{
|