From ba481718a461731ac92f1d0602d29d056251115c Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sun, 29 Oct 2006 14:58:59 +0000 Subject: Make more human readable and maintainable previous compiler warning fix since it was Ok and actually avoids the targeted compiler warning. --- lib/ldap.c | 11 +++++++++-- lib/url.c | 21 ++++++++++++++------- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/lib/ldap.c b/lib/ldap.c index 6a5e0d6dd..53c772209 100644 --- a/lib/ldap.c +++ b/lib/ldap.c @@ -3,7 +3,7 @@ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ - * \___|\___/|_| \_\_____| + * \___|\___/|_| \_\_____| * * Copyright (C) 1998 - 2006, Daniel Stenberg, , et al. * @@ -115,6 +115,13 @@ #undef HAVE_LIBDL #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); /*********************************************************************** @@ -189,7 +196,7 @@ static void DynaClose(void) static dynafunc DynaGetFunction(const char *name) { - dynafunc func = (void *(*)(void *))0; + dynafunc func = (dynafunc)ZERO_NULL; #if defined(HAVE_DLOPEN) || defined(HAVE_LIBDL) if (libldap) { diff --git a/lib/url.c b/lib/url.c index 9b9348fd4..6b823df34 100644 --- a/lib/url.c +++ b/lib/url.c @@ -165,6 +165,13 @@ static void signalPipeClose(struct curl_llist *pipe); #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 /* not for ares builds */ @@ -501,9 +508,9 @@ CURLcode Curl_open(struct SessionHandle **curl) data->set.fread = (curl_read_callback)fread; /* conversion callbacks for non-ASCII hosts */ - data->set.convfromnetwork = (CURLcode(*)(char *, size_t))0; - data->set.convtonetwork = (CURLcode(*)(char *, size_t))0; - data->set.convfromutf8 = (CURLcode(*)(char *, size_t))0; + data->set.convfromnetwork = (curl_conv_callback)ZERO_NULL; + data->set.convtonetwork = (curl_conv_callback)ZERO_NULL; + data->set.convfromutf8 = (curl_conv_callback)ZERO_NULL; #if defined(CURL_DOES_CONVERSIONS) && defined(HAVE_ICONV) /* conversion descriptors for iconv calls */ @@ -2993,7 +3000,7 @@ static CURLcode CreateConnection(struct SessionHandle *data, conn->remote_port = PORT_HTTP; conn->protocol |= PROT_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_connect = Curl_http_connect; #else @@ -3010,7 +3017,7 @@ static CURLcode CreateConnection(struct SessionHandle *data, conn->protocol |= PROT_HTTP|PROT_HTTPS|PROT_SSL; 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_connect = Curl_http_connect; conn->curl_connecting = Curl_https_connecting; @@ -3124,7 +3131,7 @@ static CURLcode CreateConnection(struct SessionHandle *data, conn->remote_port = PORT_DICT; conn->curl_do = Curl_dict; /* no DICT-specific done */ - conn->curl_done = (CURLcode(*)(struct connectdata *, CURLcode))0; + conn->curl_done = (Curl_done_func)ZERO_NULL; #else failf(data, LIBCURL_NAME " was built with DICT disabled!"); @@ -3137,7 +3144,7 @@ static CURLcode CreateConnection(struct SessionHandle *data, conn->remote_port = PORT_LDAP; conn->curl_do = Curl_ldap; /* no LDAP-specific done */ - conn->curl_done = (CURLcode(*)(struct connectdata *, CURLcode))0; + conn->curl_done = (Curl_done_func)ZERO_NULL; #else failf(data, LIBCURL_NAME " was built with LDAP disabled!"); -- cgit v1.2.3