qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: Warner Losh <imp@bsdimp.com>, Markus Armbruster <armbru@redhat.com>
Cc: "QEMU Developers" <qemu-devel@nongnu.org>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Daniel P. Berrange" <berrange@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Brian Cain" <bcain@quicinc.com>,
	"Stefan Hajnoczi" <stefanha@redhat.com>
Subject: Re: [PATCH 1/1] meson: Enable -Wshadow=local
Date: Thu, 26 Oct 2023 07:55:01 +0200	[thread overview]
Message-ID: <520430a5-3e10-4503-9bb4-7360e1f5d8fe@redhat.com> (raw)
In-Reply-To: <CANCZdfpVS0-AuobG0=BwZ+36QWkVSr_tQozn9m2ks7kKS9uXUQ@mail.gmail.com>

On 26/10/2023 07.51, Warner Losh wrote:
> 
> 
> On Wed, Oct 25, 2023, 11:31 PM Markus Armbruster <armbru@redhat.com 
> <mailto:armbru@redhat.com>> wrote:
> 
>     Local variables shadowing other local variables or parameters make the
>     code needlessly hard to understand.  Bugs love to hide in such code.
>     Evidence: commit bbde656263d (migration/rdma: Fix save_page method to
>     fail on polling error).
> 
>     Enable -Wshadow=local to prevent such issues.  Possible thanks to
>     recent cleanups.  Enabling -Wshadow would prevent more issues, but
>     we're not yet ready for that.
> 
>     As usual, the warning is only enabled when the compiler recognizes it.
>     GCC does, Clang doesn't.
> 
>     Some shadowed locals remain in bsd-user.  Since BSD prefers Clang,
>     let's not wait for its cleanup.
> 
>     Signed-off-by: Markus Armbruster <armbru@redhat.com
>     <mailto:armbru@redhat.com>>
>     ---
>       meson.build | 1 +
>       1 file changed, 1 insertion(+)
> 
>     diff --git a/meson.build b/meson.build
>     index dcef8b1e79..89220443b8 100644
>     --- a/meson.build
>     +++ b/meson.build
>     @@ -462,6 +462,7 @@ warn_flags = [
>         '-Wno-tautological-type-limit-compare',
>         '-Wno-psabi',
>         '-Wno-gnu-variable-sized-type-not-at-end',
>     +  '-Wshadow=local',
> 
> 
> Does this work with clang? I've not had good luck enabling it.

The flags are added via cc.get_supported_arguments(warn_flags), so meson 
checks whether the compiler supports them before blindly adding them to the 
list.
That means it should get ignored with Clang, i.e. we should be ok for the 
remaining spots in the bsd-user code, assuming that most FreeBSD users will 
use Clang to compile QEMU.

  Thomas




  reply	other threads:[~2023-10-26  5:55 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-26  5:31 [PATCH 0/1] Enable -Wshadow=local Markus Armbruster
2023-10-26  5:31 ` [PATCH 1/1] meson: " Markus Armbruster
2023-10-26  5:44   ` Thomas Huth
2023-10-26  5:51   ` Warner Losh
2023-10-26  5:55     ` Thomas Huth [this message]
2023-10-26  5:58   ` Philippe Mathieu-Daudé
2023-10-26  6:12     ` Thomas Huth
2023-10-26  6:17       ` Philippe Mathieu-Daudé
2023-10-26  6:50         ` Markus Armbruster
2023-10-26 10:05     ` Daniel P. Berrangé
2023-10-26  5:54 ` [PATCH 0/1] " Warner Losh
2023-10-27  0:52 ` Stefan Hajnoczi
2023-10-27  2:25   ` Brian Cain
2023-10-27  4:41   ` Markus Armbruster
2023-10-30  4:58     ` Stefan Hajnoczi

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=520430a5-3e10-4503-9bb4-7360e1f5d8fe@redhat.com \
    --to=thuth@redhat.com \
    --cc=armbru@redhat.com \
    --cc=bcain@quicinc.com \
    --cc=berrange@redhat.com \
    --cc=imp@bsdimp.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.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;
as well as URLs for NNTP newsgroup(s).