From nobody Wed Apr 16 04:35: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.zohomail.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 1499792922716305.856463836466; Tue, 11 Jul 2017 10:08:42 -0700 (PDT) Received: from localhost ([::1]:47664 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dUyeL-0003yq-9v for importer@patchew.org; Tue, 11 Jul 2017 13:08:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47020) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dUxmJ-00027Q-HN for qemu-devel@nongnu.org; Tue, 11 Jul 2017 12:12:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dUxmI-0007Hz-MY for qemu-devel@nongnu.org; Tue, 11 Jul 2017 12:12:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54134) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dUxmG-0007F8-LC; Tue, 11 Jul 2017 12:12:44 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5B2A54E04A; Tue, 11 Jul 2017 16:12:43 +0000 (UTC) Received: from localhost (ovpn-204-123.brq.redhat.com [10.40.204.123]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8349B5C6A1; Tue, 11 Jul 2017 16:12:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5B2A54E04A Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=mreitz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 5B2A54E04A From: Max Reitz To: qemu-block@nongnu.org Date: Tue, 11 Jul 2017 18:08:03 +0200 Message-Id: <20170711160814.20941-75-mreitz@redhat.com> In-Reply-To: <20170711160814.20941-1-mreitz@redhat.com> References: <20170711160814.20941-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 11 Jul 2017 16:12:43 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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] [PULL 74/85] 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: 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-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 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20170613202107.10125-6-mreitz@redhat.com Signed-off-by: Max Reitz --- 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 4a40976..3388def 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -1910,6 +1910,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 @@ -1921,7 +1923,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) { @@ -1953,7 +1954,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.9.4