git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: Johannes Sixt <j6t@kdbg.org>
Cc: Ramsay Jones <ramsay@ramsayjones.plus.com>,
	Junio C Hamano <gitster@pobox.com>,
	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 08:04:41 -0400	[thread overview]
Message-ID: <20190530120441.GD31607@sigill.intra.peff.net> (raw)
In-Reply-To: <0f1c5a49-f971-848d-700e-9c124ae8e617@kdbg.org>

On Thu, May 30, 2019 at 10:47:37AM +0200, Johannes Sixt wrote:

> 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.

I had a similar impression while perusing the commits. I don't mind
forcing some extra work on programmers to appease a warning if
disregarding it is a common source of errors. But I didn't see any real
bug-fixes in the series, so it doesn't seem like that good a tradeoff to
me.

Contrast that with the -Wunused-parameters warning. I found a dozen or
so actual bugs by sifting through the results, and another couple dozen
spots where the code could be cleaned up or simplified. If we want to
shut up the warning completely (so we can pay attention to it), we'll
then have to annotate probably a couple hundred spots, and keep those
annotations up to date. But I feel better doing that knowing that it's
shown real-world value.

-Peff

  reply	other threads:[~2019-05-30 12:04 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
2019-05-30 12:04   ` Jeff King [this message]
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=20190530120441.GD31607@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=j6t@kdbg.org \
    --cc=pclouds@gmail.com \
    --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).