From nobody Mon Feb 9 03:13:52 2026 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 149625010977262.66334021577529; Wed, 31 May 2017 10:01:49 -0700 (PDT) Received: from localhost ([::1]:32935 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG70G-0004U7-Cp for importer@patchew.org; Wed, 31 May 2017 13:01:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56994) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG6uV-0007pu-PR for qemu-devel@nongnu.org; Wed, 31 May 2017 12:55:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dG6uS-00041W-0a for qemu-devel@nongnu.org; Wed, 31 May 2017 12:55:51 -0400 Received: from mailhub.sw.ru ([195.214.232.25]:16430 helo=relay.sw.ru) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dG6uR-000405-HK for qemu-devel@nongnu.org; Wed, 31 May 2017 12:55:47 -0400 Received: from kvm.sw.ru (msk-vpn.virtuozzo.com [195.214.232.6]) by relay.sw.ru (8.13.4/8.13.4) with ESMTP id v4VGtfWo011112; Wed, 31 May 2017 19:55:42 +0300 (MSK) From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 19:55:37 +0300 Message-Id: <20170531165541.47338-9-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.11.1 In-Reply-To: <20170531165541.47338-1-vsementsov@virtuozzo.com> References: <20170531165541.47338-1-vsementsov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: OpenBSD 3.x [fuzzy] X-Received-From: 195.214.232.25 Subject: [Qemu-devel] [PATCH 08/12] nbd/server: remove NBDClientNewData 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, den@openvz.org 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" "co" field of NBDClientNewData has never been used, all the way back to its declaration in commit 1a6245a5. So let's just use client pointer instead of extra structure. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake --- nbd/server.c | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/nbd/server.c b/nbd/server.c index 8ac095d6bc..d376563527 100644 --- a/nbd/server.c +++ b/nbd/server.c @@ -535,14 +535,8 @@ static int nbd_negotiate_options(NBDClient *client) } } =20 -typedef struct { - NBDClient *client; - Coroutine *co; -} NBDClientNewData; - -static coroutine_fn int nbd_negotiate(NBDClientNewData *data) +static coroutine_fn int nbd_negotiate(NBDClient *client) { - NBDClient *client =3D data->client; char buf[8 + 8 + 8 + 128]; int rc; const uint16_t myflags =3D (NBD_FLAG_HAS_FLAGS | NBD_FLAG_SEND_TRIM | @@ -1268,16 +1262,15 @@ static void nbd_client_receive_next_request(NBDClie= nt *client) =20 static coroutine_fn void nbd_co_client_start(void *opaque) { - NBDClientNewData *data =3D opaque; - NBDClient *client =3D data->client; + NBDClient *client =3D opaque; NBDExport *exp =3D client->exp; =20 if (exp) { nbd_export_get(exp); } - if (nbd_negotiate(data)) { + if (nbd_negotiate(client)) { client_close(client); - goto out; + return; } qemu_co_mutex_init(&client->send_lock); =20 @@ -1286,9 +1279,6 @@ static coroutine_fn void nbd_co_client_start(void *op= aque) } =20 nbd_client_receive_next_request(client); - -out: - g_free(data); } =20 void nbd_client_new(NBDExport *exp, @@ -1298,7 +1288,7 @@ void nbd_client_new(NBDExport *exp, void (*close_fn)(NBDClient *)) { NBDClient *client; - NBDClientNewData *data =3D g_new(NBDClientNewData, 1); + Coroutine *co; =20 client =3D g_malloc0(sizeof(NBDClient)); client->refcount =3D 1; @@ -1314,7 +1304,6 @@ void nbd_client_new(NBDExport *exp, object_ref(OBJECT(client->ioc)); client->close =3D close_fn; =20 - data->client =3D client; - data->co =3D qemu_coroutine_create(nbd_co_client_start, data); - qemu_coroutine_enter(data->co); + co =3D qemu_coroutine_create(nbd_co_client_start, client); + qemu_coroutine_enter(co); } --=20 2.11.1