From nobody Fri Dec 19 06:56:58 2025 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) 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=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1509101005772579.5388468537518; Fri, 27 Oct 2017 03:43:25 -0700 (PDT) Received: from localhost ([::1]:56552 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e826V-0002nU-Ui for importer@patchew.org; Fri, 27 Oct 2017 06:43:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57251) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e824P-0001E6-EL for qemu-devel@nongnu.org; Fri, 27 Oct 2017 06:40:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e824O-0005bZ-Li for qemu-devel@nongnu.org; Fri, 27 Oct 2017 06:40:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40014) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e824K-0005Yj-Uv; Fri, 27 Oct 2017 06:40:53 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DF63D5D9E6; Fri, 27 Oct 2017 10:40:51 +0000 (UTC) Received: from red.redhat.com (ovpn-120-166.rdu2.redhat.com [10.10.120.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 83E405C549; Fri, 27 Oct 2017 10:40:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DF63D5D9E6 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=eblake@redhat.com From: Eric Blake To: qemu-devel@nongnu.org Date: Fri, 27 Oct 2017 12:40:30 +0200 Message-Id: <20171027104037.8319-6-eblake@redhat.com> In-Reply-To: <20171027104037.8319-1-eblake@redhat.com> References: <20171027104037.8319-1-eblake@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 27 Oct 2017 10:40:52 +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 v6 05/12] nbd/server: Simplify nbd_negotiate_options loop 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: pbonzini@redhat.com, vsementsov@virtuozzo.com, qemu-block@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Instead of making each caller check whether a transmission error occurred, we can sink a common error check to the end of the loop. Signed-off-by: Eric Blake Reviewed-by: Vladimir Sementsov-Ogievskiy --- v6: split from length validation [Vladimir] --- nbd/server.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/nbd/server.c b/nbd/server.c index 05ff7470d5..6af708662d 100644 --- a/nbd/server.c +++ b/nbd/server.c @@ -698,9 +698,6 @@ static int nbd_negotiate_options(NBDClient *client, uin= t16_t myflags, "Option 0x%" PRIx32 "not permitted before TLS= ", option); - if (ret < 0) { - return ret; - } /* Let the client keep trying, unless they asked to * quit. In this mode, we've already sent an error, so * we can't ack the abort. */ @@ -713,9 +710,6 @@ static int nbd_negotiate_options(NBDClient *client, uin= t16_t myflags, switch (option) { case NBD_OPT_LIST: ret =3D nbd_negotiate_handle_list(client, length, errp); - if (ret < 0) { - return ret; - } break; case NBD_OPT_ABORT: @@ -738,9 +732,6 @@ static int nbd_negotiate_options(NBDClient *client, uin= t16_t myflags, assert(option =3D=3D NBD_OPT_GO); return 0; } - if (ret) { - return ret; - } break; case NBD_OPT_STARTTLS: @@ -758,9 +749,6 @@ static int nbd_negotiate_options(NBDClient *client, uin= t16_t myflags, option, errp, "TLS not configured"); } - if (ret < 0) { - return ret; - } break; default: if (nbd_drop(client->ioc, length, errp) < 0) { @@ -772,9 +760,6 @@ static int nbd_negotiate_options(NBDClient *client, uin= t16_t myflags, "Unsupported option 0x%" PRIx32 " (%s)", option, nbd_opt_lookup(option)); - if (ret < 0) { - return ret; - } break; } } else { @@ -794,6 +779,9 @@ static int nbd_negotiate_options(NBDClient *client, uin= t16_t myflags, return -EINVAL; } } + if (ret < 0) { + return ret; + } } } --=20 2.13.6