From: David Gibson <david@gibson.dropbear.id.au>
To: passt-dev@passt.top, Stefano Brivio <sbrivio@redhat.com>
Cc: David Gibson <david@gibson.dropbear.id.au>
Subject: [PATCH 2/8] virtio: Reduce scope of variable
Date: Mon, 11 May 2026 20:03:16 +1000 [thread overview]
Message-ID: <20260511100322.1016757-3-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <20260511100322.1016757-1-david@gibson.dropbear.id.au>
As cppcheck points out, the 'min' variable in vu_log_queue_fill() can have
its scope reduced. Do so.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
virtio.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/virtio.c b/virtio.c
index b283de66..d7016cc3 100644
--- a/virtio.c
+++ b/virtio.c
@@ -630,9 +630,9 @@ static void vu_log_queue_fill(const struct vu_dev *vdev, struct vu_virtq *vq,
{
struct vring_desc desc_buf[VIRTQUEUE_MAX_SIZE];
struct vring_desc *desc = vq->vring.desc;
- unsigned int max, min;
unsigned num_bufs = 0;
uint64_t read_len;
+ unsigned int max;
if (!vdev->log_table || !len || !vu_has_feature(vdev, VHOST_F_LOG_ALL))
return;
@@ -672,7 +672,7 @@ static void vu_log_queue_fill(const struct vu_dev *vdev, struct vu_virtq *vq,
die("Looped descriptor");
if (le16toh(desc[index].flags) & VRING_DESC_F_WRITE) {
- min = MIN(le32toh(desc[index].len), len);
+ unsigned min = MIN(le32toh(desc[index].len), len);
vu_log_write(vdev, le64toh(desc[index].addr), min);
len -= min;
}
--
2.54.0
next prev parent reply other threads:[~2026-05-11 10:03 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-11 10:03 [PATCH 0/8] Fix assorted warnings David Gibson
2026-05-11 10:03 ` [PATCH 1/8] netlink: erromsg should be const in nl_status() David Gibson
2026-05-11 12:50 ` Laurent Vivier
2026-05-11 10:03 ` David Gibson [this message]
2026-05-11 12:51 ` [PATCH 2/8] virtio: Reduce scope of variable Laurent Vivier
2026-05-11 10:03 ` [PATCH 3/8] conf: Fix not-actually-const parameter to conf_runas() and conf_ugid() David Gibson
2026-05-11 13:00 ` Laurent Vivier
2026-05-11 10:03 ` [PATCH 4/8] clang-tidy: Squash inconsistent brace warnings in foreach macros David Gibson
2026-05-11 13:21 ` Laurent Vivier
2026-05-11 10:03 ` [PATCH 5/8] clang-tidy: Suppress sscanf() warning harder David Gibson
2026-05-11 13:23 ` Laurent Vivier
2026-05-11 10:03 ` [PATCH 6/8] packet, clang-tidy: Packet pool buffers are not NULL David Gibson
2026-05-11 13:27 ` Laurent Vivier
2026-05-11 10:03 ` [PATCH 7/8] treewide: Make some additional variables static David Gibson
2026-05-11 13:30 ` Laurent Vivier
2026-05-11 10:03 ` [PATCH 8/8] clang-tidy: Suppress some new unhelpful new warnings David Gibson
2026-05-11 13:32 ` Laurent Vivier
2026-05-12 5:45 ` [PATCH 0/8] Fix assorted warnings Stefano Brivio
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=20260511100322.1016757-3-david@gibson.dropbear.id.au \
--to=david@gibson.dropbear.id.au \
--cc=passt-dev@passt.top \
--cc=sbrivio@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.
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
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 IMAP folder(s).