public inbox for linux-kbuild@vger.kernel.org
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Masahiro Yamada' <yamada.masahiro@socionext.com>,
	Borislav Petkov <bp@alien8.de>
Cc: "Leonardo Brás" <leobras.c@gmail.com>,
	"lkcamp@lists.libreplanetbr.org" <lkcamp@lists.libreplanetbr.org>,
	"Matthew Wilcox" <willy6545@gmail.com>,
	"Andy Lutomirski" <luto@kernel.org>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Ingo Molnar" <mingo@redhat.com>,
	"H. Peter Anvin" <hpa@zytor.com>, "X86 ML" <x86@kernel.org>,
	"Michal Marek" <michal.lkml@markovi.net>,
	"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
	"Linux Kbuild mailing list" <linux-kbuild@vger.kernel.org>
Subject: RE: [PATCH 1/4] Adds -Wshadow=local on KBUILD_HOSTCFLAGS
Date: Fri, 19 Oct 2018 11:28:19 +0000	[thread overview]
Message-ID: <7b87404e2a0347968013e024e52e4cb2@AcuMS.aculab.com> (raw)
In-Reply-To: <CAK7LNAQq7aE_2QYwqei7M9fg8Yen7-ucjz-t2E_hq2xkznKsQw@mail.gmail.com>

From: Masahiro Yamada
> Sent: 18 October 2018 17:39
> 
> On Thu, Oct 18, 2018 at 6:18 PM Borislav Petkov <bp@alien8.de> wrote:
> >
> > On Wed, Oct 17, 2018 at 09:40:53PM -0300, Leonardo Bras wrote:
> > > The idea was to put it as default and fix all the shadowing warnings.
> > > What do you think?  I am open to suggestions.
> >
> > That's Masahiro's call. In the rest of the kernel, those warnings are behind
> > the W=2 switch - i.e., not enabled by default.
> 
> 
> It is not realistic to enable this warning option by default.
> Even -Wshadow=local emits tons of warnings.
> (More with -Wshadow)

The question is, how many of them are actual bugs.
IMHO -Wshadow is a good idea.

> The problem of this flag is,
> it is false positive in macro expansions.

Right, but macro expansions inside macro definitions could accidentally
use the same local variable - leading to choas.

> For example, I think the following is a legitimate case.
...
> arch/arm64/kernel/fpsimd.c:713:2: note: in expansion of macro ‘write_sysreg’
>   write_sysreg(read_sysreg(CPACR_EL1) | CPACR_EL1_ZEN_EL1EN, CPACR_EL1);
>   ^~~~~~~~~~~~

Easily fixed by using different named temporaries in the two macros.
There probably aren't that many macro pairs where that happens.
Especially since many are now inlined functions.

It might be that a small number of changes get rid of most of the warnings.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

  parent reply	other threads:[~2018-10-19 19:33 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-17  0:08 [PATCH 1/4] Adds -Wshadow=local on KBUILD_HOSTCFLAGS Leonardo Brás
2018-10-17  4:32 ` [Lkcamp] " Helen Koike
2018-10-17 23:18   ` Leonardo Bras
2018-10-17  8:11 ` Borislav Petkov
2018-10-17  8:21   ` Masahiro Yamada
2018-10-17  8:31     ` Borislav Petkov
2018-10-18  0:40       ` Leonardo Bras
2018-10-18  9:16         ` Borislav Petkov
2018-10-18 16:39           ` Masahiro Yamada
2018-10-18 16:50             ` Borislav Petkov
2018-10-19  2:41               ` Masahiro Yamada
2018-10-19  2:50                 ` Leonardo Bras
2018-10-19  8:08                 ` Borislav Petkov
2018-10-19 11:28             ` David Laight [this message]
2018-10-28 16:54               ` Masahiro Yamada
2018-10-18  0:36     ` Leonardo Bras

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=7b87404e2a0347968013e024e52e4cb2@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=bp@alien8.de \
    --cc=hpa@zytor.com \
    --cc=leobras.c@gmail.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkcamp@lists.libreplanetbr.org \
    --cc=luto@kernel.org \
    --cc=michal.lkml@markovi.net \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=willy6545@gmail.com \
    --cc=x86@kernel.org \
    --cc=yamada.masahiro@socionext.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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox