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:
@@ -129,11 +129,11 @@ static int ftp_send_command(struct connectdata *conn, const char *message, ...)
|
||||
vsnprintf(print_buffer, sizeof(print_buffer), message, args);
|
||||
va_end(args);
|
||||
|
||||
if(Curl_ftpsendf(conn, print_buffer) != CURLE_OK) {
|
||||
if(Curl_ftpsendf(conn, print_buffer)) {
|
||||
ftp_code = -1;
|
||||
}
|
||||
else {
|
||||
if(Curl_GetFTPResponse(&nread, conn, &ftp_code) != CURLE_OK)
|
||||
if(Curl_GetFTPResponse(&nread, conn, &ftp_code))
|
||||
ftp_code = -1;
|
||||
}
|
||||
|
||||
@@ -147,20 +147,20 @@ static CURLcode
|
||||
socket_read(curl_socket_t fd, void *to, size_t len)
|
||||
{
|
||||
char *to_p = to;
|
||||
CURLcode code;
|
||||
CURLcode result;
|
||||
ssize_t nread;
|
||||
|
||||
while(len > 0) {
|
||||
code = Curl_read_plain(fd, to_p, len, &nread);
|
||||
if(code == CURLE_OK) {
|
||||
result = Curl_read_plain(fd, to_p, len, &nread);
|
||||
if(!result) {
|
||||
len -= nread;
|
||||
to_p += nread;
|
||||
}
|
||||
else {
|
||||
/* FIXME: We are doing a busy wait */
|
||||
if(code == CURLE_AGAIN)
|
||||
if(result == CURLE_AGAIN)
|
||||
continue;
|
||||
return code;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return CURLE_OK;
|
||||
@@ -175,20 +175,20 @@ socket_write(struct connectdata *conn, curl_socket_t fd, const void *to,
|
||||
size_t len)
|
||||
{
|
||||
const char *to_p = to;
|
||||
CURLcode code;
|
||||
CURLcode result;
|
||||
ssize_t written;
|
||||
|
||||
while(len > 0) {
|
||||
code = Curl_write_plain(conn, fd, to_p, len, &written);
|
||||
if(code == CURLE_OK) {
|
||||
result = Curl_write_plain(conn, fd, to_p, len, &written);
|
||||
if(!result) {
|
||||
len -= written;
|
||||
to_p += written;
|
||||
}
|
||||
else {
|
||||
/* FIXME: We are doing a busy wait */
|
||||
if(code == CURLE_AGAIN)
|
||||
if(result == CURLE_AGAIN)
|
||||
continue;
|
||||
return code;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return CURLE_OK;
|
||||
@@ -200,11 +200,11 @@ static CURLcode read_data(struct connectdata *conn,
|
||||
{
|
||||
int len;
|
||||
void* tmp;
|
||||
CURLcode ret;
|
||||
CURLcode result;
|
||||
|
||||
ret = socket_read(fd, &len, sizeof(len));
|
||||
if(ret != CURLE_OK)
|
||||
return ret;
|
||||
result = socket_read(fd, &len, sizeof(len));
|
||||
if(result)
|
||||
return result;
|
||||
|
||||
len = ntohl(len);
|
||||
tmp = realloc(buf->data, len);
|
||||
@@ -212,9 +212,9 @@ static CURLcode read_data(struct connectdata *conn,
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
buf->data = tmp;
|
||||
ret = socket_read(fd, buf->data, len);
|
||||
if(ret != CURLE_OK)
|
||||
return ret;
|
||||
result = socket_read(fd, buf->data, len);
|
||||
if(result)
|
||||
return result;
|
||||
buf->size = conn->mech->decode(conn->app_data, buf->data, len,
|
||||
conn->data_prot, conn);
|
||||
buf->index = 0;
|
||||
@@ -256,7 +256,7 @@ static ssize_t sec_recv(struct connectdata *conn, int sockindex,
|
||||
buffer += bytes_read;
|
||||
|
||||
while(len > 0) {
|
||||
if(read_data(conn, fd, &conn->in_buffer) != CURLE_OK)
|
||||
if(read_data(conn, fd, &conn->in_buffer))
|
||||
return -1;
|
||||
if(conn->in_buffer.size == 0) {
|
||||
if(bytes_read > 0)
|
||||
|
||||
Reference in New Issue
Block a user