public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Florian Weimer <fw@sourceware.org>
To: glibc-cvs@sourceware.org
Subject: [glibc/release/2.34/master] Fix stdio-common tests for GCC 12 -Waddress
Date: Thu, 12 Jan 2023 06:21:31 +0000 (GMT)	[thread overview]
Message-ID: <20230112062131.A1CF13857007@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=6ff61a51459d141782fbcc32ae81c0ef1954dad6

commit 6ff61a51459d141782fbcc32ae81c0ef1954dad6
Author: Joseph Myers <joseph@codesourcery.com>
Date:   Mon Oct 4 19:10:43 2021 +0000

    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)

Diff:
---
 stdio-common/scanf14a.c                | 2 --
 stdio-common/scanf16a.c                | 2 --
 stdio-common/tst-vfprintf-width-prec.c | 6 ------
 3 files changed, 10 deletions(-)

diff --git a/stdio-common/scanf14a.c b/stdio-common/scanf14a.c
index 12adcff5a4..b37712d1c6 100644
--- a/stdio-common/scanf14a.c
+++ b/stdio-common/scanf14a.c
@@ -92,8 +92,6 @@ main (void)
 
   char fname[strlen (tmpdir) + sizeof "/tst-scanf14.XXXXXX"];
   sprintf (fname, "%s/tst-scanf14.XXXXXX", tmpdir);
-  if (fname == NULL)
-    FAIL ();
 
   /* Create a temporary file.   */
   int fd = mkstemp (fname);
diff --git a/stdio-common/scanf16a.c b/stdio-common/scanf16a.c
index 400d85a54e..74d0295c97 100644
--- a/stdio-common/scanf16a.c
+++ b/stdio-common/scanf16a.c
@@ -122,8 +122,6 @@ main (void)
 
   char fname[strlen (tmpdir) + sizeof "/tst-scanf16.XXXXXX"];
   sprintf (fname, "%s/tst-scanf16.XXXXXX", tmpdir);
-  if (fname == NULL)
-    FAIL ();
 
   /* Create a temporary file.   */
   int fd = mkstemp (fname);
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)
       {

                 reply	other threads:[~2023-01-12  6:21 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230112062131.A1CF13857007@sourceware.org \
    --to=fw@sourceware.org \
    --cc=glibc-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).