aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2015-08-29 10:34:39 (GMT)
committerJouni Malinen <j@w1.fi>2015-08-29 10:42:32 (GMT)
commit63fc84acd7de12289d5943625c0599b16a4b745f (patch)
treedf1655a26340c6e57f2c2aaf4ef4face7a76e8cf /src
parent24a5e528ce393faddc3e2d063b2c60c325127c01 (diff)
downloadhostap-63fc84acd7de12289d5943625c0599b16a4b745f.zip
hostap-63fc84acd7de12289d5943625c0599b16a4b745f.tar.gz
hostap-63fc84acd7de12289d5943625c0599b16a4b745f.tar.bz2
WPS: Clean up http_client_tx_ready()
Calculate the send() buffer length only once to make this a bit more readable. Signed-off-by: Jouni Malinen <j@w1.fi>
Diffstat (limited to 'src')
-rw-r--r--src/wps/http_client.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/wps/http_client.c b/src/wps/http_client.c
index 0290013..9d25245 100644
--- a/src/wps/http_client.c
+++ b/src/wps/http_client.c
@@ -85,15 +85,16 @@ static void http_client_tx_ready(int sock, void *eloop_ctx, void *sock_ctx)
{
struct http_client *c = eloop_ctx;
int res;
+ size_t send_len;
+ send_len = wpabuf_len(c->req) - c->req_pos;
wpa_printf(MSG_DEBUG, "HTTP: Send client request to %s:%d (%lu of %lu "
"bytes remaining)",
inet_ntoa(c->dst.sin_addr), ntohs(c->dst.sin_port),
(unsigned long) wpabuf_len(c->req),
- (unsigned long) wpabuf_len(c->req) - c->req_pos);
+ (unsigned long) send_len);
- res = send(c->sd, wpabuf_head_u8(c->req) + c->req_pos,
- wpabuf_len(c->req) - c->req_pos, 0);
+ res = send(c->sd, wpabuf_head_u8(c->req) + c->req_pos, send_len, 0);
if (res < 0) {
wpa_printf(MSG_DEBUG, "HTTP: Failed to send buffer: %s",
strerror(errno));
@@ -102,12 +103,11 @@ static void http_client_tx_ready(int sock, void *eloop_ctx, void *sock_ctx)
return;
}
- if ((size_t) res < wpabuf_len(c->req) - c->req_pos) {
+ if ((size_t) res < send_len) {
wpa_printf(MSG_DEBUG, "HTTP: Sent %d of %lu bytes; %lu bytes "
"remaining",
res, (unsigned long) wpabuf_len(c->req),
- (unsigned long) wpabuf_len(c->req) - c->req_pos -
- res);
+ (unsigned long) send_len - res);
c->req_pos += res;
return;
}