aboutsummaryrefslogtreecommitdiffstats
path: root/src/wps
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2015-08-29 10:41:40 (GMT)
committerJouni Malinen <j@w1.fi>2015-08-29 10:42:32 (GMT)
commit91d5a8e365fafc32aa86604a48cd5ffdd3c8e811 (patch)
tree08a4bd7727c521a345a69ff576b724ff9f83f3d3 /src/wps
parent63fc84acd7de12289d5943625c0599b16a4b745f (diff)
downloadhostap-91d5a8e365fafc32aa86604a48cd5ffdd3c8e811.zip
hostap-91d5a8e365fafc32aa86604a48cd5ffdd3c8e811.tar.gz
hostap-91d5a8e365fafc32aa86604a48cd5ffdd3c8e811.tar.bz2
WPS: Use a shared error path in http_client_addr()
This simplifies error processing by removing duplicated cleanup steps. Signed-off-by: Jouni Malinen <j@w1.fi>
Diffstat (limited to 'src/wps')
-rw-r--r--src/wps/http_client.c30
1 files changed, 12 insertions, 18 deletions
diff --git a/src/wps/http_client.c b/src/wps/http_client.c
index 9d25245..cdf3a51 100644
--- a/src/wps/http_client.c
+++ b/src/wps/http_client.c
@@ -146,24 +146,20 @@ struct http_client * http_client_addr(struct sockaddr_in *dst,
c->cb_ctx = cb_ctx;
c->sd = socket(AF_INET, SOCK_STREAM, 0);
- if (c->sd < 0) {
- http_client_free(c);
- return NULL;
- }
+ if (c->sd < 0)
+ goto fail;
if (fcntl(c->sd, F_SETFL, O_NONBLOCK) != 0) {
wpa_printf(MSG_DEBUG, "HTTP: fnctl(O_NONBLOCK) failed: %s",
strerror(errno));
- http_client_free(c);
- return NULL;
+ goto fail;
}
if (connect(c->sd, (struct sockaddr *) dst, sizeof(*dst))) {
if (errno != EINPROGRESS) {
wpa_printf(MSG_DEBUG, "HTTP: Failed to connect: %s",
strerror(errno));
- http_client_free(c);
- return NULL;
+ goto fail;
}
/*
@@ -173,20 +169,18 @@ struct http_client * http_client_addr(struct sockaddr_in *dst,
}
if (eloop_register_sock(c->sd, EVENT_TYPE_WRITE, http_client_tx_ready,
- c, NULL)) {
- http_client_free(c);
- return NULL;
- }
-
- if (eloop_register_timeout(HTTP_CLIENT_TIMEOUT_SEC, 0,
- http_client_timeout, c, NULL)) {
- http_client_free(c);
- return NULL;
- }
+ c, NULL) ||
+ eloop_register_timeout(HTTP_CLIENT_TIMEOUT_SEC, 0,
+ http_client_timeout, c, NULL))
+ goto fail;
c->req = req;
return c;
+
+fail:
+ http_client_free(c);
+ return NULL;
}