mirror of
https://github.com/curl/curl.git
synced 2026-08-03 11:00:29 +03:00
GHA: enable -Wunused-macros in clang-tidy jobs
Also fix fallouts found. Windows clang-tidy CI job is a little pickier than I'd prefer due to the `_CURL_TESTS_CONCAT=ON` option used there, and all macros considered local, thus checked by the compiler. Upside: it revealed macro usage dynamics in tests. If too annoying, `first.h` may be opted-out from the concat logic. Some macros may also be deleted instead of `#if 0`-ing. Follow-up toe0e56e9ae4#21550 Follow-up to5fa5cb3825#20593 Closes #21554
This commit is contained in:
parent
a15483c4ca
commit
47f411c6d8
16 changed files with 66 additions and 33 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue