]> git.proxmox.com Git - mirror_qemu.git/commitdiff
libcacard/vscclient: fix error paths for socket creation
authorAlon Levy <alevy@redhat.com>
Tue, 27 Sep 2011 14:19:25 +0000 (17:19 +0300)
committerAlon Levy <alevy@redhat.com>
Tue, 25 Oct 2011 13:44:02 +0000 (15:44 +0200)
Signed-off-by: Alon Levy <alevy@redhat.com>
libcacard/vscclient.c

index 2191f6038c0156284c99f34bb1714ae02e6c5edd..e317a25faf1f7df9acb20c989dcd557ed566cd72 100644 (file)
@@ -357,6 +357,7 @@ connect_to_qemu(
     if (sock < 0) {
         /* Error */
         fprintf(stderr, "Error opening socket!\n");
+        return -1;
     }
 
     memset(&hints, 0, sizeof(struct addrinfo));
@@ -370,13 +371,13 @@ connect_to_qemu(
     if (ret != 0) {
         /* Error */
         fprintf(stderr, "getaddrinfo failed\n");
-        return 5;
+        return -1;
     }
 
     if (connect(sock, server->ai_addr, server->ai_addrlen) < 0) {
         /* Error */
         fprintf(stderr, "Could not connect\n");
-        return 5;
+        return -1;
     }
     if (verbose) {
         printf("Connected (sizeof Header=%zd)!\n", sizeof(VSCMsgHeader));
@@ -505,6 +506,10 @@ main(
     qemu_host = strdup(argv[argc - 2]);
     qemu_port = strdup(argv[argc - 1]);
     sock = connect_to_qemu(qemu_host, qemu_port);
+    if (sock == -1) {
+        fprintf(stderr, "error opening socket, exiting.\n");
+        exit(5);
+    }
 
     qemu_mutex_init(&write_lock);
     qemu_mutex_init(&pending_reader_lock);