[glibc] Fix -Wconstant-logical-operand error in tst-printf-format-skeleton.c

Joseph Myers via Glibc-cvs <[email protected]> Wed, 10 Jun 2026 14:01:58 +0000 (GMT)
Newsgroups gmane.comp.lib.glibc.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=690472e2a50a523f77992f606724e1c26210af3d

commit 690472e2a50a523f77992f606724e1c26210af3d
Author: Joseph Myers <[email protected]>
Date:   Wed Jun 10 14:01:34 2026 +0000

    Fix -Wconstant-logical-operand error in tst-printf-format-skeleton.c
    
    Building the glibc testsuite with GCC mainline fails with:
    
    In file included from tst-printf-format-skeleton-double.c:33,
                     from tst-printf-format-p-double.c:20:
    tst-printf-format-skeleton.c: In function 'do_test':
    tst-printf-format-skeleton.c:308:12: error: use of logical '&&' with constant operand '53' [-Werror=constant-logical-operand]
      308 |   if (PREC && printf ("prec:%i\n", PREC) < 0)
          |            ^~
    tst-printf-format-skeleton.c:308:12: note: use '&' for bitwise operation
      308 |   if (PREC && printf ("prec:%i\n", PREC) < 0)
          |            ^~
          |            &
    cc1: all warnings being treated as errors
    
    Fix this using an explicit "!= 0".  Tested with build-many-glibcs.py
    for aarch64-linux-gnu.

Diff:
---
 stdio-common/tst-printf-format-skeleton.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/stdio-common/tst-printf-format-skeleton.c b/stdio-common/tst-printf-format-skeleton.c
index 3ed7668ce7..000d8fa50d 100644
--- a/stdio-common/tst-printf-format-skeleton.c
+++ b/stdio-common/tst-printf-format-skeleton.c
@@ -305,7 +305,7 @@ do_test (int argc, char *argv[])
 
   mtrace ();
 
-  if (PREC && printf ("prec:%i\n", PREC) < 0)
+  if (PREC != 0 && printf ("prec:%i\n", PREC) < 0)
     {
       perror ("printf");
       return EXIT_FAILURE;