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

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Wed Jun 10 13:52:51 GMT 2026



On 10/06/26 10:39, Joseph Myers wrote:
> 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.
> 

LGTM, thanks.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

> 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;
> 



More information about the Libc-alpha mailing list