]> git.proxmox.com Git - mirror_qemu.git/commitdiff
vhost-user-blk/scsi: Fix broken error handling for socket call
authorAlexChen <alex.chen@huawei.com>
Thu, 29 Oct 2020 06:03:52 +0000 (14:03 +0800)
committerMichael S. Tsirkin <mst@redhat.com>
Tue, 17 Nov 2020 09:16:55 +0000 (04:16 -0500)
When socket() fails, it returns -1, 0 is the normal return value and should not return error.

Reported-by: Euler Robot <euler.robot@huawei.com>
Signed-off-by: AlexChen <alex.chen@huawei.com>
Message-Id: <5F9A5B48.9030509@huawei.com>
Reviewed-by: Raphael Norwitz <raphael.norwitz@nutanix.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
contrib/vhost-user-blk/vhost-user-blk.c
contrib/vhost-user-scsi/vhost-user-scsi.c

index caad88637e9a7788322fae548c794bb4f39f6e74..dc981bf945342090233f4f9d8768938dbc6efe6c 100644 (file)
@@ -476,7 +476,7 @@ static int unix_sock_new(char *unix_fn)
     assert(unix_fn);
 
     sock = socket(AF_UNIX, SOCK_STREAM, 0);
-    if (sock <= 0) {
+    if (sock < 0) {
         perror("socket");
         return -1;
     }
index 3c912384e9f440d6dffaeb0d69ec2a0282288e64..0f9ba4b2a22d3254ec1cf8ddc6d961be4d48ec62 100644 (file)
@@ -320,7 +320,7 @@ static int unix_sock_new(char *unix_fn)
     assert(unix_fn);
 
     sock = socket(AF_UNIX, SOCK_STREAM, 0);
-    if (sock <= 0) {
+    if (sock < 0) {
         perror("socket");
         return -1;
     }