GHA: enable `-Wunused-macros` in clang-tidy jobs
No binary (build failed)
—
(log yok)
| @@ -321,6 +321,7 @@ jobs: | |
| install_steps: skiprun mbedtls-latest-intel rustls wolfssl-opensslextra-intel | |
| install_steps_brew: openssl@4 gsasl | |
| CC: clang-20 | |
| + | CFLAGS: -Wunused-macros |
| LDFLAGS: >- | |
| -Wl,-rpath,/home/runner/wolfssl-opensslextra/lib | |
| -Wl,-rpath,/home/runner/mbedtls/lib | |
| @@ -345,6 +346,7 @@ jobs: | |
| install_steps: skiprun | |
| install_steps_brew: libngtcp2 libnghttp3 c-ares | |
| CC: clang-20 | |
| + | CFLAGS: -Wunused-macros |
| LDFLAGS: >- | |
| -Wl,-rpath,/home/linuxbrew/.linuxbrew/opt/openssl/lib | |
| -Wl,-rpath,/home/linuxbrew/.linuxbrew/opt/libngtcp2/lib | |
| @@ -300,6 +300,7 @@ jobs: | |
| compiler: clang | |
| install: llvm gnutls nettle libressl krb5 mbedtls gsasl rustls-ffi libssh fish | |
| install_steps: skiprun | |
| + | CFLAGS: -Wunused-macros |
| chkprefill: _chkprefill | |
| generate: >- | |
| -DCURL_USE_OPENSSL=ON -DOPENSSL_ROOT_DIR=/opt/homebrew/opt/libressl -DCURL_DEFAULT_SSL_BACKEND=openssl | |
| @@ -316,6 +317,7 @@ jobs: | |
| compiler: clang | |
| install: llvm libnghttp3 libngtcp2 openldap krb5 | |
| install_steps: skipall | |
| + | CFLAGS: -Wunused-macros |
| generate: >- | |
| -DCURL_USE_OPENSSL=ON -DOPENSSL_ROOT_DIR=/opt/homebrew/opt/openssl -DUSE_NGTCP2=ON | |
| -DLDAP_INCLUDE_DIR=/opt/homebrew/opt/openldap/include | |
| @@ -445,6 +447,7 @@ jobs: | |
| - name: 'configure' | |
| env: | |
| + | CFLAGS: '${{ matrix.build.CFLAGS }}' |
| MATRIX_CHKPREFILL: '${{ matrix.build.chkprefill }}' | |
| MATRIX_CONFIGURE: '${{ matrix.build.configure }}' | |
| MATRIX_GENERATE: '${{ matrix.build.generate }}' | |
| @@ -479,7 +482,6 @@ jobs: | |
| false | |
| fi | |
| else | |
| - | export CFLAGS |
| if [[ "${MATRIX_COMPILER}" = 'llvm'* ]]; then | |
| options+=" --target=$(uname -m)-apple-darwin" | |
| fi | |
| @@ -782,7 +782,7 @@ jobs: | |
| include: | |
| - { build: 'autotools', compiler: 'gcc' } | |
| - { build: 'cmake' , compiler: 'gcc' } | |
| - | - { build: 'cmake' , compiler: 'clang-tidy', install_packages: 'clang-20 clang-tidy-20' } |
| + | - { build: 'cmake' , compiler: 'clang-tidy', install_packages: 'clang-20 clang-tidy-20', CFLAGS: '-Wunused-macros' } |
| steps: | |
| - name: 'install packages' | |
| timeout-minutes: 2 | |
| @@ -801,6 +801,8 @@ jobs: | |
| run: autoreconf -fi | |
| - name: 'configure' | |
| + | env: |
| + | CFLAGS: '${{ matrix.CFLAGS }}' |
| run: | | |
| if [ "${MATRIX_BUILD}" = 'cmake' ]; then | |
| if [ "${MATRIX_COMPILER}" = 'clang-tidy' ]; then | |
| @@ -98,8 +98,12 @@ const char * const Curl_month[] = { | |
| #ifndef CURL_DISABLE_PARSEDATE | |
| + | #if SIZEOF_TIME_T < 5 |
| #define PARSEDATE_LATER 1 | |
| + | #endif |
| + | #if SIZEOF_TIME_T < 5 || defined(HAVE_TIME_T_UNSIGNED) |
| #define PARSEDATE_SOONER 2 | |
| + | #endif |
| static const char * const weekday[] = { | |
| "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" | |
| @@ -58,19 +58,23 @@ extern int unitfail; /* for unittests */ | |
| #include <sys/select.h> | |
| #endif | |
| + | #ifndef UNITTESTS |
| #define test_setopt(A, B, C) \ | |
| do { \ | |
| result = curl_easy_setopt(A, B, C); \ | |
| if(result != CURLE_OK) \ | |
| goto test_cleanup; \ | |
| } while(0) | |
| + | #endif /* !UNITTESTS */ |
| + | #if 0 |
| #define test_multi_setopt(A, B, C) \ | |
| do { \ | |
| result = curl_multi_setopt(A, B, C); \ | |
| if(result != CURLE_OK) \ | |
| goto test_cleanup; \ | |
| } while(0) | |
| + | #endif |
| extern const char *libtest_arg2; /* set by first.c to the argv[2] or NULL */ | |
| extern const char *libtest_arg3; /* set by first.c to the argv[3] or NULL */ | |
| @@ -104,8 +108,10 @@ void ws_close(CURL *curl); /* just close the connection */ | |
| * | |
| * For portability reasons TEST_ERR_* values should be less than 127. | |
| */ | |
| - | |
| + | #if !defined(UNITTESTS) || defined(BUILDING_LIBCURL) |
| #define TEST_ERR_MAJOR_BAD CURLE_OBSOLETE20 | |
| + | #endif |
| + | #ifndef UNITTESTS |
| #define TEST_ERR_RUNS_FOREVER CURLE_OBSOLETE24 | |
| #define TEST_ERR_EASY_INIT CURLE_OBSOLETE29 | |
| #define TEST_ERR_MULTI CURLE_OBSOLETE32 | |
| @@ -236,8 +242,10 @@ void ws_close(CURL *curl); /* just close the connection */ | |
| } \ | |
| } while(0) | |
| + | #if 0 |
| #define res_multi_setopt(A, B, C) \ | |
| exe_multi_setopt(A, B, C, __FILE__, __LINE__) | |
| + | #endif |
| #define chk_multi_setopt(A, B, C, Y, Z) \ | |
| do { \ | |
| @@ -290,8 +298,10 @@ void ws_close(CURL *curl); /* just close the connection */ | |
| } \ | |
| } while(0) | |
| + | #if 0 |
| #define res_multi_remove_handle(A, B) \ | |
| exe_multi_remove_handle(A, B, __FILE__, __LINE__) | |
| + | #endif |
| #define chk_multi_remove_handle(A, B, Y, Z) \ | |
| do { \ | |
| @@ -426,8 +436,10 @@ void ws_close(CURL *curl); /* just close the connection */ | |
| } \ | |
| } while(0) | |
| + | #if 0 |
| #define res_multi_poll(A, B, C, D, E) \ | |
| exe_multi_poll(A, B, C, D, E, __FILE__, __LINE__) | |
| + | #endif |
| #define chk_multi_poll(A, B, C, D, E, Y, Z) \ | |
| do { \ | |
| @@ -456,6 +468,7 @@ void ws_close(CURL *curl); /* just close the connection */ | |
| #define res_multi_wakeup(A) \ | |
| exe_multi_wakeup(A, __FILE__, __LINE__) | |
| + | #if 0 |
| #define chk_multi_wakeup(A, Y, Z) \ | |
| do { \ | |
| exe_multi_wakeup(A, Y, Z); \ | |
| @@ -465,6 +478,7 @@ void ws_close(CURL *curl); /* just close the connection */ | |
| #define multi_wakeup(A) \ | |
| chk_multi_wakeup(A, __FILE__, __LINE__) | |
| + | #endif |
| /* ---------------------------------------------------------------- */ | |
| @@ -518,8 +532,10 @@ void ws_close(CURL *curl); /* just close the connection */ | |
| #define res_test_timedout() \ | |
| exe_test_timedout(TEST_HANG_TIMEOUT, __FILE__, __LINE__) | |
| + | #if 0 |
| #define res_test_timedout_custom(T) \ | |
| exe_test_timedout(T, __FILE__, __LINE__) | |
| + | #endif |
| #define chk_test_timedout(T, Y, Z) \ | |
| do { \ | |
| @@ -534,6 +550,15 @@ void ws_close(CURL *curl); /* just close the connection */ | |
| #define abort_on_test_timeout_custom(T) \ | |
| chk_test_timedout(T, __FILE__, __LINE__) | |
| + | #define NUM_HANDLES 4 /* global default */ |
| + | |
| + | #define res_global_init(A) \ |
| + | exe_global_init(A, __FILE__, __LINE__) |
| + | |
| + | #endif /* !UNITTESTS */ |
| + | |
| + | #if !defined(UNITTESTS) || defined(BUILDING_LIBCURL) |
| + | |
| /* ---------------------------------------------------------------- */ | |
| #define exe_global_init(A, Y, Z) \ | |
| @@ -548,9 +573,6 @@ void ws_close(CURL *curl); /* just close the connection */ | |
| } \ | |
| } while(0) | |
| - | #define res_global_init(A) \ |
| - | exe_global_init(A, __FILE__, __LINE__) |
| - | |
| #define chk_global_init(A, Y, Z) \ | |
| do { \ | |
| exe_global_init(A, Y, Z); \ | |
| @@ -564,13 +586,6 @@ void ws_close(CURL *curl); /* just close the connection */ | |
| #define global_init(A) \ | |
| chk_global_init(A, __FILE__, __LINE__) | |
| - | #define NO_SUPPORT_BUILT_IN \ |
| - | { \ |
| - | (void)URL; \ |
| - | curl_mfprintf(stderr, "Missing support\n"); \ |
| - | return CURLE_UNSUPPORTED_PROTOCOL; \ |
| - | } |
| - | |
| - | #define NUM_HANDLES 4 /* global default */ |
| + | #endif /* !UNITTESTS || BUILDING_LIBCURL */ |
| #endif /* HEADER_LIBTEST_FIRST_H */ | |
| @@ -23,16 +23,17 @@ | |
| ***************************************************************************/ | |
| #include "first.h" | |
| - | #define print_err(name, exp) \ |
| - | curl_mfprintf(stderr, "Type mismatch for CURLOPT_%s (expected %s)\n", \ |
| - | name, exp) |
| - | |
| static CURLcode test_lib1912(const char *URL) | |
| { | |
| /* Only test if GCC/clang type checking is available */ | |
| int error = 0; | |
| #ifdef CURLINC_TYPECHECK_GCC_H | |
| const struct curl_easyoption *o; | |
| + | |
| + | #define print_err(name, exp) \ |
| + | curl_mfprintf(stderr, "Type mismatch for CURLOPT_%s (expected %s)\n", \ |
| + | name, exp) |
| + | |
| for(o = curl_easy_option_next(NULL); o; o = curl_easy_option_next(o)) { | |
| /* Test for mismatch OR missing typecheck macros */ | |
| if(curlcheck_long_option(o->id) != | |
| @@ -97,6 +97,8 @@ static CURLcode test_lib2301(const char *URL) | |
| curl_global_cleanup(); | |
| return result; | |
| #else | |
| - | NO_SUPPORT_BUILT_IN |
| + | (void)URL; |
| + | curl_mfprintf(stderr, "Missing support\n"); |
| + | return CURLE_UNSUPPORTED_PROTOCOL; |
| #endif | |
| } | |
| @@ -125,6 +125,8 @@ static CURLcode test_lib2302(const char *URL) | |
| curl_global_cleanup(); | |
| return result; | |
| #else | |
| - | NO_SUPPORT_BUILT_IN |
| + | (void)URL; |
| + | curl_mfprintf(stderr, "Missing support\n"); |
| + | return CURLE_UNSUPPORTED_PROTOCOL; |
| #endif | |
| } | |
| @@ -85,6 +85,8 @@ static CURLcode test_lib2304(const char *URL) | |
| curl_global_cleanup(); | |
| return result; | |
| #else | |
| - | NO_SUPPORT_BUILT_IN |
| + | (void)URL; |
| + | curl_mfprintf(stderr, "Missing support\n"); |
| + | return CURLE_UNSUPPORTED_PROTOCOL; |
| #endif | |
| } | |
| @@ -249,6 +249,8 @@ test_cleanup: | |
| curl_global_cleanup(); | |
| return result; | |
| #else | |
| - | NO_SUPPORT_BUILT_IN |
| + | (void)URL; |
| + | curl_mfprintf(stderr, "Missing support\n"); |
| + | return CURLE_UNSUPPORTED_PROTOCOL; |
| #endif | |
| } | |
| @@ -23,6 +23,8 @@ | |
| ***************************************************************************/ | |
| #include "first.h" | |
| + | #if defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT) |
| + | |
| #include "testutil.h" | |
| #define T518_SAFETY_MARGIN 16 | |
| @@ -36,8 +38,6 @@ | |
| #define DEV_NULL "/dev/null" | |
| #endif | |
| - | #if defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT) |
| - | |
| static int *t518_testfd = NULL; | |
| static struct rlimit t518_num_open; | |
| static char t518_msgbuff[256]; | |
| @@ -23,6 +23,8 @@ | |
| ***************************************************************************/ | |
| #include "first.h" | |
| + | #if defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT) |
| + | |
| #include "testutil.h" | |
| #define T537_SAFETY_MARGIN 11 | |
| @@ -33,8 +35,6 @@ | |
| #define DEV_NULL "/dev/null" | |
| #endif | |
| - | #if defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT) |
| - | |
| static int *t537_testfd = NULL; | |
| static struct rlimit t537_num_open; | |
| static char t537_msgbuff[256]; | |
| @@ -159,13 +159,17 @@ static int blob_add_qname(struct blob *b, const struct Curl_str *str) | |
| #define QTYPE_AAAA 28 | |
| #define QTYPE_HTTPS 0x41 | |
| + | #if 0 |
| #define HTTPS_RR_CODE_MANDATORY 0x00 | |
| + | #endif |
| #define HTTPS_RR_CODE_ALPN 0x01 | |
| #define HTTPS_RR_CODE_NO_DEF_ALPN 0x02 | |
| + | #if 0 |
| #define HTTPS_RR_CODE_PORT 0x03 | |
| #define HTTPS_RR_CODE_IPV4 0x04 | |
| #define HTTPS_RR_CODE_ECH 0x05 | |
| #define HTTPS_RR_CODE_IPV6 0x06 | |
| + | #endif |
| static const char *type2string(uint16_t qtype) | |
| { | |
| @@ -43,8 +43,10 @@ | |
| #define MAC_DIFFER 0x40 | |
| #define MAC_SHIFT 16 | |
| + | #if 0 |
| #define MAC_MATCH ((CURL_FNMATCH_MATCH << MAC_SHIFT) | MAC_DIFFER) | |
| #define MAC_NOMATCH ((CURL_FNMATCH_NOMATCH << MAC_SHIFT) | MAC_DIFFER) | |
| + | #endif |
| #define MAC_FAIL ((CURL_FNMATCH_FAIL << MAC_SHIFT) | MAC_DIFFER) | |
| static const char *ret2name(int i) | |
| @@ -190,8 +190,6 @@ static CURLcode test_unit1666(const char *arg) | |
| UNITTEST_END_SIMPLE | |
| } | |
| - | #undef OID |
| - | |
| #else | |
| static CURLcode test_unit1666(const char *arg) | |
| @@ -37,9 +37,6 @@ struct test_1667 { | |
| CURLcode result_exp; | |
| }; | |
| - | /* the size of the object needs to deduct the null terminator */ |
| - | #define OID(x) x, sizeof(x) - 1 |
| - | |
| static bool test1667(const struct test_1667 *spec, size_t i, | |
| struct dynbuf *dbuf) | |
| { | |
| @@ -326,8 +323,6 @@ static CURLcode test_unit1667(const char *arg) | |
| UNITTEST_END_SIMPLE | |
| } | |
| - | #undef OID |
| - | |
| #else | |
| static CURLcode test_unit1667(const char *arg) | |