* [PATCH v2] hw/virtio/vhost-shadow-virtqueue: Silence GCC error "maybe-uninitialized"
@ 2022-09-10 15:11 Bernhard Beschow
2022-09-10 16:05 ` Richard Henderson
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Bernhard Beschow @ 2022-09-10 15:11 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Michael S. Tsirkin, Bernhard Beschow
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(-)
diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c
index e8e5bbc368..596d4434d2 100644
--- a/hw/virtio/vhost-shadow-virtqueue.c
+++ b/hw/virtio/vhost-shadow-virtqueue.c
@@ -289,7 +289,7 @@ static void vhost_handle_guest_kick(VhostShadowVirtqueue *svq)
virtio_queue_set_notification(svq->vq, false);
while (true) {
- g_autofree VirtQueueElement *elem;
+ g_autofree VirtQueueElement *elem = NULL;
int r;
if (svq->next_guest_avail_elem) {
--
2.37.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2] hw/virtio/vhost-shadow-virtqueue: Silence GCC error "maybe-uninitialized"
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
2022-09-10 20:20 ` Bernhard Beschow
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Richard Henderson @ 2022-09-10 16:05 UTC (permalink / raw)
To: Bernhard Beschow, qemu-devel; +Cc: qemu-trivial, Michael S. Tsirkin
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~
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] hw/virtio/vhost-shadow-virtqueue: Silence GCC error "maybe-uninitialized"
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
@ 2022-09-10 20:20 ` Bernhard Beschow
2022-09-20 5:29 ` Bernhard Beschow
2022-09-29 19:08 ` Laurent Vivier
3 siblings, 0 replies; 6+ messages in thread
From: Bernhard Beschow @ 2022-09-10 20:20 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Michael S. Tsirkin
Am 10. September 2022 15:11:17 UTC schrieb Bernhard Beschow <shentey@gmail.com>:
>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>
Forgot to add from v1:
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>---
> hw/virtio/vhost-shadow-virtqueue.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c
>index e8e5bbc368..596d4434d2 100644
>--- a/hw/virtio/vhost-shadow-virtqueue.c
>+++ b/hw/virtio/vhost-shadow-virtqueue.c
>@@ -289,7 +289,7 @@ static void vhost_handle_guest_kick(VhostShadowVirtqueue *svq)
> virtio_queue_set_notification(svq->vq, false);
>
> while (true) {
>- g_autofree VirtQueueElement *elem;
>+ g_autofree VirtQueueElement *elem = NULL;
> int r;
>
> if (svq->next_guest_avail_elem) {
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] hw/virtio/vhost-shadow-virtqueue: Silence GCC error "maybe-uninitialized"
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
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
3 siblings, 1 reply; 6+ messages in thread
From: Bernhard Beschow @ 2022-09-20 5:29 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Michael S. Tsirkin
Am 10. September 2022 15:11:17 UTC schrieb Bernhard Beschow <shentey@gmail.com>:
>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>
>---
Ping
> hw/virtio/vhost-shadow-virtqueue.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c
>index e8e5bbc368..596d4434d2 100644
>--- a/hw/virtio/vhost-shadow-virtqueue.c
>+++ b/hw/virtio/vhost-shadow-virtqueue.c
>@@ -289,7 +289,7 @@ static void vhost_handle_guest_kick(VhostShadowVirtqueue *svq)
> virtio_queue_set_notification(svq->vq, false);
>
> while (true) {
>- g_autofree VirtQueueElement *elem;
>+ g_autofree VirtQueueElement *elem = NULL;
> int r;
>
> if (svq->next_guest_avail_elem) {
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] hw/virtio/vhost-shadow-virtqueue: Silence GCC error "maybe-uninitialized"
2022-09-20 5:29 ` Bernhard Beschow
@ 2022-09-27 22:08 ` B
0 siblings, 0 replies; 6+ messages in thread
From: B @ 2022-09-27 22:08 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Michael S. Tsirkin
Am 20. September 2022 05:29:25 UTC schrieb Bernhard Beschow <shentey@gmail.com>:
>Am 10. September 2022 15:11:17 UTC schrieb Bernhard Beschow <shentey@gmail.com>:
>>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>
>>---
>
>Ping
Ping2
>
>> hw/virtio/vhost-shadow-virtqueue.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>>diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c
>>index e8e5bbc368..596d4434d2 100644
>>--- a/hw/virtio/vhost-shadow-virtqueue.c
>>+++ b/hw/virtio/vhost-shadow-virtqueue.c
>>@@ -289,7 +289,7 @@ static void vhost_handle_guest_kick(VhostShadowVirtqueue *svq)
>> virtio_queue_set_notification(svq->vq, false);
>>
>> while (true) {
>>- g_autofree VirtQueueElement *elem;
>>+ g_autofree VirtQueueElement *elem = NULL;
>> int r;
>>
>> if (svq->next_guest_avail_elem) {
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] hw/virtio/vhost-shadow-virtqueue: Silence GCC error "maybe-uninitialized"
2022-09-10 15:11 [PATCH v2] hw/virtio/vhost-shadow-virtqueue: Silence GCC error "maybe-uninitialized" Bernhard Beschow
` (2 preceding siblings ...)
2022-09-20 5:29 ` Bernhard Beschow
@ 2022-09-29 19:08 ` Laurent Vivier
3 siblings, 0 replies; 6+ messages in thread
From: Laurent Vivier @ 2022-09-29 19:08 UTC (permalink / raw)
To: Bernhard Beschow, qemu-devel; +Cc: qemu-trivial, Michael S. Tsirkin
Le 10/09/2022 à 17:11, Bernhard Beschow a écrit :
> 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(-)
>
> diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c
> index e8e5bbc368..596d4434d2 100644
> --- a/hw/virtio/vhost-shadow-virtqueue.c
> +++ b/hw/virtio/vhost-shadow-virtqueue.c
> @@ -289,7 +289,7 @@ static void vhost_handle_guest_kick(VhostShadowVirtqueue *svq)
> virtio_queue_set_notification(svq->vq, false);
>
> while (true) {
> - g_autofree VirtQueueElement *elem;
> + g_autofree VirtQueueElement *elem = NULL;
> int r;
>
> if (svq->next_guest_avail_elem) {
Applied to my trivial-patches branch.
Thanks,
Laurent
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-09-29 19:10 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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
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.