@@ -389,7 +389,7 @@ static int inet_dgram_saddr(InetSocketAddress *sraddr,
if (0 != (rc = getaddrinfo(addr, port, &ai, &peer))) {
error_setg(errp, "address resolution failed for %s:%s: %s", addr, port,
gai_strerror(rc));
- goto err;
+ goto err;
}
/* lookup local addr */
@@ -443,12 +443,16 @@ static int inet_dgram_saddr(InetSocketAddress *sraddr,
return sock;
err:
- if (-1 != sock)
+ if (sock != -1) {
closesocket(sock);
- if (local)
+ }
+ if (local) {
freeaddrinfo(local);
- if (peer)
+ }
+ if (peer) {
freeaddrinfo(peer);
+ }
+
return -1;
}
@@ -690,8 +694,10 @@ int unix_listen(const char *str, char *ostr, int olen, Error **errp)
sock = unix_listen_saddr(saddr, true, errp);
- if (sock != -1 && ostr)
+ if (sock != -1 && ostr) {
snprintf(ostr, olen, "%s%s", saddr->path, optstr ? optstr : "");
+ }
+
qapi_free_UnixSocketAddress(saddr);
return sock;
}
Fix some coding style issues found in removing NonBlockingConnectHandler. Cc: Daniel P. Berrange <berrange@redhat.com> Cc: Gerd Hoffmann <kraxel@redhat.com> Cc: Paolo Bonzini <pbonzini@redhat.com> Reviwed-by: Daniel P. Berrange <berrange@redhat.com> Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com> --- util/qemu-sockets.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)