aboutsummaryrefslogtreecommitdiff
path: root/libcacard
diff options
context:
space:
mode:
authorAlon Levy <alevy@redhat.com>2011-09-27 17:19:25 +0300
committerAlon Levy <alevy@redhat.com>2011-10-25 15:44:02 +0200
commite7c5e89318946b57bcc3f65264be595401c12663 (patch)
tree398da9773991dd48bf4d7ace61b7aa8567e2aaad /libcacard
parent7fc7e5844cd3f5018c0853268f1bc173572e5fb7 (diff)
downloadqemu-e7c5e89318946b57bcc3f65264be595401c12663.zip
qemu-e7c5e89318946b57bcc3f65264be595401c12663.tar.gz
qemu-e7c5e89318946b57bcc3f65264be595401c12663.tar.bz2
libcacard/vscclient: fix error paths for socket creation
Signed-off-by: Alon Levy <alevy@redhat.com>
Diffstat (limited to 'libcacard')
-rw-r--r--libcacard/vscclient.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/libcacard/vscclient.c b/libcacard/vscclient.c
index 2191f60..e317a25 100644
--- a/libcacard/vscclient.c
+++ b/libcacard/vscclient.c
@@ -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);