Make more human readable and maintainable previous

compiler warning fix since it was Ok and actually
avoids the targeted compiler warning.
This commit is contained in:
Yang Tse
2006-10-29 14:58:59 +00:00
parent 1be60dde7f
commit ba481718a4
2 changed files with 23 additions and 9 deletions

View File

@@ -3,7 +3,7 @@
* Project ___| | | | _ \| | * Project ___| | | | _ \| |
* / __| | | | |_) | | * / __| | | | |_) | |
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
@@ -115,6 +115,13 @@
#undef HAVE_LIBDL #undef HAVE_LIBDL
#endif #endif
/*
* We use this ZERO_NULL to avoid picky compiler warnings,
* when assigning a NULL pointer to a function pointer var.
*/
#define ZERO_NULL 0
typedef void * (*dynafunc)(void *input); typedef void * (*dynafunc)(void *input);
/*********************************************************************** /***********************************************************************
@@ -189,7 +196,7 @@ static void DynaClose(void)
static dynafunc DynaGetFunction(const char *name) static dynafunc DynaGetFunction(const char *name)
{ {
dynafunc func = (void *(*)(void *))0; dynafunc func = (dynafunc)ZERO_NULL;
#if defined(HAVE_DLOPEN) || defined(HAVE_LIBDL) #if defined(HAVE_DLOPEN) || defined(HAVE_LIBDL)
if (libldap) { if (libldap) {

View File

@@ -165,6 +165,13 @@ static void signalPipeClose(struct curl_llist *pipe);
#define MAX_PIPELINE_LENGTH 5 #define MAX_PIPELINE_LENGTH 5
/*
* We use this ZERO_NULL to avoid picky compiler warnings,
* when assigning a NULL pointer to a function pointer var.
*/
#define ZERO_NULL 0
#ifndef USE_ARES #ifndef USE_ARES
/* not for ares builds */ /* not for ares builds */
@@ -501,9 +508,9 @@ CURLcode Curl_open(struct SessionHandle **curl)
data->set.fread = (curl_read_callback)fread; data->set.fread = (curl_read_callback)fread;
/* conversion callbacks for non-ASCII hosts */ /* conversion callbacks for non-ASCII hosts */
data->set.convfromnetwork = (CURLcode(*)(char *, size_t))0; data->set.convfromnetwork = (curl_conv_callback)ZERO_NULL;
data->set.convtonetwork = (CURLcode(*)(char *, size_t))0; data->set.convtonetwork = (curl_conv_callback)ZERO_NULL;
data->set.convfromutf8 = (CURLcode(*)(char *, size_t))0; data->set.convfromutf8 = (curl_conv_callback)ZERO_NULL;
#if defined(CURL_DOES_CONVERSIONS) && defined(HAVE_ICONV) #if defined(CURL_DOES_CONVERSIONS) && defined(HAVE_ICONV)
/* conversion descriptors for iconv calls */ /* conversion descriptors for iconv calls */
@@ -2993,7 +3000,7 @@ static CURLcode CreateConnection(struct SessionHandle *data,
conn->remote_port = PORT_HTTP; conn->remote_port = PORT_HTTP;
conn->protocol |= PROT_HTTP; conn->protocol |= PROT_HTTP;
conn->curl_do = Curl_http; conn->curl_do = Curl_http;
conn->curl_do_more = (CURLcode(*)(struct connectdata *))0; conn->curl_do_more = (Curl_do_more_func)ZERO_NULL;
conn->curl_done = Curl_http_done; conn->curl_done = Curl_http_done;
conn->curl_connect = Curl_http_connect; conn->curl_connect = Curl_http_connect;
#else #else
@@ -3010,7 +3017,7 @@ static CURLcode CreateConnection(struct SessionHandle *data,
conn->protocol |= PROT_HTTP|PROT_HTTPS|PROT_SSL; conn->protocol |= PROT_HTTP|PROT_HTTPS|PROT_SSL;
conn->curl_do = Curl_http; conn->curl_do = Curl_http;
conn->curl_do_more = (CURLcode(*)(struct connectdata *))0; conn->curl_do_more = (Curl_do_more_func)ZERO_NULL;
conn->curl_done = Curl_http_done; conn->curl_done = Curl_http_done;
conn->curl_connect = Curl_http_connect; conn->curl_connect = Curl_http_connect;
conn->curl_connecting = Curl_https_connecting; conn->curl_connecting = Curl_https_connecting;
@@ -3124,7 +3131,7 @@ static CURLcode CreateConnection(struct SessionHandle *data,
conn->remote_port = PORT_DICT; conn->remote_port = PORT_DICT;
conn->curl_do = Curl_dict; conn->curl_do = Curl_dict;
/* no DICT-specific done */ /* no DICT-specific done */
conn->curl_done = (CURLcode(*)(struct connectdata *, CURLcode))0; conn->curl_done = (Curl_done_func)ZERO_NULL;
#else #else
failf(data, LIBCURL_NAME failf(data, LIBCURL_NAME
" was built with DICT disabled!"); " was built with DICT disabled!");
@@ -3137,7 +3144,7 @@ static CURLcode CreateConnection(struct SessionHandle *data,
conn->remote_port = PORT_LDAP; conn->remote_port = PORT_LDAP;
conn->curl_do = Curl_ldap; conn->curl_do = Curl_ldap;
/* no LDAP-specific done */ /* no LDAP-specific done */
conn->curl_done = (CURLcode(*)(struct connectdata *, CURLcode))0; conn->curl_done = (Curl_done_func)ZERO_NULL;
#else #else
failf(data, LIBCURL_NAME failf(data, LIBCURL_NAME
" was built with LDAP disabled!"); " was built with LDAP disabled!");