bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: shadowing warning from test-printf-posix.h


From: Bruno Haible
Subject: Re: shadowing warning from test-printf-posix.h
Date: Thu, 3 Apr 2008 00:37:41 +0200
User-agent: KMail/1.5.4

Jim Meyering wrote:
> Subject: [PATCH] Avoid "statement with no effect" warning.
> 
> * tests/test-wctype.c (main): Don't use is* function return values.
> 
> Signed-off-by: Jim Meyering <address@hidden>
> ---
>  tests/test-wctype.c |   25 +++++++++++++------------
>  1 files changed, 13 insertions(+), 12 deletions(-)
> 
> diff --git a/tests/test-wctype.c b/tests/test-wctype.c
> index 517b478..5d1296e 100644
> --- a/tests/test-wctype.c
> +++ b/tests/test-wctype.c
> @@ -23,21 +23,22 @@
>  int
>  main ()
>  {
> +  int i = 0;
>    /* Check that the isw* functions exist as functions or as macros.  */
> -  iswalnum (0);
> -  iswalpha (0);
> +  i += !!iswalnum (0);
> +  i += !!iswalpha (0);
>  #if 0 /* not portable: missing on mingw */
> -  iswblank (0);
> +  i += !!iswblank (0);
>  #endif
> -  iswcntrl (0);
> -  iswdigit (0);
> -  iswgraph (0);
> -  iswlower (0);
> -  iswprint (0);
> -  iswpunct (0);
> -  iswspace (0);
> -  iswupper (0);
> -  iswxdigit (0);
> +  i += !!iswcntrl (0);
> +  i += !!iswdigit (0);
> +  i += !!iswgraph (0);
> +  i += !!iswlower (0);
> +  i += !!iswprint (0);
> +  i += !!iswpunct (0);
> +  i += !!iswspace (0);
> +  i += !!iswupper (0);
> +  i += !!iswxdigit (0);
> 
>    return 0;
>  }

I prefer and applied this patch. (Using double negation to avoid signed
integer overflow is something that very few people understand.)


2008-04-02  Bruno Haible  <address@hidden>

        Avoid some "statement with no effect" warnings from gcc.
        * tests/test-wctype.c (main): Explicitly ignore unused values.
        Reported by Jim Meyering.

*** tests/test-wctype.c.orig    2008-04-03 00:32:02.000000000 +0200
--- tests/test-wctype.c 2008-04-03 00:30:32.000000000 +0200
***************
*** 1,5 ****
  /* Test of <wctype.h> substitute.
!    Copyright (C) 2007 Free Software Foundation, Inc.
  
     This program is free software: you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
--- 1,5 ----
  /* Test of <wctype.h> substitute.
!    Copyright (C) 2007-2008 Free Software Foundation, Inc.
  
     This program is free software: you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
***************
*** 24,43 ****
  main ()
  {
    /* Check that the isw* functions exist as functions or as macros.  */
!   iswalnum (0);
!   iswalpha (0);
  #if 0 /* not portable: missing on mingw */
!   iswblank (0);
  #endif
!   iswcntrl (0);
!   iswdigit (0);
!   iswgraph (0);
!   iswlower (0);
!   iswprint (0);
!   iswpunct (0);
!   iswspace (0);
!   iswupper (0);
!   iswxdigit (0);
  
    return 0;
  }
--- 24,43 ----
  main ()
  {
    /* Check that the isw* functions exist as functions or as macros.  */
!   (void) iswalnum (0);
!   (void) iswalpha (0);
  #if 0 /* not portable: missing on mingw */
!   (void) iswblank (0);
  #endif
!   (void) iswcntrl (0);
!   (void) iswdigit (0);
!   (void) iswgraph (0);
!   (void) iswlower (0);
!   (void) iswprint (0);
!   (void) iswpunct (0);
!   (void) iswspace (0);
!   (void) iswupper (0);
!   (void) iswxdigit (0);
  
    return 0;
  }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]