From: Viktor Szakats Date: Fri, 13 Oct 2023 00:25:20 +0000 (+0000) Subject: build: variadic macro tidy-ups X-Git-Tag: curl-8_5_0~191 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a426b5050f778fc8f0198bcca62a30928919fce6;p=thirdparty%2Fcurl.git build: variadic macro tidy-ups - delete unused `HAVE_VARIADIC_MACROS_C99/GCC` feature checks. (both autotools and CMake.) - delete duplicate `NULL` check in `Curl_trc_cf_infof()`. - fix compiler warning in `CURL_DISABLE_VERBOSE_STRINGS` builds. ``` ./lib/cf-socket.c:122:41: warning: unused parameter 'data' [-Wunused-parameter] static void nosigpipe(struct Curl_easy *data, ^ ``` - fix `#ifdef` comments in `lib/curl_trc.{c,h}`. - fix indentation in some `infof()` calls. Follow-up to dac293cfb7026b1ca4175d88b80f1432d3d3c684 #12167 Cherry-picked from #12105 Closes #12210 --- diff --git a/CMake/CurlTests.c b/CMake/CurlTests.c index 67f146899b..e546286264 100644 --- a/CMake/CurlTests.c +++ b/CMake/CurlTests.c @@ -400,58 +400,6 @@ int main(void) } #endif -#ifdef HAVE_VARIADIC_MACROS_C99 -#define c99_vmacro3(first, ...) fun3(first, __VA_ARGS__) -#define c99_vmacro2(first, ...) fun2(first, __VA_ARGS__) - -int fun3(int arg1, int arg2, int arg3); -int fun2(int arg1, int arg2); - -int fun3(int arg1, int arg2, int arg3) -{ - return arg1 + arg2 + arg3; -} -int fun2(int arg1, int arg2) -{ - return arg1 + arg2; -} - -int main(void) -{ - int res3 = c99_vmacro3(1, 2, 3); - int res2 = c99_vmacro2(1, 2); - (void)res3; - (void)res2; - return 0; -} -#endif - -#ifdef HAVE_VARIADIC_MACROS_GCC -#define gcc_vmacro3(first, args...) fun3(first, args) -#define gcc_vmacro2(first, args...) fun2(first, args) - -int fun3(int arg1, int arg2, int arg3); -int fun2(int arg1, int arg2); - -int fun3(int arg1, int arg2, int arg3) -{ - return arg1 + arg2 + arg3; -} -int fun2(int arg1, int arg2) -{ - return arg1 + arg2; -} - -int main(void) -{ - int res3 = gcc_vmacro3(1, 2, 3); - int res2 = gcc_vmacro2(1, 2); - (void)res3; - (void)res2; - return 0; -} -#endif - #ifdef HAVE_ATOMIC /* includes start */ #ifdef HAVE_SYS_TYPES_H diff --git a/CMake/Platforms/WindowsCache.cmake b/CMake/Platforms/WindowsCache.cmake index 66ebab2cfd..c6610d0a8c 100644 --- a/CMake/Platforms/WindowsCache.cmake +++ b/CMake/Platforms/WindowsCache.cmake @@ -55,11 +55,6 @@ else() set(HAVE_LOCALE_H 1) set(HAVE_STDDEF_H 1) # detected by CMake internally in check_type_size() set(HAVE_STDATOMIC_H 0) - if(NOT MSVC_VERSION LESS 1400) - set(HAVE_VARIADIC_MACROS_C99 1) - else() - set(HAVE_VARIADIC_MACROS_C99 0) - endif() if(NOT MSVC_VERSION LESS 1600) set(HAVE_STDINT_H 1) else() diff --git a/CMakeLists.txt b/CMakeLists.txt index 22832a5bcc..0654aee871 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1297,8 +1297,6 @@ foreach(CURL_TEST HAVE_BOOL_T STDC_HEADERS HAVE_FILE_OFFSET_BITS - HAVE_VARIADIC_MACROS_C99 - HAVE_VARIADIC_MACROS_GCC HAVE_ATOMIC ) curl_internal_test(${CURL_TEST}) diff --git a/acinclude.m4 b/acinclude.m4 index 18a56be8f7..ac026e39d2 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -1374,70 +1374,6 @@ int main() ]) -dnl CURL_CHECK_VARIADIC_MACROS -dnl ------------------------------------------------- -dnl Check compiler support of variadic macros - -AC_DEFUN([CURL_CHECK_VARIADIC_MACROS], [ - AC_CACHE_CHECK([for compiler support of C99 variadic macro style], - [curl_cv_variadic_macros_c99], [ - AC_COMPILE_IFELSE([ - AC_LANG_PROGRAM([[ -#define c99_vmacro3(first, ...) fun3(first, __VA_ARGS__) -#define c99_vmacro2(first, ...) fun2(first, __VA_ARGS__) - int fun3(int arg1, int arg2, int arg3); - int fun2(int arg1, int arg2); - int fun3(int arg1, int arg2, int arg3) - { return arg1 + arg2 + arg3; } - int fun2(int arg1, int arg2) - { return arg1 + arg2; } - ]],[[ - int res3 = c99_vmacro3(1, 2, 3); - int res2 = c99_vmacro2(1, 2); - ]]) - ],[ - curl_cv_variadic_macros_c99="yes" - ],[ - curl_cv_variadic_macros_c99="no" - ]) - ]) - case "$curl_cv_variadic_macros_c99" in - yes) - AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_C99, 1, - [Define to 1 if compiler supports C99 variadic macro style.]) - ;; - esac - AC_CACHE_CHECK([for compiler support of old gcc variadic macro style], - [curl_cv_variadic_macros_gcc], [ - AC_COMPILE_IFELSE([ - AC_LANG_PROGRAM([[ -#define gcc_vmacro3(first, args...) fun3(first, args) -#define gcc_vmacro2(first, args...) fun2(first, args) - int fun3(int arg1, int arg2, int arg3); - int fun2(int arg1, int arg2); - int fun3(int arg1, int arg2, int arg3) - { return arg1 + arg2 + arg3; } - int fun2(int arg1, int arg2) - { return arg1 + arg2; } - ]],[[ - int res3 = gcc_vmacro3(1, 2, 3); - int res2 = gcc_vmacro2(1, 2); - ]]) - ],[ - curl_cv_variadic_macros_gcc="yes" - ],[ - curl_cv_variadic_macros_gcc="no" - ]) - ]) - case "$curl_cv_variadic_macros_gcc" in - yes) - AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_GCC, 1, - [Define to 1 if compiler supports old gcc variadic macro style.]) - ;; - esac -]) - - dnl CURL_CHECK_CA_BUNDLE dnl ------------------------------------------------- dnl Check if a default ca-bundle should be used diff --git a/configure.ac b/configure.ac index da2523d00e..a80748c10e 100644 --- a/configure.ac +++ b/configure.ac @@ -3418,7 +3418,6 @@ dnl default includes dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST -CURL_CHECK_VARIADIC_MACROS AC_TYPE_SIZE_T CURL_CHECK_STRUCT_TIMEVAL diff --git a/lib/cf-socket.c b/lib/cf-socket.c index 870bc978b2..a782291855 100644 --- a/lib/cf-socket.c +++ b/lib/cf-socket.c @@ -123,6 +123,7 @@ static void nosigpipe(struct Curl_easy *data, curl_socket_t sockfd) { int onoff = 1; + (void)data; if(setsockopt(sockfd, SOL_SOCKET, SO_NOSIGPIPE, (void *)&onoff, sizeof(onoff)) < 0) { #if !defined(CURL_DISABLE_VERBOSE_STRINGS) diff --git a/lib/config-dos.h b/lib/config-dos.h index 550c410a12..c6fbba796a 100644 --- a/lib/config-dos.h +++ b/lib/config-dos.h @@ -122,7 +122,6 @@ #define HAVE_SIGSETJMP 1 #define HAVE_SYS_TIME_H 1 #define HAVE_TERMIOS_H 1 - #define HAVE_VARIADIC_MACROS_GCC 1 #elif defined(__HIGHC__) #define HAVE_SYS_TIME_H 1 diff --git a/lib/config-win32.h b/lib/config-win32.h index d1aceaac3c..6d110eb768 100644 --- a/lib/config-win32.h +++ b/lib/config-win32.h @@ -377,11 +377,6 @@ /* Windows should not have HAVE_GMTIME_R defined */ /* #undef HAVE_GMTIME_R */ -/* Define if the compiler supports C99 variadic macro style. */ -#if defined(_MSC_VER) && (_MSC_VER >= 1400) -#define HAVE_VARIADIC_MACROS_C99 1 -#endif - /* Define if the compiler supports the 'long long' data type. */ #if defined(__MINGW32__) || \ (defined(_MSC_VER) && (_MSC_VER >= 1310)) || \ diff --git a/lib/curl_config.h.cmake b/lib/curl_config.h.cmake index e12e7a1242..e512dce45f 100644 --- a/lib/curl_config.h.cmake +++ b/lib/curl_config.h.cmake @@ -602,12 +602,6 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_UTIME_H 1 -/* Define to 1 if compiler supports C99 variadic macro style. */ -#cmakedefine HAVE_VARIADIC_MACROS_C99 1 - -/* Define to 1 if compiler supports old gcc variadic macro style. */ -#cmakedefine HAVE_VARIADIC_MACROS_GCC 1 - /* Define to 1 if you have the windows.h header file. */ #cmakedefine HAVE_WINDOWS_H 1 diff --git a/lib/curl_trc.c b/lib/curl_trc.c index d338d52fba..0ebe40b8f7 100644 --- a/lib/curl_trc.c +++ b/lib/curl_trc.c @@ -130,7 +130,7 @@ void Curl_trc_cf_infof(struct Curl_easy *data, struct Curl_cfilter *cf, const char *fmt, ...) { DEBUGASSERT(cf); - if(data && Curl_trc_cf_is_verbose(cf, data)) { + if(Curl_trc_cf_is_verbose(cf, data)) { va_list ap; int len; char buffer[MAXINFO + 2]; @@ -228,14 +228,14 @@ CURLcode Curl_trc_init(void) if(config) { return Curl_trc_opt(config); } -#endif +#endif /* DEBUGBUILD */ return CURLE_OK; } -#else /* !CURL_DISABLE_VERBOSE_STRINGS) */ +#else /* defined(CURL_DISABLE_VERBOSE_STRINGS) */ CURLcode Curl_trc_init(void) { return CURLE_OK; } -#endif /* !DEBUGBUILD */ +#endif /* !defined(CURL_DISABLE_VERBOSE_STRINGS) */ diff --git a/lib/curl_trc.h b/lib/curl_trc.h index 1feefa974d..ade9108ac7 100644 --- a/lib/curl_trc.h +++ b/lib/curl_trc.h @@ -123,7 +123,7 @@ void Curl_trc_cf_infof(struct Curl_easy *data, struct Curl_cfilter *cf, const char *fmt, ...); #endif -#else /* !CURL_DISABLE_VERBOSE_STRINGS */ +#else /* defined(CURL_DISABLE_VERBOSE_STRINGS) */ /* All informational messages are not compiled in for size savings */ #define Curl_trc_is_verbose(d) ((void)(d), FALSE) @@ -141,6 +141,6 @@ static void Curl_trc_cf_infof(struct Curl_easy *data, (void)data; (void)cf; (void)fmt; } -#endif /* CURL_DISABLE_VERBOSE_STRINGS */ +#endif /* !defined(CURL_DISABLE_VERBOSE_STRINGS) */ #endif /* HEADER_CURL_TRC_H */ diff --git a/lib/ldap.c b/lib/ldap.c index 239d3fbf01..f3339290bb 100644 --- a/lib/ldap.c +++ b/lib/ldap.c @@ -327,7 +327,7 @@ static CURLcode ldap_do(struct Curl_easy *data, bool *done) *done = TRUE; /* unconditionally */ infof(data, "LDAP local: LDAP Vendor = %s ; LDAP Version = %d", - LDAP_VENDOR_NAME, LDAP_VENDOR_VERSION); + LDAP_VENDOR_NAME, LDAP_VENDOR_VERSION); infof(data, "LDAP local: %s", data->state.url); #ifdef HAVE_LDAP_URL_PARSE @@ -345,7 +345,7 @@ static CURLcode ldap_do(struct Curl_easy *data, bool *done) if(conn->given->flags & PROTOPT_SSL) ldap_ssl = 1; infof(data, "LDAP local: trying to establish %s connection", - ldap_ssl ? "encrypted" : "cleartext"); + ldap_ssl ? "encrypted" : "cleartext"); #if defined(USE_WIN32_LDAP) host = curlx_convert_UTF8_to_tchar(conn->host.name); diff --git a/lib/ws.c b/lib/ws.c index 3c1964b860..adde531f5e 100644 --- a/lib/ws.c +++ b/lib/ws.c @@ -274,8 +274,8 @@ static CURLcode ws_dec_pass_payload(struct ws_decoder *dec, dec->payload_offset += (curl_off_t)nwritten; remain = dec->payload_len - dec->payload_offset; /* infof(data, "WS-DEC: passed %zd bytes payload, %" - CURL_FORMAT_CURL_OFF_T " remain", - nwritten, remain); */ + CURL_FORMAT_CURL_OFF_T " remain", + nwritten, remain); */ } return remain? CURLE_AGAIN : CURLE_OK; @@ -925,8 +925,8 @@ CURL_EXTERN CURLcode curl_ws_recv(struct Curl_easy *data, void *buffer, *metap = &ws->frame; *nread = ws->frame.len; /* infof(data, "curl_ws_recv(len=%zu) -> %zu bytes (frame at %" - CURL_FORMAT_CURL_OFF_T ", %" CURL_FORMAT_CURL_OFF_T " left)", - buflen, *nread, ws->frame.offset, ws->frame.bytesleft); */ + CURL_FORMAT_CURL_OFF_T ", %" CURL_FORMAT_CURL_OFF_T " left)", + buflen, *nread, ws->frame.offset, ws->frame.bytesleft); */ return CURLE_OK; } diff --git a/tests/unit/unit2600.c b/tests/unit/unit2600.c index 3e9ecb7b09..030c80c200 100644 --- a/tests/unit/unit2600.c +++ b/tests/unit/unit2600.c @@ -124,7 +124,7 @@ static void cf_test_destroy(struct Curl_cfilter *cf, struct Curl_easy *data) struct cf_test_ctx *ctx = cf->ctx; #ifndef CURL_DISABLE_VERBOSE_STRINGS infof(data, "%04dms: cf[%s] destroyed", - (int)Curl_timediff(Curl_now(), current_tr->started), ctx->id); + (int)Curl_timediff(Curl_now(), current_tr->started), ctx->id); #else (void)data; #endif @@ -145,7 +145,7 @@ static CURLcode cf_test_connect(struct Curl_cfilter *cf, duration_ms = Curl_timediff(Curl_now(), ctx->started); if(duration_ms >= ctx->fail_delay_ms) { infof(data, "%04dms: cf[%s] fail delay reached", - (int)duration_ms, ctx->id); + (int)duration_ms, ctx->id); return CURLE_COULDNT_CONNECT; } if(duration_ms)