From: Richard Henderson <richard.henderson@linaro.org>
To: Bernhard Beschow <shentey@gmail.com>, qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org, "Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [PATCH v2] hw/virtio/vhost-shadow-virtqueue: Silence GCC error "maybe-uninitialized"
Date: Sat, 10 Sep 2022 17:05:02 +0100 [thread overview]
Message-ID: <9498efbe-8aa3-708d-f9f4-52362bc3e458@linaro.org> (raw)
In-Reply-To: <20220910151117.6665-1-shentey@gmail.com>
On 9/10/22 16:11, Bernhard Beschow wrote:
> GCC issues a false positive warning, resulting in build failure with -Werror:
>
> In file included from /usr/include/glib-2.0/glib.h:114,
> from src/include/glib-compat.h:32,
> from src/include/qemu/osdep.h:144,
> from ../src/hw/virtio/vhost-shadow-virtqueue.c:10:
> In function ‘g_autoptr_cleanup_generic_gfree’,
> inlined from ‘vhost_handle_guest_kick’ at ../src/hw/virtio/vhost-shadow-virtqueue.c:292:42:
> /usr/include/glib-2.0/glib/glib-autocleanups.h:28:3: error: ‘elem’ may be used uninitialized [-Werror=maybe-uninitialized]
> 28 | g_free (*pp);
> | ^~~~~~~~~~~~
> ../src/hw/virtio/vhost-shadow-virtqueue.c: In function ‘vhost_handle_guest_kick’:
> ../src/hw/virtio/vhost-shadow-virtqueue.c:292:42: note: ‘elem’ was declared here
> 292 | g_autofree VirtQueueElement *elem;
> | ^~~~
> cc1: all warnings being treated as errors
>
> There is actually no problem since "elem" is initialized in both branches.
> Silence the warning by initializig it with "NULL".
>
> $ gcc --version
> gcc (GCC) 12.2.0
>
> Fixes: 9c2ab2f1ec333be8614cc12272d4b91960704dbe ("vhost: stop transfer elem ownership in vhost_handle_guest_kick")
> Signed-off-by: Bernhard Beschow<shentey@gmail.com>
> ---
> hw/virtio/vhost-shadow-virtqueue.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
It's not a false positive, but the fix is correct.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
next prev parent reply other threads:[~2022-09-10 16:07 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-10 15:11 [PATCH v2] hw/virtio/vhost-shadow-virtqueue: Silence GCC error "maybe-uninitialized" Bernhard Beschow
2022-09-10 16:05 ` Richard Henderson [this message]
2022-09-10 20:20 ` Bernhard Beschow
2022-09-20 5:29 ` Bernhard Beschow
2022-09-27 22:08 ` B
2022-09-29 19:08 ` Laurent Vivier
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=9498efbe-8aa3-708d-f9f4-52362bc3e458@linaro.org \
--to=richard.henderson@linaro.org \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
--cc=shentey@gmail.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).