mirror of
https://github.com/curl/curl.git
synced 2026-08-25 08:03:34 +03:00
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:
parent
1752e9c088
commit
0eb3d15ccb
27 changed files with 413 additions and 423 deletions
44
lib/tftp.c
44
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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue