Skip to contentSkip to conversation

qemu-sockets: simplify error handling

PATCH Applied Paolo Bonzini 3 participants 3 messages Jan 22, 2016 – Jan 30, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qemu-sockets: simplify error handling

Just go always through the err label. (Noticed because Coverity complains that peer is always non-NULL in the error cleanup code, but removing the "if" is arguably more prone to introducing the opposite bug in the future).

---
 util/qemu-sockets.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
util/qemu-sockets.c +3 -3
index f455a17..a9fed00 100644
@@ -464,7 +464,7 @@ static int inet_dgram_saddr(InetSocketAddress *sraddr,
 
     if (err) {
         error_propagate(errp, err);
-        return -1;
+        goto err;
     }
 
     addr = sraddr->host;
@@ -474,13 +474,13 @@ static int inet_dgram_saddr(InetSocketAddress *sraddr,
     }
     if (port == NULL || strlen(port) == 0) {
         error_setg(errp, "remote port not specified");
-        return -1;
+        goto err;
     }
 
     if (0 != (rc = getaddrinfo(addr, port, &ai, &peer))) {
         error_setg(errp, "address resolution failed for %s:%s: %s", addr, port,
                    gai_strerror(rc));
-	return -1;
+	goto err;
     }
 
     /* lookup local addr */
Signature · 1 line
2.5.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Paolo Bonzini

Just go always through the err label. (Noticed because Coverity complains that peer is always non-NULL in the error cleanup code, but removing the "if" is arguably more prone to introducing the opposite bug in the future).

Regards,
Daniel

Signature · 4 lines
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|
#2 lore raw
In reply to Paolo Bonzini
Quoted 4 lines · Paolo Bonzini

Just go always through the err label. (Noticed because Coverity complains that peer is always non-NULL in the error cleanup code, but removing the "if" is arguably more prone to introducing the opposite bug in the future).

Applied to -trivial, thanks!

/mjt