From nobody Thu Nov 6 16:03:52 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1489441411317314.916551536509; Mon, 13 Mar 2017 14:43:31 -0700 (PDT) Received: from localhost ([::1]:54543 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnXkY-0000XN-3j for importer@patchew.org; Mon, 13 Mar 2017 17:43:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43710) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnXi5-0007RO-9W for qemu-devel@nongnu.org; Mon, 13 Mar 2017 17:40:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cnXi4-0001pf-6i for qemu-devel@nongnu.org; Mon, 13 Mar 2017 17:40:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44382) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cnXi2-0001op-42; Mon, 13 Mar 2017 17:40:54 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 437997702; Mon, 13 Mar 2017 21:40:54 +0000 (UTC) Received: from localhost (ovpn-204-63.brq.redhat.com [10.40.204.63]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2DLeqt0018960 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 13 Mar 2017 17:40:53 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 13 Mar 2017 22:40:34 +0100 Message-Id: <20170313214045.26857-3-mreitz@redhat.com> In-Reply-To: <20170313214001.26339-1-mreitz@redhat.com> References: <20170313214001.26339-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 13 Mar 2017 21:40:54 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH for-2.10 05/16] block/file-posix: Small fixes in raw_create() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Variables should be declared at the start of a block, and if a certain parameter value is not supported it may be better to return -ENOTSUP instead of -EINVAL. Signed-off-by: Max Reitz Reviewed-by: Stefan Hajnoczi --- block/file-posix.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/block/file-posix.c b/block/file-posix.c index dde8c101c8..b02d8fc37b 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -1670,6 +1670,8 @@ static int raw_create(const char *filename, QemuOpts = *opts, Error **errp) #endif case PREALLOC_MODE_FULL: { + int64_t num =3D 0, left =3D total_size; + /* * Knowing the final size from the beginning could allow the file * system driver to do less allocations and possibly avoid @@ -1681,7 +1683,6 @@ static int raw_create(const char *filename, QemuOpts = *opts, Error **errp) goto out_close; } =20 - int64_t num =3D 0, left =3D total_size; buf =3D g_malloc0(65536); =20 while (left > 0) { @@ -1713,7 +1714,7 @@ static int raw_create(const char *filename, QemuOpts = *opts, Error **errp) } break; default: - result =3D -EINVAL; + result =3D -ENOTSUP; error_setg(errp, "Unsupported preallocation mode: %s", PreallocMode_lookup[prealloc]); break; --=20 2.12.0