[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 18/22] hw/virtio: fix -Werror=maybe-uninitialized false-po
From: |
Stefano Garzarella |
Subject: |
Re: [PATCH v2 18/22] hw/virtio: fix -Werror=maybe-uninitialized false-positive |
Date: |
Wed, 25 Sep 2024 10:07:53 +0200 |
On Tue, Sep 24, 2024 at 05:05:49PM GMT, marcandre.lureau@redhat.com wrote:
From: Marc-André Lureau <marcandre.lureau@redhat.com>
For the title: I don't think it is a false positive, but a real fix,
indeed maybe not a complete one.
../hw/virtio/vhost-shadow-virtqueue.c:545:13: error: ‘r’ may be used
uninitialized [-Werror=maybe-uninitialized]
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.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 fc5f408f77..cd29cc795b 100644
--- a/hw/virtio/vhost-shadow-virtqueue.c
+++ b/hw/virtio/vhost-shadow-virtqueue.c
@@ -526,7 +526,7 @@ static void vhost_svq_flush(VhostShadowVirtqueue *svq,
size_t vhost_svq_poll(VhostShadowVirtqueue *svq, size_t num)
{
size_t len = 0;
- uint32_t r;
+ uint32_t r = 0;
while (num--) {
I think we should move the initialization to 0 here in the loop:
uint32_t r = 0;
int64_t start_us = g_get_monotonic_time();
...
vhost_svq_get_buf(svq, &r);
len += r;
}
This because we don't check vhost_svq_get_buf() return value.
IIUC, in that function, `r` is set only if the return value of
vhost_svq_get_buf() is not null, so if we don't check its return value,
we should set `r` to 0 on every cycle (or check the return value of
course).
Thanks,
Stefano
- [PATCH v2 08/22] hw/ahci: fix -Werror=maybe-uninitialized false-positive, (continued)
- [PATCH v2 08/22] hw/ahci: fix -Werror=maybe-uninitialized false-positive, marcandre . lureau, 2024/09/24
- [PATCH v2 10/22] hw/sdhci: fix -Werror=maybe-uninitialized false-positive, marcandre . lureau, 2024/09/24
- [PATCH v2 12/22] migration: fix -Werror=maybe-uninitialized false-positives, marcandre . lureau, 2024/09/24
- [PATCH v2 11/22] block/block-copy: fix -Werror=maybe-uninitialized false-positive, marcandre . lureau, 2024/09/24
- [PATCH v2 16/22] target/loongarch: fix -Werror=maybe-uninitialized false-positive, marcandre . lureau, 2024/09/24
- [PATCH v2 13/22] hw/virtio-blk: fix -Werror=maybe-uninitialized false-positive, marcandre . lureau, 2024/09/24
- [PATCH v2 15/22] linux-user/hppa: fix -Werror=maybe-uninitialized false-positive, marcandre . lureau, 2024/09/24
- [PATCH v2 18/22] hw/virtio: fix -Werror=maybe-uninitialized false-positive, marcandre . lureau, 2024/09/24
- Re: [PATCH v2 18/22] hw/virtio: fix -Werror=maybe-uninitialized false-positive, Eugenio Perez Martin, 2024/09/27
- Re: [PATCH v2 18/22] hw/virtio: fix -Werror=maybe-uninitialized false-positive, Stefano Garzarella, 2024/09/30
[PATCH v2 19/22] block: fix -Werror=maybe-uninitialized false-positive, marcandre . lureau, 2024/09/24
[PATCH v2 14/22] migration: fix -Werror=maybe-uninitialized false-positive, marcandre . lureau, 2024/09/24
[PATCH v2 21/22] fsdep/9p: fix -Werror=maybe-uninitialized false-positive, marcandre . lureau, 2024/09/24
[PATCH v2 17/22] tests: fix -Werror=maybe-uninitialized false-positive, marcandre . lureau, 2024/09/24
[PATCH v2 22/22] RFC: hw/virtio: a potential leak fix, marcandre . lureau, 2024/09/24