]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
configure: silence compiler warnings in feature checks, drop duplicates
authorViktor Szakats <commit@vsz.me>
Tue, 18 Feb 2025 01:49:31 +0000 (02:49 +0100)
committerViktor Szakats <commit@vsz.me>
Fri, 21 Feb 2025 12:59:51 +0000 (13:59 +0100)
Silence compiler warnings (200 of them across the main CI workflows):
```
warning #2193: null argument provided for parameter marked with attribute "nonnull"
warning: Null pointer passed to 1st parameter expecting 'nonnull' [core.NonNullParamChecker]
warning: Null pointer passed to 2nd parameter expecting 'nonnull' [core.NonNullParamChecker]
warning: argument 1 null where non-null expected [-Wnonnull]
warning: argument 2 null where non-null expected [-Wnonnull]
warning: comparison of unsigned expression in '< 0' is always false [-Wtype-limits]
warning: null argument where non-null required (argument 1) [-Wnonnull]
```

Also drop `if ... can be linked` feature checks that were identical to
`if ... is compilable` checks, for:
`closesocket`, `ioctlsocket`, `socket`, `freeaddrinfo`, `getaddrinfo`,
`gethostname`, `getpeername`, `getsockname`,
`CloseSocket` (AmigaOS), `IoctlSocket` (AmigaOS).
Another option is to really do the link checks. But, if they weren't
missed so far, it seems safer to drop than risk a detection failure,
as was the case with AmigaOS functions while working on this PR.

There remain 22 `-Wnonnull` warnings in `gethostbyname_r()`,
`getpeername()` `getsockname()`. Most of the rest is necessary for
detection, or originate from autotools and CMake detection code
templates. Some still fixable, like duplicate libs.

Follow-up to ca2f49ded03426a246b3db7833592157cdd7f597 #16287
Closes #16377

acinclude.m4
configure.ac
m4/curl-functions.m4

index 1ecda765615535c4bdcc3c70bf189bcc310e136e..abf19c2cd49e9e6a5979215566476a77be079b19 100644 (file)
@@ -689,7 +689,8 @@ AC_DEFUN([CURL_CHECK_FUNC_SEND], [
       #endif
       #endif
     ]],[[
-      send(0, 0, 0, 0);
+      char s[] = "";
+      send(0, (void *)s, 0, 0);
     ]])
   ],[
     AC_MSG_RESULT([yes])
index 98bacbf31fec3a4420357e1d873d21cf85340c59..6146412e749f450c12700cb872b989027f50a3e7 100644 (file)
@@ -1757,7 +1757,7 @@ AS_HELP_STRING([--disable-ipv6],[Disable IPv6 support]),
       {
         int s = (int)sizeof(struct sockaddr_in6);
         (void)s;
-        return socket(AF_INET6, SOCK_STREAM, 0) < 0;
+        return socket(AF_INET6, SOCK_STREAM, 0) > 0;
       }
     ]])
   ],
index 60008b759388fb68ec1b5d831a32b32b1500da79..82bf39a3063088c3887c8652a52b243d25c875c6 100644 (file)
@@ -650,40 +650,21 @@ dnl HAVE_CLOSESOCKET will be defined.
 AC_DEFUN([CURL_CHECK_FUNC_CLOSESOCKET], [
   AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
   #
-  tst_links_closesocket="unknown"
   tst_proto_closesocket="unknown"
   tst_compi_closesocket="unknown"
   tst_allow_closesocket="unknown"
   #
-  AC_MSG_CHECKING([if closesocket can be linked])
-  AC_LINK_IFELSE([
-    AC_LANG_PROGRAM([[
-      $curl_includes_winsock2
-    ]],[[
-      if(0 != closesocket(0))
-        return 1;
-    ]])
+  AC_MSG_CHECKING([if closesocket is prototyped])
+  AC_EGREP_CPP([closesocket],[
+    $curl_includes_winsock2
   ],[
     AC_MSG_RESULT([yes])
-    tst_links_closesocket="yes"
+    tst_proto_closesocket="yes"
   ],[
     AC_MSG_RESULT([no])
-    tst_links_closesocket="no"
+    tst_proto_closesocket="no"
   ])
   #
-  if test "$tst_links_closesocket" = "yes"; then
-    AC_MSG_CHECKING([if closesocket is prototyped])
-    AC_EGREP_CPP([closesocket],[
-      $curl_includes_winsock2
-    ],[
-      AC_MSG_RESULT([yes])
-      tst_proto_closesocket="yes"
-    ],[
-      AC_MSG_RESULT([no])
-      tst_proto_closesocket="no"
-    ])
-  fi
-  #
   if test "$tst_proto_closesocket" = "yes"; then
     AC_MSG_CHECKING([if closesocket is compilable])
     AC_COMPILE_IFELSE([
@@ -714,8 +695,7 @@ AC_DEFUN([CURL_CHECK_FUNC_CLOSESOCKET], [
   fi
   #
   AC_MSG_CHECKING([if closesocket might be used])
-  if test "$tst_links_closesocket" = "yes" &&
-     test "$tst_proto_closesocket" = "yes" &&
+  if test "$tst_proto_closesocket" = "yes" &&
      test "$tst_compi_closesocket" = "yes" &&
      test "$tst_allow_closesocket" = "yes"; then
     AC_MSG_RESULT([yes])
@@ -741,12 +721,11 @@ AC_DEFUN([CURL_CHECK_FUNC_CLOSESOCKET_CAMEL], [
   AC_REQUIRE([CURL_INCLUDES_SYS_SOCKET])dnl
   AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl
   #
-  tst_links_closesocket_camel="unknown"
   tst_compi_closesocket_camel="unknown"
   tst_allow_closesocket_camel="unknown"
   #
-  AC_MSG_CHECKING([if CloseSocket can be linked])
-  AC_LINK_IFELSE([
+  AC_MSG_CHECKING([if CloseSocket is compilable])
+  AC_COMPILE_IFELSE([
     AC_LANG_PROGRAM([[
       $curl_includes_bsdsocket
       $curl_includes_sys_socket
@@ -756,31 +735,12 @@ AC_DEFUN([CURL_CHECK_FUNC_CLOSESOCKET_CAMEL], [
     ]])
   ],[
     AC_MSG_RESULT([yes])
-    tst_links_closesocket_camel="yes"
+    tst_compi_closesocket_camel="yes"
   ],[
     AC_MSG_RESULT([no])
-    tst_links_closesocket_camel="no"
+    tst_compi_closesocket_camel="no"
   ])
   #
-  if test "$tst_links_closesocket_camel" = "yes"; then
-    AC_MSG_CHECKING([if CloseSocket is compilable])
-    AC_COMPILE_IFELSE([
-      AC_LANG_PROGRAM([[
-        $curl_includes_bsdsocket
-        $curl_includes_sys_socket
-      ]],[[
-        if(0 != CloseSocket(0))
-          return 1;
-      ]])
-    ],[
-      AC_MSG_RESULT([yes])
-      tst_compi_closesocket_camel="yes"
-    ],[
-      AC_MSG_RESULT([no])
-      tst_compi_closesocket_camel="no"
-    ])
-  fi
-  #
   if test "$tst_compi_closesocket_camel" = "yes"; then
     AC_MSG_CHECKING([if CloseSocket usage allowed])
     if test "x$curl_disallow_closesocket_camel" != "xyes"; then
@@ -793,8 +753,7 @@ AC_DEFUN([CURL_CHECK_FUNC_CLOSESOCKET_CAMEL], [
   fi
   #
   AC_MSG_CHECKING([if CloseSocket might be used])
-  if test "$tst_links_closesocket_camel" = "yes" &&
-     test "$tst_compi_closesocket_camel" = "yes" &&
+  if test "$tst_compi_closesocket_camel" = "yes" &&
      test "$tst_allow_closesocket_camel" = "yes"; then
     AC_MSG_RESULT([yes])
     AC_DEFINE_UNQUOTED(HAVE_CLOSESOCKET_CAMEL, 1,
@@ -968,43 +927,23 @@ AC_DEFUN([CURL_CHECK_FUNC_FREEADDRINFO], [
   AC_REQUIRE([CURL_INCLUDES_SYS_SOCKET])dnl
   AC_REQUIRE([CURL_INCLUDES_NETDB])dnl
   #
-  tst_links_freeaddrinfo="unknown"
   tst_proto_freeaddrinfo="unknown"
   tst_compi_freeaddrinfo="unknown"
   tst_allow_freeaddrinfo="unknown"
   #
-  AC_MSG_CHECKING([if freeaddrinfo can be linked])
-  AC_LINK_IFELSE([
-    AC_LANG_PROGRAM([[
-      $curl_includes_ws2tcpip
-      $curl_includes_sys_socket
-      $curl_includes_netdb
-    ]],[[
-      freeaddrinfo(0);
-    ]])
+  AC_MSG_CHECKING([if freeaddrinfo is prototyped])
+  AC_EGREP_CPP([freeaddrinfo],[
+    $curl_includes_ws2tcpip
+    $curl_includes_sys_socket
+    $curl_includes_netdb
   ],[
     AC_MSG_RESULT([yes])
-    tst_links_freeaddrinfo="yes"
+    tst_proto_freeaddrinfo="yes"
   ],[
     AC_MSG_RESULT([no])
-    tst_links_freeaddrinfo="no"
+    tst_proto_freeaddrinfo="no"
   ])
   #
-  if test "$tst_links_freeaddrinfo" = "yes"; then
-    AC_MSG_CHECKING([if freeaddrinfo is prototyped])
-    AC_EGREP_CPP([freeaddrinfo],[
-      $curl_includes_ws2tcpip
-      $curl_includes_sys_socket
-      $curl_includes_netdb
-    ],[
-      AC_MSG_RESULT([yes])
-      tst_proto_freeaddrinfo="yes"
-    ],[
-      AC_MSG_RESULT([no])
-      tst_proto_freeaddrinfo="no"
-    ])
-  fi
-  #
   if test "$tst_proto_freeaddrinfo" = "yes"; then
     AC_MSG_CHECKING([if freeaddrinfo is compilable])
     AC_COMPILE_IFELSE([
@@ -1036,8 +975,7 @@ AC_DEFUN([CURL_CHECK_FUNC_FREEADDRINFO], [
   fi
   #
   AC_MSG_CHECKING([if freeaddrinfo might be used])
-  if test "$tst_links_freeaddrinfo" = "yes" &&
-     test "$tst_proto_freeaddrinfo" = "yes" &&
+  if test "$tst_proto_freeaddrinfo" = "yes" &&
      test "$tst_compi_freeaddrinfo" = "yes" &&
      test "$tst_allow_freeaddrinfo" = "yes"; then
     AC_MSG_RESULT([yes])
@@ -1099,7 +1037,7 @@ AC_DEFUN([CURL_CHECK_FUNC_FSETXATTR], [
         AC_LANG_PROGRAM([[
           $curl_includes_sys_xattr
         ]],[[
-          if(0 != fsetxattr(0, 0, 0, 0, 0))
+          if(0 != fsetxattr(0, "", 0, 0, 0))
             return 1;
         ]])
       ],[
@@ -1277,46 +1215,25 @@ AC_DEFUN([CURL_CHECK_FUNC_GETADDRINFO], [
   AC_REQUIRE([CURL_INCLUDES_NETDB])dnl
   AC_REQUIRE([CURL_CHECK_NATIVE_WINDOWS])dnl
   #
-  tst_links_getaddrinfo="unknown"
   tst_proto_getaddrinfo="unknown"
   tst_compi_getaddrinfo="unknown"
   tst_works_getaddrinfo="unknown"
   tst_allow_getaddrinfo="unknown"
   tst_tsafe_getaddrinfo="unknown"
   #
-  AC_MSG_CHECKING([if getaddrinfo can be linked])
-  AC_LINK_IFELSE([
-    AC_LANG_PROGRAM([[
-      $curl_includes_ws2tcpip
-      $curl_includes_sys_socket
-      $curl_includes_netdb
-    ]],[[
-      if(0 != getaddrinfo(0, 0, 0, 0))
-        return 1;
-    ]])
+  AC_MSG_CHECKING([if getaddrinfo is prototyped])
+  AC_EGREP_CPP([getaddrinfo],[
+    $curl_includes_ws2tcpip
+    $curl_includes_sys_socket
+    $curl_includes_netdb
   ],[
     AC_MSG_RESULT([yes])
-    tst_links_getaddrinfo="yes"
+    tst_proto_getaddrinfo="yes"
   ],[
     AC_MSG_RESULT([no])
-    tst_links_getaddrinfo="no"
+    tst_proto_getaddrinfo="no"
   ])
   #
-  if test "$tst_links_getaddrinfo" = "yes"; then
-    AC_MSG_CHECKING([if getaddrinfo is prototyped])
-    AC_EGREP_CPP([getaddrinfo],[
-      $curl_includes_ws2tcpip
-      $curl_includes_sys_socket
-      $curl_includes_netdb
-    ],[
-      AC_MSG_RESULT([yes])
-      tst_proto_getaddrinfo="yes"
-    ],[
-      AC_MSG_RESULT([no])
-      tst_proto_getaddrinfo="no"
-    ])
-  fi
-  #
   if test "$tst_proto_getaddrinfo" = "yes"; then
     AC_MSG_CHECKING([if getaddrinfo is compilable])
     AC_COMPILE_IFELSE([
@@ -1325,7 +1242,8 @@ AC_DEFUN([CURL_CHECK_FUNC_GETADDRINFO], [
         $curl_includes_sys_socket
         $curl_includes_netdb
       ]],[[
-        if(0 != getaddrinfo(0, 0, 0, 0))
+        struct addrinfo *ai = 0;
+        if(0 != getaddrinfo(0, 0, 0, &ai))
           return 1;
       ]])
     ],[
@@ -1391,8 +1309,7 @@ AC_DEFUN([CURL_CHECK_FUNC_GETADDRINFO], [
   fi
   #
   AC_MSG_CHECKING([if getaddrinfo might be used])
-  if test "$tst_links_getaddrinfo" = "yes" &&
-     test "$tst_proto_getaddrinfo" = "yes" &&
+  if test "$tst_proto_getaddrinfo" = "yes" &&
      test "$tst_compi_getaddrinfo" = "yes" &&
      test "$tst_allow_getaddrinfo" = "yes" &&
      test "$tst_works_getaddrinfo" != "no"; then
@@ -1640,44 +1557,23 @@ AC_DEFUN([CURL_CHECK_FUNC_GETHOSTNAME], [
   AC_REQUIRE([CURL_INCLUDES_UNISTD])dnl
   AC_REQUIRE([CURL_PREPROCESS_CALLCONV])dnl
   #
-  tst_links_gethostname="unknown"
   tst_proto_gethostname="unknown"
   tst_compi_gethostname="unknown"
   tst_allow_gethostname="unknown"
   #
-  AC_MSG_CHECKING([if gethostname can be linked])
-  AC_LINK_IFELSE([
-    AC_LANG_PROGRAM([[
-      $curl_includes_winsock2
-      $curl_includes_unistd
-      $curl_includes_bsdsocket
-    ]],[[
-      if(0 != gethostname(0, 0))
-        return 1;
-    ]])
+  AC_MSG_CHECKING([if gethostname is prototyped])
+  AC_EGREP_CPP([gethostname],[
+    $curl_includes_winsock2
+    $curl_includes_unistd
+    $curl_includes_bsdsocket
   ],[
     AC_MSG_RESULT([yes])
-    tst_links_gethostname="yes"
+    tst_proto_gethostname="yes"
   ],[
     AC_MSG_RESULT([no])
-    tst_links_gethostname="no"
+    tst_proto_gethostname="no"
   ])
   #
-  if test "$tst_links_gethostname" = "yes"; then
-    AC_MSG_CHECKING([if gethostname is prototyped])
-    AC_EGREP_CPP([gethostname],[
-      $curl_includes_winsock2
-      $curl_includes_unistd
-      $curl_includes_bsdsocket
-    ],[
-      AC_MSG_RESULT([yes])
-      tst_proto_gethostname="yes"
-    ],[
-      AC_MSG_RESULT([no])
-      tst_proto_gethostname="no"
-    ])
-  fi
-  #
   if test "$tst_proto_gethostname" = "yes"; then
     AC_MSG_CHECKING([if gethostname is compilable])
     AC_COMPILE_IFELSE([
@@ -1686,7 +1582,8 @@ AC_DEFUN([CURL_CHECK_FUNC_GETHOSTNAME], [
         $curl_includes_unistd
         $curl_includes_bsdsocket
       ]],[[
-        if(0 != gethostname(0, 0))
+        char s[1];
+        if(0 != gethostname((void *)s, 0))
           return 1;
       ]])
     ],[
@@ -1717,7 +1614,8 @@ AC_DEFUN([CURL_CHECK_FUNC_GETHOSTNAME], [
               #endif
               int FUNCALLCONV gethostname($tst_arg1, $tst_arg2);
             ]],[[
-              if(0 != gethostname(0, 0))
+              char s[1];
+              if(0 != gethostname(($tst_arg1)s, 0))
                 return 1;
             ]])
           ],[
@@ -1745,8 +1643,7 @@ AC_DEFUN([CURL_CHECK_FUNC_GETHOSTNAME], [
   fi
   #
   AC_MSG_CHECKING([if gethostname might be used])
-  if test "$tst_links_gethostname" = "yes" &&
-     test "$tst_proto_gethostname" = "yes" &&
+  if test "$tst_proto_gethostname" = "yes" &&
      test "$tst_compi_gethostname" = "yes" &&
      test "$tst_allow_gethostname" = "yes"; then
     AC_MSG_RESULT([yes])
@@ -1773,44 +1670,23 @@ AC_DEFUN([CURL_CHECK_FUNC_GETPEERNAME], [
   AC_REQUIRE([CURL_PREPROCESS_CALLCONV])dnl
   AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl
   #
-  tst_links_getpeername="unknown"
   tst_proto_getpeername="unknown"
   tst_compi_getpeername="unknown"
   tst_allow_getpeername="unknown"
   #
-  AC_MSG_CHECKING([if getpeername can be linked])
-  AC_LINK_IFELSE([
-    AC_LANG_PROGRAM([[
-      $curl_includes_winsock2
-      $curl_includes_bsdsocket
-      $curl_includes_sys_socket
-    ]],[[
-      if(0 != getpeername(0, (void *)0, (void *)0))
-        return 1;
-    ]])
+  AC_MSG_CHECKING([if getpeername is prototyped])
+  AC_EGREP_CPP([getpeername],[
+    $curl_includes_winsock2
+    $curl_includes_bsdsocket
+    $curl_includes_sys_socket
   ],[
     AC_MSG_RESULT([yes])
-    tst_links_getpeername="yes"
+    tst_proto_getpeername="yes"
   ],[
     AC_MSG_RESULT([no])
-    tst_links_getpeername="no"
+    tst_proto_getpeername="no"
   ])
   #
-  if test "$tst_links_getpeername" = "yes"; then
-    AC_MSG_CHECKING([if getpeername is prototyped])
-    AC_EGREP_CPP([getpeername],[
-      $curl_includes_winsock2
-      $curl_includes_bsdsocket
-      $curl_includes_sys_socket
-    ],[
-      AC_MSG_RESULT([yes])
-      tst_proto_getpeername="yes"
-    ],[
-      AC_MSG_RESULT([no])
-      tst_proto_getpeername="no"
-    ])
-  fi
-  #
   if test "$tst_proto_getpeername" = "yes"; then
     AC_MSG_CHECKING([if getpeername is compilable])
     AC_COMPILE_IFELSE([
@@ -1843,8 +1719,7 @@ AC_DEFUN([CURL_CHECK_FUNC_GETPEERNAME], [
   fi
   #
   AC_MSG_CHECKING([if getpeername might be used])
-  if test "$tst_links_getpeername" = "yes" &&
-     test "$tst_proto_getpeername" = "yes" &&
+  if test "$tst_proto_getpeername" = "yes" &&
      test "$tst_compi_getpeername" = "yes" &&
      test "$tst_allow_getpeername" = "yes"; then
     AC_MSG_RESULT([yes])
@@ -1871,44 +1746,23 @@ AC_DEFUN([CURL_CHECK_FUNC_GETSOCKNAME], [
   AC_REQUIRE([CURL_PREPROCESS_CALLCONV])dnl
   AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl
   #
-  tst_links_getsockname="unknown"
   tst_proto_getsockname="unknown"
   tst_compi_getsockname="unknown"
   tst_allow_getsockname="unknown"
   #
-  AC_MSG_CHECKING([if getsockname can be linked])
-  AC_LINK_IFELSE([
-    AC_LANG_PROGRAM([[
-      $curl_includes_winsock2
-      $curl_includes_bsdsocket
-      $curl_includes_sys_socket
-    ]],[[
-      if(0 != getsockname(0, (void *)0, (void *)0))
-        return 1;
-    ]])
+  AC_MSG_CHECKING([if getsockname is prototyped])
+  AC_EGREP_CPP([getsockname],[
+    $curl_includes_winsock2
+    $curl_includes_bsdsocket
+    $curl_includes_sys_socket
   ],[
     AC_MSG_RESULT([yes])
-    tst_links_getsockname="yes"
+    tst_proto_getsockname="yes"
   ],[
     AC_MSG_RESULT([no])
-    tst_links_getsockname="no"
+    tst_proto_getsockname="no"
   ])
   #
-  if test "$tst_links_getsockname" = "yes"; then
-    AC_MSG_CHECKING([if getsockname is prototyped])
-    AC_EGREP_CPP([getsockname],[
-      $curl_includes_winsock2
-      $curl_includes_bsdsocket
-      $curl_includes_sys_socket
-    ],[
-      AC_MSG_RESULT([yes])
-      tst_proto_getsockname="yes"
-    ],[
-      AC_MSG_RESULT([no])
-      tst_proto_getsockname="no"
-    ])
-  fi
-  #
   if test "$tst_proto_getsockname" = "yes"; then
     AC_MSG_CHECKING([if getsockname is compilable])
     AC_COMPILE_IFELSE([
@@ -1941,8 +1795,7 @@ AC_DEFUN([CURL_CHECK_FUNC_GETSOCKNAME], [
   fi
   #
   AC_MSG_CHECKING([if getsockname might be used])
-  if test "$tst_links_getsockname" = "yes" &&
-     test "$tst_proto_getsockname" = "yes" &&
+  if test "$tst_proto_getsockname" = "yes" &&
      test "$tst_compi_getsockname" = "yes" &&
      test "$tst_allow_getsockname" = "yes"; then
     AC_MSG_RESULT([yes])
@@ -2120,8 +1973,11 @@ AC_DEFUN([CURL_CHECK_FUNC_GMTIME_R], [
       AC_LANG_PROGRAM([[
         $curl_includes_time
       ]],[[
-        if(0 != gmtime_r(0, 0))
+        time_t tm = 1170352587;
+        struct tm result;
+        if(0 != gmtime_r(&tm, &result))
           return 1;
+        (void)result;
       ]])
     ],[
       AC_MSG_RESULT([yes])
@@ -2238,7 +2094,9 @@ AC_DEFUN([CURL_CHECK_FUNC_INET_NTOP], [
       AC_LANG_PROGRAM([[
         $curl_includes_arpa_inet
       ]],[[
-        if(0 != inet_ntop(0, 0, 0, 0))
+        char ipv4res[sizeof("255.255.255.255")];
+        unsigned char ipv4a[5] = "";
+        if(0 != inet_ntop(0, ipv4a, ipv4res, 0))
           return 1;
       ]])
     ],[
@@ -2261,7 +2119,7 @@ AC_DEFUN([CURL_CHECK_FUNC_INET_NTOP], [
         $curl_includes_string
       ]],[[
         char ipv6res[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")];
-        char ipv4res[sizeof "255.255.255.255"];
+        char ipv4res[sizeof("255.255.255.255")];
         unsigned char ipv6a[26];
         unsigned char ipv4a[5];
         const char *ipv6ptr = 0;
@@ -2397,7 +2255,9 @@ AC_DEFUN([CURL_CHECK_FUNC_INET_PTON], [
       AC_LANG_PROGRAM([[
         $curl_includes_arpa_inet
       ]],[[
-        if(0 != inet_pton(0, 0, 0))
+        unsigned char ipv4a[4+1] = "";
+        const char *ipv4src = "192.168.100.1";
+        if(0 != inet_pton(0, ipv4src, ipv4a))
           return 1;
       ]])
     ],[
@@ -2709,40 +2569,21 @@ dnl HAVE_IOCTLSOCKET will be defined.
 AC_DEFUN([CURL_CHECK_FUNC_IOCTLSOCKET], [
   AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
   #
-  tst_links_ioctlsocket="unknown"
   tst_proto_ioctlsocket="unknown"
   tst_compi_ioctlsocket="unknown"
   tst_allow_ioctlsocket="unknown"
   #
-  AC_MSG_CHECKING([if ioctlsocket can be linked])
-  AC_LINK_IFELSE([
-    AC_LANG_PROGRAM([[
-      $curl_includes_winsock2
-    ]],[[
-      if(0 != ioctlsocket(0, 0, 0))
-        return 1;
-    ]])
+  AC_MSG_CHECKING([if ioctlsocket is prototyped])
+  AC_EGREP_CPP([ioctlsocket],[
+    $curl_includes_winsock2
   ],[
     AC_MSG_RESULT([yes])
-    tst_links_ioctlsocket="yes"
+    tst_proto_ioctlsocket="yes"
   ],[
     AC_MSG_RESULT([no])
-    tst_links_ioctlsocket="no"
+    tst_proto_ioctlsocket="no"
   ])
   #
-  if test "$tst_links_ioctlsocket" = "yes"; then
-    AC_MSG_CHECKING([if ioctlsocket is prototyped])
-    AC_EGREP_CPP([ioctlsocket],[
-      $curl_includes_winsock2
-    ],[
-      AC_MSG_RESULT([yes])
-      tst_proto_ioctlsocket="yes"
-    ],[
-      AC_MSG_RESULT([no])
-      tst_proto_ioctlsocket="no"
-    ])
-  fi
-  #
   if test "$tst_proto_ioctlsocket" = "yes"; then
     AC_MSG_CHECKING([if ioctlsocket is compilable])
     AC_COMPILE_IFELSE([
@@ -2773,8 +2614,7 @@ AC_DEFUN([CURL_CHECK_FUNC_IOCTLSOCKET], [
   fi
   #
   AC_MSG_CHECKING([if ioctlsocket might be used])
-  if test "$tst_links_ioctlsocket" = "yes" &&
-     test "$tst_proto_ioctlsocket" = "yes" &&
+  if test "$tst_proto_ioctlsocket" = "yes" &&
      test "$tst_compi_ioctlsocket" = "yes" &&
      test "$tst_allow_ioctlsocket" = "yes"; then
     AC_MSG_RESULT([yes])
@@ -2856,43 +2696,25 @@ dnl then HAVE_IOCTLSOCKET_CAMEL will be defined.
 AC_DEFUN([CURL_CHECK_FUNC_IOCTLSOCKET_CAMEL], [
   AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl
   #
-  tst_links_ioctlsocket_camel="unknown"
   tst_compi_ioctlsocket_camel="unknown"
   tst_allow_ioctlsocket_camel="unknown"
   #
-  AC_MSG_CHECKING([if IoctlSocket can be linked])
-  AC_LINK_IFELSE([
+  AC_MSG_CHECKING([if IoctlSocket is compilable])
+  AC_COMPILE_IFELSE([
     AC_LANG_PROGRAM([[
       $curl_includes_bsdsocket
     ]],[[
-      IoctlSocket(0, 0, 0);
+      if(0 != IoctlSocket(0, 0, 0))
+        return 1;
     ]])
   ],[
     AC_MSG_RESULT([yes])
-    tst_links_ioctlsocket_camel="yes"
+    tst_compi_ioctlsocket_camel="yes"
   ],[
     AC_MSG_RESULT([no])
-    tst_links_ioctlsocket_camel="no"
+    tst_compi_ioctlsocket_camel="no"
   ])
   #
-  if test "$tst_links_ioctlsocket_camel" = "yes"; then
-    AC_MSG_CHECKING([if IoctlSocket is compilable])
-    AC_COMPILE_IFELSE([
-      AC_LANG_PROGRAM([[
-        $curl_includes_bsdsocket
-      ]],[[
-        if(0 != IoctlSocket(0, 0, 0))
-          return 1;
-      ]])
-    ],[
-      AC_MSG_RESULT([yes])
-      tst_compi_ioctlsocket_camel="yes"
-    ],[
-      AC_MSG_RESULT([no])
-      tst_compi_ioctlsocket_camel="no"
-    ])
-  fi
-  #
   if test "$tst_compi_ioctlsocket_camel" = "yes"; then
     AC_MSG_CHECKING([if IoctlSocket usage allowed])
     if test "x$curl_disallow_ioctlsocket_camel" != "xyes"; then
@@ -2905,8 +2727,7 @@ AC_DEFUN([CURL_CHECK_FUNC_IOCTLSOCKET_CAMEL], [
   fi
   #
   AC_MSG_CHECKING([if IoctlSocket might be used])
-  if test "$tst_links_ioctlsocket_camel" = "yes" &&
-     test "$tst_compi_ioctlsocket_camel" = "yes" &&
+  if test "$tst_compi_ioctlsocket_camel" = "yes" &&
      test "$tst_allow_ioctlsocket_camel" = "yes"; then
     AC_MSG_RESULT([yes])
     AC_DEFINE_UNQUOTED(HAVE_IOCTLSOCKET_CAMEL, 1,
@@ -3042,7 +2863,7 @@ AC_DEFUN([CURL_CHECK_FUNC_MEMRCHR], [
       AC_LANG_PROGRAM([[
         $curl_includes_string
       ]],[[
-        if(0 != memrchr(0, 0, 0))
+        if(0 != memrchr("", 0, 0))
           return 1;
       ]])
     ],[
@@ -3455,44 +3276,23 @@ AC_DEFUN([CURL_CHECK_FUNC_SOCKET], [
   AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
   AC_REQUIRE([CURL_INCLUDES_SYS_SOCKET])dnl
   #
-  tst_links_socket="unknown"
   tst_proto_socket="unknown"
   tst_compi_socket="unknown"
   tst_allow_socket="unknown"
   #
-  AC_MSG_CHECKING([if socket can be linked])
-  AC_LINK_IFELSE([
-    AC_LANG_PROGRAM([[
-      $curl_includes_winsock2
-      $curl_includes_bsdsocket
-      $curl_includes_sys_socket
-    ]],[[
-      if(0 != socket(0, 0, 0))
-        return 1;
-    ]])
+  AC_MSG_CHECKING([if socket is prototyped])
+  AC_EGREP_CPP([socket],[
+    $curl_includes_winsock2
+    $curl_includes_bsdsocket
+    $curl_includes_sys_socket
   ],[
     AC_MSG_RESULT([yes])
-    tst_links_socket="yes"
+    tst_proto_socket="yes"
   ],[
     AC_MSG_RESULT([no])
-    tst_links_socket="no"
+    tst_proto_socket="no"
   ])
   #
-  if test "$tst_links_socket" = "yes"; then
-    AC_MSG_CHECKING([if socket is prototyped])
-    AC_EGREP_CPP([socket],[
-      $curl_includes_winsock2
-      $curl_includes_bsdsocket
-      $curl_includes_sys_socket
-    ],[
-      AC_MSG_RESULT([yes])
-      tst_proto_socket="yes"
-    ],[
-      AC_MSG_RESULT([no])
-      tst_proto_socket="no"
-    ])
-  fi
-  #
   if test "$tst_proto_socket" = "yes"; then
     AC_MSG_CHECKING([if socket is compilable])
     AC_COMPILE_IFELSE([
@@ -3525,8 +3325,7 @@ AC_DEFUN([CURL_CHECK_FUNC_SOCKET], [
   fi
   #
   AC_MSG_CHECKING([if socket might be used])
-  if test "$tst_links_socket" = "yes" &&
-     test "$tst_proto_socket" = "yes" &&
+  if test "$tst_proto_socket" = "yes" &&
      test "$tst_compi_socket" = "yes" &&
      test "$tst_allow_socket" = "yes"; then
     AC_MSG_RESULT([yes])
@@ -3805,6 +3604,7 @@ dnl HAVE_STRDUP will be defined.
 
 AC_DEFUN([CURL_CHECK_FUNC_STRDUP], [
   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
+  AC_REQUIRE([CURL_INCLUDES_STDLIB])dnl
   #
   tst_links_strdup="unknown"
   tst_proto_strdup="unknown"
@@ -3840,9 +3640,9 @@ AC_DEFUN([CURL_CHECK_FUNC_STRDUP], [
     AC_COMPILE_IFELSE([
       AC_LANG_PROGRAM([[
         $curl_includes_string
+        $curl_includes_stdlib
       ]],[[
-        if(0 != strdup(0))
-          return 1;
+        free(strdup(""));
       ]])
     ],[
       AC_MSG_RESULT([yes])
@@ -3949,7 +3749,8 @@ AC_DEFUN([CURL_CHECK_FUNC_STRERROR_R], [
       AC_LANG_PROGRAM([[
         $curl_includes_string
       ]],[[
-        if(0 != strerror_r(0, 0, 0))
+        char s[1];
+        if(0 != strerror_r(0, s, 0))
           return 1;
       ]])
     ],[