git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Johannes Sixt <j6t@kdbg.org>
To: Ramsay Jones <ramsay@ramsayjones.plus.com>
Cc: Junio C Hamano <gitster@pobox.com>, Jeff King <peff@peff.net>,
	Nguyen Thai Ngoc Duy <pclouds@gmail.com>,
	GIT Mailing-list <git@vger.kernel.org>
Subject: Re: [PATCH 00/52] fix some -Wmissing-field-initializer warnings
Date: Thu, 30 May 2019 10:47:37 +0200	[thread overview]
Message-ID: <0f1c5a49-f971-848d-700e-9c124ae8e617@kdbg.org> (raw)
In-Reply-To: <cf0b720e-ad29-79e7-17d5-b69d50e7007e@ramsayjones.plus.com>

Hi Ramsay,

I had a brief look at the series. IMO, it is a mistake to appease
-Wmissing-field-initializer.

We have two sorts of initializers:

 - zero initializers: they just want to null out every field,
   like CHILD_PROCESS_INIT and ad-hoc initializers of structs
   such as xpparam_t pp = { 0 }; in range-diff.c

 - value initializers are always macros, such as STRING_LIST_INIT_DUP
   and the OPT_* family.

I am strongly against forcing zero initializers to write down a value
for every field. It is much more preferable to depend on that the
compiler does the right thing with them. -Wmissing-field-initializer
would provide guidance in the wrong direction. A zero initializer looks
like this: = { 0 }; and nothing else.

(And for this reason, I also think it is wrong to change 0 to NULL in
initializers to appease sparse's "zero used as pointer value" warning.
Let the compiler do the right thing.)

Value initializers are a different matter. The changes you have prepared
around struct option initializers are good, IMO. Whether or not you add
trailing zeros to the macros makes no difference for the users of the
macros.

-- Hannes

  parent reply	other threads:[~2019-05-30  8:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-24 20:28 [PATCH 00/52] fix some -Wmissing-field-initializer warnings Ramsay Jones
2019-05-24 22:30 ` Ævar Arnfjörð Bjarmason
2019-05-24 23:08   ` Ramsay Jones
2019-05-30  8:47 ` Johannes Sixt [this message]
2019-05-30 12:04   ` Jeff King
2019-05-30 14:59     ` Ramsay Jones

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0f1c5a49-f971-848d-700e-9c124ae8e617@kdbg.org \
    --to=j6t@kdbg.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=pclouds@gmail.com \
    --cc=peff@peff.net \
    --cc=ramsay@ramsayjones.plus.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).