提交 e7c5e893 编写于 作者: A Alon Levy

libcacard/vscclient: fix error paths for socket creation

Signed-off-by: NAlon Levy <alevy@redhat.com>
上级 7fc7e584
无相关合并请求
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册
新手
引导
客服 返回
顶部