aboutsummaryrefslogtreecommitdiff
path: root/util/qemu-sockets.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2022-11-21 09:50:52 +0100
committerMarkus Armbruster <armbru@redhat.com>2022-12-14 16:19:35 +0100
commitf560eb1f0a73b786a9c306d453d9e2e846ecb3e7 (patch)
tree3fe9940bc215c1dd090cf9329cc48be5d0006705 /util/qemu-sockets.c
parent0a3090b1d2e3f62578b2f982b11fc5f0185b1de2 (diff)
sockets: Use ERRP_GUARD() where obviously appropriate
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20221121085054.683122-9-armbru@redhat.com>
Diffstat (limited to 'util/qemu-sockets.c')
-rw-r--r--util/qemu-sockets.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index d185245023..6538859b87 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -210,7 +210,8 @@ static int inet_listen_saddr(InetSocketAddress *saddr,
int num,
Error **errp)
{
- struct addrinfo ai,*res,*e;
+ ERRP_GUARD();
+ struct addrinfo ai, *res, *e;
char port[33];
char uaddr[INET6_ADDRSTRLEN+1];
char uport[33];
@@ -218,7 +219,6 @@ static int inet_listen_saddr(InetSocketAddress *saddr,
int slisten = -1;
int saved_errno = 0;
bool socket_created = false;
- Error *err = NULL;
if (saddr->keep_alive) {
error_setg(errp, "keep-alive option is not supported for passive "
@@ -231,11 +231,9 @@ static int inet_listen_saddr(InetSocketAddress *saddr,
if (saddr->has_numeric && saddr->numeric) {
ai.ai_flags |= AI_NUMERICHOST | AI_NUMERICSERV;
}
- ai.ai_family = inet_ai_family_from_address(saddr, &err);
ai.ai_socktype = SOCK_STREAM;
-
- if (err) {
- error_propagate(errp, err);
+ ai.ai_family = inet_ai_family_from_address(saddr, errp);
+ if (*errp) {
return -1;
}
@@ -392,9 +390,9 @@ static int inet_connect_addr(const InetSocketAddress *saddr,
static struct addrinfo *inet_parse_connect_saddr(InetSocketAddress *saddr,
Error **errp)
{
+ ERRP_GUARD();
struct addrinfo ai, *res;
int rc;
- Error *err = NULL;
static int useV4Mapped = 1;
memset(&ai, 0, sizeof(ai));
@@ -403,11 +401,9 @@ static struct addrinfo *inet_parse_connect_saddr(InetSocketAddress *saddr,
if (qatomic_read(&useV4Mapped)) {
ai.ai_flags |= AI_V4MAPPED;
}
- ai.ai_family = inet_ai_family_from_address(saddr, &err);
ai.ai_socktype = SOCK_STREAM;
-
- if (err) {
- error_propagate(errp, err);
+ ai.ai_family = inet_ai_family_from_address(saddr, errp);
+ if (*errp) {
return NULL;
}
@@ -499,20 +495,18 @@ static int inet_dgram_saddr(InetSocketAddress *sraddr,
InetSocketAddress *sladdr,
Error **errp)
{
+ ERRP_GUARD();
struct addrinfo ai, *peer = NULL, *local = NULL;
const char *addr;
const char *port;
int sock = -1, rc;
- Error *err = NULL;
/* lookup peer addr */
memset(&ai,0, sizeof(ai));
ai.ai_flags = AI_CANONNAME | AI_V4MAPPED | AI_ADDRCONFIG;
- ai.ai_family = inet_ai_family_from_address(sraddr, &err);
ai.ai_socktype = SOCK_DGRAM;
-
- if (err) {
- error_propagate(errp, err);
+ ai.ai_family = inet_ai_family_from_address(sraddr, errp);
+ if (*errp) {
goto err;
}