From nobody Sat Nov 15 12:42:45 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=1752608642; cv=none; d=zohomail.com; s=zohoarc; b=jvFKGWpf6674ILy43inWOimOttxdA4wL48EOFCClVVvBagcV0htf9VWfWKx0ASpBcmuQTZcF6owNB/cQBp9VkQovn+zjgIi6BGIk+us9l2L9IMAdBCogHvuBxv8C8kQzFgetPdGvpq8eH3kQi61i/j6i+s4IH/3q5S70ypsJS/w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1752608642; 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=9NhuAW73W93wsBq/i0J12yeR0nN/1/SZBmn64E0RS5A=; b=higdJ0tpmqanZH2XLI0rnpIVmZMHowzVGoFUWQEfBC7jixb0kUBdXSRZC+mvJufbtzR2o++CnYerr45CyWlhE0nWrOArZ/2XluEm4XF5/V/xR7pJZCMnly2OldjeYDasaBU59NVWPLySHFGPEIx7ur6RHYbhKCfcrTFNPlHpdKo= 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 1752608642215123.34212288916558; Tue, 15 Jul 2025 12:44:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ublZ9-000512-HC; Tue, 15 Jul 2025 15:43:51 -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 1ubkxO-0004CS-Ma for qemu-devel@nongnu.org; Tue, 15 Jul 2025 15:04:50 -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 1ubkxM-0001RX-I1 for qemu-devel@nongnu.org; Tue, 15 Jul 2025 15:04:49 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-685-7xOFwz53PGCAQ2b7K2TJcw-1; Tue, 15 Jul 2025 15:04:46 -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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5962E180120B; Tue, 15 Jul 2025 19:04:45 +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 6C138197702C; Tue, 15 Jul 2025 19:04:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1752606287; 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=9NhuAW73W93wsBq/i0J12yeR0nN/1/SZBmn64E0RS5A=; b=P8cck4ZADp2AR3pM8caVYeoMtRCuAGS47oSjvErU1cv/77GnHWwv88wU16DBOM7hB8odpA tc2mDlZiw2Osn5bNe4jjoaMlFy6gU62qp4VHGcUvIua3Quity8eyMWI5iFjCaON5nMtcek a/ROehxZtCAn0IGVGjScFRu2MJK4CNM= X-MC-Unique: 7xOFwz53PGCAQ2b7K2TJcw-1 X-Mimecast-MFC-AGG-ID: 7xOFwz53PGCAQ2b7K2TJcw_1752606285 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 32/57] qemu-img: create: convert img_size to signed, simplify handling Date: Tue, 15 Jul 2025 21:03:05 +0200 Message-ID: <20250715190330.378764-33-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: 1752608643139116600 From: Michael Tokarev Initializing an unsigned as -1, or using temporary sval for conversion is awkward. Since we don't allow other "negative" values anyway, use signed value and pass it to bdrv_img_create() (where it is properly converted to unsigned), simplifying code. Signed-off-by: Michael Tokarev Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Kevin Wolf Message-ID: <20250531171609.197078-3-mjt@tls.msk.ru> Signed-off-by: Kevin Wolf --- qemu-img.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index e676602fc7..6750d0657c 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -511,7 +511,7 @@ static int64_t cvtnum(const char *name, const char *val= ue) static int img_create(int argc, char **argv) { int c; - uint64_t img_size =3D -1; + int64_t img_size =3D -1; const char *fmt =3D "raw"; const char *base_fmt =3D NULL; const char *filename; @@ -582,13 +582,10 @@ static int img_create(int argc, char **argv) =20 /* Get image size, if specified */ if (optind < argc) { - int64_t sval; - - sval =3D cvtnum("image size", argv[optind++]); - if (sval < 0) { + img_size =3D cvtnum("image size", argv[optind++]); + if (img_size < 0) { goto fail; } - img_size =3D (uint64_t)sval; } if (optind !=3D argc) { error_exit("Unexpected argument: %s", argv[optind]); --=20 2.50.1