From nobody Tue Feb 10 05:46:08 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.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 1505842770891685.0626836989844; Tue, 19 Sep 2017 10:39:30 -0700 (PDT) Received: from localhost ([::1]:44374 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1duMUc-0003oP-1S for importer@patchew.org; Tue, 19 Sep 2017 13:39:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46135) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1duLlg-0005Nk-J4 for qemu-devel@nongnu.org; Tue, 19 Sep 2017 12:53:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1duLlf-0001c2-Mm for qemu-devel@nongnu.org; Tue, 19 Sep 2017 12:53:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47646) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1duLlf-0001bS-GM for qemu-devel@nongnu.org; Tue, 19 Sep 2017 12:53:03 -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 6E337C0587E4; Tue, 19 Sep 2017 16:53:02 +0000 (UTC) Received: from localhost (ovpn-112-56.ams2.redhat.com [10.36.112.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id CA8FE5C882; Tue, 19 Sep 2017 16:53:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6E337C0587E4 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Tue, 19 Sep 2017 18:52:06 +0200 Message-Id: <20170919165226.23022-8-marcandre.lureau@redhat.com> In-Reply-To: <20170919165226.23022-1-marcandre.lureau@redhat.com> References: <20170919165226.23022-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 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.32]); Tue, 19 Sep 2017 16:53:02 +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] [PATCH v2 07/27] vhost-user-scsi: connect unix socket before allocating 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, felipe@nutanix.com, changpeng.liu@intel.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , f4bug@amsat.org 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" This simplify a little bit memory management in the following patches. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- contrib/vhost-user-scsi/vhost-user-scsi.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/contrib/vhost-user-scsi/vhost-user-scsi.c b/contrib/vhost-user= -scsi/vhost-user-scsi.c index 1fb57da2da..e01bf31296 100644 --- a/contrib/vhost-user-scsi/vhost-user-scsi.c +++ b/contrib/vhost-user-scsi/vhost-user-scsi.c @@ -715,23 +715,17 @@ static void vdev_scsi_deinit(vhost_scsi_dev_t *vdev_s= csi) } } =20 -static vhost_scsi_dev_t *vdev_scsi_new(char *unix_fn) +static vhost_scsi_dev_t *vdev_scsi_new(int server_sock) { vhost_scsi_dev_t *vdev_scsi =3D NULL; =20 - assert(unix_fn); - vdev_scsi =3D calloc(1, sizeof(vhost_scsi_dev_t)); if (!vdev_scsi) { PERR("calloc: %s", strerror(errno)); return NULL; } =20 - vdev_scsi->server_sock =3D unix_sock_new(unix_fn); - if (vdev_scsi->server_sock < 0) { - goto err; - } - + vdev_scsi->server_sock =3D server_sock; vdev_scsi->loop =3D g_main_loop_new(NULL, FALSE); if (!vdev_scsi->loop) { PERR("Error creating glib event loop"); @@ -815,7 +809,7 @@ int main(int argc, char **argv) vhost_scsi_dev_t *vdev_scsi =3D NULL; char *unix_fn =3D NULL; char *iscsi_uri =3D NULL; - int opt, err =3D EXIT_SUCCESS; + int sock, opt, err =3D EXIT_SUCCESS; =20 while ((opt =3D getopt(argc, argv, "u:i:")) !=3D -1) { switch (opt) { @@ -835,7 +829,11 @@ int main(int argc, char **argv) goto help; } =20 - vdev_scsi =3D vdev_scsi_new(unix_fn); + sock =3D unix_sock_new(unix_fn); + if (sock < 0) { + goto err; + } + vdev_scsi =3D vdev_scsi_new(sock); if (!vdev_scsi) { goto err; } --=20 2.14.1.146.gd35faa819