1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-22 08:08:50 -05:00

code cleanup: We prefer 'CURLcode result'

This commit is contained in:
Steve Holme 2014-10-28 22:42:42 +00:00
parent b790bdf46b
commit 085081fc6e
4 changed files with 36 additions and 33 deletions

View File

@ -977,10 +977,9 @@ void Curl_sndbufset(curl_socket_t sockfd)
* singleipconnect() connects to the given IP only, and it may return without * singleipconnect() connects to the given IP only, and it may return without
* having connected. * having connected.
*/ */
static CURLcode static CURLcode singleipconnect(struct connectdata *conn,
singleipconnect(struct connectdata *conn, const Curl_addrinfo *ai,
const Curl_addrinfo *ai, curl_socket_t *sockp)
curl_socket_t *sockp)
{ {
struct Curl_sockaddr_ex addr; struct Curl_sockaddr_ex addr;
int rc; int rc;
@ -988,14 +987,14 @@ singleipconnect(struct connectdata *conn,
bool isconnected = FALSE; bool isconnected = FALSE;
struct SessionHandle *data = conn->data; struct SessionHandle *data = conn->data;
curl_socket_t sockfd; curl_socket_t sockfd;
CURLcode res; CURLcode result;
char ipaddress[MAX_IPADR_LEN]; char ipaddress[MAX_IPADR_LEN];
long port; long port;
*sockp = CURL_SOCKET_BAD; *sockp = CURL_SOCKET_BAD;
res = Curl_socket(conn, ai, &addr, &sockfd); result = Curl_socket(conn, ai, &addr, &sockfd);
if(res) if(result)
/* Failed to create the socket, but still return OK since we signal the /* Failed to create the socket, but still return OK since we signal the
lack of socket as well. This allows the parent function to keep looping lack of socket as well. This allows the parent function to keep looping
over alternative addresses/socket families etc. */ over alternative addresses/socket families etc. */
@ -1038,15 +1037,16 @@ singleipconnect(struct connectdata *conn,
} }
/* possibly bind the local end to an IP, interface or port */ /* possibly bind the local end to an IP, interface or port */
res = bindlocal(conn, sockfd, addr.family); result = bindlocal(conn, sockfd, addr.family);
if(res) { if(result) {
Curl_closesocket(conn, sockfd); /* close socket and bail out */ Curl_closesocket(conn, sockfd); /* close socket and bail out */
if(res == CURLE_UNSUPPORTED_PROTOCOL) { if(result == CURLE_UNSUPPORTED_PROTOCOL) {
/* The address family is not supported on this interface. /* The address family is not supported on this interface.
We can continue trying addresses */ We can continue trying addresses */
return CURLE_OK; return CURLE_OK;
} }
return res;
return result;
} }
/* set socket non-blocking */ /* set socket non-blocking */
@ -1084,7 +1084,7 @@ singleipconnect(struct connectdata *conn,
case EAGAIN: case EAGAIN:
#endif #endif
#endif #endif
res = CURLE_OK; result = CURLE_OK;
break; break;
default: default:
@ -1095,14 +1095,14 @@ singleipconnect(struct connectdata *conn,
/* connect failed */ /* connect failed */
Curl_closesocket(conn, sockfd); Curl_closesocket(conn, sockfd);
res = CURLE_COULDNT_CONNECT; result = CURLE_COULDNT_CONNECT;
} }
} }
if(!res) if(!result)
*sockp = sockfd; *sockp = sockfd;
return res; return result;
} }
/* /*

View File

@ -87,7 +87,7 @@ char *curl_easy_escape(CURL *handle, const char *string, int inlength)
size_t newlen = alloc; size_t newlen = alloc;
size_t strindex=0; size_t strindex=0;
size_t length; size_t length;
CURLcode res; CURLcode result;
ns = malloc(alloc); ns = malloc(alloc);
if(!ns) if(!ns)
@ -115,8 +115,8 @@ char *curl_easy_escape(CURL *handle, const char *string, int inlength)
} }
} }
res = Curl_convert_to_network(handle, &in, 1); result = Curl_convert_to_network(handle, &in, 1);
if(res) { if(result) {
/* Curl_convert_to_network calls failf if unsuccessful */ /* Curl_convert_to_network calls failf if unsuccessful */
free(ns); free(ns);
return NULL; return NULL;
@ -152,7 +152,7 @@ CURLcode Curl_urldecode(struct SessionHandle *data,
unsigned char in; unsigned char in;
size_t strindex=0; size_t strindex=0;
unsigned long hex; unsigned long hex;
CURLcode res; CURLcode result;
if(!ns) if(!ns)
return CURLE_OUT_OF_MEMORY; return CURLE_OUT_OF_MEMORY;
@ -172,16 +172,17 @@ CURLcode Curl_urldecode(struct SessionHandle *data,
in = curlx_ultouc(hex); /* this long is never bigger than 255 anyway */ in = curlx_ultouc(hex); /* this long is never bigger than 255 anyway */
res = Curl_convert_from_network(data, &in, 1); result = Curl_convert_from_network(data, &in, 1);
if(res) { if(result) {
/* Curl_convert_from_network calls failf if unsuccessful */ /* Curl_convert_from_network calls failf if unsuccessful */
free(ns); free(ns);
return res; return result;
} }
string+=2; string+=2;
alloc-=2; alloc-=2;
} }
if(reject_ctrl && (in < 0x20)) { if(reject_ctrl && (in < 0x20)) {
free(ns); free(ns);
return CURLE_URL_MALFORMAT; return CURLE_URL_MALFORMAT;

View File

@ -321,16 +321,16 @@ CURLcode Curl_output_digest(struct connectdata *conn,
struct SessionHandle *data = conn->data; struct SessionHandle *data = conn->data;
struct digestdata *d; struct digestdata *d;
CURLcode rc; CURLcode result;
/* The CURL_OUTPUT_DIGEST_CONV macro below is for non-ASCII machines. /* The CURL_OUTPUT_DIGEST_CONV macro below is for non-ASCII machines.
It converts digest text to ASCII so the MD5 will be correct for It converts digest text to ASCII so the MD5 will be correct for
what ultimately goes over the network. what ultimately goes over the network.
*/ */
#define CURL_OUTPUT_DIGEST_CONV(a, b) \ #define CURL_OUTPUT_DIGEST_CONV(a, b) \
rc = Curl_convert_to_network(a, (char *)b, strlen((const char*)b)); \ result = Curl_convert_to_network(a, (char *)b, strlen((const char*)b)); \
if(rc) { \ if(result) { \
free(b); \ free(b); \
return rc; \ return result; \
} }
if(proxy) { if(proxy) {
@ -370,10 +370,12 @@ CURLcode Curl_output_digest(struct connectdata *conn,
snprintf(cnoncebuf, sizeof(cnoncebuf), "%08x%08x%08x%08x", snprintf(cnoncebuf, sizeof(cnoncebuf), "%08x%08x%08x%08x",
Curl_rand(data), Curl_rand(data), Curl_rand(data), Curl_rand(data),
Curl_rand(data), Curl_rand(data)); Curl_rand(data), Curl_rand(data));
rc = Curl_base64_encode(data, cnoncebuf, strlen(cnoncebuf),
&cnonce, &cnonce_sz); result = Curl_base64_encode(data, cnoncebuf, strlen(cnoncebuf),
if(rc) &cnonce, &cnonce_sz);
return rc; if(result)
return result;
d->cnonce = cnonce; d->cnonce = cnonce;
} }

View File

@ -99,11 +99,11 @@ CURLcode Curl_add_handle_to_pipeline(struct SessionHandle *handle,
{ {
struct curl_llist_element *sendhead = conn->send_pipe->head; struct curl_llist_element *sendhead = conn->send_pipe->head;
struct curl_llist *pipeline; struct curl_llist *pipeline;
CURLcode rc; CURLcode result;
pipeline = conn->send_pipe; pipeline = conn->send_pipe;
rc = Curl_addHandleToPipeline(handle, pipeline); result = Curl_addHandleToPipeline(handle, pipeline);
if(pipeline == conn->send_pipe && sendhead != conn->send_pipe->head) { if(pipeline == conn->send_pipe && sendhead != conn->send_pipe->head) {
/* this is a new one as head, expire it */ /* this is a new one as head, expire it */
@ -115,7 +115,7 @@ CURLcode Curl_add_handle_to_pipeline(struct SessionHandle *handle,
print_pipeline(conn); print_pipeline(conn);
#endif #endif
return rc; return result;
} }
/* Move this transfer from the sending list to the receiving list. /* Move this transfer from the sending list to the receiving list.