Make more human readable and maintainable previous
authorYang Tse <yangsita@gmail.com>
Sun, 29 Oct 2006 14:58:59 +0000 (14:58 +0000)
committerYang Tse <yangsita@gmail.com>
Sun, 29 Oct 2006 14:58:59 +0000 (14:58 +0000)
compiler warning fix since it was Ok and actually
avoids the targeted compiler warning.

lib/ldap.c
lib/url.c

index 6a5e0d6..53c7722 100644 (file)
@@ -3,7 +3,7 @@
  *  Project         ___| | | |  _ \| |
  *                 / __| | | | |_) | |
  *                | (__| |_| |  _ <| |___
- *                \___|\___/|_| \_\_____|
+ *                 \___|\___/|_| \_\_____|
  *
  * Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
  *
 #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) {
index 9b9348f..6b823df 100644 (file)
--- 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!");