linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Borislav Petkov <bp@alien8.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	Ingo Molnar <mingo@kernel.org>, Michal Marek <mmarek@suse.com>,
	Sam Ravnborg <sam@ravnborg.org>,
	lkml <linux-kernel@vger.kernel.org>, Michael Matz <matz@suse.de>,
	Linux Kbuild mailing list <linux-kbuild@vger.kernel.org>,
	x86-ml <x86@kernel.org>
Subject: Re: [PATCH] Kbuild: Move -Wmaybe-uninitialized to W=1
Date: Fri, 29 Jul 2016 12:35:57 +0200	[thread overview]
Message-ID: <4090105.Iz5p5IbnPA@wuerfel> (raw)
In-Reply-To: <20160729101932.GA27543@nazgul.tnic>

On Friday, July 29, 2016 12:19:32 PM CEST Borislav Petkov wrote:
> On Fri, Jul 29, 2016 at 12:08:51PM +0200, Arnd Bergmann wrote:
> > Let me try to get to the bottom of this, maybe we can get the warning
> > back in the future. It has found a number of actual bugs. The majority
> > of -Wmaybe-uninitialized warnings that I fixed in linux-next were
> > false positives (maybe four out of five) but I would think the reason
> 
> So this is exactly the problem: we should not fix perfectly fine code
> just so that gcc remains quiet. So when you say "fixed false positives"
> you actually mean, "changed it so that gcc -Wmaybe-u... doesn't fire"
> right?
> 
> And we should not do that.

As I said elsewhere in the mail, in general the code becomes more
readable in the process and/or the compiler gets to optimize it better.

What typically happens here is that something prevents the compiler
from seeing that a condition is always true, so it has to evaluate
it at runtime when it should have noticed that it can never hit.

If the code is written in a way that the compiler can actually see
that the condition is known based on what happened earlier, we save
an extra branch, or in some cases duplication of object code.

There have been a small number of cases where this was not possible
and I actually ended up adding a fake initialization because rearranging
the code for the compiler would have made it less readable for humans
(e.g. b268c34e5ee92a [1]), but that has been the rare exception because
of the reasons that Rusty nicely described in [2].

	Arnd

[1] https://patchwork.kernel.org/patch/9212881/
[2] https://rusty.ozlabs.org/?p=232

  reply	other threads:[~2016-07-29 10:38 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-16 13:20 [RFC] Turn off -Wmaybe-uninitialized completely and move it to W=1 Borislav Petkov
2014-06-16 21:14 ` Sam Ravnborg
2014-06-24 21:38   ` [PATCH] Kbuild: Move -Wmaybe-uninitialized " Borislav Petkov
2014-07-07 10:53     ` Borislav Petkov
2014-07-08  9:25       ` Paul Bolle
2014-07-08 11:37         ` Borislav Petkov
2014-07-10 10:42           ` Borislav Petkov
2014-07-10 11:03             ` Paul Bolle
2016-07-28  4:20       ` Borislav Petkov
2016-07-28  8:29         ` Ingo Molnar
2016-07-28  8:46           ` Borislav Petkov
2016-07-28 16:49             ` Ingo Molnar
2016-07-28 17:04               ` Ingo Molnar
2016-07-28 17:56             ` Markus Trippelsdorf
2016-07-28 19:03           ` Linus Torvalds
2016-07-28 19:08             ` Linus Torvalds
2016-07-28 20:28               ` Ingo Molnar
2016-07-28 21:22             ` Linus Torvalds
2016-07-29 10:08               ` Arnd Bergmann
2016-07-29 10:19                 ` Borislav Petkov
2016-07-29 10:35                   ` Arnd Bergmann [this message]
2016-07-29 18:26                   ` Linus Torvalds

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

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

  git send-email \
    --in-reply-to=4090105.Iz5p5IbnPA@wuerfel \
    --to=arnd@arndb.de \
    --cc=bp@alien8.de \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matz@suse.de \
    --cc=mingo@kernel.org \
    --cc=mmarek@suse.com \
    --cc=sam@ravnborg.org \
    --cc=torvalds@linux-foundation.org \
    --cc=x86@kernel.org \
    /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.
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 NNTP newsgroup(s).