qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 05/27] vhost-user-scsi: connect unix socket befo


From: Philippe Mathieu-Daudé
Subject: Re: [Qemu-devel] [PATCH 05/27] vhost-user-scsi: connect unix socket before allocating
Date: Tue, 12 Sep 2017 13:37:59 -0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0

On 08/23/2017 01:19 PM, Marc-André Lureau wrote:
This simplify a little bit memory management in the following patches.

Signed-off-by: Marc-André Lureau <address@hidden>
---
  contrib/vhost-user-scsi/vhost-user-scsi.c | 18 +++++++++---------
  1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/contrib/vhost-user-scsi/vhost-user-scsi.c 
b/contrib/vhost-user-scsi/vhost-user-scsi.c
index 1fb57da2da..cddaaf8995 100644
--- a/contrib/vhost-user-scsi/vhost-user-scsi.c
+++ b/contrib/vhost-user-scsi/vhost-user-scsi.c
@@ -715,11 +715,11 @@ static void vdev_scsi_deinit(vhost_scsi_dev_t *vdev_scsi)
      }
  }
-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 = NULL;
- assert(unix_fn);
+    assert(server_sock >= 0);

This assert() can't happen anymore.

Removing it:
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>

vdev_scsi = calloc(1, sizeof(vhost_scsi_dev_t));
      if (!vdev_scsi) {
@@ -727,11 +727,7 @@ static vhost_scsi_dev_t *vdev_scsi_new(char *unix_fn)
          return NULL;
      }
- vdev_scsi->server_sock = unix_sock_new(unix_fn);
-    if (vdev_scsi->server_sock < 0) {
-        goto err;
-    }
-
+    vdev_scsi->server_sock = server_sock;
      vdev_scsi->loop = g_main_loop_new(NULL, FALSE);
      if (!vdev_scsi->loop) {
          PERR("Error creating glib event loop");
@@ -815,7 +811,7 @@ int main(int argc, char **argv)
      vhost_scsi_dev_t *vdev_scsi = NULL;
      char *unix_fn = NULL;
      char *iscsi_uri = NULL;
-    int opt, err = EXIT_SUCCESS;
+    int sock, opt, err = EXIT_SUCCESS;
while ((opt = getopt(argc, argv, "u:i:")) != -1) {
          switch (opt) {
@@ -835,7 +831,11 @@ int main(int argc, char **argv)
          goto help;
      }
- vdev_scsi = vdev_scsi_new(unix_fn);
+    sock = unix_sock_new(unix_fn);
+    if (sock < 0) {
+        goto err;
+    }
+    vdev_scsi = vdev_scsi_new(sock);
      if (!vdev_scsi) {
          goto err;
      }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]