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 dac293cfb7 #12167

Cherry-picked from #12105
Closes #12210
This commit is contained in:
Viktor Szakats 2023-10-13 00:25:20 +00:00
parent 191e695fe4
commit a426b5050f
No known key found for this signature in database
GPG Key ID: B5ABD165E2AEF201
14 changed files with 15 additions and 150 deletions

View File

@ -400,58 +400,6 @@ int main(void)
} }
#endif #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 #ifdef HAVE_ATOMIC
/* includes start */ /* includes start */
#ifdef HAVE_SYS_TYPES_H #ifdef HAVE_SYS_TYPES_H

View File

@ -55,11 +55,6 @@ else()
set(HAVE_LOCALE_H 1) set(HAVE_LOCALE_H 1)
set(HAVE_STDDEF_H 1) # detected by CMake internally in check_type_size() set(HAVE_STDDEF_H 1) # detected by CMake internally in check_type_size()
set(HAVE_STDATOMIC_H 0) 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) if(NOT MSVC_VERSION LESS 1600)
set(HAVE_STDINT_H 1) set(HAVE_STDINT_H 1)
else() else()

View File

@ -1297,8 +1297,6 @@ foreach(CURL_TEST
HAVE_BOOL_T HAVE_BOOL_T
STDC_HEADERS STDC_HEADERS
HAVE_FILE_OFFSET_BITS HAVE_FILE_OFFSET_BITS
HAVE_VARIADIC_MACROS_C99
HAVE_VARIADIC_MACROS_GCC
HAVE_ATOMIC HAVE_ATOMIC
) )
curl_internal_test(${CURL_TEST}) curl_internal_test(${CURL_TEST})

View File

@ -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 CURL_CHECK_CA_BUNDLE
dnl ------------------------------------------------- dnl -------------------------------------------------
dnl Check if a default ca-bundle should be used dnl Check if a default ca-bundle should be used

View File

@ -3418,7 +3418,6 @@ dnl default includes
dnl Checks for typedefs, structures, and compiler characteristics. dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST AC_C_CONST
CURL_CHECK_VARIADIC_MACROS
AC_TYPE_SIZE_T AC_TYPE_SIZE_T
CURL_CHECK_STRUCT_TIMEVAL CURL_CHECK_STRUCT_TIMEVAL

View File

@ -123,6 +123,7 @@ static void nosigpipe(struct Curl_easy *data,
curl_socket_t sockfd) curl_socket_t sockfd)
{ {
int onoff = 1; int onoff = 1;
(void)data;
if(setsockopt(sockfd, SOL_SOCKET, SO_NOSIGPIPE, (void *)&onoff, if(setsockopt(sockfd, SOL_SOCKET, SO_NOSIGPIPE, (void *)&onoff,
sizeof(onoff)) < 0) { sizeof(onoff)) < 0) {
#if !defined(CURL_DISABLE_VERBOSE_STRINGS) #if !defined(CURL_DISABLE_VERBOSE_STRINGS)

View File

@ -122,7 +122,6 @@
#define HAVE_SIGSETJMP 1 #define HAVE_SIGSETJMP 1
#define HAVE_SYS_TIME_H 1 #define HAVE_SYS_TIME_H 1
#define HAVE_TERMIOS_H 1 #define HAVE_TERMIOS_H 1
#define HAVE_VARIADIC_MACROS_GCC 1
#elif defined(__HIGHC__) #elif defined(__HIGHC__)
#define HAVE_SYS_TIME_H 1 #define HAVE_SYS_TIME_H 1

View File

@ -377,11 +377,6 @@
/* Windows should not have HAVE_GMTIME_R defined */ /* Windows should not have HAVE_GMTIME_R defined */
/* #undef HAVE_GMTIME_R */ /* #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. */ /* Define if the compiler supports the 'long long' data type. */
#if defined(__MINGW32__) || \ #if defined(__MINGW32__) || \
(defined(_MSC_VER) && (_MSC_VER >= 1310)) || \ (defined(_MSC_VER) && (_MSC_VER >= 1310)) || \

View File

@ -602,12 +602,6 @@
/* Define to 1 if you have the <utime.h> header file. */ /* Define to 1 if you have the <utime.h> header file. */
#cmakedefine HAVE_UTIME_H 1 #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. */ /* Define to 1 if you have the windows.h header file. */
#cmakedefine HAVE_WINDOWS_H 1 #cmakedefine HAVE_WINDOWS_H 1

View File

@ -130,7 +130,7 @@ void Curl_trc_cf_infof(struct Curl_easy *data, struct Curl_cfilter *cf,
const char *fmt, ...) const char *fmt, ...)
{ {
DEBUGASSERT(cf); DEBUGASSERT(cf);
if(data && Curl_trc_cf_is_verbose(cf, data)) { if(Curl_trc_cf_is_verbose(cf, data)) {
va_list ap; va_list ap;
int len; int len;
char buffer[MAXINFO + 2]; char buffer[MAXINFO + 2];
@ -228,14 +228,14 @@ CURLcode Curl_trc_init(void)
if(config) { if(config) {
return Curl_trc_opt(config); return Curl_trc_opt(config);
} }
#endif #endif /* DEBUGBUILD */
return CURLE_OK; return CURLE_OK;
} }
#else /* !CURL_DISABLE_VERBOSE_STRINGS) */ #else /* defined(CURL_DISABLE_VERBOSE_STRINGS) */
CURLcode Curl_trc_init(void) CURLcode Curl_trc_init(void)
{ {
return CURLE_OK; return CURLE_OK;
} }
#endif /* !DEBUGBUILD */ #endif /* !defined(CURL_DISABLE_VERBOSE_STRINGS) */

View File

@ -123,7 +123,7 @@ void Curl_trc_cf_infof(struct Curl_easy *data, struct Curl_cfilter *cf,
const char *fmt, ...); const char *fmt, ...);
#endif #endif
#else /* !CURL_DISABLE_VERBOSE_STRINGS */ #else /* defined(CURL_DISABLE_VERBOSE_STRINGS) */
/* All informational messages are not compiled in for size savings */ /* All informational messages are not compiled in for size savings */
#define Curl_trc_is_verbose(d) ((void)(d), FALSE) #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; (void)data; (void)cf; (void)fmt;
} }
#endif /* CURL_DISABLE_VERBOSE_STRINGS */ #endif /* !defined(CURL_DISABLE_VERBOSE_STRINGS) */
#endif /* HEADER_CURL_TRC_H */ #endif /* HEADER_CURL_TRC_H */