All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Gerd Hoffmann" <kraxel@redhat.com>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>
Subject: Re: [v3] Help wanted for enabling -Wshadow=local
Date: Fri, 06 Oct 2023 20:41:20 +0200	[thread overview]
Message-ID: <874jj3egq7.fsf@pond.sub.org> (raw)
In-Reply-To: <87mswvg683.fsf@pond.sub.org> (Markus Armbruster's message of "Fri, 06 Oct 2023 16:45:16 +0200")

Markus Armbruster <armbru@redhat.com> writes:

> Local variables shadowing other local variables or parameters make the
> code needlessly hard to understand.  Bugs love to hide in such code.
> Evidence: "[PATCH v3 1/7] migration/rdma: Fix save_page method to fail
> on polling error".
>
> Enabling -Wshadow would prevent bugs like this one.  But we have to
> clean up all the offenders first.
>
> Quite a few people responded to my calls for help.  Thank you so much!
>
> I'm collecting patches in my git repo at
> https://repo.or.cz/qemu/armbru.git in branch shadow-next.  All but the
> last two are in a pending pull request.
>
> My test build is down to seven files with warnings.  "[PATCH v2 0/3]
> hexagon: GETPC() and shadowing fixes" takes care of four, but it needs a
> rebase.
>
> Remaining three:
>
>     In file included from ../hw/display/virtio-gpu-virgl.c:19:
>     ../hw/display/virtio-gpu-virgl.c: In function ‘virgl_cmd_submit_3d’:
>     /work/armbru/qemu/include/hw/virtio/virtio-gpu.h:228:16: warning: declaration of ‘s’ shadows a previous local [-Wshadow=compatible-local]
>       228 |         size_t s;                                                       \
>           |                ^
>     ../hw/display/virtio-gpu-virgl.c:215:5: note: in expansion of macro ‘VIRTIO_GPU_FILL_CMD’
>       215 |     VIRTIO_GPU_FILL_CMD(cs);
>           |     ^~~~~~~~~~~~~~~~~~~
>     ../hw/display/virtio-gpu-virgl.c:213:12: note: shadowed declaration is here
>       213 |     size_t s;
>           |            ^
>
>     In file included from ../contrib/vhost-user-gpu/virgl.h:18,
>                      from ../contrib/vhost-user-gpu/virgl.c:17:
>     ../contrib/vhost-user-gpu/virgl.c: In function ‘virgl_cmd_submit_3d’:
>     ../contrib/vhost-user-gpu/vugpu.h:167:16: warning: declaration of ‘s’ shadows a previous local [-Wshadow=compatible-local]
>       167 |         size_t s;                                               \
>           |                ^
>     ../contrib/vhost-user-gpu/virgl.c:203:5: note: in expansion of macro ‘VUGPU_FILL_CMD’
>       203 |     VUGPU_FILL_CMD(cs);
>           |     ^~~~~~~~~~~~~~
>     ../contrib/vhost-user-gpu/virgl.c:201:12: note: shadowed declaration is here
>       201 |     size_t s;
>           |            ^
>
>     ../contrib/vhost-user-gpu/vhost-user-gpu.c: In function ‘vg_resource_flush’:
>     ../contrib/vhost-user-gpu/vhost-user-gpu.c:837:29: warning: declaration of ‘i’ shadows a previous local [-Wshadow=local]
>       837 |             pixman_image_t *i =
>           |                             ^
>     ../contrib/vhost-user-gpu/vhost-user-gpu.c:757:9: note: shadowed declaration is here
>       757 |     int i;
>           |         ^
>
> Gerd, Marc-André, or anybody else?

Thomas posted patches:

    [PATCH] hw/virtio/virtio-gpu: Fix compiler warning when compiling with -Wshadow
    [PATCH] contrib/vhost-user-gpu: Fix compiler warning when compiling with -Wshadow

> More warnings may lurk in code my test build doesn't compile.  Need a
> full CI build with -Wshadow=local to find them.  Anybody care to kick
> one off?

Thomas did; see his reply downthread.

Thank you, Thomas!



      parent reply	other threads:[~2023-10-06 18:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-06 14:45 [v3] Help wanted for enabling -Wshadow=local Markus Armbruster
2023-10-06 16:18 ` Thomas Huth
2023-10-06 17:55   ` Thomas Huth
2023-10-06 19:08     ` Warner Losh
2023-10-09  6:24       ` Markus Armbruster
2023-10-09  7:50       ` Thomas Huth
2023-10-06 18:41 ` Markus Armbruster [this message]

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=874jj3egq7.fsf@pond.sub.org \
    --to=armbru@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=qemu-devel@nongnu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.