sockets: Use ERRP_GUARD() where obviously appropriate
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20221121085054.683122-9-armbru@redhat.com>
This commit is contained in:
parent
0a3090b1d2
commit
f560eb1f0a
@ -210,7 +210,8 @@ static int inet_listen_saddr(InetSocketAddress *saddr,
|
|||||||
int num,
|
int num,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
struct addrinfo ai,*res,*e;
|
ERRP_GUARD();
|
||||||
|
struct addrinfo ai, *res, *e;
|
||||||
char port[33];
|
char port[33];
|
||||||
char uaddr[INET6_ADDRSTRLEN+1];
|
char uaddr[INET6_ADDRSTRLEN+1];
|
||||||
char uport[33];
|
char uport[33];
|
||||||
@ -218,7 +219,6 @@ static int inet_listen_saddr(InetSocketAddress *saddr,
|
|||||||
int slisten = -1;
|
int slisten = -1;
|
||||||
int saved_errno = 0;
|
int saved_errno = 0;
|
||||||
bool socket_created = false;
|
bool socket_created = false;
|
||||||
Error *err = NULL;
|
|
||||||
|
|
||||||
if (saddr->keep_alive) {
|
if (saddr->keep_alive) {
|
||||||
error_setg(errp, "keep-alive option is not supported for passive "
|
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) {
|
if (saddr->has_numeric && saddr->numeric) {
|
||||||
ai.ai_flags |= AI_NUMERICHOST | AI_NUMERICSERV;
|
ai.ai_flags |= AI_NUMERICHOST | AI_NUMERICSERV;
|
||||||
}
|
}
|
||||||
ai.ai_family = inet_ai_family_from_address(saddr, &err);
|
|
||||||
ai.ai_socktype = SOCK_STREAM;
|
ai.ai_socktype = SOCK_STREAM;
|
||||||
|
ai.ai_family = inet_ai_family_from_address(saddr, errp);
|
||||||
if (err) {
|
if (*errp) {
|
||||||
error_propagate(errp, err);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -392,9 +390,9 @@ static int inet_connect_addr(const InetSocketAddress *saddr,
|
|||||||
static struct addrinfo *inet_parse_connect_saddr(InetSocketAddress *saddr,
|
static struct addrinfo *inet_parse_connect_saddr(InetSocketAddress *saddr,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
|
ERRP_GUARD();
|
||||||
struct addrinfo ai, *res;
|
struct addrinfo ai, *res;
|
||||||
int rc;
|
int rc;
|
||||||
Error *err = NULL;
|
|
||||||
static int useV4Mapped = 1;
|
static int useV4Mapped = 1;
|
||||||
|
|
||||||
memset(&ai, 0, sizeof(ai));
|
memset(&ai, 0, sizeof(ai));
|
||||||
@ -403,11 +401,9 @@ static struct addrinfo *inet_parse_connect_saddr(InetSocketAddress *saddr,
|
|||||||
if (qatomic_read(&useV4Mapped)) {
|
if (qatomic_read(&useV4Mapped)) {
|
||||||
ai.ai_flags |= AI_V4MAPPED;
|
ai.ai_flags |= AI_V4MAPPED;
|
||||||
}
|
}
|
||||||
ai.ai_family = inet_ai_family_from_address(saddr, &err);
|
|
||||||
ai.ai_socktype = SOCK_STREAM;
|
ai.ai_socktype = SOCK_STREAM;
|
||||||
|
ai.ai_family = inet_ai_family_from_address(saddr, errp);
|
||||||
if (err) {
|
if (*errp) {
|
||||||
error_propagate(errp, err);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -499,20 +495,18 @@ static int inet_dgram_saddr(InetSocketAddress *sraddr,
|
|||||||
InetSocketAddress *sladdr,
|
InetSocketAddress *sladdr,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
|
ERRP_GUARD();
|
||||||
struct addrinfo ai, *peer = NULL, *local = NULL;
|
struct addrinfo ai, *peer = NULL, *local = NULL;
|
||||||
const char *addr;
|
const char *addr;
|
||||||
const char *port;
|
const char *port;
|
||||||
int sock = -1, rc;
|
int sock = -1, rc;
|
||||||
Error *err = NULL;
|
|
||||||
|
|
||||||
/* lookup peer addr */
|
/* lookup peer addr */
|
||||||
memset(&ai,0, sizeof(ai));
|
memset(&ai,0, sizeof(ai));
|
||||||
ai.ai_flags = AI_CANONNAME | AI_V4MAPPED | AI_ADDRCONFIG;
|
ai.ai_flags = AI_CANONNAME | AI_V4MAPPED | AI_ADDRCONFIG;
|
||||||
ai.ai_family = inet_ai_family_from_address(sraddr, &err);
|
|
||||||
ai.ai_socktype = SOCK_DGRAM;
|
ai.ai_socktype = SOCK_DGRAM;
|
||||||
|
ai.ai_family = inet_ai_family_from_address(sraddr, errp);
|
||||||
if (err) {
|
if (*errp) {
|
||||||
error_propagate(errp, err);
|
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user