From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org
Subject: [PULL 09/14] sockets: Use ERRP_GUARD() where obviously appropriate
Date: Wed, 14 Dec 2022 17:46:24 +0100 [thread overview]
Message-ID: <20221214164629.919880-10-armbru@redhat.com> (raw)
In-Reply-To: <20221214164629.919880-1-armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20221121085054.683122-9-armbru@redhat.com>
---
util/qemu-sockets.c | 26 ++++++++++----------------
1 file 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;
}
--
2.37.3
next prev parent reply other threads:[~2022-12-14 16:55 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-14 16:46 [PULL 00/14] Miscellaneous patches for 2022-12-14 Markus Armbruster
2022-12-14 16:46 ` [PULL 01/14] Drop more useless casts from void * to pointer Markus Armbruster
2022-12-14 16:46 ` [PULL 02/14] error: Drop some obviously superfluous error_propagate() Markus Armbruster
2022-12-14 16:46 ` [PULL 03/14] error: Drop a few superfluous ERRP_GUARD() Markus Armbruster
2022-12-14 16:46 ` [PULL 04/14] error: Move ERRP_GUARD() to the beginning of the function Markus Armbruster
2022-12-14 16:46 ` [PULL 05/14] monitor: Simplify monitor_fd_param()'s error handling Markus Armbruster
2022-12-14 16:46 ` [PULL 06/14] monitor: Use ERRP_GUARD() in monitor_init() Markus Armbruster
2022-12-14 16:46 ` [PULL 07/14] qemu-config: Make config_parse_qdict() return bool Markus Armbruster
2022-12-14 16:46 ` [PULL 08/14] qemu-config: Use ERRP_GUARD() where obviously appropriate Markus Armbruster
2022-12-14 16:46 ` Markus Armbruster [this message]
2022-12-14 16:46 ` [PULL 10/14] qapi: Use returned bool to check for failure (again) Markus Armbruster
2022-12-14 16:46 ` [PULL 11/14] io: Tidy up fat-fingered parameter name Markus Armbruster
2022-12-14 16:46 ` [PULL 12/14] cleanup: Tweak and re-run return_directly.cocci Markus Armbruster
2022-12-14 16:46 ` [PULL 13/14] block/vmdk: Simplify vmdk_co_create() to return directly Markus Armbruster
2022-12-14 16:46 ` [PULL 14/14] ppc4xx_sdram: Simplify sdram_ddr_size() to return Markus Armbruster
2022-12-15 13:06 ` [PULL 00/14] Miscellaneous patches for 2022-12-14 Peter Maydell
2022-12-15 13:10 ` Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221214164629.919880-10-armbru@redhat.com \
--to=armbru@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).