[PATCH] ui-snapshot.c: Terminate cgit_snapshot_formats[] properly

John Keeping john at keeping.me.uk
Sun Mar 3 23:55:16 CET 2013


On Sun, Mar 03, 2013 at 11:09:01PM +0100, Lukas Fleischer wrote:
> Explicitly set the suffix field of the terminating format entry to 0.
> This fixes a GCC warning seen with "-Wmissing-field-initializers".
> 
> Signed-off-by: Lukas Fleischer <cgit at cryptocrack.de>
> ---
>  ui-snapshot.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/ui-snapshot.c b/ui-snapshot.c
> index 47432bd..e740645 100644
> --- a/ui-snapshot.c
> +++ b/ui-snapshot.c
> @@ -48,7 +48,7 @@ const struct cgit_snapshot_format cgit_snapshot_formats[] = {
>  	{ ".tar.bz2", "application/x-bzip2", write_tar_bzip2_archive, 0x04 },
>  	{ ".tar", "application/x-tar", write_tar_archive, 0x08 },
>  	{ ".tar.xz", "application/x-xz", write_tar_xz_archive, 0x10 },
> -	{}
> +	{ 0 }

I'm mildly against this - we're not fixing an issue that's been found with some
specific compiler, the meaning of both versions is the same and
-Wmissing-field-initializers isn't in -Wall.  It feels like a warning that was
added for people following some overly prescriptive coding standard, not a
warning that's actually useful.

[Also, I'm surprised this is sufficient to squelch the warning given the
description of -Wmissing-field-initializers in gcc(1):

   Warn if a structure's initializer has some fields missing.  For example,
   the following code would cause such a warning, because "x.h" is implicitly
   zero:

       struct s { int f, g, h; };
       struct s x = { 3, 4 };
]

>  };
>  
>  static const struct cgit_snapshot_format *get_format(const char *filename)
> -- 
> 1.8.2.rc0.247.g811e0c0




More information about the CGit mailing list