build: fix compiler warnings in feature detections

Fix or silence compiler warnings happening in feature detections
to reduce log noise. Warnings may also get promoted to errors in certain
cases, causing missed detections.

It reduces the number of warnings by 4500+ across the linux, linux-old,
macos, non-native and windows GHA workflows (~142 jobs).

Also move picky warning logic for MSVC/Borland to
`CMake/PickyWarnings.cmake. To make them listed in the picky-warnings
log output, and to also apply to feature detections to make them compile
under the same conditions as source code. The hope is to help catching
issues faster. It also improves code quality of feature tests.

Fixed/silenced:
```
warning #177: variable "dummy" was declared but never referenced
warning #177: variable "flag" was declared but never referenced
warning #177: variable "res" was declared but never referenced
warning #592: variable "s" is used before its value is set
warning #1011: missing return statement at end of non-void function "main"
warning #1786: function "SSL_CTX_set_srp_password" (declared at line 1888 of "/usr/include/openssl/ssl.h") was declared deprecated ("Since OpenSSL 3.0")
warning #1786: function "SSL_CTX_set_srp_username" (declared at line 1887 of "/usr/include/openssl/ssl.h") was declared deprecated ("Since OpenSSL 3.0")
warning #2332: a value of type "const char *" cannot be assigned to an entity of type "char *" (dropping qualifiers)
warning: 'SSL_CTX_set_srp_password' is deprecated [-Wdeprecated-declarations]
warning: 'SSL_CTX_set_srp_password' is deprecated: Since OpenSSL 3.0 [-Wdeprecated-declarations]
warning: 'SSL_CTX_set_srp_username' is deprecated [-Wdeprecated-declarations]
warning: 'SSL_CTX_set_srp_username' is deprecated: Since OpenSSL 3.0 [-Wdeprecated-declarations]
warning: 'b' is used uninitialized [-Wuninitialized]
warning: 'gethostname' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
warning: Undefined or garbage value returned to caller [core.uninitialized.UndefReturn]
warning: Value stored to 'i' is never read [deadcode.DeadStores]
warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
warning: control reaches end of non-void function [-Wreturn-type]
warning: empty expression statement has no effect; remove unnecessary ';' to silence this warning [-Wextra-semi-stmt]
warning: excess elements in struct initializer
warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
warning: macro "_FILE_OFFSET_BITS" is not used [-Wunused-macros]
warning: macro "_REENTRANT" is not used [-Wunused-macros]
warning: missing braces around initializer [-Wmissing-braces]
warning: no previous extern declaration for non-static variable 'off_t_is_large' [-Wmissing-variable-declarations]
warning: no previous prototype for 'check' [-Wmissing-prototypes]
warning: no previous prototype for function 'check' [-Wmissing-prototypes]
warning: null argument where non-null required (argument 2) [-Wnonnull]
warning: passing 'const char[1]' to parameter of type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
warning: passing argument 2 of 'SSL_CTX_set_srp_password' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
warning: passing argument 2 of 'SSL_CTX_set_srp_username' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
warning: unused parameter 'c' [-Wunused-parameter]
warning: unused parameter 'f' [-Wunused-parameter]
warning: unused variable 'data' [-Wunused-variable]
warning: unused variable 'dummy' [-Wunused-variable]
warning: unused variable 'flag' [-Wunused-variable]
warning: unused variable 'res' [-Wunused-variable]
warning: unused variable 's' [-Wunused-variable]
warning: variable 's' set but not used [-Wunused-but-set-variable]
warning: variable 'ts' set but not used [-Wunused-but-set-variable]
```

Closes #16287
This commit is contained in:
Viktor Szakats 2025-02-11 02:46:29 +01:00
parent ebbf51e191
commit ca2f49ded0
No known key found for this signature in database
GPG Key ID: B5ABD165E2AEF201
12 changed files with 164 additions and 137 deletions

View File

@ -30,14 +30,14 @@
/* */
#if defined(sun) || defined(__sun__) || \
defined(__SUNPRO_C) || defined(__SUNPRO_CC)
# if defined(__SVR4) || defined(__srv4__)
# define PLATFORM_SOLARIS
# else
# define PLATFORM_SUNOS4
# endif
# if defined(__SVR4) || defined(__srv4__)
# define PLATFORM_SOLARIS
# else
# define PLATFORM_SUNOS4
# endif
#endif
#if (defined(_AIX) || defined(__xlC__)) && !defined(_AIX41)
# define PLATFORM_AIX_V3
# define PLATFORM_AIX_V3
#endif
/* */
#if defined(PLATFORM_SUNOS4) || defined(PLATFORM_AIX_V3)
@ -55,52 +55,47 @@ int main(void)
#endif
/* tests for gethostbyname_r */
#if defined(HAVE_GETHOSTBYNAME_R_3_REENTRANT) || \
defined(HAVE_GETHOSTBYNAME_R_5_REENTRANT) || \
defined(HAVE_GETHOSTBYNAME_R_6_REENTRANT)
# define _REENTRANT
/* no idea whether _REENTRANT is always set, just invent a new flag */
# define TEST_GETHOSTBYFOO_REENTRANT
#endif
#if defined(HAVE_GETHOSTBYNAME_R_3) || \
defined(HAVE_GETHOSTBYNAME_R_3_REENTRANT) || \
defined(HAVE_GETHOSTBYNAME_R_5) || \
defined(HAVE_GETHOSTBYNAME_R_5_REENTRANT) || \
defined(HAVE_GETHOSTBYNAME_R_6) || \
defined(TEST_GETHOSTBYFOO_REENTRANT)
defined(HAVE_GETHOSTBYNAME_R_6_REENTRANT)
#include <sys/types.h>
#include <netdb.h>
int main(void)
{
const char *address = "example.com";
int length = 0;
int type = 0;
struct hostent h;
int rc = 0;
#if defined(HAVE_GETHOSTBYNAME_R_3) || \
defined(HAVE_GETHOSTBYNAME_R_3_REENTRANT)
#if defined(HAVE_GETHOSTBYNAME_R_3) || \
defined(HAVE_GETHOSTBYNAME_R_3_REENTRANT)
struct hostent_data hdata;
#elif defined(HAVE_GETHOSTBYNAME_R_5) || \
defined(HAVE_GETHOSTBYNAME_R_5_REENTRANT) || \
defined(HAVE_GETHOSTBYNAME_R_6) || \
defined(HAVE_GETHOSTBYNAME_R_6_REENTRANT)
char buffer[8192];
int h_errnop;
struct hostent *hp;
int h_errnop;
#endif
#if defined(HAVE_GETHOSTBYNAME_R_3) || \
defined(HAVE_GETHOSTBYNAME_R_3_REENTRANT)
rc = gethostbyname_r(address, &h, &hdata);
(void)hdata;
#elif defined(HAVE_GETHOSTBYNAME_R_5) || \
defined(HAVE_GETHOSTBYNAME_R_5_REENTRANT)
rc = gethostbyname_r(address, &h, buffer, 8192, &h_errnop);
(void)hp; /* not used for test */
(void)h_errnop;
#elif defined(HAVE_GETHOSTBYNAME_R_6) || \
defined(HAVE_GETHOSTBYNAME_R_6_REENTRANT)
rc = gethostbyname_r(address, &h, buffer, 8192, &hp, &h_errnop);
(void)hp;
(void)h_errnop;
#endif
(void)length;
(void)type;
(void)h;
(void)rc;
return 0;
}
@ -115,10 +110,7 @@ int main(void)
#endif
int main(void)
{
if(sizeof(bool *))
return 0;
;
return 0;
return (int)sizeof(bool *);
}
#endif
@ -131,18 +123,20 @@ int main(void) { return 0; }
#endif
#ifdef HAVE_FILE_OFFSET_BITS
#undef _FILE_OFFSET_BITS
#define _FILE_OFFSET_BITS 64
#include <sys/types.h>
/* Check that off_t can represent 2**63 - 1 correctly.
We cannot simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
int main(void) { return 0; }
static int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 &&
LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
int main(void)
{
(void)off_t_is_large;
return 0;
}
#endif
#ifdef HAVE_IOCTLSOCKET
@ -154,7 +148,7 @@ int main(void)
/* ioctlsocket source code */
int socket = -1;
unsigned long flags = ioctlsocket(socket, FIONBIO, &flags);
;
(void)flags;
return 0;
}
@ -167,7 +161,6 @@ int main(void)
/* IoctlSocket source code */
if(0 != IoctlSocket(0, 0, 0))
return 1;
;
return 0;
}
#endif
@ -183,7 +176,7 @@ int main(void)
long flags = 0;
if(0 != IoctlSocket(0, FIONBIO, &flags))
return 1;
;
(void)flags;
return 0;
}
#endif
@ -197,7 +190,7 @@ int main(void)
unsigned long flags = 0;
if(0 != ioctlsocket(0, FIONBIO, &flags))
return 1;
;
(void)flags;
return 0;
}
#endif
@ -224,7 +217,7 @@ int main(void)
int flags = 0;
if(0 != ioctl(0, FIONBIO, &flags))
return 1;
;
(void)flags;
return 0;
}
#endif
@ -252,7 +245,7 @@ int main(void)
struct ifreq ifr;
if(0 != ioctl(0, SIOCGIFADDR, &ifr))
return 1;
;
(void)ifr;
return 0;
}
#endif
@ -271,7 +264,6 @@ int main(void)
{
if(0 != setsockopt(0, SOL_SOCKET, SO_NONBLOCK, 0, 0))
return 1;
;
return 0;
}
#endif
@ -280,7 +272,7 @@ int main(void)
#include <string.h>
#include <errno.h>
void check(char c) {}
static void check(char c) { (void)c; }
int main(void)
{
@ -296,7 +288,7 @@ int main(void)
#include <errno.h>
/* Float, because a pointer cannot be implicitly cast to float */
void check(float f) {}
static void check(float f) { (void)f; }
int main(void)
{
@ -329,8 +321,9 @@ int main(void)
#include <time.h>
int main(void)
{
struct timespec ts = {0, 0};
clock_gettime(CLOCK_MONOTONIC, &ts);
struct timespec ts;
(void)clock_gettime(CLOCK_MONOTONIC, &ts);
(void)ts;
return 0;
}
#endif

View File

@ -107,11 +107,10 @@ if(NOT DEFINED HAVE_GETADDRINFO_THREADSAFE)
check_c_source_compiles("${_source_epilogue}
int main(void)
{
#ifdef h_errno
return 0;
#else
#ifndef h_errno
#error force compilation error
#endif
return 0;
}" HAVE_H_ERRNO)
if(NOT HAVE_H_ERRNO)
@ -127,12 +126,11 @@ if(NOT DEFINED HAVE_GETADDRINFO_THREADSAFE)
int main(void)
{
#if defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200809L)
return 0;
#elif defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 700)
return 0;
#else
#error force compilation error
#endif
return 0;
}" HAVE_H_ERRNO_SBS_ISSUE_7)
endif()
endif()

View File

@ -44,6 +44,15 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
list(APPEND _picky "-Werror-implicit-function-declaration") # clang 1.0 gcc 2.95
endif()
if(MSVC)
if(CMAKE_C_FLAGS MATCHES "[/-]W[0-4]")
string(REGEX REPLACE "[/-]W[0-4]" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
endif()
list(APPEND _picky "-W4")
elseif(BORLAND)
list(APPEND _picky "-w-") # Disable warnings on Borland to avoid changing 3rd party code.
endif()
if(PICKY_COMPILER)
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")

View File

@ -511,11 +511,6 @@ if(ENABLE_CURL_MANUAL OR BUILD_LIBCURL_DOCS)
endif()
endif()
# Disable warnings on Borland to avoid changing 3rd party code.
if(BORLAND)
string(APPEND CMAKE_C_FLAGS " -w-")
endif()
# If we are on AIX, do the _ALL_SOURCE magic
if(CMAKE_SYSTEM_NAME STREQUAL "AIX")
add_definitions("-D_ALL_SOURCE")
@ -1813,17 +1808,44 @@ foreach(_curl_test IN ITEMS
HAVE_GETHOSTBYNAME_R_3
HAVE_GETHOSTBYNAME_R_5
HAVE_GETHOSTBYNAME_R_6
HAVE_GETHOSTBYNAME_R_3_REENTRANT
HAVE_GETHOSTBYNAME_R_5_REENTRANT
HAVE_GETHOSTBYNAME_R_6_REENTRANT
HAVE_BOOL_T
STDC_HEADERS
HAVE_FILE_OFFSET_BITS
HAVE_ATOMIC
)
curl_internal_test(${_curl_test})
endforeach()
# Check for reentrant
cmake_push_check_state()
list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_REENTRANT")
foreach(_curl_test IN ITEMS
HAVE_GETHOSTBYNAME_R_3
HAVE_GETHOSTBYNAME_R_5
HAVE_GETHOSTBYNAME_R_6)
curl_internal_test(${_curl_test}_REENTRANT)
if(NOT ${_curl_test} AND ${_curl_test}_REENTRANT)
set(NEED_REENTRANT 1)
endif()
endforeach()
cmake_pop_check_state()
if(NEED_REENTRANT)
foreach(_curl_test IN ITEMS
HAVE_GETHOSTBYNAME_R_3
HAVE_GETHOSTBYNAME_R_5
HAVE_GETHOSTBYNAME_R_6)
set(${_curl_test} 0)
if(${_curl_test}_REENTRANT)
set(${_curl_test} 1)
endif()
endforeach()
endif()
cmake_push_check_state()
list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_FILE_OFFSET_BITS=64")
curl_internal_test(HAVE_FILE_OFFSET_BITS)
cmake_pop_check_state()
cmake_push_check_state()
if(HAVE_FILE_OFFSET_BITS)
set(_FILE_OFFSET_BITS 64)
@ -1877,30 +1899,6 @@ endif()
curl_internal_test(HAVE_GLIBC_STRERROR_R)
curl_internal_test(HAVE_POSIX_STRERROR_R)
# Check for reentrant
foreach(_curl_test IN ITEMS
HAVE_GETHOSTBYNAME_R_3
HAVE_GETHOSTBYNAME_R_5
HAVE_GETHOSTBYNAME_R_6)
if(NOT ${_curl_test})
if(${_curl_test}_REENTRANT)
set(NEED_REENTRANT 1)
endif()
endif()
endforeach()
if(NEED_REENTRANT)
foreach(_curl_test IN ITEMS
HAVE_GETHOSTBYNAME_R_3
HAVE_GETHOSTBYNAME_R_5
HAVE_GETHOSTBYNAME_R_6)
set(${_curl_test} 0)
if(${_curl_test}_REENTRANT)
set(${_curl_test} 1)
endif()
endforeach()
endif()
if(NOT WIN32)
curl_internal_test(HAVE_CLOCK_GETTIME_MONOTONIC) # Check clock_gettime(CLOCK_MONOTONIC, x) support
endif()
@ -1962,12 +1960,6 @@ if(MSVC)
# Disable default manifest added by CMake
string(APPEND CMAKE_EXE_LINKER_FLAGS " -MANIFEST:NO")
if(CMAKE_C_FLAGS MATCHES "[/-]W[0-4]")
string(REGEX REPLACE "[/-]W[0-4]" "-W4" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
else()
string(APPEND CMAKE_C_FLAGS " -W4")
endif()
# Use multithreaded compilation on VS2008+
if(CMAKE_C_COMPILER_ID STREQUAL "MSVC" AND MSVC_VERSION GREATER_EQUAL 1500)
string(APPEND CMAKE_C_FLAGS " -MP")

View File

@ -48,7 +48,7 @@ AC_DEFUN([CURL_CHECK_DEF], [
tmp_exp=""
AC_PREPROC_IFELSE([
AC_LANG_SOURCE(
ifelse($2,,,[$2])[[
ifelse($2,,,[$2])[[
#ifdef $1
CURL_DEF_TOKEN $1
#endif
@ -88,14 +88,13 @@ AC_DEFUN([CURL_CHECK_DEF_CC], [
ifelse($3,,[AC_MSG_CHECKING([for compiler definition of $1])])
AC_COMPILE_IFELSE([
AC_LANG_SOURCE(
ifelse($2,,,[$2])[[
ifelse($2,,,[$2])[[
int main(void)
{
#ifdef $1
return 0;
#else
#ifndef $1
#error force compilation error
#endif
return 0;
}
]])
],[
@ -126,12 +125,11 @@ AC_DEFUN([CURL_CHECK_LIB_XNET], [
int main(void)
{
#if defined(__hpux) && defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 600)
return 0;
#elif defined(__hpux) && defined(_XOPEN_SOURCE_EXTENDED)
return 0;
#else
#error force compilation error
#endif
return 0;
}
]])
],[
@ -180,7 +178,8 @@ AC_DEFUN([CURL_CHECK_NATIVE_WINDOWS], [
AC_LANG_PROGRAM([[
]],[[
#ifdef _WIN32
int dummy=1;
int dummy = 1;
(void)dummy;
#else
#error Not a native Windows build target.
#endif
@ -306,6 +305,7 @@ AC_DEFUN([CURL_CHECK_HEADER_LDAP], [
]],[[
LDAP *ldp = ldap_init("0.0.0.0", LDAP_PORT);
int res = ldap_unbind(ldp);
(void)res;
]])
],[
curl_cv_header_ldap_h="yes"
@ -354,6 +354,7 @@ AC_DEFUN([CURL_CHECK_HEADER_LDAP_SSL], [
#include <ldap_ssl.h>
]],[[
LDAP *ldp = ldapssl_init("0.0.0.0", LDAPS_PORT, 1);
(void)ldp;
]])
],[
curl_cv_header_ldap_ssl_h="yes"
@ -433,6 +434,7 @@ AC_DEFUN([CURL_CHECK_LIBS_WINLDAP], [
LDAP *ldp = ldap_init("0.0.0.0", LDAP_PORT);
ULONG res = ldap_unbind(ldp);
ber_free(bep, 1);
(void)res;
]])
],[
curl_cv_ldap_LIBS="$x_nlibs"
@ -543,6 +545,7 @@ AC_DEFUN([CURL_CHECK_LIBS_LDAP], [
LDAP *ldp = ldap_init("0.0.0.0", LDAP_PORT);
int res = ldap_unbind(ldp);
ber_free(bep, 1);
(void)res;
]])
],[
curl_cv_ldap_LIBS="$x_nlibs"
@ -729,7 +732,8 @@ AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
#endif
#endif
]],[[
int flag=MSG_NOSIGNAL;
int flag = MSG_NOSIGNAL;
(void)flag;
]])
],[
curl_cv_msg_nosignal="yes"
@ -777,6 +781,7 @@ AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
struct timeval ts;
ts.tv_sec = 0;
ts.tv_usec = 0;
(void)ts;
]])
],[
curl_cv_struct_timeval="yes"
@ -814,6 +819,7 @@ AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC], [
]],[[
struct timespec ts;
(void)clock_gettime(CLOCK_MONOTONIC, &ts);
(void)ts;
]])
],[
AC_MSG_RESULT([yes])
@ -848,6 +854,7 @@ AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC_RAW], [
]],[[
struct timespec ts;
(void)clock_gettime(CLOCK_MONOTONIC_RAW, &ts);
(void)ts;
]])
],[
AC_MSG_RESULT([yes])
@ -894,6 +901,7 @@ AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [
]],[[
struct timespec ts;
(void)clock_gettime(CLOCK_MONOTONIC, &ts);
(void)ts;
]])
],[
curl_cv_gclk_LIBS="$x_xlibs"
@ -940,10 +948,10 @@ AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [
#include <time.h>
]],[[
struct timespec ts;
if (0 == clock_gettime(CLOCK_MONOTONIC, &ts))
exit(0);
else
exit(1);
if(0 == clock_gettime(CLOCK_MONOTONIC, &ts))
return 0;
(void)ts;
return 1;
]])
],[
AC_MSG_RESULT([yes])
@ -1090,7 +1098,7 @@ AC_DEFUN([CURL_VERIFY_RUNTIMELIBS], [
dnl point also is available run-time!
AC_MSG_CHECKING([run-time libs availability])
CURL_RUN_IFELSE([
int main()
int main(void)
{
return 0;
}

View File

@ -1243,7 +1243,8 @@ if test "$HAVE_GETHOSTBYNAME" != "1" -o "${with_amissl+set}" = set; then
struct Library *SocketBase = NULL;
#endif
]],[[
gethostbyname("localhost");
unsigned char host[] = "localhost";
gethostbyname(host);
]])
],[
AC_MSG_RESULT([yes])
@ -1717,10 +1718,9 @@ AS_HELP_STRING([--disable-ipv6],[Disable IPv6 support]),
#include <netinet/in6.h>
#endif
#endif
int main(void)
{
struct sockaddr_in6 s;
int s = (int)sizeof(struct sockaddr_in6);
(void)s;
return socket(AF_INET6, SOCK_STREAM, 0) < 0;
}
@ -1754,6 +1754,7 @@ if test "$ipv6" = yes; then
]], [[
struct sockaddr_in6 s;
s.sin6_scope_id = 0;
(void)s;
]])
],[
AC_MSG_RESULT([yes])

View File

@ -1310,9 +1310,10 @@ AC_DEFUN([CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE], [
AC_MSG_CHECKING([if compiler halts on negative sized arrays])
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([[
typedef char bad_t[sizeof(char) == sizeof(int) ? -1 : -1 ];
typedef char bad_t[sizeof(char) == sizeof(int) ? -1 : -1];
]],[[
bad_t dummy;
(void)dummy;
]])
],[
AC_MSG_RESULT([no])
@ -1342,11 +1343,13 @@ AC_DEFUN([CURL_CHECK_COMPILER_STRUCT_MEMBER_SIZE], [
struct mystruct *next;
};
struct mystruct myfunc();
typedef char good_t1[sizeof(myfunc().mi) == sizeof(int) ? 1 : -1 ];
typedef char good_t2[sizeof(myfunc().mc) == sizeof(char) ? 1 : -1 ];
typedef char good_t1[sizeof(myfunc().mi) == sizeof(int) ? 1 : -1];
typedef char good_t2[sizeof(myfunc().mc) == sizeof(char) ? 1 : -1];
]],[[
good_t1 dummy1;
good_t2 dummy2;
(void)dummy1;
(void)dummy2;
]])
],[
tst_compiler_check_one_works="yes"
@ -1364,11 +1367,13 @@ AC_DEFUN([CURL_CHECK_COMPILER_STRUCT_MEMBER_SIZE], [
struct mystruct *next;
};
struct mystruct myfunc();
typedef char bad_t1[sizeof(myfunc().mi) != sizeof(int) ? 1 : -1 ];
typedef char bad_t2[sizeof(myfunc().mc) != sizeof(char) ? 1 : -1 ];
typedef char bad_t1[sizeof(myfunc().mi) != sizeof(int) ? 1 : -1];
typedef char bad_t2[sizeof(myfunc().mc) != sizeof(char) ? 1 : -1];
]],[[
bad_t1 dummy1;
bad_t2 dummy2;
(void)dummy1;
(void)dummy2;
]])
],[
tst_compiler_check_two_works="no"
@ -1452,8 +1457,8 @@ AC_DEFUN([CURL_CHECK_COMPILER_SYMBOL_HIDING], [
squeeze CFLAGS
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([[
$tmp_EXTERN char *dummy(char *buff);
char *dummy(char *buff)
$tmp_EXTERN const char *dummy(const char *buff);
const char *dummy(const char *buff)
{
if(buff)
return ++buff;
@ -1461,8 +1466,8 @@ AC_DEFUN([CURL_CHECK_COMPILER_SYMBOL_HIDING], [
return buff;
}
]],[[
char b[16];
char *r = dummy(&b[0]);
const char *b = "example";
const char *r = dummy(&b[0]);
if(r)
return (int)*r;
]])

View File

@ -504,11 +504,11 @@ AC_DEFUN([CURL_CHECK_LIB_ARES], [
AC_LANG_PROGRAM([[
#include <ares.h>
/* set of dummy functions in case c-ares was built with debug */
void curl_dofree() { }
void curl_sclose() { }
void curl_domalloc() { }
void curl_docalloc() { }
void curl_socket() { }
void curl_dofree(void); void curl_dofree(void) {}
void curl_sclose(void); void curl_sclose(void) {}
void curl_domalloc(void); void curl_domalloc(void) {}
void curl_docalloc(void); void curl_docalloc(void) {}
void curl_socket(void); void curl_socket(void) {}
]],[[
ares_channel channel;
ares_cancel(channel); /* added in 1.2.0 */

View File

@ -1710,7 +1710,12 @@ AC_DEFUN([CURL_CHECK_FUNC_GETHOSTNAME], [
$curl_includes_unistd
$curl_includes_bsdsocket
$curl_preprocess_callconv
extern int FUNCALLCONV gethostname($tst_arg1, $tst_arg2);
#if defined(_WIN32) && defined(WINSOCK_API_LINKAGE)
WINSOCK_API_LINKAGE
#else
extern
#endif
int FUNCALLCONV gethostname($tst_arg1, $tst_arg2);
]],[[
if(0 != gethostname(0, 0))
return 1;
@ -2140,6 +2145,7 @@ AC_DEFUN([CURL_CHECK_FUNC_GMTIME_R], [
struct tm *gmt = 0;
struct tm result;
gmt = gmtime_r(&local, &result);
(void)result;
if(gmt)
exit(0);
else
@ -2258,8 +2264,8 @@ AC_DEFUN([CURL_CHECK_FUNC_INET_NTOP], [
char ipv4res[sizeof "255.255.255.255"];
unsigned char ipv6a[26];
unsigned char ipv4a[5];
char *ipv6ptr = 0;
char *ipv4ptr = 0;
const char *ipv6ptr = 0;
const char *ipv4ptr = 0;
/* - */
ipv4res[0] = '\0';
ipv4a[0] = 0xc0;
@ -3004,7 +3010,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;
]])
],[
@ -3666,7 +3672,7 @@ AC_DEFUN([CURL_CHECK_FUNC_STRCASECMP], [
AC_LANG_PROGRAM([[
$curl_includes_string
]],[[
if(0 != strcasecmp(0, 0))
if(0 != strcasecmp("", ""))
return 1;
]])
],[
@ -3965,8 +3971,10 @@ AC_DEFUN([CURL_CHECK_FUNC_STRERROR_R], [
$curl_includes_string
char *strerror_r(int errnum, char *workbuf, $arg3 bufsize);
]],[[
if(0 != strerror_r(0, 0, 0))
char s[1];
if(0 != strerror_r(0, s, 0))
return 1;
(void)s;
]])
],[
tst_glibc_strerror_r_type_arg3="$arg3"
@ -3993,7 +4001,7 @@ AC_DEFUN([CURL_CHECK_FUNC_STRERROR_R], [
AC_LANG_PROGRAM([[
$curl_includes_stdlib
$curl_includes_string
# include <errno.h>
#include <errno.h>
]],[[
char buffer[1024];
char *string = 0;
@ -4026,8 +4034,10 @@ AC_DEFUN([CURL_CHECK_FUNC_STRERROR_R], [
$curl_includes_string
int strerror_r(int errnum, char *resultbuf, $arg3 bufsize);
]],[[
if(0 != strerror_r(0, 0, 0))
char s[1];
if(0 != strerror_r(0, s, 0))
return 1;
(void)s;
]])
],[
tst_posix_strerror_r_type_arg3="$arg3"
@ -4054,7 +4064,7 @@ AC_DEFUN([CURL_CHECK_FUNC_STRERROR_R], [
AC_LANG_PROGRAM([[
$curl_includes_stdlib
$curl_includes_string
# include <errno.h>
#include <errno.h>
]],[[
char buffer[1024];
int error = 1;
@ -4266,7 +4276,7 @@ AC_DEFUN([CURL_CHECK_FUNC_STRTOK_R], [
AC_LANG_PROGRAM([[
$curl_includes_string
]],[[
if(0 != strtok_r(0, 0, 0))
if(0 != strtok_r(0, "", 0))
return 1;
]])
],[
@ -4351,7 +4361,7 @@ AC_DEFUN([CURL_CHECK_FUNC_STRTOLL], [
AC_LANG_PROGRAM([[
$curl_includes_stdlib
]],[[
if(0 != strtoll(0, 0, 0))
if(0 != strtoll("", 0, 0))
return 1;
]])
],[
@ -4463,6 +4473,7 @@ AC_DEFUN([CURL_ATOMIC],[
]],[[
_Atomic int i = 0;
i = 4; // Force an atomic-write operation.
(void)i;
]])
],[
AC_MSG_RESULT([yes])

View File

@ -46,6 +46,9 @@ if test "x$OPT_OPENSSL" != xno; then
my_ac_save_LIBS=$LIBS
LIBS="-lgdi32 $LIBS"
AC_LINK_IFELSE([ AC_LANG_PROGRAM([[
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windef.h>
#include <wingdi.h>
]],
@ -284,6 +287,7 @@ if test "x$OPT_OPENSSL" != xno; then
#include <openssl/opensslv.h>
]],[[
int dummy = LIBRESSL_VERSION_NUMBER;
(void)dummy;
]])
],[
AC_MSG_RESULT([yes])
@ -352,10 +356,13 @@ if test "$OPENSSL_ENABLED" = "1"; then
AC_MSG_CHECKING([for SRP support in OpenSSL])
AC_LINK_IFELSE([
AC_LANG_PROGRAM([[
#ifndef OPENSSL_SUPPRESS_DEPRECATED
#define OPENSSL_SUPPRESS_DEPRECATED
#endif
#include <openssl/ssl.h>
]],[[
SSL_CTX_set_srp_username(NULL, "");
SSL_CTX_set_srp_password(NULL, "");
SSL_CTX_set_srp_username(NULL, NULL);
SSL_CTX_set_srp_password(NULL, NULL);
]])
],[
AC_MSG_RESULT([yes])

View File

@ -51,8 +51,7 @@ m4_define([AC_LANG_PROGRAM(C)],
int main(void)
{
$2
;
return 0;
return 0;
}])
dnl Override Autoconf's AC_LANG_CALL (C)

View File

@ -56,7 +56,8 @@ AC_DEFUN([CURL_CHECK_NEED_REENTRANT_ERRNO], [
#include <errno.h>
]],[[
#ifdef errno
int dummy=1;
int dummy = 1;
(void)dummy;
#else
#error force compilation error
#endif
@ -70,7 +71,8 @@ AC_DEFUN([CURL_CHECK_NEED_REENTRANT_ERRNO], [
#include <errno.h>
]],[[
#ifdef errno
int dummy=1;
int dummy = 1;
(void)dummy;
#else
#error force compilation error
#endif
@ -411,7 +413,8 @@ AC_DEFUN([CURL_CONFIGURE_REENTRANT], [
AC_LANG_PROGRAM([[
]],[[
#ifdef _REENTRANT
int dummy=1;
int dummy = 1;
(void)dummy;
#else
#error force compilation error
#endif
@ -471,7 +474,8 @@ AC_DEFUN([CURL_CONFIGURE_THREAD_SAFE], [
AC_LANG_PROGRAM([[
]],[[
#ifdef _THREAD_SAFE
int dummy=1;
int dummy = 1;
(void)dummy;
#else
#error force compilation error
#endif