From e52fc1e2970bcb9295d6ca192f2c45df22ee5fc5 Mon Sep 17 00:00:00 2001 From: Steve Holme Date: Sat, 16 Feb 2013 23:37:50 +0000 Subject: email: Tidied up result code variables Tidied up result variables to be consistent in name, declaration order and default values. --- lib/imap.c | 35 +++++++++++++++++------------------ lib/pop3.c | 39 +++++++++++++++++++-------------------- lib/smtp.c | 33 ++++++++++++++++----------------- 3 files changed, 52 insertions(+), 55 deletions(-) (limited to 'lib') diff --git a/lib/imap.c b/lib/imap.c index 5fdaf69c7..0b7dbc391 100644 --- a/lib/imap.c +++ b/lib/imap.c @@ -222,7 +222,7 @@ static void imap_to_imaps(struct connectdata *conn) */ static CURLcode imap_sendf(struct connectdata *conn, const char *fmt, ...) { - CURLcode result; + CURLcode result = CURLE_OK; struct imap_conn *imapc = &conn->proto.imapc; char *taggedfmt; va_list ap; @@ -501,8 +501,8 @@ static CURLcode imap_state_starttls(struct connectdata *conn) static CURLcode imap_state_upgrade_tls(struct connectdata *conn) { + CURLcode result = CURLE_OK; struct imap_conn *imapc = &conn->proto.imapc; - CURLcode result; /* Start the SSL connection */ result = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET, &imapc->ssldone); @@ -1229,7 +1229,7 @@ static CURLcode imap_state_fetch_resp(struct connectdata *conn, int imapcode, static CURLcode imap_statemach_act(struct connectdata *conn) { - CURLcode result; + CURLcode result = CURLE_OK; curl_socket_t sock = conn->sock[FIRSTSOCKET]; int imapcode; struct imap_conn *imapc = &conn->proto.imapc; @@ -1333,8 +1333,8 @@ static CURLcode imap_statemach_act(struct connectdata *conn) /* Called repeatedly until done from multi.c */ static CURLcode imap_multi_statemach(struct connectdata *conn, bool *done) { + CURLcode result = CURLE_OK; struct imap_conn *imapc = &conn->proto.imapc; - CURLcode result; if((conn->handler->flags & PROTOPT_SSL) && !imapc->ssldone) result = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET, &imapc->ssldone); @@ -1348,12 +1348,11 @@ static CURLcode imap_multi_statemach(struct connectdata *conn, bool *done) static CURLcode imap_block_statemach(struct connectdata *conn) { - struct imap_conn *imapc = &conn->proto.imapc; - struct pingpong *pp = &imapc->pp; CURLcode result = CURLE_OK; + struct imap_conn *imapc = &conn->proto.imapc; while(imapc->state != IMAP_STOP) { - result = Curl_pp_statemach(pp, TRUE); + result = Curl_pp_statemach(&imapc->pp, TRUE); if(result) break; } @@ -1405,7 +1404,7 @@ static int imap_getsock(struct connectdata *conn, curl_socket_t *socks, */ static CURLcode imap_connect(struct connectdata *conn, bool *done) { - CURLcode result; + CURLcode result = CURLE_OK; struct imap_conn *imapc = &conn->proto.imapc; struct pingpong *pp = &imapc->pp; @@ -1455,9 +1454,9 @@ static CURLcode imap_connect(struct connectdata *conn, bool *done) static CURLcode imap_done(struct connectdata *conn, CURLcode status, bool premature) { + CURLcode result = CURLE_OK; struct SessionHandle *data = conn->data; struct FTP *imap = data->state.proto.imap; - CURLcode result=CURLE_OK; (void)premature; @@ -1530,7 +1529,7 @@ static CURLcode imap_perform(struct connectdata *conn, bool *connected, */ static CURLcode imap_do(struct connectdata *conn, bool *done) { - CURLcode retcode = CURLE_OK; + CURLcode result = CURLE_OK; *done = FALSE; /* default to false */ @@ -1541,18 +1540,18 @@ static CURLcode imap_do(struct connectdata *conn, bool *done) the struct IMAP is allocated and setup in the imap_connect() function. */ Curl_reset_reqproto(conn); - retcode = imap_init(conn); - if(retcode) - return retcode; + result = imap_init(conn); + if(result) + return result; /* Parse the URL path */ - retcode = imap_parse_url_path(conn); - if(retcode) - return retcode; + result = imap_parse_url_path(conn); + if(result) + return result; - retcode = imap_regular_transfer(conn, done); + result = imap_regular_transfer(conn, done); - return retcode; + return result; } /*********************************************************************** diff --git a/lib/pop3.c b/lib/pop3.c index de332f1f4..c18e7528c 100644 --- a/lib/pop3.c +++ b/lib/pop3.c @@ -412,8 +412,8 @@ static CURLcode pop3_state_starttls(struct connectdata *conn) static CURLcode pop3_state_upgrade_tls(struct connectdata *conn) { + CURLcode result = CURLE_OK; struct pop3_conn *pop3c = &conn->proto.pop3c; - CURLcode result; /* Start the SSL connection */ result = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET, &pop3c->ssldone); @@ -1147,7 +1147,7 @@ static CURLcode pop3_state_command_resp(struct connectdata *conn, static CURLcode pop3_statemach_act(struct connectdata *conn) { - CURLcode result; + CURLcode result = CURLE_OK; curl_socket_t sock = conn->sock[FIRSTSOCKET]; int pop3code; struct pop3_conn *pop3c = &conn->proto.pop3c; @@ -1257,8 +1257,8 @@ static CURLcode pop3_statemach_act(struct connectdata *conn) /* Called repeatedly until done from multi.c */ static CURLcode pop3_multi_statemach(struct connectdata *conn, bool *done) { + CURLcode result = CURLE_OK; struct pop3_conn *pop3c = &conn->proto.pop3c; - CURLcode result; if((conn->handler->flags & PROTOPT_SSL) && !pop3c->ssldone) result = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET, &pop3c->ssldone); @@ -1272,12 +1272,11 @@ static CURLcode pop3_multi_statemach(struct connectdata *conn, bool *done) static CURLcode pop3_block_statemach(struct connectdata *conn) { - struct pop3_conn *pop3c = &conn->proto.pop3c; - struct pingpong *pp = &pop3c->pp; CURLcode result = CURLE_OK; + struct pop3_conn *pop3c = &conn->proto.pop3c; while(pop3c->state != POP3_STOP) { - result = Curl_pp_statemach(pp, TRUE); + result = Curl_pp_statemach(&pop3c->pp, TRUE); if(result) break; } @@ -1331,7 +1330,7 @@ static int pop3_getsock(struct connectdata *conn, curl_socket_t *socks, */ static CURLcode pop3_connect(struct connectdata *conn, bool *done) { - CURLcode result; + CURLcode result = CURLE_OK; struct pop3_conn *pop3c = &conn->proto.pop3c; struct pingpong *pp = &pop3c->pp; @@ -1378,10 +1377,10 @@ static CURLcode pop3_connect(struct connectdata *conn, bool *done) static CURLcode pop3_done(struct connectdata *conn, CURLcode status, bool premature) { + CURLcode result = CURLE_OK; struct SessionHandle *data = conn->data; struct FTP *pop3 = data->state.proto.pop3; struct pop3_conn *pop3c = &conn->proto.pop3c; - CURLcode result = CURLE_OK; (void)premature; @@ -1458,7 +1457,7 @@ static CURLcode pop3_perform(struct connectdata *conn, bool *connected, */ static CURLcode pop3_do(struct connectdata *conn, bool *done) { - CURLcode retcode = CURLE_OK; + CURLcode result = CURLE_OK; *done = FALSE; /* default to false */ @@ -1469,23 +1468,23 @@ static CURLcode pop3_do(struct connectdata *conn, bool *done) the struct POP3 is allocated and setup in the pop3_connect() function. */ Curl_reset_reqproto(conn); - retcode = pop3_init(conn); - if(retcode) - return retcode; + result = pop3_init(conn); + if(result) + return result; /* Parse the URL path */ - retcode = pop3_parse_url_path(conn); - if(retcode) - return retcode; + result = pop3_parse_url_path(conn); + if(result) + return result; /* Parse the custom request */ - retcode = pop3_parse_custom_request(conn); - if(retcode) - return retcode; + result = pop3_parse_custom_request(conn); + if(result) + return result; - retcode = pop3_regular_transfer(conn, done); + result = pop3_regular_transfer(conn, done); - return retcode; + return result; } /*********************************************************************** diff --git a/lib/smtp.c b/lib/smtp.c index a8a73f304..d63b4e1ea 100644 --- a/lib/smtp.c +++ b/lib/smtp.c @@ -331,7 +331,7 @@ static void state(struct connectdata *conn, smtpstate newstate) static CURLcode smtp_state_ehlo(struct connectdata *conn) { - CURLcode result; + CURLcode result = CURLE_OK; struct smtp_conn *smtpc = &conn->proto.smtpc; smtpc->authmechs = 0; /* No known authentication mechanisms yet */ @@ -352,7 +352,7 @@ static CURLcode smtp_state_ehlo(struct connectdata *conn) static CURLcode smtp_state_helo(struct connectdata *conn) { - CURLcode result; + CURLcode result = CURLE_OK; struct smtp_conn *smtpc = &conn->proto.smtpc; smtpc->authused = 0; /* No authentication mechanism used in smtp @@ -384,8 +384,8 @@ static CURLcode smtp_state_starttls(struct connectdata *conn) static CURLcode smtp_state_upgrade_tls(struct connectdata *conn) { + CURLcode result = CURLE_OK; struct smtp_conn *smtpc = &conn->proto.smtpc; - CURLcode result; /* Start the SSL connection */ result = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET, &smtpc->ssldone); @@ -407,8 +407,8 @@ static CURLcode smtp_authenticate(struct connectdata *conn) { CURLcode result = CURLE_OK; struct smtp_conn *smtpc = &conn->proto.smtpc; - char *initresp = NULL; const char *mech = NULL; + char *initresp = NULL; size_t len = 0; smtpstate state1 = SMTP_STOP; smtpstate state2 = SMTP_STOP; @@ -1130,7 +1130,7 @@ static CURLcode smtp_state_postdata_resp(struct connectdata *conn, static CURLcode smtp_statemach_act(struct connectdata *conn) { - CURLcode result; + CURLcode result = CURLE_OK; curl_socket_t sock = conn->sock[FIRSTSOCKET]; struct SessionHandle *data = conn->data; int smtpcode; @@ -1247,8 +1247,8 @@ static CURLcode smtp_statemach_act(struct connectdata *conn) /* Called repeatedly until done from multi.c */ static CURLcode smtp_multi_statemach(struct connectdata *conn, bool *done) { + CURLcode result = CURLE_OK; struct smtp_conn *smtpc = &conn->proto.smtpc; - CURLcode result; if((conn->handler->flags & PROTOPT_SSL) && !smtpc->ssldone) result = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET, &smtpc->ssldone); @@ -1262,12 +1262,11 @@ static CURLcode smtp_multi_statemach(struct connectdata *conn, bool *done) static CURLcode smtp_block_statemach(struct connectdata *conn) { - struct smtp_conn *smtpc = &conn->proto.smtpc; - struct pingpong *pp = &smtpc->pp; CURLcode result = CURLE_OK; + struct smtp_conn *smtpc = &conn->proto.smtpc; while(smtpc->state != SMTP_STOP) { - result = Curl_pp_statemach(pp, TRUE); + result = Curl_pp_statemach(&smtpc->pp, TRUE); if(result) break; } @@ -1321,7 +1320,7 @@ static int smtp_getsock(struct connectdata *conn, curl_socket_t *socks, */ static CURLcode smtp_connect(struct connectdata *conn, bool *done) { - CURLcode result; + CURLcode result = CURLE_OK; struct smtp_conn *smtpc = &conn->proto.smtpc; struct pingpong *pp = &smtpc->pp; const char *path = conn->data->state.path; @@ -1383,9 +1382,9 @@ static CURLcode smtp_connect(struct connectdata *conn, bool *done) static CURLcode smtp_done(struct connectdata *conn, CURLcode status, bool premature) { + CURLcode result = CURLE_OK; struct SessionHandle *data = conn->data; struct FTP *smtp = data->state.proto.smtp; - CURLcode result = CURLE_OK; ssize_t bytes_written; (void)premature; @@ -1495,7 +1494,7 @@ static CURLcode smtp_perform(struct connectdata *conn, bool *connected, */ static CURLcode smtp_do(struct connectdata *conn, bool *done) { - CURLcode retcode = CURLE_OK; + CURLcode result = CURLE_OK; *done = FALSE; /* default to false */ @@ -1506,13 +1505,13 @@ static CURLcode smtp_do(struct connectdata *conn, bool *done) the struct SMTP is allocated and setup in the smtp_connect() function. */ Curl_reset_reqproto(conn); - retcode = smtp_init(conn); - if(retcode) - return retcode; + result = smtp_init(conn); + if(result) + return result; - retcode = smtp_regular_transfer(conn, done); + result = smtp_regular_transfer(conn, done); - return retcode; + return result; } /*********************************************************************** -- cgit v1.2.3