From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202602 header.b=TdyVPOKG; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 7D8A45A026D for ; Mon, 11 May 2026 12:03:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202602; t=1778493804; bh=H0EP3Tc9KnGvh4aIomMjyVvQMs96LZs4yirGqFLaJpE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TdyVPOKGOEdlZFz/62RtieELqcJfZj6XCLxd3lGvyGulYW1yabJSjPlZu5T4XdNhN s/apraNgUwsa6MNyqMECC/XahlMHB+SkmkCyU0hIQb7lzTJjzCW+CZq2v7cPKapEX+ 98cVr0VtWW5E+OV9ZXq+2JEhwgYfBoRNQ6/FBgZ4qEltvz2u6nt2LkdmBYzwKm2rMA pXHdmNtO/N3XZIkR2dlo+MafTz1uu/RBBckmvTTvozPa89xmKy+ih/y0GUWqG+GEbY fOHSXlnGMfnFSaupYBQhZtpyIRPW08FU8Etjccaqnkno4S6Dtdkg4wU72zMM3ipyyF WNwbBGhC4VOxQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4gDZzw18Ssz4wJT; Mon, 11 May 2026 20:03:24 +1000 (AEST) From: David Gibson To: passt-dev@passt.top, Stefano Brivio Subject: [PATCH 2/8] virtio: Reduce scope of variable Date: Mon, 11 May 2026 20:03:16 +1000 Message-ID: <20260511100322.1016757-3-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260511100322.1016757-1-david@gibson.dropbear.id.au> References: <20260511100322.1016757-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: 3ULZC2FFVHT7IUTDULL57RHWNTZPCBCC X-Message-ID-Hash: 3ULZC2FFVHT7IUTDULL57RHWNTZPCBCC X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: David Gibson X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: As cppcheck points out, the 'min' variable in vu_log_queue_fill() can have its scope reduced. Do so. Signed-off-by: David Gibson --- 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