code cleanup: we prefer 'CURLcode result'

... for the local variable name in functions holding the return
code. Using the same name universally makes code easier to read and
follow.

Also, unify code for checking for CURLcode errors with:

 if(result) or if(!result)

instead of

 if(result == CURLE_OK), if(CURLE_OK == result) or if(result != CURLE_OK)
This commit is contained in:
Daniel Stenberg
2014-10-23 22:56:35 +02:00
parent 1752e9c088
commit 0eb3d15ccb
27 changed files with 413 additions and 423 deletions

View File

@@ -165,7 +165,7 @@ CURLcode Curl_pp_vsendf(struct pingpong *pp,
size_t write_len;
char *fmt_crlf;
char *s;
CURLcode error;
CURLcode result;
struct connectdata *conn = pp->conn;
struct SessionHandle *data = conn->data;
@@ -191,26 +191,26 @@ CURLcode Curl_pp_vsendf(struct pingpong *pp,
Curl_pp_init(pp);
error = Curl_convert_to_network(data, s, write_len);
result = Curl_convert_to_network(data, s, write_len);
/* Curl_convert_to_network calls failf if unsuccessful */
if(error) {
if(result) {
free(s);
return error;
return result;
}
#ifdef HAVE_GSSAPI
conn->data_prot = PROT_CMD;
#endif
error = Curl_write(conn, conn->sock[FIRSTSOCKET], s, write_len,
result = Curl_write(conn, conn->sock[FIRSTSOCKET], s, write_len,
&bytes_written);
#ifdef HAVE_GSSAPI
DEBUGASSERT(data_sec > PROT_NONE && data_sec < PROT_LAST);
conn->data_prot = data_sec;
#endif
if(error) {
if(result) {
free(s);
return error;
return result;
}
if(conn->data->set.verbose)
@@ -247,15 +247,15 @@ CURLcode Curl_pp_vsendf(struct pingpong *pp,
CURLcode Curl_pp_sendf(struct pingpong *pp,
const char *fmt, ...)
{
CURLcode res;
CURLcode result;
va_list ap;
va_start(ap, fmt);
res = Curl_pp_vsendf(pp, fmt, ap);
result = Curl_pp_vsendf(pp, fmt, ap);
va_end(ap);
return res;
return result;
}
/*
@@ -303,30 +303,28 @@ CURLcode Curl_pp_readresp(curl_socket_t sockfd,
pp->cache_size = 0; /* zero the size just in case */
}
else {
int res;
#ifdef HAVE_GSSAPI
enum protection_level prot = conn->data_prot;
conn->data_prot = PROT_CLEAR;
#endif
DEBUGASSERT((ptr+BUFSIZE-pp->nread_resp) <= (buf+BUFSIZE+1));
res = Curl_read(conn, sockfd, ptr, BUFSIZE-pp->nread_resp,
&gotbytes);
result = Curl_read(conn, sockfd, ptr, BUFSIZE-pp->nread_resp,
&gotbytes);
#ifdef HAVE_GSSAPI
DEBUGASSERT(prot > PROT_NONE && prot < PROT_LAST);
conn->data_prot = prot;
#endif
if(res == CURLE_AGAIN)
if(result == CURLE_AGAIN)
return CURLE_OK; /* return */
if((res == CURLE_OK) && (gotbytes > 0))
if(!result && (gotbytes > 0))
/* convert from the network encoding */
res = Curl_convert_from_network(data, ptr, gotbytes);
result = Curl_convert_from_network(data, ptr, gotbytes);
/* Curl_convert_from_network calls failf if unsuccessful */
if(CURLE_OK != res) {
result = (CURLcode)res; /* Set outer result variable to this error. */
if(result)
/* Set outer result variable to this error. */
keepon = FALSE;
}
}
if(!keepon)