bug-gnulib
[Top][All Lists]
Advanced

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

Re: vasnprintf.c needs IF_LINT, too


From: Bruno Haible
Subject: Re: vasnprintf.c needs IF_LINT, too
Date: Thu, 22 May 2008 00:53:20 +0200
User-agent: KMail/1.5.4

Jim Meyering wrote:
> Oops.  I mistakenly pushed the latter unreviewed change (to avoid
> this warning) along with the typo-fixing one.  Sorry, Bruno.

So here's my review afterwards.

  - The patch was incomplete: When I turn on all possible NEED_* options
    in config.h, I get more warnings:

    vasnprintf.c: In function 'scale10_round_decimal_long_double':
    vasnprintf.c:1208: warning: 'e' may be used uninitialized in this function
    vasnprintf.c: In function 'scale10_round_decimal_double':
    vasnprintf.c:1226: warning: 'e' may be used uninitialized in this function
    vasnprintf.c: In function 'vasnprintf':
    vasnprintf.c:4253: warning: 'prefixes[1]' is used uninitialized in this 
function
    vasnprintf.c:3703: warning: 'prefixes[0u]' may be used uninitialized in 
this function

  - The IF_LINT macro comes a bit too early, for my taste, at a place where the
    code still deals with includes and system dependent functions.

  - The comments mention a different wording than the one actually used by gcc
    3.x and 4.x.

So I added IF_LINT also for the array initializer. (Note that Solaris cc
_does_ support array initializers for stack-allocated arrays if all elements
are constant expressions. It complains only about non-constant array
initializers.)


2008-05-21  Bruno Haible  <address@hidden>

        Avoid one more warning from gcc.
        * lib/vasnprintf.c (IF_LINT): Update comments.
        (VASNPRINTF): Use it also for the 'prefix' array initializer.

*** lib/vasnprintf.c.orig       2008-05-22 00:51:29.000000000 +0200
--- lib/vasnprintf.c    2008-05-22 00:50:12.000000000 +0200
***************
*** 117,129 ****
  # include "fpucw.h"
  #endif
  
- /* Use this to suppress gcc's `...may be used before initialized' warnings. */
- #ifdef lint
- # define IF_LINT(Code) Code
- #else
- # define IF_LINT(Code) /* empty */
- #endif
- 
  #if HAVE_WCHAR_T
  # if HAVE_WCSLEN
  #  define local_wcslen wcslen
--- 117,122 ----
***************
*** 207,212 ****
--- 200,213 ----
  /* Here we need to call the native sprintf, not rpl_sprintf.  */
  #undef sprintf
  
+ /* GCC >= 4.0 with -Wall emits unjustified "... may be used uninitialized"
+    warnings in this file.  Use -Dlint to suppress them.  */
+ #ifdef lint
+ # define IF_LINT(Code) Code
+ #else
+ # define IF_LINT(Code) /* empty */
+ #endif
+ 
  /* Avoid some warnings from "gcc -Wshadow".
     This file doesn't use the exp() and remainder() functions.  */
  #undef exp
***************
*** 3707,3713 ****
  #endif
                TCHAR_T *fbp;
                unsigned int prefix_count;
!               int prefixes[2];
  #if !USE_SNPRINTF
                size_t tmp_length;
                TCHAR_T tmpbuf[700];
--- 3708,3714 ----
  #endif
                TCHAR_T *fbp;
                unsigned int prefix_count;
!               int prefixes[2] IF_LINT (= { 0, 0 });
  #if !USE_SNPRINTF
                size_t tmp_length;
                TCHAR_T tmpbuf[700];





reply via email to

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