From 1176bf055283c264f5b3e9e482498446408a1a8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Mon, 27 Feb 2023 14:09:26 +0100 Subject: [PATCH 1/2] Use C23 attributes if available, add ISC_ATTR_UNUSED Use C23 attribute styles if available: * Add new ISC_ATTR_UNUSED attribute macro that either expands to C23's [[maybe_unused]] or __attribute__((__unused__)); * Add default expansion of the `noreturn` to [[noreturn]] if available; * Move the FALLTHROUGH from to --- lib/isc/include/isc/attributes.h | 28 +++++++++++++++++++++++++++- lib/isc/include/isc/util.h | 10 ++-------- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/lib/isc/include/isc/attributes.h b/lib/isc/include/isc/attributes.h index abe615223e..812f136c8b 100644 --- a/lib/isc/include/isc/attributes.h +++ b/lib/isc/include/isc/attributes.h @@ -13,7 +13,17 @@ #pragma once -#ifdef HAVE_STDNORETURN_H +/*** + *** Clang Compatibility Macros + ***/ + +#if !defined(__has_c_attribute) +#define __has_c_attribute(x) 0 +#endif /* if !defined(__has_c_attribute) */ + +#if __has_c_attribute(noreturn) +#define noreturn [[noreturn]] +#elif defined(HAVE_STDNORETURN_H) #include #elif HAVE_FUNC_ATTRIBUTE_NORETURN #define noreturn __attribute__((noreturn)) @@ -80,3 +90,19 @@ #define ISC_ATTR_MALLOC_DEALLOCATOR(deallocator) #define ISC_ATTR_MALLOC_DEALLOCATOR_IDX(deallocator, idx) #endif /* HAVE_FUNC_ATTRIBUTE_MALLOC */ + +#if __has_c_attribute(fallthrough) +#define FALLTHROUGH [[fallthrough]] +#elif __GNUC__ >= 7 && !defined(__clang__) +#define FALLTHROUGH __attribute__((fallthrough)) +#else +/* clang-format off */ +#define FALLTHROUGH do {} while (0) /* FALLTHROUGH */ +/* clang-format on */ +#endif + +#if __has_c_attribute(maybe_unused) +#define ISC_ATTR_UNUSED [[maybe_unused]] +#else +#define ISC_ATTR_UNUSED __attribute__((__unused__)) +#endif diff --git a/lib/isc/include/isc/util.h b/lib/isc/include/isc/util.h index 65835920b6..9c5c5c5024 100644 --- a/lib/isc/include/isc/util.h +++ b/lib/isc/include/isc/util.h @@ -27,18 +27,12 @@ * ISC_ or isc_ to the name. */ +#include + /*** *** Clang Compatibility Macros ***/ -#if !defined(__has_attribute) -#define __has_attribute(x) 0 -#endif /* if !defined(__has_attribute) */ - -#if !defined(__has_c_attribute) -#define __has_c_attribute(x) 0 -#endif /* if !defined(__has_c_attribute) */ - #if !defined(__has_feature) #define __has_feature(x) 0 #endif /* if !defined(__has_feature) */ From 2c0a9575d71f3e9956a04bb81c0758f536b16a0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Tue, 10 Jan 2023 10:20:44 +0100 Subject: [PATCH 2/2] Replace __attribute__((unused)) with ISC_ATTR_UNUSED attribute macro Instead of marking the unused entities with UNUSED(x) macro in the function body, use a `ISC_ATTR_UNUSED` attribute macro that expans to C23 [[maybe_unused]] or __attribute__((__unused__)) as fallback. --- bin/dig/nslookup.c | 2 +- bin/tests/test_server.c | 2 +- contrib/dlz/modules/include/dlz_minimal.h | 10 +-- fuzz/dns_message_checksig.c | 3 +- fuzz/dns_message_parse.c | 3 +- fuzz/dns_name_fromtext_target.c | 3 +- fuzz/dns_name_fromwire.c | 3 +- fuzz/dns_rdata_fromwire_text.c | 3 +- fuzz/fuzz.h | 3 +- fuzz/isc_lex_getmastertoken.c | 6 +- fuzz/isc_lex_gettoken.c | 3 +- lib/dns/include/dns/librpz.h | 2 +- lib/dns/include/dns/trace.h | 7 +-- lib/isc/hashmap.c | 2 +- lib/isc/include/isc/attributes.h | 4 +- lib/isc/include/isc/netmgr.h | 7 +-- lib/isc/include/isc/util.h | 20 ++---- lib/isc/netmgr/netmgr-int.h | 7 +-- lib/isc/netmgr/netmgr.c | 4 +- tests/dns/dnstap_test.c | 2 +- tests/dns/zt_test.c | 2 +- tests/include/tests/isc.h | 76 +++++++++++------------ tests/include/tests/ns.h | 9 ++- tests/isc/doh_test.c | 19 +++--- tests/isc/hmac_test.c | 4 +- tests/isc/loop_test.c | 3 +- tests/isc/md_test.c | 4 +- tests/isc/netmgr_common.c | 40 ++++++------ tests/isc/netmgr_common.h | 39 ++++++------ tests/isc/tcp_test.c | 2 +- tests/isc/tcpdns_test.c | 4 +- tests/isc/timer_test.c | 2 +- tests/isc/tls_test.c | 2 +- tests/isc/tlsdns_test.c | 4 +- tests/isc/udp_test.c | 6 +- tests/isc/uv_wrap.h | 5 +- tests/libtest/isc.c | 12 ++-- tests/libtest/ns.c | 2 +- tests/ns/netmgr_wrap.c | 7 +-- 39 files changed, 158 insertions(+), 180 deletions(-) diff --git a/bin/dig/nslookup.c b/bin/dig/nslookup.c index 1012a99bd0..dc43f7cdcf 100644 --- a/bin/dig/nslookup.c +++ b/bin/dig/nslookup.c @@ -888,7 +888,7 @@ static void start_next_command(void); static void -process_next_command(void *arg __attribute__((__unused__))) { +process_next_command(void *arg ISC_ATTR_UNUSED) { isc_loop_t *loop = isc_loop_main(loopmgr); if (cmdline == NULL) { in_use = false; diff --git a/bin/tests/test_server.c b/bin/tests/test_server.c index e0d3bb45ec..6186a7a2a0 100644 --- a/bin/tests/test_server.c +++ b/bin/tests/test_server.c @@ -39,7 +39,7 @@ static isc_nm_t *netmgr = NULL; static protocol_t protocol; static in_port_t port; static isc_netaddr_t netaddr; -static isc_sockaddr_t sockaddr __attribute__((unused)); +static isc_sockaddr_t sockaddr ISC_ATTR_UNUSED; static int workers; static isc_tlsctx_t *tls_ctx = NULL; diff --git a/contrib/dlz/modules/include/dlz_minimal.h b/contrib/dlz/modules/include/dlz_minimal.h index 7acdbb19ca..32f0f12f93 100644 --- a/contrib/dlz/modules/include/dlz_minimal.h +++ b/contrib/dlz/modules/include/dlz_minimal.h @@ -85,11 +85,13 @@ typedef uint32_t dns_ttl_t; var = _u.v; \ } while (0) -#if !defined(__has_attribute) -#define __has_attribute(x) 0 -#endif /* if !defined(__has_attribute) */ +#if !defined(__has_c_attribute) +#define __has_c_attribute(x) 0 +#endif /* if !defined(__has_c_attribute) */ -#if __GNUC__ >= 7 || __has_attribute(fallthrough) +#if __has_c_attribute(fallthrough) +#define FALLTHROUGH [[fallthrough]] +#elif __GNUC__ >= 7 && !defined(__clang__) #define FALLTHROUGH __attribute__((fallthrough)) #else /* clang-format off */ diff --git a/fuzz/dns_message_checksig.c b/fuzz/dns_message_checksig.c index 5c8f81aeb9..b21665c4bf 100644 --- a/fuzz/dns_message_checksig.c +++ b/fuzz/dns_message_checksig.c @@ -177,8 +177,7 @@ cleanup(void) { } int -LLVMFuzzerInitialize(int *argc __attribute__((unused)), - char ***argv __attribute__((unused))) { +LLVMFuzzerInitialize(int *argc ISC_ATTR_UNUSED, char ***argv ISC_ATTR_UNUSED) { isc_result_t result; dns_fixedname_t fixed; dns_name_t *name = dns_fixedname_initname(&fixed); diff --git a/fuzz/dns_message_parse.c b/fuzz/dns_message_parse.c index c6b23ebf82..a2366f85f8 100644 --- a/fuzz/dns_message_parse.c +++ b/fuzz/dns_message_parse.c @@ -35,8 +35,7 @@ static size_t output_len = 1024; static uint8_t render_buf[64 * 1024 - 1]; int -LLVMFuzzerInitialize(int *argc __attribute__((unused)), - char ***argv __attribute__((unused))) { +LLVMFuzzerInitialize(int *argc ISC_ATTR_UNUSED, char ***argv ISC_ATTR_UNUSED) { isc_mem_create(&mctx); output = isc_mem_get(mctx, output_len); diff --git a/fuzz/dns_name_fromtext_target.c b/fuzz/dns_name_fromtext_target.c index ba9c7ab2a2..437496e5ce 100644 --- a/fuzz/dns_name_fromtext_target.c +++ b/fuzz/dns_name_fromtext_target.c @@ -25,8 +25,7 @@ bool debug = false; int -LLVMFuzzerInitialize(int *argc __attribute__((unused)), - char ***argv __attribute__((unused))) { +LLVMFuzzerInitialize(int *argc ISC_ATTR_UNUSED, char ***argv ISC_ATTR_UNUSED) { return (0); } diff --git a/fuzz/dns_name_fromwire.c b/fuzz/dns_name_fromwire.c index 6fd02a51e7..e6ad89a577 100644 --- a/fuzz/dns_name_fromwire.c +++ b/fuzz/dns_name_fromwire.c @@ -29,8 +29,7 @@ bool debug = false; int -LLVMFuzzerInitialize(int *argc __attribute__((unused)), - char ***argv __attribute__((unused))) { +LLVMFuzzerInitialize(int *argc ISC_ATTR_UNUSED, char ***argv ISC_ATTR_UNUSED) { return (0); } diff --git a/fuzz/dns_rdata_fromwire_text.c b/fuzz/dns_rdata_fromwire_text.c index dee7d00282..c559849f77 100644 --- a/fuzz/dns_rdata_fromwire_text.c +++ b/fuzz/dns_rdata_fromwire_text.c @@ -42,8 +42,7 @@ static isc_mem_t *mctx = NULL; static isc_lex_t *lex = NULL; int -LLVMFuzzerInitialize(int *argc __attribute__((unused)), - char ***argv __attribute__((unused))) { +LLVMFuzzerInitialize(int *argc ISC_ATTR_UNUSED, char ***argv ISC_ATTR_UNUSED) { isc_lexspecials_t specials; isc_mem_create(&mctx); diff --git a/fuzz/fuzz.h b/fuzz/fuzz.h index 769f846815..49ad08fd6e 100644 --- a/fuzz/fuzz.h +++ b/fuzz/fuzz.h @@ -31,8 +31,7 @@ ISC_LANG_BEGINDECLS extern bool debug; int -LLVMFuzzerInitialize(int *argc __attribute__((unused)), - char ***argv __attribute__((unused))); +LLVMFuzzerInitialize(int *argc ISC_ATTR_UNUSED, char ***argv ISC_ATTR_UNUSED); int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); diff --git a/fuzz/isc_lex_getmastertoken.c b/fuzz/isc_lex_getmastertoken.c index 1967bfb493..3dc8f558f1 100644 --- a/fuzz/isc_lex_getmastertoken.c +++ b/fuzz/isc_lex_getmastertoken.c @@ -25,8 +25,7 @@ bool debug = false; int -LLVMFuzzerInitialize(int *argc __attribute__((unused)), - char ***argv __attribute__((unused))); +LLVMFuzzerInitialize(int *argc ISC_ATTR_UNUSED, char ***argv ISC_ATTR_UNUSED); int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); @@ -35,8 +34,7 @@ static isc_mem_t *mctx = NULL; static isc_lex_t *lex = NULL; int -LLVMFuzzerInitialize(int *argc __attribute__((unused)), - char ***argv __attribute__((unused))) { +LLVMFuzzerInitialize(int *argc ISC_ATTR_UNUSED, char ***argv ISC_ATTR_UNUSED) { isc_mem_create(&mctx); isc_lex_create(mctx, 1024, &lex); diff --git a/fuzz/isc_lex_gettoken.c b/fuzz/isc_lex_gettoken.c index c98d5138e2..94d60f952b 100644 --- a/fuzz/isc_lex_gettoken.c +++ b/fuzz/isc_lex_gettoken.c @@ -27,8 +27,7 @@ static isc_mem_t *mctx = NULL; static isc_lex_t *lex = NULL; int -LLVMFuzzerInitialize(int *argc __attribute__((unused)), - char ***argv __attribute__((unused))) { +LLVMFuzzerInitialize(int *argc ISC_ATTR_UNUSED, char ***argv ISC_ATTR_UNUSED) { isc_mem_create(&mctx); isc_lex_create(mctx, 1024, &lex); diff --git a/lib/dns/include/dns/librpz.h b/lib/dns/include/dns/librpz.h index 17b55e604f..87d189afb8 100644 --- a/lib/dns/include/dns/librpz.h +++ b/lib/dns/include/dns/librpz.h @@ -215,7 +215,7 @@ typedef struct { } librpz_emsg_t; #ifdef LIBRPZ_HAVE_ATTR -#define LIBRPZ_UNUSED __attribute__((unused)) +#define LIBRPZ_UNUSED ISC_ATTR_UNUSED #define LIBRPZ_PF(f, l) __attribute__((format(printf, f, l))) #define LIBRPZ_NORET __attribute__((__noreturn__)) #else /* ifdef LIBRPZ_HAVE_ATTR */ diff --git a/lib/dns/include/dns/trace.h b/lib/dns/include/dns/trace.h index f1a0b680c6..e7326917a2 100644 --- a/lib/dns/include/dns/trace.h +++ b/lib/dns/include/dns/trace.h @@ -19,10 +19,9 @@ #define DNS__DB_FILELINE , __func__, __FILE__, __LINE__ #define DNS__DB_FLARG_PASS , func, file, line -#define DNS__DB_FLARG \ - , const char *func __attribute__((__unused__)), \ - const char *file __attribute__((__unused__)), \ - unsigned int line __attribute__((__unused__)) +#define DNS__DB_FLARG \ + , const char *func ISC_ATTR_UNUSED, const char *file ISC_ATTR_UNUSED, \ + unsigned int line ISC_ATTR_UNUSED #else /* DNS_DB_NODETRACE */ diff --git a/lib/isc/hashmap.c b/lib/isc/hashmap.c index 1a8f15e0a2..d5d8eb13bb 100644 --- a/lib/isc/hashmap.c +++ b/lib/isc/hashmap.c @@ -145,7 +145,7 @@ hashmap_node_init(hashmap_node_t *node, const uint32_t hashval, }; } -static void __attribute__((__unused__)) +ISC_ATTR_UNUSED static void hashmap_dump_table(const isc_hashmap_t *hashmap, const uint8_t idx) { fprintf(stderr, "====== %" PRIu8 " (bits = %" PRIu8 ", size = %zu =====\n", idx, diff --git a/lib/isc/include/isc/attributes.h b/lib/isc/include/isc/attributes.h index 812f136c8b..edb50ed826 100644 --- a/lib/isc/include/isc/attributes.h +++ b/lib/isc/include/isc/attributes.h @@ -21,9 +21,7 @@ #define __has_c_attribute(x) 0 #endif /* if !defined(__has_c_attribute) */ -#if __has_c_attribute(noreturn) -#define noreturn [[noreturn]] -#elif defined(HAVE_STDNORETURN_H) +#ifdef HAVE_STDNORETURN_H #include #elif HAVE_FUNC_ATTRIBUTE_NORETURN #define noreturn __attribute__((noreturn)) diff --git a/lib/isc/include/isc/netmgr.h b/lib/isc/include/isc/netmgr.h index aa90e6f80a..944dccaabb 100644 --- a/lib/isc/include/isc/netmgr.h +++ b/lib/isc/include/isc/netmgr.h @@ -153,10 +153,9 @@ isc_nmsocket_set_max_streams(isc_nmsocket_t *listener, #define isc_nmhandle_detach(handlep) \ isc__nmhandle_detach(handlep, __FILE__, __LINE__, __func__) #define FLARG_PASS , file, line, func -#define FLARG \ - , const char *file __attribute__((unused)), \ - unsigned int line __attribute__((unused)), \ - const char *func __attribute__((unused)) +#define FLARG \ + , const char *file ISC_ATTR_UNUSED, unsigned int line ISC_ATTR_UNUSED, \ + const char *func ISC_ATTR_UNUSED #else #define isc_nmhandle_attach(handle, dest) isc__nmhandle_attach(handle, dest) #define isc_nmhandle_detach(handlep) isc__nmhandle_detach(handlep) diff --git a/lib/isc/include/isc/util.h b/lib/isc/include/isc/util.h index 9c5c5c5024..503c624aaf 100644 --- a/lib/isc/include/isc/util.h +++ b/lib/isc/include/isc/util.h @@ -42,12 +42,14 @@ ***/ /*% - * Use this to hide unused function arguments. + * Legacy way how to hide unused function arguments, don't use in + * the new code, rather use the ISC_ATTR_UNUSED macro that expands + * to either C23's [[maybe_unused]] or __attribute__((__unused__)). + * * \code * int - * foo(char *bar) - * { - * UNUSED(bar); + * foo(ISC_ATTR_UNUSED char *bar) { + * ...; * } * \endcode */ @@ -59,16 +61,6 @@ #define ISC_NONSTRING #endif /* __GNUC__ */ -#if __has_c_attribute(fallthrough) -#define FALLTHROUGH [[fallthrough]] -#elif __GNUC__ >= 7 && !defined(__clang__) -#define FALLTHROUGH __attribute__((fallthrough)) -#else -/* clang-format off */ -#define FALLTHROUGH do {} while (0) /* FALLTHROUGH */ -/* clang-format on */ -#endif - #if HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR && HAVE_FUNC_ATTRIBUTE_DESTRUCTOR #define ISC_CONSTRUCTOR __attribute__((constructor)) #define ISC_DESTRUCTOR __attribute__((destructor)) diff --git a/lib/isc/netmgr/netmgr-int.h b/lib/isc/netmgr/netmgr-int.h index a852fefb42..eaf14f6637 100644 --- a/lib/isc/netmgr/netmgr-int.h +++ b/lib/isc/netmgr/netmgr-int.h @@ -129,10 +129,9 @@ STATIC_ASSERT(ISC_NETMGR_TCP_RECVBUF_SIZE <= ISC_NETMGR_RECVBUF_SIZE, fprintf(stderr, "%" PRIu32 ":%d:%s:%u:%s:" format, gettid(), \ isc_tid(), file, line, func, __VA_ARGS__) -#define FLARG \ - , const char *file __attribute__((unused)), \ - unsigned int line __attribute__((unused)), \ - const char *func __attribute__((unused)) +#define FLARG \ + , const char *file ISC_ATTR_UNUSED, unsigned int line ISC_ATTR_UNUSED, \ + const char *func ISC_ATTR_UNUSED #define FLARG_PASS , file, line, func #define FLARG_IEVENT(ievent) \ const char *file = ievent->file; \ diff --git a/lib/isc/netmgr/netmgr.c b/lib/isc/netmgr/netmgr.c index 162d5261dd..464a678878 100644 --- a/lib/isc/netmgr/netmgr.c +++ b/lib/isc/netmgr/netmgr.c @@ -374,13 +374,11 @@ isc_nm_getloadbalancesockets(isc_nm_t *mgr) { } void -isc_nm_setloadbalancesockets(isc_nm_t *mgr, bool enabled) { +isc_nm_setloadbalancesockets(isc_nm_t *mgr, ISC_ATTR_UNUSED bool enabled) { REQUIRE(VALID_NM(mgr)); #if HAVE_SO_REUSEPORT_LB mgr->load_balance_sockets = enabled; -#else - UNUSED(enabled); #endif } diff --git a/tests/dns/dnstap_test.c b/tests/dns/dnstap_test.c index 1514674d3f..6aa054e069 100644 --- a/tests/dns/dnstap_test.c +++ b/tests/dns/dnstap_test.c @@ -44,7 +44,7 @@ #define TAPTEXT TESTS_DIR "/testdata/dnstap/dnstap.text" static int -cleanup(void **state __attribute__((__unused__))) { +cleanup(void **state ISC_ATTR_UNUSED) { (void)isc_file_remove(TAPFILE); (void)isc_file_remove(TAPSOCK); diff --git a/tests/dns/zt_test.c b/tests/dns/zt_test.c index 70b7cbca24..18a2848853 100644 --- a/tests/dns/zt_test.c +++ b/tests/dns/zt_test.c @@ -191,7 +191,7 @@ ISC_LOOP_TEST_IMPL(asyncload_zone) { dns_zone_t *zone1 = NULL, *zone2 = NULL, *zone3 = NULL; static isc_result_t -all_done(void *arg __attribute__((__unused__))) { +all_done(void *arg ISC_ATTR_UNUSED) { isc_result_t result; /* Both zones should now be loaded; test them */ diff --git a/tests/include/tests/isc.h b/tests/include/tests/isc.h index 8d51f22bbb..391a64454b 100644 --- a/tests/include/tests/isc.h +++ b/tests/include/tests/isc.h @@ -76,17 +76,17 @@ teardown_managers(void **state); /* clang-format on */ #define ISC_SETUP_TEST_DECLARE(name) \ - int setup_test_##name(void **state __attribute__((unused))); + int setup_test_##name(void **state ISC_ATTR_UNUSED); #define ISC_RUN_TEST_DECLARE(name) \ - void run_test_##name(void **state __attribute__((unused))); + void run_test_##name(void **state ISC_ATTR_UNUSED); #define ISC_TEARDOWN_TEST_DECLARE(name) \ - int teardown_test_##name(void **state __attribute__((unused))) + int teardown_test_##name(void **state ISC_ATTR_UNUSED) -#define ISC_LOOP_TEST_CUSTOM_DECLARE(name, setup, teardown) \ - void run_test_##name(void **state __attribute__((__unused__))); \ - void loop_test_##name(void *arg __attribute__((__unused__))); +#define ISC_LOOP_TEST_CUSTOM_DECLARE(name, setup, teardown) \ + void run_test_##name(void **state ISC_ATTR_UNUSED); \ + void loop_test_##name(void *arg ISC_ATTR_UNUSED); #define ISC_LOOP_TEST_DECLARE(name) \ ISC_LOOP_TEST_CUSTOM_DECLARE(name, NULL, NULL) @@ -102,41 +102,41 @@ teardown_managers(void **state); ISC_LOOP_TEST_CUSTOM_DECLARE(name, NULL, teardown_loop_##name) #define ISC_LOOP_SETUP_DECLARE(name) \ - void setup_loop_##name(void *arg __attribute__((__unused__))); + void setup_loop_##name(void *arg ISC_ATTR_UNUSED); -#define ISC_SETUP_TEST_IMPL(name) \ - int setup_test_##name(void **state __attribute__((unused))); \ - int setup_test_##name(void **state __attribute__((unused))) +#define ISC_SETUP_TEST_IMPL(name) \ + int setup_test_##name(void **state ISC_ATTR_UNUSED); \ + int setup_test_##name(void **state ISC_ATTR_UNUSED) -#define ISC_RUN_TEST_IMPL(name) \ - void run_test_##name(void **state __attribute__((unused))); \ - void run_test_##name(void **state __attribute__((unused))) +#define ISC_RUN_TEST_IMPL(name) \ + void run_test_##name(void **state ISC_ATTR_UNUSED); \ + void run_test_##name(void **state ISC_ATTR_UNUSED) -#define ISC_TEARDOWN_TEST_IMPL(name) \ - int teardown_test_##name(void **state __attribute__((unused))); \ - int teardown_test_##name(void **state __attribute__((unused))) +#define ISC_TEARDOWN_TEST_IMPL(name) \ + int teardown_test_##name(void **state ISC_ATTR_UNUSED); \ + int teardown_test_##name(void **state ISC_ATTR_UNUSED) #define ISC_TEST_LIST_START const struct CMUnitTest tests[] = { #define ISC_TEST_LIST_END \ } \ ; -#define ISC_LOOP_TEST_CUSTOM_IMPL(name, setup, teardown) \ - void run_test_##name(void **state __attribute__((__unused__))); \ - void loop_test_##name(void *arg __attribute__((__unused__))); \ - void run_test_##name(void **state __attribute__((__unused__))) { \ - isc_job_cb setup_loop = setup; \ - isc_job_cb teardown_loop = teardown; \ - if (setup_loop != NULL) { \ - setup_loop(state); \ - } \ - isc_loop_setup(mainloop, loop_test_##name, state); \ - isc_loopmgr_run(loopmgr); \ - if (teardown_loop != NULL) { \ - teardown_loop(state); \ - } \ - } \ - void loop_test_##name(void *arg __attribute__((__unused__))) +#define ISC_LOOP_TEST_CUSTOM_IMPL(name, setup, teardown) \ + void run_test_##name(void **state ISC_ATTR_UNUSED); \ + void loop_test_##name(void *arg ISC_ATTR_UNUSED); \ + void run_test_##name(void **state ISC_ATTR_UNUSED) { \ + isc_job_cb setup_loop = setup; \ + isc_job_cb teardown_loop = teardown; \ + if (setup_loop != NULL) { \ + setup_loop(state); \ + } \ + isc_loop_setup(mainloop, loop_test_##name, state); \ + isc_loopmgr_run(loopmgr); \ + if (teardown_loop != NULL) { \ + teardown_loop(state); \ + } \ + } \ + void loop_test_##name(void *arg ISC_ATTR_UNUSED) #define ISC_LOOP_TEST_IMPL(name) ISC_LOOP_TEST_CUSTOM_IMPL(name, NULL, NULL) @@ -149,13 +149,13 @@ teardown_managers(void **state); #define ISC_LOOP_TEST_TEARDOWN_IMPL(name) \ ISC_LOOP_TEST_CUSTOM_IMPL(name, NULL, teardown_loop_##name) -#define ISC_LOOP_SETUP_IMPL(name) \ - void setup_loop_##name(void *arg __attribute__((__unused__))); \ - void setup_loop_##name(void *arg __attribute__((__unused__))) +#define ISC_LOOP_SETUP_IMPL(name) \ + void setup_loop_##name(void *arg ISC_ATTR_UNUSED); \ + void setup_loop_##name(void *arg ISC_ATTR_UNUSED) -#define ISC_LOOP_TEARDOWN_IMPL(name) \ - void teardown_loop_##name(void *arg __attribute__((__unused__))); \ - void teardown_loop_##name(void *arg __attribute__((__unused__))) +#define ISC_LOOP_TEARDOWN_IMPL(name) \ + void teardown_loop_##name(void *arg ISC_ATTR_UNUSED); \ + void teardown_loop_##name(void *arg ISC_ATTR_UNUSED) #define ISC_TEST_DECLARE(name) void run_test_##name(void **state); diff --git a/tests/include/tests/ns.h b/tests/include/tests/ns.h index 90e2cf180e..8661d1d8dd 100644 --- a/tests/include/tests/ns.h +++ b/tests/include/tests/ns.h @@ -54,10 +54,9 @@ extern atomic_uint_fast32_t client_refs[32]; extern atomic_uintptr_t client_addrs[32]; #if ISC_NETMGR_TRACE -#define FLARG \ - , const char *file __attribute__((unused)), \ - unsigned int line __attribute__((unused)), \ - const char *func __attribute__((unused)) +#define FLARG \ + , const char *file ISC_ATTR_UNUSED, unsigned int line ISC_ATTR_UNUSED, \ + const char *func ISC_ATTR_UNUSED #else #define FLARG #endif @@ -67,7 +66,7 @@ setup_server(void **state); int teardown_server(void **state); void -shutdown_interfacemgr(void *arg __attribute__((unused))); +shutdown_interfacemgr(void *arg ISC_ATTR_UNUSED); /*% * Load data for zone "zonename" from file "filename" and start serving it to diff --git a/tests/isc/doh_test.c b/tests/isc/doh_test.c index 43c0f98191..bb19298df9 100644 --- a/tests/isc/doh_test.c +++ b/tests/isc/doh_test.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include "uv_wrap.h" @@ -335,7 +336,7 @@ setup_test(void **state) { } static int -teardown_test(void **state __attribute__((__unused__))) { +teardown_test(void **state ISC_ATTR_UNUSED) { for (size_t i = 0; i < MAX_NM; i++) { isc_netmgr_destroy(&nm[i]); assert_null(nm[i]); @@ -483,7 +484,7 @@ listen_sock_close(void *arg) { } static void -doh_noop(void *arg __attribute__((__unused__))) { +doh_noop(void *arg ISC_ATTR_UNUSED) { isc_nm_t *listen_nm = nm[0]; isc_nm_t *connect_nm = nm[1]; isc_result_t result = ISC_R_SUCCESS; @@ -526,7 +527,7 @@ ISC_LOOP_TEST_IMPL(doh_noop_GET) { } static void -doh_noresponse(void *arg __attribute__((__unused__))) { +doh_noresponse(void *arg ISC_ATTR_UNUSED) { isc_nm_t *listen_nm = nm[0]; isc_nm_t *connect_nm = nm[1]; isc_result_t result = ISC_R_SUCCESS; @@ -580,8 +581,8 @@ timeout_query_sent_cb(isc_nmhandle_t *handle, isc_result_t eresult, static void timeout_retry_cb(isc_nmhandle_t *handle, isc_result_t eresult, - isc_region_t *region __attribute__((__unused__)), - void *arg __attribute__((__unused__))) { + isc_region_t *region ISC_ATTR_UNUSED, + void *arg ISC_ATTR_UNUSED) { assert_non_null(handle); atomic_fetch_add(&ctimeouts, 1); @@ -617,7 +618,7 @@ timeout_request_cb(isc_nmhandle_t *handle, isc_result_t result, void *arg) { } static void -doh_timeout_recovery(void *arg __attribute__((__unused__))) { +doh_timeout_recovery(void *arg ISC_ATTR_UNUSED) { isc_nm_t *listen_nm = nm[0]; isc_nmsocket_t *listen_sock = NULL; isc_nm_t *connect_nm = nm[1]; @@ -740,7 +741,7 @@ next : {} } static void -doh_recv_one(void *arg __attribute__((__unused__))) { +doh_recv_one(void *arg ISC_ATTR_UNUSED) { isc_nm_t *listen_nm = nm[0]; isc_nm_t *connect_nm = nm[1]; isc_result_t result = ISC_R_SUCCESS; @@ -866,7 +867,7 @@ doh_connect_send_two_requests_cb(isc_nmhandle_t *handle, isc_result_t result, } static void -doh_recv_two(void *arg __attribute__((__unused__))) { +doh_recv_two(void *arg ISC_ATTR_UNUSED) { isc_nm_t *listen_nm = nm[0]; isc_nm_t *connect_nm = nm[1]; isc_result_t result = ISC_R_SUCCESS; @@ -969,7 +970,7 @@ ISC_LOOP_TEST_IMPL(doh_recv_two_GET_TLS_quota) { } static void -doh_recv_send(void *arg __attribute__((__unused__))) { +doh_recv_send(void *arg ISC_ATTR_UNUSED) { isc_nm_t *listen_nm = nm[0]; isc_nm_t *connect_nm = nm[1]; isc_result_t result = ISC_R_SUCCESS; diff --git a/tests/isc/hmac_test.c b/tests/isc/hmac_test.c index ac567d6884..89e23a6291 100644 --- a/tests/isc/hmac_test.c +++ b/tests/isc/hmac_test.c @@ -166,8 +166,8 @@ ISC_RUN_TEST_IMPL(isc_hmac_update) { ISC_RUN_TEST_IMPL(isc_hmac_reset) { isc_hmac_t *hmac = *state; #if 0 - unsigned char digest[ISC_MAX_MD_SIZE] __attribute((unused)); - unsigned int digestlen __attribute((unused)); + unsigned char digest[ISC_MAX_MD_SIZE] ISC_ATTR_UNUSED; + unsigned int digestlen ISC_ATTR_UNUSED; #endif /* if 0 */ assert_non_null(hmac); diff --git a/tests/isc/loop_test.c b/tests/isc/loop_test.c index cf13a4a586..b7acad4224 100644 --- a/tests/isc/loop_test.c +++ b/tests/isc/loop_test.c @@ -65,9 +65,8 @@ ISC_RUN_TEST_IMPL(isc_loopmgr) { } static void -runjob(void *arg __attribute__((__unused__))) { +runjob(void *arg ISC_ATTR_UNUSED) { isc_async_current(loopmgr, count, loopmgr); - if (isc_tid() == 0) { isc_async_current(loopmgr, shutdown_loopmgr, loopmgr); } diff --git a/tests/isc/md_test.c b/tests/isc/md_test.c index d7d154c13b..446367fc3b 100644 --- a/tests/isc/md_test.c +++ b/tests/isc/md_test.c @@ -151,8 +151,8 @@ ISC_RUN_TEST_IMPL(isc_md_update) { ISC_RUN_TEST_IMPL(isc_md_reset) { isc_md_t *md = *state; #if 0 - unsigned char digest[ISC_MAX_MD_SIZE] __attribute((unused)); - unsigned int digestlen __attribute((unused)); + unsigned char digest[ISC_MAX_MD_SIZE] ISC_ATTR_UNUSED; + unsigned int digestlen ISC_ATTR_UNUSED; #endif /* if 0 */ assert_non_null(md); diff --git a/tests/isc/netmgr_common.c b/tests/isc/netmgr_common.c index 62bd912a1f..b8988b9154 100644 --- a/tests/isc/netmgr_common.c +++ b/tests/isc/netmgr_common.c @@ -195,7 +195,7 @@ setup_netmgr_test(void **state) { } int -teardown_netmgr_test(void **state __attribute__((__unused__))) { +teardown_netmgr_test(void **state ISC_ATTR_UNUSED) { UNUSED(state); isc_tlsctx_client_session_cache_detach(&tcp_tlsctx_client_sess_cache); @@ -221,7 +221,7 @@ teardown_netmgr_test(void **state __attribute__((__unused__))) { } static void -stop_listening(void *arg __attribute__((__unused__))) { +stop_listening(void *arg ISC_ATTR_UNUSED) { isc_nm_stoplistening(listen_sock); isc_nmsocket_close(&listen_sock); assert_null(listen_sock); @@ -628,14 +628,14 @@ connect_success_cb(isc_nmhandle_t *handle, isc_result_t eresult, void *cbarg) { } int -stream_noop_setup(void **state __attribute__((__unused__))) { +stream_noop_setup(void **state ISC_ATTR_UNUSED) { int r = setup_netmgr_test(state); expected_cconnects = 1; return (r); } void -stream_noop(void **state __attribute__((__unused__))) { +stream_noop(void **state ISC_ATTR_UNUSED) { isc_result_t result = ISC_R_SUCCESS; result = stream_listen(noop_accept_cb, NULL, 128, NULL, &listen_sock); @@ -647,7 +647,7 @@ stream_noop(void **state __attribute__((__unused__))) { } int -stream_noop_teardown(void **state __attribute__((__unused__))) { +stream_noop_teardown(void **state ISC_ATTR_UNUSED) { atomic_assert_int_eq(cconnects, 1); atomic_assert_int_eq(csends, 0); atomic_assert_int_eq(creads, 0); @@ -713,7 +713,7 @@ noresponse_connectcb(isc_nmhandle_t *handle, isc_result_t eresult, } int -stream_noresponse_setup(void **state __attribute__((__unused__))) { +stream_noresponse_setup(void **state ISC_ATTR_UNUSED) { int r = setup_netmgr_test(state); expected_cconnects = 1; expected_saccepts = 1; @@ -721,7 +721,7 @@ stream_noresponse_setup(void **state __attribute__((__unused__))) { } void -stream_noresponse(void **state __attribute__((__unused__))) { +stream_noresponse(void **state ISC_ATTR_UNUSED) { isc_result_t result = ISC_R_SUCCESS; result = stream_listen(noop_accept_cb, NULL, 128, NULL, &listen_sock); @@ -732,7 +732,7 @@ stream_noresponse(void **state __attribute__((__unused__))) { } int -stream_noresponse_teardown(void **state __attribute__((__unused__))) { +stream_noresponse_teardown(void **state ISC_ATTR_UNUSED) { X(cconnects); X(csends); X(creads); @@ -748,7 +748,7 @@ stream_noresponse_teardown(void **state __attribute__((__unused__))) { } int -stream_timeout_recovery_setup(void **state __attribute__((__unused__))) { +stream_timeout_recovery_setup(void **state ISC_ATTR_UNUSED) { int r = setup_netmgr_test(state); expected_ctimeouts = 4; @@ -761,7 +761,7 @@ stream_timeout_recovery_setup(void **state __attribute__((__unused__))) { } void -stream_timeout_recovery(void **state __attribute__((__unused__))) { +stream_timeout_recovery(void **state ISC_ATTR_UNUSED) { isc_result_t result = ISC_R_SUCCESS; /* @@ -782,13 +782,13 @@ stream_timeout_recovery(void **state __attribute__((__unused__))) { } int -stream_timeout_recovery_teardown(void **state __attribute__((__unused__))) { +stream_timeout_recovery_teardown(void **state ISC_ATTR_UNUSED) { atomic_assert_int_eq(ctimeouts, expected_ctimeouts); return (teardown_netmgr_test(state)); } int -stream_recv_one_setup(void **state __attribute__((__unused__))) { +stream_recv_one_setup(void **state ISC_ATTR_UNUSED) { int r = setup_netmgr_test(state); expected_cconnects = 1; @@ -813,7 +813,7 @@ stream_recv_one_setup(void **state __attribute__((__unused__))) { } void -stream_recv_one(void **state __attribute__((__unused__))) { +stream_recv_one(void **state ISC_ATTR_UNUSED) { isc_result_t result = ISC_R_SUCCESS; isc_quota_t *quotap = tcp_listener_init_quota(1); @@ -828,7 +828,7 @@ stream_recv_one(void **state __attribute__((__unused__))) { } int -stream_recv_one_teardown(void **state __attribute__((__unused__))) { +stream_recv_one_teardown(void **state ISC_ATTR_UNUSED) { atomic_assert_int_eq(cconnects, expected_cconnects); atomic_assert_int_eq(csends, expected_csends); atomic_assert_int_eq(saccepts, expected_saccepts); @@ -840,7 +840,7 @@ stream_recv_one_teardown(void **state __attribute__((__unused__))) { } int -stream_recv_two_setup(void **state __attribute__((__unused__))) { +stream_recv_two_setup(void **state ISC_ATTR_UNUSED) { int r = setup_netmgr_test(state); expected_cconnects = 2; @@ -865,7 +865,7 @@ stream_recv_two_setup(void **state __attribute__((__unused__))) { } void -stream_recv_two(void **state __attribute__((__unused__))) { +stream_recv_two(void **state ISC_ATTR_UNUSED) { isc_result_t result = ISC_R_SUCCESS; isc_quota_t *quotap = tcp_listener_init_quota(1); @@ -882,7 +882,7 @@ stream_recv_two(void **state __attribute__((__unused__))) { } int -stream_recv_two_teardown(void **state __attribute__((__unused__))) { +stream_recv_two_teardown(void **state ISC_ATTR_UNUSED) { atomic_assert_int_eq(cconnects, expected_cconnects); atomic_assert_int_eq(csends, expected_csends); atomic_assert_int_eq(sreads, expected_saccepts); @@ -894,7 +894,7 @@ stream_recv_two_teardown(void **state __attribute__((__unused__))) { } int -stream_recv_send_setup(void **state __attribute__((__unused__))) { +stream_recv_send_setup(void **state ISC_ATTR_UNUSED) { int r = setup_netmgr_test(state); expected_cconnects = workers; cconnects_shutdown = false; @@ -905,7 +905,7 @@ stream_recv_send_setup(void **state __attribute__((__unused__))) { } void -stream_recv_send(void **state __attribute__((__unused__))) { +stream_recv_send(void **state ISC_ATTR_UNUSED) { isc_result_t result = ISC_R_SUCCESS; isc_quota_t *quotap = tcp_listener_init_quota(workers); @@ -922,7 +922,7 @@ stream_recv_send(void **state __attribute__((__unused__))) { } int -stream_recv_send_teardown(void **state __attribute__((__unused__))) { +stream_recv_send_teardown(void **state ISC_ATTR_UNUSED) { X(cconnects); X(csends); X(creads); diff --git a/tests/isc/netmgr_common.h b/tests/isc/netmgr_common.h index 31d63f3fc9..3ff3f62fef 100644 --- a/tests/isc/netmgr_common.h +++ b/tests/isc/netmgr_common.h @@ -15,6 +15,7 @@ #include #include #include +#include #include "netmgr/netmgr-int.h" @@ -227,7 +228,7 @@ extern isc_nm_recv_cb_t connect_readcb; int setup_netmgr_test(void **state); int -teardown_netmgr_test(void **state __attribute__((unused))); +teardown_netmgr_test(void **state ISC_ATTR_UNUSED); void noop_recv_cb(isc_nmhandle_t *handle, isc_result_t eresult, isc_region_t *region, @@ -282,45 +283,45 @@ void stream_connect(isc_nm_cb_t cb, void *cbarg, unsigned int timeout); int -stream_noop_setup(void **state __attribute__((unused))); +stream_noop_setup(void **state ISC_ATTR_UNUSED); void -stream_noop(void **state __attribute__((unused))); +stream_noop(void **state ISC_ATTR_UNUSED); int -stream_noop_teardown(void **state __attribute__((unused))); +stream_noop_teardown(void **state ISC_ATTR_UNUSED); int -stream_noresponse_setup(void **state __attribute__((unused))); +stream_noresponse_setup(void **state ISC_ATTR_UNUSED); void -stream_noresponse(void **state __attribute__((unused))); +stream_noresponse(void **state ISC_ATTR_UNUSED); int -stream_noresponse_teardown(void **state __attribute__((unused))); +stream_noresponse_teardown(void **state ISC_ATTR_UNUSED); int -stream_timeout_recovery_setup(void **state __attribute__((unused))); +stream_timeout_recovery_setup(void **state ISC_ATTR_UNUSED); void -stream_timeout_recovery(void **state __attribute__((unused))); +stream_timeout_recovery(void **state ISC_ATTR_UNUSED); int -stream_timeout_recovery_teardown(void **state __attribute__((unused))); +stream_timeout_recovery_teardown(void **state ISC_ATTR_UNUSED); int -stream_recv_one_setup(void **state __attribute__((unused))); +stream_recv_one_setup(void **state ISC_ATTR_UNUSED); void -stream_recv_one(void **state __attribute__((unused))); +stream_recv_one(void **state ISC_ATTR_UNUSED); int -stream_recv_one_teardown(void **state __attribute__((unused))); +stream_recv_one_teardown(void **state ISC_ATTR_UNUSED); int -stream_recv_two_setup(void **state __attribute__((unused))); +stream_recv_two_setup(void **state ISC_ATTR_UNUSED); void -stream_recv_two(void **state __attribute__((unused))); +stream_recv_two(void **state ISC_ATTR_UNUSED); int -stream_recv_two_teardown(void **state __attribute__((unused))); +stream_recv_two_teardown(void **state ISC_ATTR_UNUSED); int -stream_recv_send_setup(void **state __attribute__((unused))); +stream_recv_send_setup(void **state ISC_ATTR_UNUSED); void -stream_recv_send(void **state __attribute__((unused))); +stream_recv_send(void **state ISC_ATTR_UNUSED); int -stream_recv_send_teardown(void **state __attribute__((unused))); +stream_recv_send_teardown(void **state ISC_ATTR_UNUSED); void stream_recv_send_connect(void *arg); diff --git a/tests/isc/tcp_test.c b/tests/isc/tcp_test.c index b76394fa6f..1095fb66e0 100644 --- a/tests/isc/tcp_test.c +++ b/tests/isc/tcp_test.c @@ -131,7 +131,7 @@ ISC_TEST_ENTRY_CUSTOM(tcp_recv_send_quota_sendback, stream_recv_send_setup, ISC_TEST_LIST_END static int -tcp_setup(void **state __attribute__((__unused__))) { +tcp_setup(void **state ISC_ATTR_UNUSED) { stream_port = TCP_TEST_PORT; stream_use_TLS = false; stream = true; diff --git a/tests/isc/tcpdns_test.c b/tests/isc/tcpdns_test.c index 4747f4ad20..7006add141 100644 --- a/tests/isc/tcpdns_test.c +++ b/tests/isc/tcpdns_test.c @@ -41,7 +41,7 @@ /* TCPDNS */ static void -stop_listening(void *arg __attribute__((__unused__))) { +stop_listening(void *arg ISC_ATTR_UNUSED) { isc_nm_stoplistening(listen_sock); isc_nmsocket_close(&listen_sock); assert_null(listen_sock); @@ -143,7 +143,7 @@ ISC_TEST_ENTRY_CUSTOM(tcpdns_recv_send, stream_recv_send_setup, ISC_TEST_LIST_END static int -tcpdns_setup(void **state __attribute__((__unused__))) { +tcpdns_setup(void **state ISC_ATTR_UNUSED) { stream_port = TCPDNS_TEST_PORT; return (0); diff --git a/tests/isc/timer_test.c b/tests/isc/timer_test.c index cd9412e648..ba68056196 100644 --- a/tests/isc/timer_test.c +++ b/tests/isc/timer_test.c @@ -427,7 +427,7 @@ ISC_LOOP_TEARDOWN_IMPL(timer_expect) { } static void -timer_event(void *arg __attribute__((__unused__))) { +timer_event(void *arg ISC_ATTR_UNUSED) { if (--timer_ticks == 0) { isc_timer_destroy(&timer); isc_loopmgr_shutdown(loopmgr); diff --git a/tests/isc/tls_test.c b/tests/isc/tls_test.c index 200fc2adfd..6ba6269336 100644 --- a/tests/isc/tls_test.c +++ b/tests/isc/tls_test.c @@ -126,7 +126,7 @@ ISC_TEST_ENTRY_CUSTOM(tls_recv_send_quota_sendback, stream_recv_send_setup, ISC_TEST_LIST_END static int -tls_setup(void **state __attribute__((__unused__))) { +tls_setup(void **state ISC_ATTR_UNUSED) { stream_port = TLS_TEST_PORT; stream_use_TLS = true; stream = true; diff --git a/tests/isc/tlsdns_test.c b/tests/isc/tlsdns_test.c index b33496ba7d..e42be5e6bb 100644 --- a/tests/isc/tlsdns_test.c +++ b/tests/isc/tlsdns_test.c @@ -40,7 +40,7 @@ #include static void -stop_listening(void *arg __attribute__((__unused__))) { +stop_listening(void *arg ISC_ATTR_UNUSED) { isc_nm_stoplistening(listen_sock); isc_nmsocket_close(&listen_sock); assert_null(listen_sock); @@ -153,7 +153,7 @@ ISC_TEST_ENTRY_CUSTOM(tlsdns_recv_send, stream_recv_send_setup, ISC_TEST_LIST_END static int -tlsdns_setup(void **state __attribute__((__unused__))) { +tlsdns_setup(void **state ISC_ATTR_UNUSED) { stream_port = TLSDNS_TEST_PORT; return (0); diff --git a/tests/isc/udp_test.c b/tests/isc/udp_test.c index 17221a1fb9..ab6742d77b 100644 --- a/tests/isc/udp_test.c +++ b/tests/isc/udp_test.c @@ -139,7 +139,7 @@ connect_nomemory_cb(isc_nmhandle_t *handle, isc_result_t eresult, void *cbarg) { } static void -stop_listening(void *arg __attribute__((__unused__))) { +stop_listening(void *arg ISC_ATTR_UNUSED) { isc_nm_stoplistening(listen_sock); isc_nmsocket_close(&listen_sock); assert_null(listen_sock); @@ -520,7 +520,7 @@ udp_shutdown_connect_connect_cb(isc_nmhandle_t *handle, isc_result_t eresult, } static void -udp_connect_udpconnect(void *arg __attribute__((__unused__))) { +udp_connect_udpconnect(void *arg ISC_ATTR_UNUSED) { isc_nm_udpconnect(netmgr, &udp_connect_addr, &udp_listen_addr, udp_shutdown_connect_connect_cb, NULL, T_SOFT); } @@ -790,7 +790,7 @@ udp__send_cb(isc_nmhandle_t *handle, isc_result_t eresult, void *cbarg) { static void udp__connect_cb(isc_nmhandle_t *handle, isc_result_t eresult, void *cbarg); static void -udp__connect(void *arg __attribute__((__unused__))) { +udp__connect(void *arg ISC_ATTR_UNUSED) { isc_sockaddr_t connect_addr; connect_addr = (isc_sockaddr_t){ .length = 0 }; diff --git a/tests/isc/uv_wrap.h b/tests/isc/uv_wrap.h index 8a6f7598ff..c499fa6db9 100644 --- a/tests/isc/uv_wrap.h +++ b/tests/isc/uv_wrap.h @@ -25,6 +25,7 @@ #include #include +#include #define UNIT_TESTING #include @@ -114,7 +115,7 @@ __wrap_uv_udp_bind(uv_udp_t *handle, const struct sockaddr *addr, return (atomic_load(&__state_uv_udp_bind)); } -static atomic_int __state_uv_udp_connect __attribute__((unused)) = 0; +static atomic_int __state_uv_udp_connect ISC_ATTR_UNUSED = 0; int __wrap_uv_udp_connect(uv_udp_t *handle, const struct sockaddr *addr) { @@ -124,7 +125,7 @@ __wrap_uv_udp_connect(uv_udp_t *handle, const struct sockaddr *addr) { return (atomic_load(&__state_uv_udp_connect)); } -static atomic_int __state_uv_udp_getpeername __attribute__((unused)) = 0; +static atomic_int __state_uv_udp_getpeername ISC_ATTR_UNUSED = 0; int __wrap_uv_udp_getpeername(const uv_udp_t *handle, struct sockaddr *name, diff --git a/tests/libtest/isc.c b/tests/libtest/isc.c index d9da8e2e61..bc542a7f1f 100644 --- a/tests/libtest/isc.c +++ b/tests/libtest/isc.c @@ -52,7 +52,7 @@ adjustnofile(void) { } int -setup_mctx(void **state __attribute__((__unused__))) { +setup_mctx(void **state ISC_ATTR_UNUSED) { isc_mem_debugging |= ISC_MEM_DEBUGRECORD; isc_mem_create(&mctx); @@ -60,14 +60,14 @@ setup_mctx(void **state __attribute__((__unused__))) { } int -teardown_mctx(void **state __attribute__((__unused__))) { +teardown_mctx(void **state ISC_ATTR_UNUSED) { isc_mem_destroy(&mctx); return (0); } int -setup_loopmgr(void **state __attribute__((__unused__))) { +setup_loopmgr(void **state ISC_ATTR_UNUSED) { char *env_workers = NULL; REQUIRE(mctx != NULL); @@ -88,7 +88,7 @@ setup_loopmgr(void **state __attribute__((__unused__))) { } int -teardown_loopmgr(void **state __attribute__((__unused__))) { +teardown_loopmgr(void **state ISC_ATTR_UNUSED) { REQUIRE(netmgr == NULL); mainloop = NULL; @@ -98,7 +98,7 @@ teardown_loopmgr(void **state __attribute__((__unused__))) { } int -setup_netmgr(void **state __attribute__((__unused__))) { +setup_netmgr(void **state ISC_ATTR_UNUSED) { REQUIRE(loopmgr != NULL); adjustnofile(); @@ -109,7 +109,7 @@ setup_netmgr(void **state __attribute__((__unused__))) { } int -teardown_netmgr(void **state __attribute__((__unused__))) { +teardown_netmgr(void **state ISC_ATTR_UNUSED) { REQUIRE(loopmgr != NULL); isc_netmgr_destroy(&netmgr); diff --git a/tests/libtest/ns.c b/tests/libtest/ns.c index 4e450c86dd..4d9014ae17 100644 --- a/tests/libtest/ns.c +++ b/tests/libtest/ns.c @@ -115,7 +115,7 @@ cleanup: } void -shutdown_interfacemgr(void *arg __attribute__((__unused__))) { +shutdown_interfacemgr(void *arg ISC_ATTR_UNUSED) { if (interfacemgr != NULL) { ns_interfacemgr_shutdown(interfacemgr); ns_interfacemgr_detach(&interfacemgr); diff --git a/tests/ns/netmgr_wrap.c b/tests/ns/netmgr_wrap.c index e347b0612a..ef5b7dd4c1 100644 --- a/tests/ns/netmgr_wrap.c +++ b/tests/ns/netmgr_wrap.c @@ -22,10 +22,9 @@ #include #if ISC_NETMGR_TRACE -#define FLARG \ - , const char *file __attribute__((unused)), \ - unsigned int line __attribute__((unused)), \ - const char *func __attribute__((unused)) +#define FLARG \ + , const char *file ISC_ATTR_UNUSED, unsigned int line ISC_ATTR_UNUSED, \ + const char *func ISC_ATTR_UNUSED #else #define FLARG #endif