From 6632d957e7d658566288406276dc98669e8228c7 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 16 Apr 2010 20:22:46 +0200 Subject: krb5_auth: fix my previous change to compile --- lib/krb5.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/krb5.c b/lib/krb5.c index 92f2b7155..9fb44f2d7 100644 --- a/lib/krb5.c +++ b/lib/krb5.c @@ -1,6 +1,6 @@ /* GSSAPI/krb5 support for FTP - loosely based on old krb4.c * - * Copyright (c) 1995, 1996, 1997, 1998, 1999 Kungliga Tekniska Högskolan + * Copyright (c) 1995, 1996, 1997, 1998, 1999, 2010 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * Copyright (c) 2004 - 2009 Daniel Stenberg * All rights reserved. @@ -163,7 +163,7 @@ krb5_auth(void *app_data, struct connectdata *conn) { int ret; char *p; - const char *host = conn->host->name; + const char *host = conn->host.name; ssize_t nread; curl_socklen_t l = sizeof(conn->local_addr); struct SessionHandle *data = conn->data; -- cgit v1.2.3 From c2888604d7ead19473b5621f8f2edab60fc418de Mon Sep 17 00:00:00 2001 From: Jerome Vouillon Date: Fri, 16 Apr 2010 22:43:01 +0200 Subject: GnuTLS: make the connection phase non-blocking When multi interface is used, the SSL handshake is no longer blocking when GnuTLS is used. --- lib/gtls.c | 212 +++++++++++++++++++++++++++++++++++++++++----------------- lib/gtls.h | 4 ++ lib/http.c | 18 +---- lib/urldata.h | 1 + 4 files changed, 160 insertions(+), 75 deletions(-) diff --git a/lib/gtls.c b/lib/gtls.c index 92d780530..4f5edaf78 100644 --- a/lib/gtls.c +++ b/lib/gtls.c @@ -182,54 +182,76 @@ static void unload_file(gnutls_datum data) { } -/* this function does a BLOCKING SSL/TLS (re-)handshake */ +/* this function does a SSL/TLS (re-)handshake */ static CURLcode handshake(struct connectdata *conn, - gnutls_session session, int sockindex, - bool duringconnect) + bool duringconnect, + bool nonblocking) { struct SessionHandle *data = conn->data; + struct ssl_connect_data *connssl = &conn->ssl[sockindex]; + gnutls_session session = conn->ssl[sockindex].session; + curl_socket_t sockfd = conn->sock[sockindex]; + long timeout_ms; int rc; - if(!gtls_inited) - Curl_gtls_init(); - do { - rc = gnutls_handshake(session); + int what; - if((rc == GNUTLS_E_AGAIN) || (rc == GNUTLS_E_INTERRUPTED)) { - long timeout_ms = Curl_timeleft(conn, NULL, duringconnect); + while(1) { + /* check allowed time left */ + timeout_ms = Curl_timeleft(conn, NULL, duringconnect); - if(timeout_ms < 0) { - /* a precaution, no need to continue if time already is up */ - failf(data, "SSL connection timeout"); - return CURLE_OPERATION_TIMEDOUT; - } + if(timeout_ms < 0) { + /* no need to continue if time already is up */ + failf(data, "SSL connection timeout"); + return CURLE_OPERATION_TIMEDOUT; + } - rc = Curl_socket_ready(conn->sock[sockindex], - conn->sock[sockindex], (int)timeout_ms); - if(rc > 0) - /* reabable or writable, go loop*/ - continue; - else if(0 == rc) { - /* timeout */ - failf(data, "SSL connection timeout"); - return CURLE_OPERATION_TIMEDOUT; - } - else { - /* anything that gets here is fatally bad */ + /* if ssl is expecting something, check if it's available. */ + if(connssl->connecting_state == ssl_connect_2_reading + || connssl->connecting_state == ssl_connect_2_writing) { + + curl_socket_t writefd = ssl_connect_2_writing== + connssl->connecting_state?sockfd:CURL_SOCKET_BAD; + curl_socket_t readfd = ssl_connect_2_reading== + connssl->connecting_state?sockfd:CURL_SOCKET_BAD; + + what = Curl_socket_ready(readfd, writefd, + nonblocking?0:(int)timeout_ms); + if(what < 0) { + /* fatal error */ failf(data, "select/poll on SSL socket, errno: %d", SOCKERRNO); return CURLE_SSL_CONNECT_ERROR; } + else if(0 == what) { + if(nonblocking) { + return CURLE_OK; + } + else { + /* timeout */ + failf(data, "SSL connection timeout"); + return CURLE_OPERATION_TIMEDOUT; + } + } + /* socket is readable or writable */ } - else - break; - } while(1); - if(rc < 0) { - failf(data, "gnutls_handshake() failed: %s", gnutls_strerror(rc)); - return CURLE_SSL_CONNECT_ERROR; - } + rc = gnutls_handshake(session); - return CURLE_OK; + if((rc == GNUTLS_E_AGAIN) || (rc == GNUTLS_E_INTERRUPTED)) { + connssl->connecting_state = + gnutls_record_get_direction(session)? + ssl_connect_2_writing:ssl_connect_2_reading; + if(nonblocking) { + return CURLE_OK; + } + } else if (rc < 0) { + failf(data, "gnutls_handshake() failed: %s", gnutls_strerror(rc)); + } else { + /* Reset our connect state machine */ + connssl->connecting_state = ssl_connect_1; + return CURLE_OK; + } + } } static gnutls_x509_crt_fmt do_file_type(const char *type) @@ -243,31 +265,14 @@ static gnutls_x509_crt_fmt do_file_type(const char *type) return -1; } - -/* - * This function is called after the TCP connect has completed. Setup the TLS - * layer and do all necessary magic. - */ -CURLcode -Curl_gtls_connect(struct connectdata *conn, - int sockindex) - +static CURLcode +gtls_connect_step1(struct connectdata *conn, + int sockindex) { static const int cert_type_priority[] = { GNUTLS_CRT_X509, 0 }; struct SessionHandle *data = conn->data; gnutls_session session; int rc; - unsigned int cert_list_size; - const gnutls_datum *chainp; - unsigned int verify_status; - gnutls_x509_crt x509_cert,x509_issuer; - gnutls_datum issuerp; - char certbuf[256]; /* big enough? */ - size_t size; - unsigned int algo; - unsigned int bits; - time_t certclock; - const char *ptr; void *ssl_sessionid; size_t ssl_idsize; bool sni = TRUE; /* default is SNI enabled */ @@ -411,10 +416,29 @@ Curl_gtls_connect(struct connectdata *conn, infof (data, "SSL re-using session ID\n"); } - rc = handshake(conn, session, sockindex, TRUE); - if(rc) - /* handshake() sets its own error message with failf() */ - return rc; + return CURLE_OK; +} + +static CURLcode +gtls_connect_step3(struct connectdata *conn, + int sockindex) +{ + unsigned int cert_list_size; + const gnutls_datum *chainp; + unsigned int verify_status; + gnutls_x509_crt x509_cert,x509_issuer; + gnutls_datum issuerp; + char certbuf[256]; /* big enough? */ + size_t size; + unsigned int algo; + unsigned int bits; + time_t certclock; + const char *ptr; + struct SessionHandle *data = conn->data; + gnutls_session session = conn->ssl[sockindex].session; + int rc; + int incache; + void *ssl_sessionid; /* This function will return the peer's raw certificate (chain) as sent by the peer. These certificates are in raw format (DER encoded for @@ -623,20 +647,88 @@ Curl_gtls_connect(struct connectdata *conn, /* extract session ID to the allocated buffer */ gnutls_session_get_data(session, connect_sessionid, &connect_idsize); - if(ssl_sessionid) + incache = !(Curl_ssl_getsessionid(conn, &ssl_sessionid, NULL)); + if (incache) { /* there was one before in the cache, so instead of risking that the previous one was rejected, we just kill that and store the new */ Curl_ssl_delsessionid(conn, ssl_sessionid); + } /* store this session id */ return Curl_ssl_addsessionid(conn, connect_sessionid, connect_idsize); } + } + + return CURLE_OK; +} + +/* + * This function is called after the TCP connect has completed. Setup the TLS + * layer and do all necessary magic. + */ +/* We use connssl->connecting_state to keep track of the connection status; + there are three states: 'ssl_connect_1' (not started yet or complete), + 'ssl_connect_2_reading' (waiting for data from server), and + 'ssl_connect_2_writing' (waiting to be able to write). + */ +static CURLcode +gtls_connect_common(struct connectdata *conn, + int sockindex, + bool nonblocking, + bool *done) +{ + int rc; + struct ssl_connect_data *connssl = &conn->ssl[sockindex]; + + /* Initiate the connection, if not already done */ + if(ssl_connect_1==connssl->connecting_state) { + rc = gtls_connect_step1 (conn, sockindex); + if(rc) + return rc; } + rc = handshake(conn, sockindex, TRUE, nonblocking); + if(rc) + /* handshake() sets its own error message with failf() */ + return rc; + + /* Finish connecting once the handshake is done */ + if(ssl_connect_1==connssl->connecting_state) { + rc = gtls_connect_step3(conn, sockindex); + if(rc) + return rc; + } + + *done = ssl_connect_1==connssl->connecting_state; + return CURLE_OK; } +CURLcode +Curl_gtls_connect_nonblocking(struct connectdata *conn, + int sockindex, + bool *done) +{ + return gtls_connect_common(conn, sockindex, TRUE, done); +} + +CURLcode +Curl_gtls_connect(struct connectdata *conn, + int sockindex) + +{ + CURLcode retcode; + bool done = FALSE; + + retcode = gtls_connect_common(conn, sockindex, FALSE, &done); + if(retcode) + return retcode; + + DEBUGASSERT(done); + + return CURLE_OK; +} /* for documentation see Curl_ssl_send() in sslgen.h */ ssize_t Curl_gtls_send(struct connectdata *conn, @@ -769,7 +861,7 @@ ssize_t Curl_gtls_recv(struct connectdata *conn, /* connection data */ if(ret == GNUTLS_E_REHANDSHAKE) { /* BLOCKING call, this is bad but a work-around for now. Fixing this "the proper way" takes a whole lot of work. */ - CURLcode rc = handshake(conn, conn->ssl[num].session, num, FALSE); + CURLcode rc = handshake(conn, num, FALSE, FALSE); if(rc) /* handshake() writes error message on its own */ *curlcode = rc; diff --git a/lib/gtls.h b/lib/gtls.h index 9fe618a32..da3489bc3 100644 --- a/lib/gtls.h +++ b/lib/gtls.h @@ -27,6 +27,9 @@ int Curl_gtls_init(void); int Curl_gtls_cleanup(void); CURLcode Curl_gtls_connect(struct connectdata *conn, int sockindex); +CURLcode Curl_gtls_connect_nonblocking(struct connectdata *conn, + int sockindex, + bool *done); /* tell GnuTLS to close down all open information regarding connections (and thus session ID caching etc) */ @@ -52,6 +55,7 @@ int Curl_gtls_seed(struct SessionHandle *data); #define curlssl_init Curl_gtls_init #define curlssl_cleanup Curl_gtls_cleanup #define curlssl_connect Curl_gtls_connect +#define curlssl_connect_nonblocking Curl_gtls_connect_nonblocking #define curlssl_session_free(x) Curl_gtls_session_free(x) #define curlssl_close_all Curl_gtls_close_all #define curlssl_close Curl_gtls_close diff --git a/lib/http.c b/lib/http.c index 7ffc34d49..99d34e661 100644 --- a/lib/http.c +++ b/lib/http.c @@ -1817,9 +1817,9 @@ static CURLcode https_connecting(struct connectdata *conn, bool *done) } #endif -#ifdef USE_SSLEAY -/* This function is OpenSSL-specific. It should be made to query the generic - SSL layer instead. */ +#if defined(USE_SSLEAY) || defined(USE_GNUTLS) +/* This function is for OpenSSL and GnuTLS only. It should be made to query + the generic SSL layer instead. */ static int https_getsock(struct connectdata *conn, curl_socket_t *socks, int numsocks) @@ -1844,17 +1844,6 @@ static int https_getsock(struct connectdata *conn, return CURLE_OK; } #else -#ifdef USE_GNUTLS -static int https_getsock(struct connectdata *conn, - curl_socket_t *socks, - int numsocks) -{ - (void)conn; - (void)socks; - (void)numsocks; - return GETSOCK_BLANK; -} -#else #ifdef USE_NSS static int https_getsock(struct connectdata *conn, curl_socket_t *socks, @@ -1879,7 +1868,6 @@ static int https_getsock(struct connectdata *conn, #endif #endif #endif -#endif /* * Curl_http_done() gets called from Curl_done() after a single HTTP request diff --git a/lib/urldata.h b/lib/urldata.h index ad172d66a..02233b685 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -231,6 +231,7 @@ struct ssl_connect_data { #ifdef USE_GNUTLS gnutls_session session; gnutls_certificate_credentials cred; + ssl_connect_state connecting_state; #endif /* USE_GNUTLS */ #ifdef USE_NSS PRFileDesc *handle; -- cgit v1.2.3 From 0a4ccce054c8b47642e01055bf6c8531c9e2a07f Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 16 Apr 2010 22:45:06 +0200 Subject: changelog: GnuTLS: SSL handshake phase is non-blocking --- CHANGES | 2 ++ RELEASE-NOTES | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index be2bf0425..dda8a4cbc 100644 --- a/CHANGES +++ b/CHANGES @@ -7,6 +7,8 @@ Changelog Daniel Stenberg (16 Apr 2010) +- Jerome Vouillon made the GnuTLS SSL handshake phase non-blocking. + - The recent overhaul of the SSL recv function made the GnuTLS specific code treat a zero returned from gnutls_record_recv() as an error, and this caused our HTTPS test cases to fail. We leave it to upper layer code to detect if diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 82a9e93fa..3117bf8b7 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -16,6 +16,7 @@ This release includes the following bugfixes: o prevent needless reverse name lookups o detect GSS on ancient Linux distros o GnuTLS: EOF caused error when it wasn't + o GnuTLS: SSL handshake phase is non-blocking This release includes the following known bugs: @@ -24,6 +25,6 @@ This release includes the following known bugs: This release would not have looked like this without help, code, reports and advice from friends like these: - Rainer Canavan, Paul Howarth + Rainer Canavan, Paul Howarth, Jerome Vouillon Thanks! (and sorry if I forgot to mention someone) -- cgit v1.2.3 From 01fc53e027efc9c9217be0b773c7a49f97291add Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 16 Apr 2010 22:52:49 +0200 Subject: file_range: Value stored to 'totalsize' is never read --- lib/file.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/file.c b/lib/file.c index 6c14ee8e6..f96f8f51a 100644 --- a/lib/file.c +++ b/lib/file.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2009, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2010, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -161,11 +161,10 @@ static CURLcode file_range(struct connectdata *conn) } else if(from < 0) { /* -Y */ - totalsize = -from; data->req.maxdownload = -from; data->state.resume_from = from; DEBUGF(infof(data, "RANGE the last %" FORMAT_OFF_T " bytes\n", - totalsize)); + -from)); } else { /* X-Y */ -- cgit v1.2.3 From 313a5b05c225ccf7de326cb137dfca053782e0e1 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 16 Apr 2010 22:55:07 +0200 Subject: tftp_rx: Value stored to 'sbytes' is never read --- lib/tftp.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/tftp.c b/lib/tftp.c index dc21c542c..564de4916 100644 --- a/lib/tftp.c +++ b/lib/tftp.c @@ -659,7 +659,6 @@ static CURLcode tftp_rx(tftp_state_data_t *state, tftp_event_t event) 4, SEND_4TH_ARG, (struct sockaddr *)&state->remote_addr, state->remote_addrlen); - /* Check all sbytes were sent */ if(sbytes<0) { failf(data, "%s", Curl_strerror(state->conn, SOCKERRNO)); return CURLE_SEND_ERROR; @@ -670,10 +669,10 @@ static CURLcode tftp_rx(tftp_state_data_t *state, tftp_event_t event) case TFTP_EVENT_ERROR: setpacketevent(&state->spacket, TFTP_EVENT_ERROR); setpacketblock(&state->spacket, state->block); - sbytes = sendto(state->sockfd, (void *)state->spacket.data, - 4, SEND_4TH_ARG, - (struct sockaddr *)&state->remote_addr, - state->remote_addrlen); + (void)sendto(state->sockfd, (void *)state->spacket.data, + 4, SEND_4TH_ARG, + (struct sockaddr *)&state->remote_addr, + state->remote_addrlen); /* don't bother with the return code, but if the socket is still up we * should be a good TFTP client and let the server know we're done */ state->state = TFTP_STATE_FIN; -- cgit v1.2.3 From fa7341143a4bb5c1c1a2d43375bbc9a2157938ec Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 16 Apr 2010 22:56:13 +0200 Subject: POP3: when USER command fails, don't even try PASS --- lib/pop3.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/pop3.c b/lib/pop3.c index 4894f3c44..34c6fdfb1 100644 --- a/lib/pop3.c +++ b/lib/pop3.c @@ -311,10 +311,10 @@ static CURLcode pop3_state_user_resp(struct connectdata *conn, failf(data, "Access denied. %c", pop3code); result = CURLE_LOGIN_DENIED; } - - /* send PASS */ - result = Curl_pp_sendf(&conn->proto.pop3c.pp, "PASS %s", - pop3->passwd?pop3->passwd:""); + else + /* send PASS */ + result = Curl_pp_sendf(&conn->proto.pop3c.pp, "PASS %s", + pop3->passwd?pop3->passwd:""); if(result) return result; -- cgit v1.2.3 From 520cee3fb7319eb44d226aaaab9688ae91bc3278 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 16 Apr 2010 22:58:04 +0200 Subject: SOCKS5: when name resolves fail return immediately This makes the code flow more obvious and reacts on the return code properly, even if the code acted the same way before. --- lib/socks.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/socks.c b/lib/socks.c index eb7956798..0b051545c 100644 --- a/lib/socks.c +++ b/lib/socks.c @@ -597,9 +597,12 @@ CURLcode Curl_SOCKS5(const char *proxy_name, if(rc == CURLRESOLV_ERROR) return CURLE_COULDNT_RESOLVE_HOST; - if(rc == CURLRESOLV_PENDING) + if(rc == CURLRESOLV_PENDING) { /* this requires that we're in "wait for resolve" state */ rc = Curl_wait_for_resolv(conn, &dns); + if(rc) + return rc; + } /* * We cannot use 'hostent' as a struct that Curl_resolv() returns. It -- cgit v1.2.3 From 743bd81e64887644228665642f4c59fd15697371 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 16 Apr 2010 23:00:21 +0200 Subject: ftp_range: Value stored to 'totalsize' is never read Simplified the code by removing a local variable completely. --- lib/ftp.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/ftp.c b/lib/ftp.c index f821d124d..9460dd9d5 100644 --- a/lib/ftp.c +++ b/lib/ftp.c @@ -3285,7 +3285,6 @@ ftp_pasv_verbose(struct connectdata *conn, static CURLcode ftp_range(struct connectdata *conn) { curl_off_t from, to; - curl_off_t totalsize=-1; char *ptr; char *ptr2; struct SessionHandle *data = conn->data; @@ -3308,16 +3307,14 @@ static CURLcode ftp_range(struct connectdata *conn) } else if(from < 0) { /* -Y */ - totalsize = -from; data->req.maxdownload = -from; data->state.resume_from = from; DEBUGF(infof(conn->data, "FTP RANGE the last %" FORMAT_OFF_T " bytes\n", - totalsize)); + -from)); } else { /* X-Y */ - totalsize = to-from; - data->req.maxdownload = totalsize+1; /* include last byte */ + data->req.maxdownload = (to-from)+1; /* include last byte */ data->state.resume_from = from; DEBUGF(infof(conn->data, "FTP RANGE from %" FORMAT_OFF_T " getting %" FORMAT_OFF_T " bytes\n", -- cgit v1.2.3 From 516dfd17054c771833c4a4096f5f978e5446e7c4 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 16 Apr 2010 23:02:15 +0200 Subject: FTP PASV: Value stored to 'rc' is never read --- lib/ftp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/ftp.c b/lib/ftp.c index 9460dd9d5..ee1fb066b 100644 --- a/lib/ftp.c +++ b/lib/ftp.c @@ -1630,8 +1630,9 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn, */ rc = Curl_resolv(conn, conn->proxy.name, (int)conn->port, &addr); if(rc == CURLRESOLV_PENDING) - /* BLOCKING */ - rc = Curl_wait_for_resolv(conn, &addr); + /* BLOCKING, ignores the return code but 'addr' will be NULL in + case of failure */ + (void)Curl_wait_for_resolv(conn, &addr); connectport = (unsigned short)conn->port; /* we connect to the proxy's port */ -- cgit v1.2.3 From 15fa5dcfe6ad34f8f9d360163c44caf05c771210 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 16 Apr 2010 23:03:55 +0200 Subject: SOCKS4: Value stored to 'rc' is never read --- lib/socks.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/socks.c b/lib/socks.c index 0b051545c..df301ecec 100644 --- a/lib/socks.c +++ b/lib/socks.c @@ -172,8 +172,8 @@ CURLcode Curl_SOCKS4(const char *proxy_name, return CURLE_COULDNT_RESOLVE_PROXY; if(rc == CURLRESOLV_PENDING) - /* this requires that we're in "wait for resolve" state */ - rc = Curl_wait_for_resolv(conn, &dns); + /* ignores the return code, but 'dns' remains NULL on failure */ + (void)Curl_wait_for_resolv(conn, &dns); /* * We cannot use 'hostent' as a struct that Curl_resolv() returns. It -- cgit v1.2.3 From 5d43c75c6696f991bc29dd6ee3bf35ca06101a69 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 16 Apr 2010 23:18:43 +0200 Subject: file_range: remove unnecessary check for NULL pointer --- lib/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/file.c b/lib/file.c index f96f8f51a..91176aa11 100644 --- a/lib/file.c +++ b/lib/file.c @@ -146,7 +146,7 @@ static CURLcode file_range(struct connectdata *conn) if(data->state.use_range && data->state.range) { from=curlx_strtoofft(data->state.range, &ptr, 0); - while(ptr && *ptr && (isspace((int)*ptr) || (*ptr=='-'))) + while(*ptr && (isspace((int)*ptr) || (*ptr=='-'))) ptr++; to=curlx_strtoofft(ptr, &ptr2, 0); if(ptr == ptr2) { -- cgit v1.2.3 From b025ac16a6ea2d4c167a2bfe86f623c3ae2d9f4b Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 16 Apr 2010 23:20:07 +0200 Subject: ftp_range: remove unnecessary check for NULL pointer --- lib/ftp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ftp.c b/lib/ftp.c index ee1fb066b..870befc86 100644 --- a/lib/ftp.c +++ b/lib/ftp.c @@ -3293,7 +3293,7 @@ static CURLcode ftp_range(struct connectdata *conn) if(data->state.use_range && data->state.range) { from=curlx_strtoofft(data->state.range, &ptr, 0); - while(ptr && *ptr && (ISSPACE(*ptr) || (*ptr=='-'))) + while(*ptr && (ISSPACE(*ptr) || (*ptr=='-'))) ptr++; to=curlx_strtoofft(ptr, &ptr2, 0); if(ptr == ptr2) { -- cgit v1.2.3 From 9799dbebd6ab174a01fef2ff62d8806b1ea8bbd5 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 16 Apr 2010 23:20:50 +0200 Subject: sftp range: remove unnecessary check for NULL pointer --- lib/ssh.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ssh.c b/lib/ssh.c index ff5994b44..b3da65562 100644 --- a/lib/ssh.c +++ b/lib/ssh.c @@ -1910,7 +1910,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block) char *ptr2; from=curlx_strtoofft(conn->data->state.range, &ptr, 0); - while(ptr && *ptr && (isspace((int)*ptr) || (*ptr=='-'))) + while(*ptr && (isspace((int)*ptr) || (*ptr=='-'))) ptr++; to=curlx_strtoofft(ptr, &ptr2, 0); if((ptr == ptr2) /* no "to" value given */ -- cgit v1.2.3 From 8f136288c5b6ad9fe3be9cd69a96f585f6eda2aa Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 16 Apr 2010 23:27:35 +0200 Subject: Curl_perform: Value stored to 'res2' is never read --- lib/transfer.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/transfer.c b/lib/transfer.c index 2d504050c..8985892df 100644 --- a/lib/transfer.c +++ b/lib/transfer.c @@ -2113,9 +2113,9 @@ CURLcode Curl_perform(struct SessionHandle *data) /* Curl_do() failed, clean up left-overs in the done-call, but note that at some cases the conn pointer is NULL when Curl_do() failed and the connection cache is very small so only call Curl_done() if - conn is still "alive". - */ - res2 = Curl_done(&conn, res, FALSE); + conn is still "alive". */ + /* ignore return code since we already have an error to return */ + (void)Curl_done(&conn, res, FALSE); /* * Important: 'conn' cannot be used here, since it may have been closed -- cgit v1.2.3 From 93981bb9b5026f88ed4dec5d790bb7c84265210a Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 16 Apr 2010 23:28:20 +0200 Subject: PASV response: Value stored to 'rc' is never read --- lib/ftp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ftp.c b/lib/ftp.c index 870befc86..9df4e23bc 100644 --- a/lib/ftp.c +++ b/lib/ftp.c @@ -1648,7 +1648,7 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn, rc = Curl_resolv(conn, newhost, newport, &addr); if(rc == CURLRESOLV_PENDING) /* BLOCKING */ - rc = Curl_wait_for_resolv(conn, &addr); + (void)Curl_wait_for_resolv(conn, &addr); connectport = newport; /* we connect to the remote port */ -- cgit v1.2.3 From c0111460b0689d74731cc56ff019cc869a0d16a8 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 16 Apr 2010 23:43:04 +0200 Subject: Curl_setup_transfer: no longer returns anything This function could only return CURLE_OK and by changing it to a void instead, we can simplify code all over. --- lib/dict.c | 31 +++++++++++++------------------ lib/ftp.c | 19 ++++++++----------- lib/http.c | 36 +++++++++++++++--------------------- lib/imap.c | 12 +++++------- lib/pop3.c | 17 +++++++---------- lib/rtsp.c | 16 +++++----------- lib/smtp.c | 12 +++++------- lib/ssh.c | 18 ++++++++---------- lib/tftp.c | 13 ++++++------- lib/transfer.c | 6 ++---- lib/transfer.h | 4 ++-- lib/url.c | 5 ++--- 12 files changed, 78 insertions(+), 111 deletions(-) diff --git a/lib/dict.c b/lib/dict.c index 1deab76ec..d86923a9f 100644 --- a/lib/dict.c +++ b/lib/dict.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2009, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2010, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -217,13 +217,12 @@ static CURLcode dict_do(struct connectdata *conn, bool *done) free(eword); - if(result) + if(result) { failf(data, "Failed sending DICT request"); - else - result = Curl_setup_transfer(conn, FIRSTSOCKET, -1, FALSE, bytecount, - -1, NULL); /* no upload */ - if(result) return result; + } + Curl_setup_transfer(conn, FIRSTSOCKET, -1, FALSE, bytecount, + -1, NULL); /* no upload */ } else if(Curl_raw_nequal(path, DICT_DEFINE, sizeof(DICT_DEFINE)-1) || Curl_raw_nequal(path, DICT_DEFINE2, sizeof(DICT_DEFINE2)-1) || @@ -265,15 +264,12 @@ static CURLcode dict_do(struct connectdata *conn, bool *done) free(eword); - if(result) + if(result) { failf(data, "Failed sending DICT request"); - else - result = Curl_setup_transfer(conn, FIRSTSOCKET, -1, FALSE, bytecount, - -1, NULL); /* no upload */ - - if(result) return result; - + } + Curl_setup_transfer(conn, FIRSTSOCKET, -1, FALSE, bytecount, + -1, NULL); /* no upload */ } else { @@ -290,13 +286,12 @@ static CURLcode dict_do(struct connectdata *conn, bool *done) "CLIENT " LIBCURL_NAME " " LIBCURL_VERSION "\r\n" "%s\r\n" "QUIT\r\n", ppath); - if(result) + if(result) { failf(data, "Failed sending DICT request"); - else - result = Curl_setup_transfer(conn, FIRSTSOCKET, -1, FALSE, bytecount, - -1, NULL); - if(result) return result; + } + + Curl_setup_transfer(conn, FIRSTSOCKET, -1, FALSE, bytecount, -1, NULL); } } diff --git a/lib/ftp.c b/lib/ftp.c index 9df4e23bc..11bd80fd6 100644 --- a/lib/ftp.c +++ b/lib/ftp.c @@ -1378,7 +1378,7 @@ static CURLcode ftp_state_ul_setup(struct connectdata *conn, infof(data, "File already completely uploaded\n"); /* no data to transfer */ - result=Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL); + Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL); /* Set ->transfer so that we won't get any error in * ftp_done() because we didn't transfer anything! */ @@ -1974,7 +1974,7 @@ static CURLcode ftp_state_post_retr_size(struct connectdata *conn, if(ftp->downloadsize == 0) { /* no data to transfer */ - result = Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL); + Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL); infof(data, "File already completely downloaded\n"); /* Set ->transfer so that we won't get any error in ftp_done() @@ -2116,8 +2116,8 @@ static CURLcode ftp_state_stor_resp(struct connectdata *conn, /* set the SO_SNDBUF for the secondary socket for those who need it */ Curl_sndbufset(conn->sock[SECONDARYSOCKET]); - result = Curl_setup_transfer(conn, -1, -1, FALSE, NULL, /* no download */ - SECONDARYSOCKET, ftp->bytecountp); + Curl_setup_transfer(conn, -1, -1, FALSE, NULL, /* no download */ + SECONDARYSOCKET, ftp->bytecountp); state(conn, FTP_STOP); conn->proto.ftpc.pp.pending_resp = TRUE; /* expect a server response */ @@ -2230,11 +2230,8 @@ static CURLcode ftp_state_get_resp(struct connectdata *conn, infof(data, "Getting file with size: %" FORMAT_OFF_T "\n", size); /* FTP download: */ - result=Curl_setup_transfer(conn, SECONDARYSOCKET, size, FALSE, - ftp->bytecountp, - -1, NULL); /* no upload here */ - if(result) - return result; + Curl_setup_transfer(conn, SECONDARYSOCKET, size, FALSE, + ftp->bytecountp, -1, NULL); /* no upload here */ conn->proto.ftpc.pp.pending_resp = TRUE; /* expect server response */ state(conn, FTP_STOP); @@ -3391,7 +3388,7 @@ static CURLcode ftp_nextconnect(struct connectdata *conn) if((result == CURLE_OK) && (ftp->transfer != FTPTRANSFER_BODY)) /* no data to transfer. FIX: it feels like a kludge to have this here too! */ - result = Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL); + Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL); /* end of transfer */ DEBUGF(infof(data, "DO-MORE phase ends with %d\n", (int)result)); @@ -3818,7 +3815,7 @@ static CURLcode ftp_dophase_done(struct connectdata *conn, if(ftp->transfer != FTPTRANSFER_BODY) /* no data to transfer */ - result=Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL); + Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL); else if(!connected) /* since we didn't connect now, we want do_more to get called */ conn->bits.do_more = TRUE; diff --git a/lib/http.c b/lib/http.c index 99d34e661..cfc09cd5e 100644 --- a/lib/http.c +++ b/lib/http.c @@ -2653,14 +2653,13 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) return result; result = Curl_add_buffer_send(req_buffer, conn, - &data->info.request_size, 0, FIRSTSOCKET); + &data->info.request_size, 0, FIRSTSOCKET); if(result) failf(data, "Failed sending POST request"); else /* setup variables for the upcoming transfer */ - result = Curl_setup_transfer(conn, FIRSTSOCKET, -1, TRUE, - &http->readbytecount, - -1, NULL); + Curl_setup_transfer(conn, FIRSTSOCKET, -1, TRUE, &http->readbytecount, + -1, NULL); break; } @@ -2728,10 +2727,9 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) failf(data, "Failed sending POST request"); else /* setup variables for the upcoming transfer */ - result = Curl_setup_transfer(conn, FIRSTSOCKET, -1, TRUE, - &http->readbytecount, - FIRSTSOCKET, - &http->writebytecount); + Curl_setup_transfer(conn, FIRSTSOCKET, -1, TRUE, + &http->readbytecount, FIRSTSOCKET, + &http->writebytecount); if(result) { Curl_formclean(&http->sendit); /* free that whole lot */ @@ -2781,10 +2779,9 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) failf(data, "Failed sending PUT request"); else /* prepare for transfer */ - result = Curl_setup_transfer(conn, FIRSTSOCKET, -1, TRUE, - &http->readbytecount, - postsize?FIRSTSOCKET:-1, - postsize?&http->writebytecount:NULL); + Curl_setup_transfer(conn, FIRSTSOCKET, -1, TRUE, + &http->readbytecount, postsize?FIRSTSOCKET:-1, + postsize?&http->writebytecount:NULL); if(result) return result; break; @@ -2931,11 +2928,9 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) if(result) failf(data, "Failed sending HTTP POST request"); else - result = - Curl_setup_transfer(conn, FIRSTSOCKET, -1, TRUE, - &http->readbytecount, - http->postdata?FIRSTSOCKET:-1, - http->postdata?&http->writebytecount:NULL); + Curl_setup_transfer(conn, FIRSTSOCKET, -1, TRUE, + &http->readbytecount, http->postdata?FIRSTSOCKET:-1, + http->postdata?&http->writebytecount:NULL); break; default: @@ -2951,10 +2946,9 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) failf(data, "Failed sending HTTP request"); else /* HTTP GET/HEAD download: */ - result = Curl_setup_transfer(conn, FIRSTSOCKET, -1, TRUE, - &http->readbytecount, - http->postdata?FIRSTSOCKET:-1, - http->postdata?&http->writebytecount:NULL); + Curl_setup_transfer(conn, FIRSTSOCKET, -1, TRUE, &http->readbytecount, + http->postdata?FIRSTSOCKET:-1, + http->postdata?&http->writebytecount:NULL); } if(result) return result; diff --git a/lib/imap.c b/lib/imap.c index f7b895dde..cdadd1713 100644 --- a/lib/imap.c +++ b/lib/imap.c @@ -436,12 +436,11 @@ static CURLcode imap_state_fetch_resp(struct connectdata *conn, if(!filesize) /* the entire data is already transfered! */ - result=Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL); + Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL); else /* IMAP download */ - result=Curl_setup_transfer(conn, FIRSTSOCKET, filesize, FALSE, - imap->bytecountp, - -1, NULL); /* no upload here */ + Curl_setup_transfer(conn, FIRSTSOCKET, filesize, FALSE, + imap->bytecountp, -1, NULL); /* no upload here */ data->req.maxdownload = filesize; } @@ -924,15 +923,14 @@ static CURLcode imap_parse_url_path(struct connectdata *conn) static CURLcode imap_dophase_done(struct connectdata *conn, bool connected) { - CURLcode result = CURLE_OK; struct FTP *imap = conn->data->state.proto.imap; (void)connected; if(imap->transfer != FTPTRANSFER_BODY) /* no data to transfer */ - result=Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL); + Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL); - return result; + return CURLE_OK; } /* called from multi.c while DOing */ diff --git a/lib/pop3.c b/lib/pop3.c index 34c6fdfb1..4d79eebb2 100644 --- a/lib/pop3.c +++ b/lib/pop3.c @@ -359,9 +359,8 @@ static CURLcode pop3_state_retr_resp(struct connectdata *conn, } /* POP3 download */ - result=Curl_setup_transfer(conn, FIRSTSOCKET, -1, FALSE, - pop3->bytecountp, - -1, NULL); /* no upload here */ + Curl_setup_transfer(conn, FIRSTSOCKET, -1, FALSE, + pop3->bytecountp, -1, NULL); /* no upload here */ if(pp->cache) { /* At this point there is a bunch of data in the header "cache" that is @@ -403,9 +402,8 @@ static CURLcode pop3_state_list_resp(struct connectdata *conn, } /* POP3 download */ - result=Curl_setup_transfer(conn, FIRSTSOCKET, -1, FALSE, - pop3->bytecountp, - -1, NULL); /* no upload here */ + Curl_setup_transfer(conn, FIRSTSOCKET, -1, FALSE, pop3->bytecountp, + -1, NULL); /* no upload here */ if(pp->cache) { /* cache holds the email ID listing */ @@ -863,18 +861,17 @@ static CURLcode pop3_parse_url_path(struct connectdata *conn) static CURLcode pop3_dophase_done(struct connectdata *conn, bool connected) { - CURLcode result = CURLE_OK; struct FTP *pop3 = conn->data->state.proto.pop3; struct pop3_conn *pop3c = &conn->proto.pop3c; - (void)connected; + (void)connected; if(pop3->transfer != FTPTRANSFER_BODY) /* no data to transfer */ - result=Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL); + Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL); free(pop3c->mailbox); - return result; + return CURLE_OK; } /* called from multi.c while DOing */ diff --git a/lib/rtsp.c b/lib/rtsp.c index 8cc200bda..032f58f7e 100644 --- a/lib/rtsp.c +++ b/lib/rtsp.c @@ -254,8 +254,8 @@ CURLcode Curl_rtsp(struct connectdata *conn, bool *done) } if(rtspreq == RTSPREQ_RECEIVE) { - result = Curl_setup_transfer(conn, FIRSTSOCKET, -1, TRUE, - &http->readbytecount, -1, NULL); + Curl_setup_transfer(conn, FIRSTSOCKET, -1, TRUE, + &http->readbytecount, -1, NULL); return result; } @@ -503,15 +503,9 @@ CURLcode Curl_rtsp(struct connectdata *conn, bool *done) return result; } - result = Curl_setup_transfer(conn, FIRSTSOCKET, -1, TRUE, - &http->readbytecount, - putsize?FIRSTSOCKET:-1, - putsize?&http->writebytecount:NULL); - - if(result) { - failf(data, "Failed RTSP transfer"); - return result; - } + Curl_setup_transfer(conn, FIRSTSOCKET, -1, TRUE, &http->readbytecount, + putsize?FIRSTSOCKET:-1, + putsize?&http->writebytecount:NULL); /* Increment the CSeq on success */ data->state.rtsp_next_client_CSeq++; diff --git a/lib/smtp.c b/lib/smtp.c index 654f43505..b4fa58f95 100644 --- a/lib/smtp.c +++ b/lib/smtp.c @@ -465,7 +465,6 @@ static CURLcode smtp_state_data_resp(struct connectdata *conn, int smtpcode, smtpstate instate) { - CURLcode result = CURLE_OK; struct SessionHandle *data = conn->data; struct FTP *smtp = data->state.proto.smtp; @@ -477,11 +476,11 @@ static CURLcode smtp_state_data_resp(struct connectdata *conn, } /* SMTP upload */ - result = Curl_setup_transfer(conn, -1, -1, FALSE, NULL, /* no download */ - FIRSTSOCKET, smtp->bytecountp); + Curl_setup_transfer(conn, -1, -1, FALSE, NULL, /* no download */ + FIRSTSOCKET, smtp->bytecountp); state(conn, SMTP_STOP); - return result; + return CURLE_OK; } /* for the POSTDATA response, which is received after the entire DATA @@ -934,18 +933,17 @@ static CURLcode smtp_disconnect(struct connectdata *conn) static CURLcode smtp_dophase_done(struct connectdata *conn, bool connected) { - CURLcode result = CURLE_OK; struct FTP *smtp = conn->data->state.proto.smtp; struct smtp_conn *smtpc= &conn->proto.smtpc; (void)connected; if(smtp->transfer != FTPTRANSFER_BODY) /* no data to transfer */ - result=Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL); + Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL); free(smtpc->domain); - return result; + return CURLE_OK; } /* called from multi.c while DOing */ diff --git a/lib/ssh.c b/lib/ssh.c index b3da65562..e4e5767c7 100644 --- a/lib/ssh.c +++ b/lib/ssh.c @@ -1556,8 +1556,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block) Curl_pgrsSetUploadSize(data, data->set.infilesize); } /* upload data */ - result = Curl_setup_transfer(conn, -1, -1, FALSE, NULL, - FIRSTSOCKET, NULL); + Curl_setup_transfer(conn, -1, -1, FALSE, NULL, FIRSTSOCKET, NULL); /* not set by Curl_setup_transfer to preserve keepon bits */ conn->sockfd = conn->writesockfd; @@ -1850,7 +1849,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block) sshc->readdir_longentry = NULL; /* no data to transfer */ - result = Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL); + Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL); state(conn, SSH_STOP); break; @@ -1975,14 +1974,14 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block) /* Setup the actual download */ if(data->req.size == 0) { /* no data to transfer */ - result = Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL); + Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL); infof(data, "File already completely downloaded\n"); state(conn, SSH_STOP); break; } else { - result = Curl_setup_transfer(conn, FIRSTSOCKET, data->req.size, - FALSE, NULL, -1, NULL); + Curl_setup_transfer(conn, FIRSTSOCKET, data->req.size, + FALSE, NULL, -1, NULL); /* not set by Curl_setup_transfer to preserve keepon bits */ conn->writesockfd = conn->sockfd; @@ -2107,8 +2106,8 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block) } /* upload data */ - result = Curl_setup_transfer(conn, -1, data->req.size, FALSE, NULL, - FIRSTSOCKET, NULL); + Curl_setup_transfer(conn, -1, data->req.size, FALSE, NULL, + FIRSTSOCKET, NULL); /* not set by Curl_setup_transfer to preserve keepon bits */ conn->sockfd = conn->writesockfd; @@ -2159,8 +2158,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block) /* download data */ bytecount = (curl_off_t)sb.st_size; data->req.maxdownload = (curl_off_t)sb.st_size; - result = Curl_setup_transfer(conn, FIRSTSOCKET, - bytecount, FALSE, NULL, -1, NULL); + Curl_setup_transfer(conn, FIRSTSOCKET, bytecount, FALSE, NULL, -1, NULL); /* not set by Curl_setup_transfer to preserve keepon bits */ conn->writesockfd = conn->sockfd; diff --git a/lib/tftp.c b/lib/tftp.c index 564de4916..3c288b66e 100644 --- a/lib/tftp.c +++ b/lib/tftp.c @@ -797,10 +797,9 @@ static CURLcode tftp_tx(tftp_state_data_t *state, tftp_event_t event) state->state = TFTP_STATE_FIN; setpacketevent(&state->spacket, TFTP_EVENT_ERROR); setpacketblock(&state->spacket, state->block); - sbytes = sendto(state->sockfd, (void *)state->spacket.data, - 4, SEND_4TH_ARG, - (struct sockaddr *)&state->remote_addr, - state->remote_addrlen); + (void)sendto(state->sockfd, (void *)state->spacket.data, 4, SEND_4TH_ARG, + (struct sockaddr *)&state->remote_addr, + state->remote_addrlen); /* don't bother with the return code, but if the socket is still up we * should be a good TFTP client and let the server know we're done */ state->state = TFTP_STATE_FIN; @@ -1295,7 +1294,7 @@ static CURLcode tftp_easy_statemach(struct connectdata *conn) } /* Tell curl we're done */ - result = Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL); + Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL); return(result); } @@ -1329,7 +1328,7 @@ static CURLcode tftp_multi_statemach(struct connectdata *conn, bool *done) *done = (bool)(state->state == TFTP_STATE_FIN); if(*done) /* Tell curl we're done */ - result = Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL); + Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL); } else { /* no timeouts to handle, check our socket */ @@ -1351,7 +1350,7 @@ static CURLcode tftp_multi_statemach(struct connectdata *conn, bool *done) *done = (bool)(state->state == TFTP_STATE_FIN); if(*done) /* Tell curl we're done */ - result = Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL); + Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL); } /* if rc == 0, then select() timed out */ } diff --git a/lib/transfer.c b/lib/transfer.c index 8985892df..92a59d038 100644 --- a/lib/transfer.c +++ b/lib/transfer.c @@ -2169,7 +2169,7 @@ CURLcode Curl_perform(struct SessionHandle *data) * Curl_setup_transfer() is called to setup some basic properties for the * upcoming transfer. */ -CURLcode +void Curl_setup_transfer( struct connectdata *conn, /* connection data */ int sockindex, /* socket index to read from or -1 */ @@ -2214,9 +2214,8 @@ Curl_setup_transfer( /* we want header and/or body, if neither then don't do this! */ if(k->getheader || !data->set.opt_no_body) { - if(conn->sockfd != CURL_SOCKET_BAD) { + if(conn->sockfd != CURL_SOCKET_BAD) k->keepon |= KEEP_RECV; - } if(conn->writesockfd != CURL_SOCKET_BAD) { /* HTTP 1.1 magic: @@ -2246,5 +2245,4 @@ Curl_setup_transfer( } /* if(conn->writesockfd != CURL_SOCKET_BAD) */ } /* if(k->getheader || !data->set.opt_no_body) */ - return CURLE_OK; } diff --git a/lib/transfer.h b/lib/transfer.h index 4c2bc9e02..790e1e3ef 100644 --- a/lib/transfer.h +++ b/lib/transfer.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2009, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2010, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -49,7 +49,7 @@ CURLcode Curl_reconnect_request(struct connectdata **connp); CURLcode Curl_retry_request(struct connectdata *conn, char **url); /* This sets up a forthcoming transfer */ -CURLcode +void Curl_setup_transfer (struct connectdata *data, int sockindex, /* socket index to read from or -1 */ curl_off_t size, /* -1 if unknown at this point */ diff --git a/lib/url.c b/lib/url.c index 6dc267204..a84e69d35 100644 --- a/lib/url.c +++ b/lib/url.c @@ -4779,9 +4779,8 @@ static CURLcode create_conn(struct SessionHandle *data, return result; } - result = Curl_setup_transfer(conn, -1, -1, FALSE, - NULL, /* no download */ - -1, NULL); /* no upload */ + Curl_setup_transfer(conn, -1, -1, FALSE, NULL, /* no download */ + -1, NULL); /* no upload */ } return result; -- cgit v1.2.3 From d6be52d80e10ddb04e55177a9d4afbd27aafb634 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 16 Apr 2010 23:43:54 +0200 Subject: FTP PORT: Value stored to 'rc' is never read --- lib/ftp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ftp.c b/lib/ftp.c index 11bd80fd6..95e2a1200 100644 --- a/lib/ftp.c +++ b/lib/ftp.c @@ -820,7 +820,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn, /* resolv ip/host to ip */ rc = Curl_resolv(conn, host, 0, &h); if(rc == CURLRESOLV_PENDING) - rc = Curl_wait_for_resolv(conn, &h); + (void)Curl_wait_for_resolv(conn, &h); if(h) { res = h->addr; /* when we return from this function, we can forget about this entry -- cgit v1.2.3 From d841ab82b8cf3b0db5e46c2f8cf943b845ab077f Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 16 Apr 2010 23:49:03 +0200 Subject: curl_version: remove superfluous assignments --- lib/version.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/version.c b/lib/version.c index aa86e3902..86cb113d7 100644 --- a/lib/version.c +++ b/lib/version.c @@ -107,9 +107,15 @@ char *curl_version(void) ptr += len; #endif #ifdef USE_LIBSSH2 + (void)snprintf(ptr, left, " libssh2/%s", CURL_LIBSSH2_VERSION); +/* + If another lib version is added below libssh2, this code would instead + have to do: + len = snprintf(ptr, left, " libssh2/%s", CURL_LIBSSH2_VERSION); left -= len; ptr += len; +*/ #endif return version; -- cgit v1.2.3 From dfad8a6dad9f42516a3228d10c44806606fd1c79 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 16 Apr 2010 23:50:39 +0200 Subject: dprintf_formatf: Value stored to 'left' is never read --- lib/mprintf.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/mprintf.c b/lib/mprintf.c index 1d93c5828..536c0c247 100644 --- a/lib/mprintf.c +++ b/lib/mprintf.c @@ -963,7 +963,6 @@ static int dprintf_formatf( /* RECURSIVE USAGE */ len = curl_msnprintf(fptr, left, ".%ld", prec); fptr += len; - left -= len; } if(p->flags & FLAGS_LONG) *fptr++ = 'l'; -- cgit v1.2.3 From 99ec359b4d07bb3468aa617a2f13ad302ded0da3 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sat, 17 Apr 2010 18:55:52 +0200 Subject: check_gzip_header: Value stored to 'data' is never read --- lib/content_encoding.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/content_encoding.c b/lib/content_encoding.c index 69aa7bcc6..a7511af7e 100644 --- a/lib/content_encoding.c +++ b/lib/content_encoding.c @@ -255,7 +255,6 @@ static enum { return GZIP_UNDERFLOW; len -= 2; - data += 2; } *headerlen = totallen - len; -- cgit v1.2.3 From b7848e4a7272e5319cf5794ec59ecaa955642e1c Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sat, 17 Apr 2010 18:57:39 +0200 Subject: parsedate: Value stored to 'found' is never read --- lib/parsedate.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/parsedate.c b/lib/parsedate.c index 8e26f1c7e..26f7d84ce 100644 --- a/lib/parsedate.c +++ b/lib/parsedate.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2009, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2010, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -370,7 +370,6 @@ int Curl_parsedate(const char *date, time_t *output) (3 == sscanf(date, "%02d:%02d:%02d", &hournum, &minnum, &secnum))) { /* time stamp! */ date += 8; - found = TRUE; } else { val = (int)strtol(date, &end, 10); -- cgit v1.2.3 From 5d93525f30e8b2a422644b4ec09a82ebf04283cd Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sat, 17 Apr 2010 18:59:54 +0200 Subject: parseconfig: Value stored to 'line' is never read Make the function call with (void) as we don't care about the return code. --- src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index 6e3ef3d6a..0670b5f5c 100644 --- a/src/main.c +++ b/src/main.c @@ -3247,7 +3247,7 @@ static int parseconfig(const char *filename, break; } alloced_param=TRUE; - line = (char*) unslashquote(line, param); + (void)unslashquote(line, param); } else { param=line; /* parameter starts here */ -- cgit v1.2.3