1
0
mirror of https://github.com/moparisthebest/curl synced 2024-08-13 17:03:50 -04:00

cleanup: make local functions static

urlapi: turn three local-only functions into statics

conncache: make conncache_find_first_connection static

multi: make detach_connnection static

connect: make getaddressinfo static

curl_ntlm_core: make hmac_md5 static

http2: make two functions static

http: make http_setup_conn static

connect: make tcpnodelay static

tests: make UNITTEST a thing to mark functions with, so they can be static for
normal builds and non-static for unit test builds

... and mark Curl_shuffle_addr accordingly.

url: make up_free static

setopt: make vsetopt static

curl_endian: make write32_le static

rtsp: make rtsp_connisdead static

warnless: remove unused functions

memdebug: remove one unused function, made another static
This commit is contained in:
Daniel Stenberg 2019-02-08 09:33:42 +01:00
parent 9a36c0ae21
commit 05b100aee2
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
22 changed files with 103 additions and 160 deletions

View File

@ -392,8 +392,8 @@ bool Curl_conncache_foreach(struct Curl_easy *data,
NOTE: no locking is done here as this is presumably only done when cleaning NOTE: no locking is done here as this is presumably only done when cleaning
up a cache! up a cache!
*/ */
struct connectdata * static struct connectdata *
Curl_conncache_find_first_connection(struct conncache *connc) conncache_find_first_connection(struct conncache *connc)
{ {
struct curl_hash_iterator iter; struct curl_hash_iterator iter;
struct curl_hash_element *he; struct curl_hash_element *he;
@ -566,7 +566,7 @@ void Curl_conncache_close_all_connections(struct conncache *connc)
{ {
struct connectdata *conn; struct connectdata *conn;
conn = Curl_conncache_find_first_connection(connc); conn = conncache_find_first_connection(connc);
while(conn) { while(conn) {
SIGPIPE_VARIABLE(pipe_st); SIGPIPE_VARIABLE(pipe_st);
conn->data = connc->closure_handle; conn->data = connc->closure_handle;
@ -577,7 +577,7 @@ void Curl_conncache_close_all_connections(struct conncache *connc)
(void)Curl_disconnect(connc->closure_handle, conn, FALSE); (void)Curl_disconnect(connc->closure_handle, conn, FALSE);
sigpipe_restore(&pipe_st); sigpipe_restore(&pipe_st);
conn = Curl_conncache_find_first_connection(connc); conn = conncache_find_first_connection(connc);
} }
if(connc->closure_handle) { if(connc->closure_handle) {

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -617,10 +617,13 @@ void Curl_persistconninfo(struct connectdata *conn)
conn->data->info.conn_local_port = conn->local_port; conn->data->info.conn_local_port = conn->local_port;
} }
UNITTEST bool getaddressinfo(struct sockaddr *sa, char *addr,
long *port);
/* retrieves ip address and port from a sockaddr structure. /* retrieves ip address and port from a sockaddr structure.
note it calls Curl_inet_ntop which sets errno on fail, not SOCKERRNO. */ note it calls Curl_inet_ntop which sets errno on fail, not SOCKERRNO. */
bool Curl_getaddressinfo(struct sockaddr *sa, char *addr, UNITTEST bool getaddressinfo(struct sockaddr *sa, char *addr,
long *port) long *port)
{ {
unsigned short us_port; unsigned short us_port;
struct sockaddr_in *si = NULL; struct sockaddr_in *si = NULL;
@ -700,16 +703,16 @@ void Curl_updateconninfo(struct connectdata *conn, curl_socket_t sockfd)
return; return;
} }
if(!Curl_getaddressinfo((struct sockaddr*)&ssrem, if(!getaddressinfo((struct sockaddr*)&ssrem,
conn->primary_ip, &conn->primary_port)) { conn->primary_ip, &conn->primary_port)) {
failf(data, "ssrem inet_ntop() failed with errno %d: %s", failf(data, "ssrem inet_ntop() failed with errno %d: %s",
errno, Curl_strerror(conn, errno)); errno, Curl_strerror(conn, errno));
return; return;
} }
memcpy(conn->ip_addr_str, conn->primary_ip, MAX_IPADR_LEN); memcpy(conn->ip_addr_str, conn->primary_ip, MAX_IPADR_LEN);
if(!Curl_getaddressinfo((struct sockaddr*)&ssloc, if(!getaddressinfo((struct sockaddr*)&ssloc,
conn->local_ip, &conn->local_port)) { conn->local_ip, &conn->local_port)) {
failf(data, "ssloc inet_ntop() failed with errno %d: %s", failf(data, "ssloc inet_ntop() failed with errno %d: %s",
errno, Curl_strerror(conn, errno)); errno, Curl_strerror(conn, errno));
return; return;
@ -881,7 +884,7 @@ CURLcode Curl_is_connected(struct connectdata *conn,
return result; return result;
} }
void Curl_tcpnodelay(struct connectdata *conn, curl_socket_t sockfd) static void tcpnodelay(struct connectdata *conn, curl_socket_t sockfd)
{ {
#if defined(TCP_NODELAY) #if defined(TCP_NODELAY)
#if !defined(CURL_DISABLE_VERBOSE_STRINGS) #if !defined(CURL_DISABLE_VERBOSE_STRINGS)
@ -1006,8 +1009,8 @@ static CURLcode singleipconnect(struct connectdata *conn,
return CURLE_OK; return CURLE_OK;
/* store remote address and port used in this connection attempt */ /* store remote address and port used in this connection attempt */
if(!Curl_getaddressinfo((struct sockaddr*)&addr.sa_addr, if(!getaddressinfo((struct sockaddr*)&addr.sa_addr,
ipaddress, &port)) { ipaddress, &port)) {
/* malformed address or bug in inet_ntop, try next address */ /* malformed address or bug in inet_ntop, try next address */
failf(data, "sa_addr inet_ntop() failed with errno %d: %s", failf(data, "sa_addr inet_ntop() failed with errno %d: %s",
errno, Curl_strerror(conn, errno)); errno, Curl_strerror(conn, errno));
@ -1023,7 +1026,7 @@ static CURLcode singleipconnect(struct connectdata *conn,
is_tcp = (addr.family == AF_INET) && addr.socktype == SOCK_STREAM; is_tcp = (addr.family == AF_INET) && addr.socktype == SOCK_STREAM;
#endif #endif
if(is_tcp && data->set.tcp_nodelay) if(is_tcp && data->set.tcp_nodelay)
Curl_tcpnodelay(conn, sockfd); tcpnodelay(conn, sockfd);
nosigpipe(conn, sockfd); nosigpipe(conn, sockfd);

View File

@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -75,11 +75,6 @@ void Curl_updateconninfo(struct connectdata *conn, curl_socket_t sockfd);
void Curl_persistconninfo(struct connectdata *conn); void Curl_persistconninfo(struct connectdata *conn);
int Curl_closesocket(struct connectdata *conn, curl_socket_t sock); int Curl_closesocket(struct connectdata *conn, curl_socket_t sock);
/*
* Get presentation format IP address and port from a sockaddr.
*/
bool Curl_getaddressinfo(struct sockaddr *sa, char *addr, long *port);
/* /*
* The Curl_sockaddr_ex structure is basically libcurl's external API * The Curl_sockaddr_ex structure is basically libcurl's external API
* curl_sockaddr structure with enough space available to directly hold any * curl_sockaddr structure with enough space available to directly hold any
@ -111,8 +106,6 @@ CURLcode Curl_socket(struct connectdata *conn,
struct Curl_sockaddr_ex *addr, struct Curl_sockaddr_ex *addr,
curl_socket_t *sockfd); curl_socket_t *sockfd);
void Curl_tcpnodelay(struct connectdata *conn, curl_socket_t sockfd);
/* /*
* Curl_conncontrol() marks the end of a connection/stream. The 'closeit' * Curl_conncontrol() marks the end of a connection/stream. The 'closeit'
* argument specifies if it is the end of a connection or a stream. * argument specifies if it is the end of a connection or a stream.

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -82,7 +82,7 @@ unsigned short Curl_read16_be(const unsigned char *buf)
} }
/* /*
* Curl_write32_le() * write32_le()
* *
* This function converts a 32-bit integer from the native endian format, * This function converts a 32-bit integer from the native endian format,
* to little endian format ready for sending down the wire. * to little endian format ready for sending down the wire.
@ -92,7 +92,7 @@ unsigned short Curl_read16_be(const unsigned char *buf)
* value [in] - The 32-bit integer value. * value [in] - The 32-bit integer value.
* buffer [in] - A pointer to the output buffer. * buffer [in] - A pointer to the output buffer.
*/ */
void Curl_write32_le(const int value, unsigned char *buffer) static void write32_le(const int value, unsigned char *buffer)
{ {
buffer[0] = (char)(value & 0x000000FF); buffer[0] = (char)(value & 0x000000FF);
buffer[1] = (char)((value & 0x0000FF00) >> 8); buffer[1] = (char)((value & 0x0000FF00) >> 8);
@ -118,7 +118,7 @@ void Curl_write64_le(const long long value, unsigned char *buffer)
void Curl_write64_le(const __int64 value, unsigned char *buffer) void Curl_write64_le(const __int64 value, unsigned char *buffer)
#endif #endif
{ {
Curl_write32_le((int)value, buffer); write32_le((int)value, buffer);
Curl_write32_le((int)(value >> 32), buffer + 4); write32_le((int)(value >> 32), buffer + 4);
} }
#endif /* CURL_SIZEOF_CURL_OFF_T > 4 */ #endif /* CURL_SIZEOF_CURL_OFF_T > 4 */

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -621,9 +621,9 @@ CURLcode Curl_ntlm_core_mk_nt_hash(struct Curl_easy *data,
#if defined(USE_NTLM_V2) && !defined(USE_WINDOWS_SSPI) #if defined(USE_NTLM_V2) && !defined(USE_WINDOWS_SSPI)
/* This returns the HMAC MD5 digest */ /* This returns the HMAC MD5 digest */
CURLcode Curl_hmac_md5(const unsigned char *key, unsigned int keylen, static CURLcode hmac_md5(const unsigned char *key, unsigned int keylen,
const unsigned char *data, unsigned int datalen, const unsigned char *data, unsigned int datalen,
unsigned char *output) unsigned char *output)
{ {
HMAC_context *ctxt = Curl_HMAC_init(Curl_HMAC_MD5, key, keylen); HMAC_context *ctxt = Curl_HMAC_init(Curl_HMAC_MD5, key, keylen);
@ -668,9 +668,8 @@ CURLcode Curl_ntlm_core_mk_ntlmv2_hash(const char *user, size_t userlen,
ascii_uppercase_to_unicode_le(identity, user, userlen); ascii_uppercase_to_unicode_le(identity, user, userlen);
ascii_to_unicode_le(identity + (userlen << 1), domain, domlen); ascii_to_unicode_le(identity + (userlen << 1), domain, domlen);
result = Curl_hmac_md5(ntlmhash, 16, identity, curlx_uztoui(identity_len), result = hmac_md5(ntlmhash, 16, identity, curlx_uztoui(identity_len),
ntlmv2hash); ntlmv2hash);
free(identity); free(identity);
return result; return result;
@ -756,8 +755,8 @@ CURLcode Curl_ntlm_core_mk_ntlmv2_resp(unsigned char *ntlmv2hash,
/* Concatenate the Type 2 challenge with the BLOB and do HMAC MD5 */ /* Concatenate the Type 2 challenge with the BLOB and do HMAC MD5 */
memcpy(ptr + 8, &ntlm->nonce[0], 8); memcpy(ptr + 8, &ntlm->nonce[0], 8);
result = Curl_hmac_md5(ntlmv2hash, NTLM_HMAC_MD5_LEN, ptr + 8, result = hmac_md5(ntlmv2hash, NTLM_HMAC_MD5_LEN, ptr + 8,
NTLMv2_BLOB_LEN + 8, hmac_output); NTLMv2_BLOB_LEN + 8, hmac_output);
if(result) { if(result) {
free(ptr); free(ptr);
return result; return result;
@ -799,7 +798,7 @@ CURLcode Curl_ntlm_core_mk_lmv2_resp(unsigned char *ntlmv2hash,
memcpy(&data[0], challenge_server, 8); memcpy(&data[0], challenge_server, 8);
memcpy(&data[8], challenge_client, 8); memcpy(&data[8], challenge_client, 8);
result = Curl_hmac_md5(ntlmv2hash, 16, &data[0], 16, hmac_output); result = hmac_md5(ntlmv2hash, 16, &data[0], 16, hmac_output);
if(result) if(result)
return result; return result;

View File

@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -816,4 +816,10 @@ int getpwuid_r(uid_t uid, struct passwd *pwd, char *buf,
size_t buflen, struct passwd **result); size_t buflen, struct passwd **result);
#endif #endif
#ifdef DEBUGBUILD
#define UNITTEST
#else
#define UNITTEST static
#endif
#endif /* HEADER_CURL_SETUP_H */ #endif /* HEADER_CURL_SETUP_H */

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -388,6 +388,9 @@ Curl_fetch_addr(struct connectdata *conn,
return dns; return dns;
} }
UNITTEST CURLcode Curl_shuffle_addr(struct Curl_easy *data,
Curl_addrinfo **addr);
/* /*
* Curl_shuffle_addr() shuffles the order of addresses in a 'Curl_addrinfo' * Curl_shuffle_addr() shuffles the order of addresses in a 'Curl_addrinfo'
* struct by re-linking its linked list. * struct by re-linking its linked list.
@ -400,7 +403,8 @@ Curl_fetch_addr(struct connectdata *conn,
* *
* @unittest: 1608 * @unittest: 1608
*/ */
CURLcode Curl_shuffle_addr(struct Curl_easy *data, Curl_addrinfo **addr) UNITTEST CURLcode Curl_shuffle_addr(struct Curl_easy *data,
Curl_addrinfo **addr)
{ {
CURLcode result = CURLE_OK; CURLcode result = CURLE_OK;
const int num_addrs = Curl_num_addresses(*addr); const int num_addrs = Curl_num_addresses(*addr);

View File

@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -178,16 +178,6 @@ Curl_fetch_addr(struct connectdata *conn,
const char *hostname, const char *hostname,
int port); int port);
/*
* Curl_shuffle_addr() shuffles the order of addresses in a 'Curl_addrinfo'
* struct by re-linking its linked list.
*
* The addr argument should be the address of a pointer to the head node of a
* `Curl_addrinfo` list and it will be modified to point to the new head after
* shuffling.
*/
CURLcode Curl_shuffle_addr(struct Curl_easy *data, Curl_addrinfo **addr);
/* /*
* Curl_cache_addr() stores a 'Curl_addrinfo' struct in the DNS cache. * Curl_cache_addr() stores a 'Curl_addrinfo' struct in the DNS cache.
* *

View File

@ -102,13 +102,14 @@ static int https_getsock(struct connectdata *conn,
#else #else
#define https_connecting(x,y) CURLE_COULDNT_CONNECT #define https_connecting(x,y) CURLE_COULDNT_CONNECT
#endif #endif
static CURLcode http_setup_conn(struct connectdata *conn);
/* /*
* HTTP handler interface. * HTTP handler interface.
*/ */
const struct Curl_handler Curl_handler_http = { const struct Curl_handler Curl_handler_http = {
"HTTP", /* scheme */ "HTTP", /* scheme */
Curl_http_setup_conn, /* setup_connection */ http_setup_conn, /* setup_connection */
Curl_http, /* do_it */ Curl_http, /* do_it */
Curl_http_done, /* done */ Curl_http_done, /* done */
ZERO_NULL, /* do_more */ ZERO_NULL, /* do_more */
@ -133,7 +134,7 @@ const struct Curl_handler Curl_handler_http = {
*/ */
const struct Curl_handler Curl_handler_https = { const struct Curl_handler Curl_handler_https = {
"HTTPS", /* scheme */ "HTTPS", /* scheme */
Curl_http_setup_conn, /* setup_connection */ http_setup_conn, /* setup_connection */
Curl_http, /* do_it */ Curl_http, /* do_it */
Curl_http_done, /* done */ Curl_http_done, /* done */
ZERO_NULL, /* do_more */ ZERO_NULL, /* do_more */
@ -153,7 +154,7 @@ const struct Curl_handler Curl_handler_https = {
}; };
#endif #endif
CURLcode Curl_http_setup_conn(struct connectdata *conn) static CURLcode http_setup_conn(struct connectdata *conn)
{ {
/* allocate the HTTP-specific struct for the Curl_easy, only to survive /* allocate the HTTP-specific struct for the Curl_easy, only to survive
during this request */ during this request */

View File

@ -357,7 +357,7 @@ int Curl_http2_ver(char *p, size_t len)
https://tools.ietf.org/html/rfc7540#page-77 https://tools.ietf.org/html/rfc7540#page-77
nghttp2_error_code enums are identical. nghttp2_error_code enums are identical.
*/ */
const char *Curl_http2_strerror(uint32_t err) static const char *http2_strerror(uint32_t err)
{ {
#ifndef NGHTTP2_HAS_HTTP2_STRERROR #ifndef NGHTTP2_HAS_HTTP2_STRERROR
const char *str[] = { const char *str[] = {
@ -837,7 +837,7 @@ static int on_stream_close(nghttp2_session *session, int32_t stream_id,
return 0; return 0;
} }
H2BUGF(infof(data_s, "on_stream_close(), %s (err %d), stream %u\n", H2BUGF(infof(data_s, "on_stream_close(), %s (err %d), stream %u\n",
Curl_http2_strerror(error_code), error_code, stream_id)); http2_strerror(error_code), error_code, stream_id));
stream = data_s->req.protop; stream = data_s->req.protop;
if(!stream) if(!stream)
return NGHTTP2_ERR_CALLBACK_FAILURE; return NGHTTP2_ERR_CALLBACK_FAILURE;
@ -1197,7 +1197,7 @@ void Curl_http2_done(struct connectdata *conn, bool premature)
/* /*
* Initialize nghttp2 for a Curl connection * Initialize nghttp2 for a Curl connection
*/ */
CURLcode Curl_http2_init(struct connectdata *conn) static CURLcode http2_init(struct connectdata *conn)
{ {
if(!conn->proto.httpc.h2) { if(!conn->proto.httpc.h2) {
int rc; int rc;
@ -1431,7 +1431,7 @@ static ssize_t http2_handle_stream_close(struct connectdata *conn,
} }
else if(httpc->error_code != NGHTTP2_NO_ERROR) { else if(httpc->error_code != NGHTTP2_NO_ERROR) {
failf(data, "HTTP/2 stream %d was not closed cleanly: %s (err %u)", failf(data, "HTTP/2 stream %d was not closed cleanly: %s (err %u)",
stream->stream_id, Curl_http2_strerror(httpc->error_code), stream->stream_id, http2_strerror(httpc->error_code),
httpc->error_code); httpc->error_code);
*err = CURLE_HTTP2_STREAM; *err = CURLE_HTTP2_STREAM;
return -1; return -1;
@ -2141,7 +2141,7 @@ CURLcode Curl_http2_setup(struct connectdata *conn)
else else
conn->handler = &Curl_handler_http2; conn->handler = &Curl_handler_http2;
result = Curl_http2_init(conn); result = http2_init(conn);
if(result) { if(result) {
Curl_add_buffer_free(&stream->header_recvbuf); Curl_add_buffer_free(&stream->header_recvbuf);
return result; return result;

View File

@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -63,7 +63,6 @@ void Curl_http2_cleanup_dependencies(struct Curl_easy *data);
/* returns true if the HTTP/2 stream error was HTTP_1_1_REQUIRED */ /* returns true if the HTTP/2 stream error was HTTP_1_1_REQUIRED */
bool Curl_h2_http_1_1_error(struct connectdata *conn); bool Curl_h2_http_1_1_error(struct connectdata *conn);
#else /* USE_NGHTTP2 */ #else /* USE_NGHTTP2 */
#define Curl_http2_init(x) CURLE_UNSUPPORTED_PROTOCOL
#define Curl_http2_send_request(x) CURLE_UNSUPPORTED_PROTOCOL #define Curl_http2_send_request(x) CURLE_UNSUPPORTED_PROTOCOL
#define Curl_http2_request_upgrade(x,y) CURLE_UNSUPPORTED_PROTOCOL #define Curl_http2_request_upgrade(x,y) CURLE_UNSUPPORTED_PROTOCOL
#define Curl_http2_setup(x) CURLE_UNSUPPORTED_PROTOCOL #define Curl_http2_setup(x) CURLE_UNSUPPORTED_PROTOCOL

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -426,7 +426,7 @@ curl_socket_t curl_accept(curl_socket_t s, void *saddr, void *saddrlen,
} }
/* separate function to allow libcurl to mark a "faked" close */ /* separate function to allow libcurl to mark a "faked" close */
void curl_mark_sclose(curl_socket_t sockfd, int line, const char *source) static void mark_sclose(curl_socket_t sockfd, int line, const char *source)
{ {
const char *fmt = (sizeof(curl_socket_t) == sizeof(int)) ? const char *fmt = (sizeof(curl_socket_t) == sizeof(int)) ?
"FD %s:%d sclose(%d)\n": "FD %s:%d sclose(%d)\n":
@ -442,7 +442,7 @@ void curl_mark_sclose(curl_socket_t sockfd, int line, const char *source)
int curl_sclose(curl_socket_t sockfd, int line, const char *source) int curl_sclose(curl_socket_t sockfd, int line, const char *source)
{ {
int res = sclose(sockfd); int res = sclose(sockfd);
curl_mark_sclose(sockfd, line, source); mark_sclose(sockfd, line, source);
return res; return res;
} }
@ -458,20 +458,6 @@ FILE *curl_fopen(const char *file, const char *mode,
return res; return res;
} }
#ifdef HAVE_FDOPEN
FILE *curl_fdopen(int filedes, const char *mode,
int line, const char *source)
{
FILE *res = fdopen(filedes, mode);
if(source)
curl_memlog("FILE %s:%d fdopen(\"%d\",\"%s\") = %p\n",
source, line, filedes, mode, (void *)res);
return res;
}
#endif
int curl_fclose(FILE *file, int line, const char *source) int curl_fclose(FILE *file, int line, const char *source)
{ {
int res; int res;

View File

@ -80,6 +80,7 @@ static CURLMcode add_next_timeout(struct curltime now,
static CURLMcode multi_timeout(struct Curl_multi *multi, static CURLMcode multi_timeout(struct Curl_multi *multi,
long *timeout_ms); long *timeout_ms);
static void process_pending_handles(struct Curl_multi *multi); static void process_pending_handles(struct Curl_multi *multi);
static void detach_connnection(struct Curl_easy *data);
#ifdef DEBUGBUILD #ifdef DEBUGBUILD
static const char * const statename[]={ static const char * const statename[]={
@ -114,7 +115,7 @@ static void Curl_init_completed(struct Curl_easy *data)
/* Important: reset the conn pointer so that we don't point to memory /* Important: reset the conn pointer so that we don't point to memory
that could be freed anytime */ that could be freed anytime */
Curl_detach_connnection(data); detach_connnection(data);
Curl_expire_clear(data); /* stop all timers */ Curl_expire_clear(data); /* stop all timers */
} }
@ -572,7 +573,7 @@ static CURLcode multi_done(struct Curl_easy *data,
if(conn->send_pipe.size || conn->recv_pipe.size) { if(conn->send_pipe.size || conn->recv_pipe.size) {
/* Stop if pipeline is not empty . */ /* Stop if pipeline is not empty . */
Curl_detach_connnection(data); detach_connnection(data);
DEBUGF(infof(data, "Connection still in use %zu/%zu, " DEBUGF(infof(data, "Connection still in use %zu/%zu, "
"no more multi_done now!\n", "no more multi_done now!\n",
conn->send_pipe.size, conn->recv_pipe.size)); conn->send_pipe.size, conn->recv_pipe.size));
@ -645,7 +646,7 @@ static CURLcode multi_done(struct Curl_easy *data,
data->state.lastconnect = NULL; data->state.lastconnect = NULL;
} }
Curl_detach_connnection(data); detach_connnection(data);
Curl_free_request_state(data); Curl_free_request_state(data);
return result; return result;
} }
@ -752,7 +753,7 @@ CURLMcode curl_multi_remove_handle(struct Curl_multi *multi,
/* Remove the association between the connection and the handle */ /* Remove the association between the connection and the handle */
if(data->conn) { if(data->conn) {
data->conn->data = NULL; data->conn->data = NULL;
Curl_detach_connnection(data); detach_connnection(data);
} }
#ifdef USE_LIBPSL #ifdef USE_LIBPSL
@ -804,7 +805,7 @@ bool Curl_pipeline_wanted(const struct Curl_multi *multi, int bits)
/* This is the only function that should clear data->conn. This will /* This is the only function that should clear data->conn. This will
occasionally be called with the pointer already cleared. */ occasionally be called with the pointer already cleared. */
void Curl_detach_connnection(struct Curl_easy *data) static void detach_connnection(struct Curl_easy *data)
{ {
data->conn = NULL; data->conn = NULL;
} }
@ -1549,7 +1550,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
if(result) if(result)
/* if Curl_once_resolved() returns failure, the connection struct /* if Curl_once_resolved() returns failure, the connection struct
is already freed and gone */ is already freed and gone */
Curl_detach_connnection(data); /* no more connection */ detach_connnection(data); /* no more connection */
else { else {
/* call again please so that we get the next socket setup */ /* call again please so that we get the next socket setup */
rc = CURLM_CALL_MULTI_PERFORM; rc = CURLM_CALL_MULTI_PERFORM;
@ -2087,7 +2088,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
* removed before we perform the processing in CURLM_STATE_COMPLETED * removed before we perform the processing in CURLM_STATE_COMPLETED
*/ */
if(data->conn) if(data->conn)
Curl_detach_connnection(data); detach_connnection(data);
} }
if(data->state.wildcardmatch) { if(data->state.wildcardmatch) {
@ -2145,7 +2146,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
/* This is where we make sure that the conn pointer is reset. /* This is where we make sure that the conn pointer is reset.
We don't have to do this in every case block above where a We don't have to do this in every case block above where a
failure is detected */ failure is detected */
Curl_detach_connnection(data); detach_connnection(data);
} }
} }
else if(data->mstate == CURLM_STATE_CONNECT) { else if(data->mstate == CURLM_STATE_CONNECT) {

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -80,8 +80,6 @@ static CURLcode rtsp_rtp_readwrite(struct Curl_easy *data,
bool *readmore); bool *readmore);
static CURLcode rtsp_setup_connection(struct connectdata *conn); static CURLcode rtsp_setup_connection(struct connectdata *conn);
bool rtsp_connisdead(struct connectdata *check);
static unsigned int rtsp_conncheck(struct connectdata *check, static unsigned int rtsp_conncheck(struct connectdata *check,
unsigned int checks_to_perform); unsigned int checks_to_perform);
@ -147,7 +145,7 @@ static CURLcode rtsp_setup_connection(struct connectdata *conn)
* Instead, if it is readable, run Curl_connalive() to peek at the socket * Instead, if it is readable, run Curl_connalive() to peek at the socket
* and distinguish between closed and data. * and distinguish between closed and data.
*/ */
bool rtsp_connisdead(struct connectdata *check) static bool rtsp_connisdead(struct connectdata *check)
{ {
int sval; int sval;
bool ret_val = TRUE; bool ret_val = TRUE;

View File

@ -111,8 +111,8 @@ static CURLcode setstropt_userpwd(char *option, char **userp, char **passwdp)
#define C_SSLVERSION_VALUE(x) (x & 0xffff) #define C_SSLVERSION_VALUE(x) (x & 0xffff)
#define C_SSLVERSION_MAX_VALUE(x) (x & 0xffff0000) #define C_SSLVERSION_MAX_VALUE(x) (x & 0xffff0000)
CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, static CURLcode vsetopt(struct Curl_easy *data, CURLoption option,
va_list param) va_list param)
{ {
char *argptr; char *argptr;
CURLcode result = CURLE_OK; CURLcode result = CURLE_OK;
@ -2679,7 +2679,7 @@ CURLcode curl_easy_setopt(struct Curl_easy *data, CURLoption tag, ...)
va_start(arg, tag); va_start(arg, tag);
result = Curl_vsetopt(data, tag, arg); result = vsetopt(data, tag, arg);
va_end(arg); va_end(arg);
return result; return result;

View File

@ -292,7 +292,7 @@ void Curl_freeset(struct Curl_easy *data)
} }
/* free the URL pieces */ /* free the URL pieces */
void Curl_up_free(struct Curl_easy *data) static void up_free(struct Curl_easy *data)
{ {
struct urlpieces *up = &data->state.up; struct urlpieces *up = &data->state.up;
Curl_safefree(up->scheme); Curl_safefree(up->scheme);
@ -369,7 +369,7 @@ CURLcode Curl_close(struct Curl_easy *data)
} }
data->change.referer = NULL; data->change.referer = NULL;
Curl_up_free(data); up_free(data);
Curl_safefree(data->state.buffer); Curl_safefree(data->state.buffer);
Curl_safefree(data->state.headerbuff); Curl_safefree(data->state.headerbuff);
Curl_safefree(data->state.ulbuf); Curl_safefree(data->state.ulbuf);
@ -2019,7 +2019,7 @@ static CURLcode parseurlandfillconn(struct Curl_easy *data,
CURLUcode uc; CURLUcode uc;
char *hostname; char *hostname;
Curl_up_free(data); /* cleanup previous leftovers first */ up_free(data); /* cleanup previous leftovers first */
/* parse the URL */ /* parse the URL */
if(data->set.uh) { if(data->set.uh) {

View File

@ -67,12 +67,6 @@ struct Curl_URL {
#define DEFAULT_SCHEME "https" #define DEFAULT_SCHEME "https"
#ifdef DEBUGBUILD
#define UNITTEST
#else
#define UNITTEST static
#endif
static void free_urlhandle(struct Curl_URL *u) static void free_urlhandle(struct Curl_URL *u)
{ {
free(u->scheme); free(u->scheme);
@ -141,7 +135,7 @@ static bool urlchar_needs_escaping(int c)
* URL encoding should be skipped for host names, otherwise IDN resolution * URL encoding should be skipped for host names, otherwise IDN resolution
* will fail. * will fail.
*/ */
size_t Curl_strlen_url(const char *url, bool relative) static size_t strlen_url(const char *url, bool relative)
{ {
const unsigned char *ptr; const unsigned char *ptr;
size_t newlen = 0; size_t newlen = 0;
@ -183,7 +177,7 @@ size_t Curl_strlen_url(const char *url, bool relative)
* URL encoding should be skipped for host names, otherwise IDN resolution * URL encoding should be skipped for host names, otherwise IDN resolution
* will fail. * will fail.
*/ */
void Curl_strcpy_url(char *output, const char *url, bool relative) static void strcpy_url(char *output, const char *url, bool relative)
{ {
/* we must add this with whitespace-replacing */ /* we must add this with whitespace-replacing */
bool left = TRUE; bool left = TRUE;
@ -268,7 +262,7 @@ bool Curl_is_absolute_url(const char *url, char *buf, size_t buflen)
* The returned pointer must be freed by the caller unless NULL * The returned pointer must be freed by the caller unless NULL
* (returns NULL on out of memory). * (returns NULL on out of memory).
*/ */
char *Curl_concat_url(const char *base, const char *relurl) static char *concat_url(const char *base, const char *relurl)
{ {
/*** /***
TRY to append this new path to the old URL TRY to append this new path to the old URL
@ -392,7 +386,7 @@ char *Curl_concat_url(const char *base, const char *relurl)
letter we replace each space with %20 while it is replaced with '+' letter we replace each space with %20 while it is replaced with '+'
on the right side of the '?' letter. on the right side of the '?' letter.
*/ */
newlen = Curl_strlen_url(useurl, !host_changed); newlen = strlen_url(useurl, !host_changed);
urllen = strlen(url_clone); urllen = strlen(url_clone);
@ -414,7 +408,7 @@ char *Curl_concat_url(const char *base, const char *relurl)
newest[urllen++]='/'; newest[urllen++]='/';
/* then append the new piece on the right side */ /* then append the new piece on the right side */
Curl_strcpy_url(&newest[urllen], useurl, !host_changed); strcpy_url(&newest[urllen], useurl, !host_changed);
free(url_clone); free(url_clone);
@ -1252,7 +1246,7 @@ CURLUcode curl_url_set(CURLU *u, CURLUPart what,
} }
/* apply the relative part to create a new URL */ /* apply the relative part to create a new URL */
redired_url = Curl_concat_url(oldurl, part); redired_url = concat_url(oldurl, part);
free(oldurl); free(oldurl);
if(!redired_url) if(!redired_url)
return CURLUE_OUT_OF_MEMORY; return CURLUE_OUT_OF_MEMORY;

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -400,44 +400,6 @@ unsigned short curlx_uitous(unsigned int uinum)
#endif #endif
} }
/*
** unsigned int to unsigned char
*/
unsigned char curlx_uitouc(unsigned int uinum)
{
#ifdef __INTEL_COMPILER
# pragma warning(push)
# pragma warning(disable:810) /* conversion may lose significant bits */
#endif
DEBUGASSERT(uinum <= (unsigned int) CURL_MASK_UCHAR);
return (unsigned char) (uinum & (unsigned int) CURL_MASK_UCHAR);
#ifdef __INTEL_COMPILER
# pragma warning(pop)
#endif
}
/*
** unsigned int to signed int
*/
int curlx_uitosi(unsigned int uinum)
{
#ifdef __INTEL_COMPILER
# pragma warning(push)
# pragma warning(disable:810) /* conversion may lose significant bits */
#endif
DEBUGASSERT(uinum <= (unsigned int) CURL_MASK_SINT);
return (int) (uinum & (unsigned int) CURL_MASK_SINT);
#ifdef __INTEL_COMPILER
# pragma warning(pop)
#endif
}
/* /*
** signed int to unsigned size_t ** signed int to unsigned size_t
*/ */

View File

@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -57,10 +57,6 @@ int curlx_sztosi(ssize_t sznum);
unsigned short curlx_uitous(unsigned int uinum); unsigned short curlx_uitous(unsigned int uinum);
unsigned char curlx_uitouc(unsigned int uinum);
int curlx_uitosi(unsigned int uinum);
size_t curlx_sitouz(int sinum); size_t curlx_sitouz(int sinum);
#ifdef USE_WINSOCK #ifdef USE_WINSOCK

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -25,6 +25,10 @@
#include "connect.h" #include "connect.h"
#include "share.h" #include "share.h"
/* retrieves ip address and port from a sockaddr structure.
note it calls Curl_inet_ntop which sets errno on fail, not SOCKERRNO. */
bool getaddressinfo(struct sockaddr *sa, char *addr, long *port);
#include "memdebug.h" /* LAST include file */ #include "memdebug.h" /* LAST include file */
static struct Curl_easy *easy; static struct Curl_easy *easy;
@ -159,8 +163,8 @@ UNITTEST_START
if(tests[i].address[j] == &skip) if(tests[i].address[j] == &skip)
continue; continue;
if(addr && !Curl_getaddressinfo(addr->ai_addr, if(addr && !getaddressinfo(addr->ai_addr,
ipaddress, &port)) { ipaddress, &port)) {
fprintf(stderr, "%s:%d tests[%d] failed. getaddressinfo failed.\n", fprintf(stderr, "%s:%d tests[%d] failed. getaddressinfo failed.\n",
__FILE__, __LINE__, i); __FILE__, __LINE__, i);
problem = true; problem = true;

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -23,6 +23,9 @@
#include "hostip.h" #include "hostip.h"
CURLcode Curl_shuffle_addr(struct Curl_easy *data,
Curl_addrinfo **addr);
#define NUM_ADDRS 8 #define NUM_ADDRS 8
static struct Curl_addrinfo addrs[NUM_ADDRS]; static struct Curl_addrinfo addrs[NUM_ADDRS];

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -25,6 +25,10 @@
#include "connect.h" #include "connect.h"
#include "share.h" #include "share.h"
/* retrieves ip address and port from a sockaddr structure.
note it calls Curl_inet_ntop which sets errno on fail, not SOCKERRNO. */
bool getaddressinfo(struct sockaddr *sa, char *addr, long *port);
#include "memdebug.h" /* LAST include file */ #include "memdebug.h" /* LAST include file */
static struct Curl_easy *easy; static struct Curl_easy *easy;
@ -158,8 +162,8 @@ UNITTEST_START
if(!addr && !tests[i].address[j]) if(!addr && !tests[i].address[j])
break; break;
if(addr && !Curl_getaddressinfo(addr->ai_addr, if(addr && !getaddressinfo(addr->ai_addr,
ipaddress, &port)) { ipaddress, &port)) {
fprintf(stderr, "%s:%d tests[%d] failed. getaddressinfo failed.\n", fprintf(stderr, "%s:%d tests[%d] failed. getaddressinfo failed.\n",
__FILE__, __LINE__, i); __FILE__, __LINE__, i);
problem = true; problem = true;