From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id F0B0A7075C for ; Wed, 22 Jun 2022 10:45:54 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id E7474DA2D for ; Wed, 22 Jun 2022 10:45:24 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id CC9C7DA11 for ; Wed, 22 Jun 2022 10:45:23 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 9F90C43C56 for ; Wed, 22 Jun 2022 10:45:16 +0200 (CEST) From: Fabian Ebner To: pve-devel@lists.proxmox.com Date: Wed, 22 Jun 2022 10:45:13 +0200 Message-Id: <20220622084513.160867-4-f.ebner@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220622084513.160867-1-f.ebner@proxmox.com> References: <20220622084513.160867-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.046 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pve-devel] [PATCH v2 qemu 3/3] block: alloc-track: avoid premature break X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Jun 2022 08:45:55 -0000 While the bdrv_co_preadv() calls are expected to return 0 on success, qemu_iovec_memset() will return the number of bytes set (will be local_bytes, because the slice with that size was just initialized). Don't break out of the loop after the branch with qemu_iovec_memset(), because there might still be work to do. Additionally, ret is an int, which on 64-bit platforms is too small to hold the size_t returned by qemu_iovec_memset(). The branch seems to be difficult to reach in practice, because the whole point of alloc-track is to be used with a backing device. Signed-off-by: Fabian Ebner --- New in v2. block/alloc-track.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/block/alloc-track.c b/block/alloc-track.c index 6b50fbe537..c1160af04b 100644 --- a/block/alloc-track.c +++ b/block/alloc-track.c @@ -174,7 +174,8 @@ static int coroutine_fn track_co_preadv(BlockDriverState *bs, ret = bdrv_co_preadv(bs->backing, local_offset, local_bytes, &local_qiov, flags); } else { - ret = qemu_iovec_memset(&local_qiov, cur_offset, 0, local_bytes); + qemu_iovec_memset(&local_qiov, cur_offset, 0, local_bytes); + ret = 0; } if (ret != 0) { -- 2.30.2