summaryrefslogtreecommitdiff
path: root/lib/tftp.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2014-10-23 22:56:35 +0200
committerDaniel Stenberg <daniel@haxx.se>2014-10-24 08:23:19 +0200
commit0eb3d15ccb419bfda41ee31bdbf73c36facc7388 (patch)
tree0c4abf7bf4bac279cbcfd708e1cdd1bcdf29bb77 /lib/tftp.c
parent1752e9c088d9bb7a3156dba9c66f7f64dd87afa9 (diff)
downloadcurl-0eb3d15ccb419bfda41ee31bdbf73c36facc7388.tar.gz
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)
Diffstat (limited to 'lib/tftp.c')
-rw-r--r--lib/tftp.c44
1 files changed, 22 insertions, 22 deletions
diff --git a/lib/tftp.c b/lib/tftp.c
index e499c4516..b9723c000 100644
--- a/lib/tftp.c
+++ b/lib/tftp.c
@@ -417,32 +417,32 @@ static size_t tftp_option_add(tftp_state_data_t *state, size_t csize,
static CURLcode tftp_connect_for_tx(tftp_state_data_t *state,
tftp_event_t event)
{
- CURLcode res;
+ CURLcode result;
#ifndef CURL_DISABLE_VERBOSE_STRINGS
struct SessionHandle *data = state->conn->data;
infof(data, "%s\n", "Connected for transmit");
#endif
state->state = TFTP_STATE_TX;
- res = tftp_set_timeouts(state);
- if(res != CURLE_OK)
- return(res);
+ result = tftp_set_timeouts(state);
+ if(result)
+ return(result);
return tftp_tx(state, event);
}
static CURLcode tftp_connect_for_rx(tftp_state_data_t *state,
tftp_event_t event)
{
- CURLcode res;
+ CURLcode result;
#ifndef CURL_DISABLE_VERBOSE_STRINGS
struct SessionHandle *data = state->conn->data;
infof(data, "%s\n", "Connected for receive");
#endif
state->state = TFTP_STATE_RX;
- res = tftp_set_timeouts(state);
- if(res != CURLE_OK)
- return(res);
+ result = tftp_set_timeouts(state);
+ if(result)
+ return(result);
return tftp_rx(state, event);
}
@@ -1208,7 +1208,7 @@ static CURLcode tftp_multi_statemach(struct connectdata *conn, bool *done)
}
else if(event != TFTP_EVENT_NONE) {
result = tftp_state_machine(state, event);
- if(result != CURLE_OK)
+ if(result)
return(result);
*done = (state->state == TFTP_STATE_FIN) ? TRUE : FALSE;
if(*done)
@@ -1227,10 +1227,10 @@ static CURLcode tftp_multi_statemach(struct connectdata *conn, bool *done)
}
else if(rc != 0) {
result = tftp_receive_packet(conn);
- if(result != CURLE_OK)
+ if(result)
return(result);
result = tftp_state_machine(state, state->event);
- if(result != CURLE_OK)
+ if(result)
return(result);
*done = (state->state == TFTP_STATE_FIN) ? TRUE : FALSE;
if(*done)
@@ -1286,8 +1286,8 @@ static CURLcode tftp_perform(struct connectdata *conn, bool *dophase_done)
result = tftp_state_machine(state, TFTP_EVENT_INIT);
- if(state->state == TFTP_STATE_FIN || result != CURLE_OK)
- return(result);
+ if((state->state == TFTP_STATE_FIN) || result)
+ return result;
tftp_multi_statemach(conn, dophase_done);
@@ -1310,30 +1310,30 @@ static CURLcode tftp_perform(struct connectdata *conn, bool *dophase_done)
static CURLcode tftp_do(struct connectdata *conn, bool *done)
{
- tftp_state_data_t *state;
- CURLcode code;
+ tftp_state_data_t *state;
+ CURLcode result;
*done = FALSE;
if(!conn->proto.tftpc) {
- code = tftp_connect(conn, done);
- if(code)
- return code;
+ result = tftp_connect(conn, done);
+ if(result)
+ return result;
}
state = (tftp_state_data_t *)conn->proto.tftpc;
if(!state)
return CURLE_BAD_CALLING_ORDER;
- code = tftp_perform(conn, done);
+ result = tftp_perform(conn, done);
/* If tftp_perform() returned an error, use that for return code. If it
was OK, see if tftp_translate_code() has an error. */
- if(code == CURLE_OK)
+ if(!result)
/* If we have encountered an internal tftp error, translate it. */
- code = tftp_translate_code(state->error);
+ result = tftp_translate_code(state->error);
- return code;
+ return result;
}
static CURLcode tftp_setup_connection(struct connectdata * conn)