coreutils
[Top][All Lists]
Advanced

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

Re: ls, pathchk, shred, stty, wc: warning: missing initializer [-Wmissin


From: Jim Meyering
Subject: Re: ls, pathchk, shred, stty, wc: warning: missing initializer [-Wmissing-field-initializers]
Date: Fri, 23 Mar 2012 20:29:11 +0100

Bernhard Voelker wrote:
> According to the comment of commit v8.12-20-g73fd918:
>
>     maint: remove -Wmissing-field-initializers workarounds
>
>     * configure.ac: Rather than disabling -Wmissing-field-initializers,
>     use the fact that gnulib now disables it automatically when required
>     (on versions of GCC older than 4.7).
>     * src/system.h: Remove the no longer needed DECLARE_ZEROED_AGGREGATE.
>     * src/ls.c: Likewise.
>     * src/pathchk.c: Likewise.
>     * src/shred.c: Likewise.
>     * src/stty.c: Likewise.
>     * src/wc.c: Likewise.
>
> these warnings should not happen:
>
>   stty.c: In function 'main':
>   stty.c:732:10: warning: missing initializer [-Wmissing-field-initializers]
>   stty.c:732:10: warning: (near initialization for 'mode.c_oflag') 
> [-Wmissing-field-initializers]
>   stty.c:1005:14: warning: missing initializer [-Wmissing-field-initializers]
>   stty.c:1005:14: warning: (near initialization for 'new_mode.c_oflag') 
> [-Wmissing-field-initializers]
>   ls.c: In function 'quote_name':
>   ls.c:4046:21: warning: missing initializer [-Wmissing-field-initializers]
>   ls.c:4046:21: warning: (near initialization for 'mbstate.__value') 
> [-Wmissing-field-initializers]
>   pathchk.c: In function 'portable_chars_only':
>   pathchk.c:193:7: warning: missing initializer [-Wmissing-field-initializers]
>   pathchk.c:193:7: warning: (near initialization for 'mbstate.__value') 
> [-Wmissing-field-initializers]
>   shred.c: In function 'main':
>   shred.c:1094:10: warning: missing initializer [-Wmissing-field-initializers]
>   shred.c:1094:10: warning: (near initialization for 'flags.n_iterations') 
> [-Wmissing-field-initializers]
>   wc.c: In function 'wc':
>   wc.c:289:7: warning: missing initializer [-Wmissing-field-initializers]
>   wc.c:289:7: warning: (near initialization for 'state.__value') 
> [-Wmissing-field-initializers]
>
> But they do: the compiler used on that system (OpenSuSE-12.1) is
> "gcc (SUSE Linux) 4.6.2". As these are the only warnings here when
> using --enable-gcc-warnings, shouldn't we go with a more conservative
> memset? See patch proposal below.

Hi Berny,

Thanks, but changes like these (that separate decl/init) reduce
maintainability/readability, and are best avoided.

If the configure-time test for that warning option is not
working for you, please try to determine why and fix the root cause.

...
> -                    mbstate_t mbstate = { 0, };
> +                    mbstate_t mbstate;
> +                    memset (&mbstate, 0, sizeof (mbstate));
>                      do
>                        {
>                          wchar_t wc;
> diff --git a/src/pathchk.c b/src/pathchk.c
> index 194de22..b119dc0 100644
> --- a/src/pathchk.c
> +++ b/src/pathchk.c
> @@ -190,7 +190,8 @@ portable_chars_only (char const *file, size_t filelen)
>
>    if (*invalid)
>      {
> -      mbstate_t mbstate = { 0, };
> +      mbstate_t mbstate;
> +      memset (&mbstate, 0, sizeof (mbstate));
...



reply via email to

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