From nobody Sat Nov 15 12:38:10 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1752608841; cv=none; d=zohomail.com; s=zohoarc; b=GCbskrYHvFNF0sgiRgAIjB/PJGeyb8TkDJ9C9ke/6/nwKCaz6PRTfOEaPLi8FYFCIct/Yfo56o4w6MsxFDeebNq3p8q7uVDMvbgFV1EqVBLWtxSM0G1sHgRYSWTJJp2qcAzMX6ft7xgoLl3JR+zZQtSuBRHV54dcAQEAi1FKoHI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1752608841; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=dyVMTv6sGhp4EucS+e3TQ9pqVVDsby/Mjxux88RCYOU=; b=TwanFfIUi1X++lbgz4703gMoXQ8skQgcQ8vurvr8/xYKosEXxnLoHqV+9aJgsMXc1y8US7hbLTJJlHbpkcX20S77S41cM6yqHYHOmw3lpoQxSq0Yf47HF3JqDBWEmHcpiVgYX1kqnmn1h5qSg1+aVcPbBYqj2/LbC1f21Z5LDTw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1752608841173231.34616746078393; Tue, 15 Jul 2025 12:47:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ublYp-0003GB-OG; Tue, 15 Jul 2025 15:43:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ubkxM-0004BD-72 for qemu-devel@nongnu.org; Tue, 15 Jul 2025 15:04:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ubkxK-0001RA-De for qemu-devel@nongnu.org; Tue, 15 Jul 2025 15:04:47 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-93-FOwqosT3MmOyx3uCB1DHZA-1; Tue, 15 Jul 2025 15:04:43 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id EB1D31956080; Tue, 15 Jul 2025 19:04:42 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.44.34.84]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 66780197702B; Tue, 15 Jul 2025 19:04:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1752606285; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dyVMTv6sGhp4EucS+e3TQ9pqVVDsby/Mjxux88RCYOU=; b=OGLdp+lAofnAlFTwLibRKJNrP4LoIljX9CHxFYlIzOBhdlfNsN9OVNLkRQSy4nDPAXYhqP WUJWpSpng+dJ9JQE1cuSNPdCBwvqkECHbJTNwuFrB3YS9VLyIKbq3kjSbXPXkzND2rcmLr azbqcI0tfrTb9JMuV3+kOerzM5mvd5A= X-MC-Unique: FOwqosT3MmOyx3uCB1DHZA-1 X-Mimecast-MFC-AGG-ID: FOwqosT3MmOyx3uCB1DHZA_1752606283 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 31/57] qemu-img: measure: convert img_size to signed, simplify handling Date: Tue, 15 Jul 2025 21:03:04 +0200 Message-ID: <20250715190330.378764-32-kwolf@redhat.com> In-Reply-To: <20250715190330.378764-1-kwolf@redhat.com> References: <20250715190330.378764-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1752608841877116600 From: Michael Tokarev qemu_opt_set_number() expects signed int64_t. Use int64_t instead of uint64_t for img_size, use -1 as "unset" value instead of UINT64_MAX, and do not require temporary sval for conversion from string. Signed-off-by: Michael Tokarev Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Kevin Wolf Message-ID: <20250531171609.197078-2-mjt@tls.msk.ru> Signed-off-by: Kevin Wolf --- qemu-img.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index e75707180d..e676602fc7 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -5370,7 +5370,7 @@ static int img_measure(int argc, char **argv) QemuOpts *sn_opts =3D NULL; QemuOptsList *create_opts =3D NULL; bool image_opts =3D false; - uint64_t img_size =3D UINT64_MAX; + int64_t img_size =3D -1; BlockMeasureInfo *info =3D NULL; Error *local_err =3D NULL; int ret =3D 1; @@ -5428,16 +5428,11 @@ static int img_measure(int argc, char **argv) } break; case OPTION_SIZE: - { - int64_t sval; - - sval =3D cvtnum("image size", optarg); - if (sval < 0) { + img_size =3D cvtnum("image size", optarg); + if (img_size < 0) { goto out; } - img_size =3D (uint64_t)sval; - } - break; + break; } } =20 @@ -5452,11 +5447,11 @@ static int img_measure(int argc, char **argv) error_report("--image-opts, -f, and -l require a filename argument= ."); goto out; } - if (filename && img_size !=3D UINT64_MAX) { + if (filename && img_size !=3D -1) { error_report("--size N cannot be used together with a filename."); goto out; } - if (!filename && img_size =3D=3D UINT64_MAX) { + if (!filename && img_size =3D=3D -1) { error_report("Either --size N or one filename must be specified."); goto out; } @@ -5504,7 +5499,7 @@ static int img_measure(int argc, char **argv) goto out; } } - if (img_size !=3D UINT64_MAX) { + if (img_size !=3D -1) { qemu_opt_set_number(opts, BLOCK_OPT_SIZE, img_size, &error_abort); } =20 --=20 2.50.1