From nobody Thu Nov 6 08:32:57 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; dkim=fail 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 1497525008821908.7565760006336; Thu, 15 Jun 2017 04:10:08 -0700 (PDT) Received: from localhost ([::1]:53198 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dLSf8-0007BI-DX for importer@patchew.org; Thu, 15 Jun 2017 07:10:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41153) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dLSPO-0000BG-Fs for qemu-devel@nongnu.org; Thu, 15 Jun 2017 06:53:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dLSPK-0007gV-LO for qemu-devel@nongnu.org; Thu, 15 Jun 2017 06:53:50 -0400 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]:34400) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dLSPK-0007g8-Ei for qemu-devel@nongnu.org; Thu, 15 Jun 2017 06:53:46 -0400 Received: by mail-wr0-x243.google.com with SMTP id y25so548045wrd.1 for ; Thu, 15 Jun 2017 03:53:46 -0700 (PDT) Received: from 640k.lan (94-39-191-51.adsl-ull.clienti.tiscali.it. [94.39.191.51]) by smtp.gmail.com with ESMTPSA id f21sm3258597wra.5.2017.06.15.03.53.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Jun 2017 03:53:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=VXw3z/TL0Tb0mc8zqBR1kMRKh8eLBf0FbVEbT7pGBlM=; b=lQeJtGqiFX7fEYJDmeMLE30a8FH94TzxepnRCe9qAmg3zZsfQXvf3ISBVrwggu6JEL sXIp4X9QVR2ajjXryDu5kam/RY225HDH6PKb1mPsDs7RhvSxcylUeKn0w58+Uq14VTuK /Iu1uqIkGWmCamud6AoXHhqIWOkkCHTGk2sEZS7g3Cm4yjonMJoYe7HgnrImgVSQI3hg jHDqmctnYitx68ulR6AqiIfYlNrdQVD4lpVZaPUgFBfn3pzDGl0A/1vDbIP1TWGO50eT 8bmpH+XkCGdF2dq6wiHrWgWGdrs8adcOx1gbAsba4pgKGDBm2K5qKAiPHfh6wzDKe6rW zbog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=VXw3z/TL0Tb0mc8zqBR1kMRKh8eLBf0FbVEbT7pGBlM=; b=m+eGEi+DXVVFOArm8ccGlu0/ydOKRxW4zlTPsP6qF8rDqOPAzY/30kTK4sOvJ4A1eH o83gsGuAVQBUf6wNAjrPqHElQrL5QrlcjrKAZuFAVrZKgDnkoU1MBYS/IzBo1bSxAae5 8sPSZ7CY13GHcP54hWIxn55K9jRtbxl6ZVeuFEv8ClNrhqzD3VE3P1EZXDLeb5+aNCte f6QrERSkOmc+mYiZ664fe78446BHfBhJOU8TfAukKTJAvuLIufAESXBflV7uu8u8X7ro I89lQ7pZj9apdbr4w3SIN9QXxG5j+qAefIMQuYaEGFbTz7VM9wvmEAf96doSfU2WDlBz QkLg== X-Gm-Message-State: AKS2vOwjBYPPzkNsLOfrUDiTcSS8GjQFkpUpVoksKn/vB1mmKxpUGH1R LjbHCOWd7eiMUsvpN98= X-Received: by 10.223.160.44 with SMTP id k41mr3054226wrk.186.1497524025198; Thu, 15 Jun 2017 03:53:45 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 15 Jun 2017 12:52:51 +0200 Message-Id: <1497523981-38449-32-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1497523981-38449-1-git-send-email-pbonzini@redhat.com> References: <1497523981-38449-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::243 Subject: [Qemu-devel] [PULL 31/41] 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: Vladimir Sementsov-Ogievskiy Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy "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 Message-Id: <20170602150150.258222-9-vsementsov@virtuozzo.com> Signed-off-by: Paolo Bonzini --- nbd/server.c | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/nbd/server.c b/nbd/server.c index 9fb03ce..d526827 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,8 +1262,7 @@ static void nbd_client_receive_next_request(NBDClient= *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) { @@ -1278,15 +1271,12 @@ static coroutine_fn void nbd_co_client_start(void *= opaque) } qemu_co_mutex_init(&client->send_lock); =20 - if (nbd_negotiate(data)) { + if (nbd_negotiate(client)) { client_close(client, false); - goto out; + return; } =20 nbd_client_receive_next_request(client); - -out: - g_free(data); } =20 /* @@ -1302,7 +1292,7 @@ void nbd_client_new(NBDExport *exp, void (*close_fn)(NBDClient *, bool)) { NBDClient *client; - NBDClientNewData *data =3D g_new(NBDClientNewData, 1); + Coroutine *co; =20 client =3D g_malloc0(sizeof(NBDClient)); client->refcount =3D 1; @@ -1318,7 +1308,6 @@ void nbd_client_new(NBDExport *exp, object_ref(OBJECT(client->ioc)); client->close_fn =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 1.8.3.1