diff --git a/bin/dig/dig.c b/bin/dig/dig.c index c268e35218..7b4fd41274 100644 --- a/bin/dig/dig.c +++ b/bin/dig/dig.c @@ -59,7 +59,7 @@ dig_lookup_t *default_lookup = NULL; -static atomic_uintptr_t batchname = ATOMIC_VAR_INIT(0); +static atomic_uintptr_t batchname = 0; static FILE *batchfp = NULL; static char *argv0; static int addresscount = 0; diff --git a/bin/dig/dighost.c b/bin/dig/dighost.c index c736a3357a..10bf24fc13 100644 --- a/bin/dig/dighost.c +++ b/bin/dig/dighost.c @@ -89,7 +89,7 @@ dig_lookuplist_t lookup_list; dig_serverlist_t server_list; dig_searchlistlist_t search_list; -static atomic_bool cancel_now = ATOMIC_VAR_INIT(false); +static atomic_bool cancel_now = false; bool check_ra = false, have_ipv4 = false, have_ipv6 = false, specified_source = false, free_now = false, usesearch = false, @@ -105,8 +105,8 @@ isc_nm_t *netmgr = NULL; isc_taskmgr_t *taskmgr = NULL; isc_task_t *global_task = NULL; isc_sockaddr_t localaddr; -isc_refcount_t sendcount = ATOMIC_VAR_INIT(0); -isc_refcount_t recvcount = ATOMIC_VAR_INIT(0); +isc_refcount_t sendcount = 0; +isc_refcount_t recvcount = 0; int ndots = -1; int tries = -1; int lookup_counter = 0; diff --git a/bin/rndc/rndc.c b/bin/rndc/rndc.c index f25db5a80a..949ab609a3 100644 --- a/bin/rndc/rndc.c +++ b/bin/rndc/rndc.c @@ -80,9 +80,9 @@ static isccc_region_t secret; static bool failed = false; static bool c_flag = false; static isc_mem_t *rndc_mctx = NULL; -static atomic_uint_fast32_t sends = ATOMIC_VAR_INIT(0); -static atomic_uint_fast32_t recvs = ATOMIC_VAR_INIT(0); -static atomic_uint_fast32_t connects = ATOMIC_VAR_INIT(0); +static atomic_uint_fast32_t sends = 0; +static atomic_uint_fast32_t recvs = 0; +static atomic_uint_fast32_t connects = 0; static char *command = NULL; static char *args = NULL; static char program[256]; diff --git a/lib/dns/rbtdb.c b/lib/dns/rbtdb.c index 1f3be609d6..df79f5de64 100644 --- a/lib/dns/rbtdb.c +++ b/lib/dns/rbtdb.c @@ -719,7 +719,7 @@ setownercase(rdatasetheader_t *header, const dns_name_t *name); * that indicates that the database does not implement cyclic * processing. */ -static atomic_uint_fast32_t init_count = ATOMIC_VAR_INIT(0); +static atomic_uint_fast32_t init_count = 0; /* * Locking @@ -819,7 +819,8 @@ update_rrsetstats(dns_rbtdb_t *rbtdb, const rbtdb_rdatatype_t htype, dns_rdatastatstype_t base = 0; dns_rdatastatstype_t type; rdatasetheader_t *header = &(rdatasetheader_t){ - .type = htype, .attributes = ATOMIC_VAR_INIT(hattributes) + .type = htype, + .attributes = hattributes, }; if (!do_stats(header)) { diff --git a/lib/dns/tests/dispatch_test.c b/lib/dns/tests/dispatch_test.c index c264ade13d..89a4c2e083 100644 --- a/lib/dns/tests/dispatch_test.c +++ b/lib/dns/tests/dispatch_test.c @@ -276,7 +276,7 @@ struct { static dns_dispatch_t *dispatch = NULL; static dns_dispentry_t *dispentry = NULL; -static atomic_bool first = ATOMIC_VAR_INIT(true); +static atomic_bool first = true; static void reset_testdata(void) { diff --git a/lib/isc/app.c b/lib/isc/app.c index 90f5d161f2..d5bf097e99 100644 --- a/lib/isc/app.c +++ b/lib/isc/app.c @@ -43,7 +43,7 @@ */ static isc_thread_t blockedthread; -static atomic_bool is_running = ATOMIC_VAR_INIT(0); +static atomic_bool is_running = 0; /* * The application context of this module. diff --git a/lib/isc/include/isc/stdatomic.h b/lib/isc/include/isc/stdatomic.h index cd3c99bc55..7c2e21caa5 100644 --- a/lib/isc/include/isc/stdatomic.h +++ b/lib/isc/include/isc/stdatomic.h @@ -29,8 +29,6 @@ #error "isc/stdatomic.h does not support your compiler" #endif /* if !defined(__GNUC_ATOMICS) */ -#define ATOMIC_VAR_INIT(x) x - typedef enum memory_order { memory_order_relaxed = __ATOMIC_RELAXED, memory_order_consume = __ATOMIC_CONSUME, diff --git a/lib/isc/mem.c b/lib/isc/mem.c index 890b4dd0ab..f21954b65a 100644 --- a/lib/isc/mem.c +++ b/lib/isc/mem.c @@ -1414,7 +1414,7 @@ print_contexts(FILE *file) { } #endif -static atomic_uintptr_t checkdestroyed = ATOMIC_VAR_INIT(0); +static atomic_uintptr_t checkdestroyed = 0; void isc_mem_checkdestroyed(FILE *file) { diff --git a/lib/isc/netmgr/tcp.c b/lib/isc/netmgr/tcp.c index c924c25e6c..43761b6337 100644 --- a/lib/isc/netmgr/tcp.c +++ b/lib/isc/netmgr/tcp.c @@ -37,7 +37,7 @@ #include "netmgr-int.h" #include "uv-compat.h" -static atomic_uint_fast32_t last_tcpquota_log = ATOMIC_VAR_INIT(0); +static atomic_uint_fast32_t last_tcpquota_log = 0; static bool can_log_tcp_quota(void) { diff --git a/lib/isc/netmgr/tcpdns.c b/lib/isc/netmgr/tcpdns.c index d57e2a149d..fd5a1b6781 100644 --- a/lib/isc/netmgr/tcpdns.c +++ b/lib/isc/netmgr/tcpdns.c @@ -37,7 +37,7 @@ #include "netmgr-int.h" #include "uv-compat.h" -static atomic_uint_fast32_t last_tcpdnsquota_log = ATOMIC_VAR_INIT(0); +static atomic_uint_fast32_t last_tcpdnsquota_log = 0; static bool can_log_tcpdns_quota(void) { diff --git a/lib/isc/netmgr/tlsdns.c b/lib/isc/netmgr/tlsdns.c index 1e93a92c5e..cea2041f9e 100644 --- a/lib/isc/netmgr/tlsdns.c +++ b/lib/isc/netmgr/tlsdns.c @@ -38,7 +38,7 @@ #include "openssl_shim.h" #include "uv-compat.h" -static atomic_uint_fast32_t last_tlsdnsquota_log = ATOMIC_VAR_INIT(0); +static atomic_uint_fast32_t last_tlsdnsquota_log = 0; static void tls_error(isc_nmsocket_t *sock, isc_result_t result); diff --git a/lib/isc/tests/doh_test.c b/lib/isc/tests/doh_test.c index 179c5fba97..0a8a045f65 100644 --- a/lib/isc/tests/doh_test.c +++ b/lib/isc/tests/doh_test.c @@ -58,32 +58,32 @@ static uint64_t stop_magic = 0; static uv_buf_t send_msg = { .base = (char *)&send_magic, .len = sizeof(send_magic) }; -static atomic_int_fast64_t active_cconnects = ATOMIC_VAR_INIT(0); -static atomic_int_fast64_t nsends = ATOMIC_VAR_INIT(0); -static atomic_int_fast64_t ssends = ATOMIC_VAR_INIT(0); -static atomic_int_fast64_t sreads = ATOMIC_VAR_INIT(0); -static atomic_int_fast64_t csends = ATOMIC_VAR_INIT(0); -static atomic_int_fast64_t creads = ATOMIC_VAR_INIT(0); -static atomic_int_fast64_t ctimeouts = ATOMIC_VAR_INIT(0); -static atomic_int_fast64_t total_sends = ATOMIC_VAR_INIT(0); +static atomic_int_fast64_t active_cconnects = 0; +static atomic_int_fast64_t nsends = 0; +static atomic_int_fast64_t ssends = 0; +static atomic_int_fast64_t sreads = 0; +static atomic_int_fast64_t csends = 0; +static atomic_int_fast64_t creads = 0; +static atomic_int_fast64_t ctimeouts = 0; +static atomic_int_fast64_t total_sends = 0; -static atomic_bool was_error = ATOMIC_VAR_INIT(false); +static atomic_bool was_error = false; static unsigned int workers = 0; static bool reuse_supported = true; static bool noanswer = false; -static atomic_bool POST = ATOMIC_VAR_INIT(true); +static atomic_bool POST = true; -static atomic_bool slowdown = ATOMIC_VAR_INIT(false); +static atomic_bool slowdown = false; -static atomic_bool use_TLS = ATOMIC_VAR_INIT(false); +static atomic_bool use_TLS = false; static isc_tlsctx_t *server_tlsctx = NULL; static isc_tlsctx_t *client_tlsctx = NULL; static isc_quota_t listener_quota; -static atomic_bool check_listener_quota = ATOMIC_VAR_INIT(false); +static atomic_bool check_listener_quota = false; static isc_nm_http_endpoints_t *endpoints = NULL; diff --git a/lib/isc/tests/netmgr_test.c b/lib/isc/tests/netmgr_test.c index 50cf0d9e44..1acaca5e90 100644 --- a/lib/isc/tests/netmgr_test.c +++ b/lib/isc/tests/netmgr_test.c @@ -69,20 +69,20 @@ static uv_buf_t send_msg = { .base = (char *)&send_magic, static uv_buf_t stop_msg = { .base = (char *)&stop_magic, .len = sizeof(stop_magic) }; -static atomic_bool do_send = ATOMIC_VAR_INIT(false); +static atomic_bool do_send = false; static unsigned int workers = 0; static atomic_int_fast64_t nsends; static int_fast64_t esends; /* expected sends */ -static atomic_int_fast64_t ssends = ATOMIC_VAR_INIT(0); -static atomic_int_fast64_t sreads = ATOMIC_VAR_INIT(0); -static atomic_int_fast64_t saccepts = ATOMIC_VAR_INIT(0); +static atomic_int_fast64_t ssends = 0; +static atomic_int_fast64_t sreads = 0; +static atomic_int_fast64_t saccepts = 0; -static atomic_int_fast64_t cconnects = ATOMIC_VAR_INIT(0); -static atomic_int_fast64_t csends = ATOMIC_VAR_INIT(0); -static atomic_int_fast64_t creads = ATOMIC_VAR_INIT(0); -static atomic_int_fast64_t ctimeouts = ATOMIC_VAR_INIT(0); +static atomic_int_fast64_t cconnects = 0; +static atomic_int_fast64_t csends = 0; +static atomic_int_fast64_t creads = 0; +static atomic_int_fast64_t ctimeouts = 0; static isc_refcount_t active_cconnects; static isc_refcount_t active_csends; diff --git a/lib/isc/tests/quota_test.c b/lib/isc/tests/quota_test.c index 28668cf99e..854afd92b5 100644 --- a/lib/isc/tests/quota_test.c +++ b/lib/isc/tests/quota_test.c @@ -139,7 +139,7 @@ isc_quota_soft_test(void **state) { isc_quota_destroy("a); } -static atomic_uint_fast32_t cb_calls = ATOMIC_VAR_INIT(0); +static atomic_uint_fast32_t cb_calls = 0; static isc_quota_cb_t cbs[30]; static isc_quota_t *qp; @@ -253,7 +253,7 @@ typedef struct qthreadinfo { isc_quota_cb_t callbacks[100]; } qthreadinfo_t; -static atomic_uint_fast32_t g_tnum = ATOMIC_VAR_INIT(0); +static atomic_uint_fast32_t g_tnum = 0; /* at most 10 * 100 quota_detach threads */ isc_thread_t g_threads[10 * 100]; diff --git a/lib/isc/tests/uv_wrap.h b/lib/isc/tests/uv_wrap.h index 50b4e5ad43..5c557b8988 100644 --- a/lib/isc/tests/uv_wrap.h +++ b/lib/isc/tests/uv_wrap.h @@ -96,7 +96,7 @@ __wrap_uv_fileno(const uv_handle_t *handle, uv_os_fd_t *fd); * uv_timer_start */ -static atomic_int __state_uv_udp_open = ATOMIC_VAR_INIT(0); +static atomic_int __state_uv_udp_open = 0; int __wrap_uv_udp_open(uv_udp_t *handle, uv_os_sock_t sock) { @@ -106,7 +106,7 @@ __wrap_uv_udp_open(uv_udp_t *handle, uv_os_sock_t sock) { return (atomic_load(&__state_uv_udp_open)); } -static atomic_int __state_uv_udp_bind = ATOMIC_VAR_INIT(0); +static atomic_int __state_uv_udp_bind = 0; int __wrap_uv_udp_bind(uv_udp_t *handle, const struct sockaddr *addr, @@ -117,8 +117,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)) = ATOMIC_VAR_INIT(0); +static atomic_int __state_uv_udp_connect __attribute__((unused)) = 0; #if UV_VERSION_HEX >= UV_VERSION(1, 27, 0) int @@ -130,8 +129,7 @@ __wrap_uv_udp_connect(uv_udp_t *handle, const struct sockaddr *addr) { } #endif /* UV_VERSION_HEX >= UV_VERSION(1, 27, 0) */ -static atomic_int __state_uv_udp_getpeername - __attribute__((unused)) = ATOMIC_VAR_INIT(0); +static atomic_int __state_uv_udp_getpeername __attribute__((unused)) = 0; #if UV_VERSION_HEX >= UV_VERSION(1, 27, 0) int @@ -144,7 +142,7 @@ __wrap_uv_udp_getpeername(const uv_udp_t *handle, struct sockaddr *name, } #endif /* UV_VERSION_HEX >= UV_VERSION(1, 27, 0) */ -static atomic_int __state_uv_udp_getsockname = ATOMIC_VAR_INIT(0); +static atomic_int __state_uv_udp_getsockname = 0; int __wrap_uv_udp_getsockname(const uv_udp_t *handle, struct sockaddr *name, int *namelen) { @@ -154,7 +152,7 @@ __wrap_uv_udp_getsockname(const uv_udp_t *handle, struct sockaddr *name, return (atomic_load(&__state_uv_udp_getsockname)); } -static atomic_int __state_uv_udp_send = ATOMIC_VAR_INIT(0); +static atomic_int __state_uv_udp_send = 0; int __wrap_uv_udp_send(uv_udp_send_t *req, uv_udp_t *handle, const uv_buf_t bufs[], unsigned int nbufs, const struct sockaddr *addr, @@ -165,7 +163,7 @@ __wrap_uv_udp_send(uv_udp_send_t *req, uv_udp_t *handle, const uv_buf_t bufs[], return (atomic_load(&__state_uv_udp_send)); } -static atomic_int __state_uv_udp_recv_start = ATOMIC_VAR_INIT(0); +static atomic_int __state_uv_udp_recv_start = 0; int __wrap_uv_udp_recv_start(uv_udp_t *handle, uv_alloc_cb alloc_cb, uv_udp_recv_cb recv_cb) { @@ -175,7 +173,7 @@ __wrap_uv_udp_recv_start(uv_udp_t *handle, uv_alloc_cb alloc_cb, return (atomic_load(&__state_uv_udp_recv_start)); } -static atomic_int __state_uv_udp_recv_stop = ATOMIC_VAR_INIT(0); +static atomic_int __state_uv_udp_recv_stop = 0; int __wrap_uv_udp_recv_stop(uv_udp_t *handle) { if (atomic_load(&__state_uv_udp_recv_stop) == 0) { @@ -184,7 +182,7 @@ __wrap_uv_udp_recv_stop(uv_udp_t *handle) { return (atomic_load(&__state_uv_udp_recv_stop)); } -static atomic_int __state_uv_tcp_open = ATOMIC_VAR_INIT(0); +static atomic_int __state_uv_tcp_open = 0; int __wrap_uv_tcp_open(uv_tcp_t *handle, uv_os_sock_t sock) { if (atomic_load(&__state_uv_tcp_open) == 0) { @@ -193,7 +191,7 @@ __wrap_uv_tcp_open(uv_tcp_t *handle, uv_os_sock_t sock) { return (atomic_load(&__state_uv_tcp_open)); } -static atomic_int __state_uv_tcp_bind = ATOMIC_VAR_INIT(0); +static atomic_int __state_uv_tcp_bind = 0; int __wrap_uv_tcp_bind(uv_tcp_t *handle, const struct sockaddr *addr, unsigned int flags) { @@ -203,7 +201,7 @@ __wrap_uv_tcp_bind(uv_tcp_t *handle, const struct sockaddr *addr, return (atomic_load(&__state_uv_tcp_bind)); } -static atomic_int __state_uv_tcp_getsockname = ATOMIC_VAR_INIT(0); +static atomic_int __state_uv_tcp_getsockname = 0; int __wrap_uv_tcp_getsockname(const uv_tcp_t *handle, struct sockaddr *name, int *namelen) { @@ -213,7 +211,7 @@ __wrap_uv_tcp_getsockname(const uv_tcp_t *handle, struct sockaddr *name, return (atomic_load(&__state_uv_tcp_getsockname)); } -static atomic_int __state_uv_tcp_getpeername = ATOMIC_VAR_INIT(0); +static atomic_int __state_uv_tcp_getpeername = 0; int __wrap_uv_tcp_getpeername(const uv_tcp_t *handle, struct sockaddr *name, int *namelen) { @@ -223,7 +221,7 @@ __wrap_uv_tcp_getpeername(const uv_tcp_t *handle, struct sockaddr *name, return (atomic_load(&__state_uv_tcp_getpeername)); } -static atomic_int __state_uv_tcp_connect = ATOMIC_VAR_INIT(0); +static atomic_int __state_uv_tcp_connect = 0; int __wrap_uv_tcp_connect(uv_connect_t *req, uv_tcp_t *handle, const struct sockaddr *addr, uv_connect_cb cb) { @@ -233,7 +231,7 @@ __wrap_uv_tcp_connect(uv_connect_t *req, uv_tcp_t *handle, return (atomic_load(&__state_uv_tcp_connect)); } -static atomic_int __state_uv_listen = ATOMIC_VAR_INIT(0); +static atomic_int __state_uv_listen = 0; int __wrap_uv_listen(uv_stream_t *stream, int backlog, uv_connection_cb cb) { if (atomic_load(&__state_uv_listen) == 0) { @@ -242,7 +240,7 @@ __wrap_uv_listen(uv_stream_t *stream, int backlog, uv_connection_cb cb) { return (atomic_load(&__state_uv_listen)); } -static atomic_int __state_uv_accept = ATOMIC_VAR_INIT(0); +static atomic_int __state_uv_accept = 0; int __wrap_uv_accept(uv_stream_t *server, uv_stream_t *client) { if (atomic_load(&__state_uv_accept) == 0) { @@ -251,7 +249,7 @@ __wrap_uv_accept(uv_stream_t *server, uv_stream_t *client) { return (atomic_load(&__state_uv_accept)); } -static atomic_int __state_uv_send_buffer_size = ATOMIC_VAR_INIT(0); +static atomic_int __state_uv_send_buffer_size = 0; int __wrap_uv_send_buffer_size(uv_handle_t *handle, int *value) { if (atomic_load(&__state_uv_send_buffer_size) == 0) { @@ -260,7 +258,7 @@ __wrap_uv_send_buffer_size(uv_handle_t *handle, int *value) { return (atomic_load(&__state_uv_send_buffer_size)); } -static atomic_int __state_uv_recv_buffer_size = ATOMIC_VAR_INIT(0); +static atomic_int __state_uv_recv_buffer_size = 0; int __wrap_uv_recv_buffer_size(uv_handle_t *handle, int *value) { if (atomic_load(&__state_uv_recv_buffer_size) == 0) { @@ -269,7 +267,7 @@ __wrap_uv_recv_buffer_size(uv_handle_t *handle, int *value) { return (atomic_load(&__state_uv_recv_buffer_size)); } -static atomic_int __state_uv_fileno = ATOMIC_VAR_INIT(0); +static atomic_int __state_uv_fileno = 0; int __wrap_uv_fileno(const uv_handle_t *handle, uv_os_fd_t *fd) { if (atomic_load(&__state_uv_fileno) == 0) { diff --git a/lib/isc/tls.c b/lib/isc/tls.c index 349e026ea0..a726d94aeb 100644 --- a/lib/isc/tls.c +++ b/lib/isc/tls.c @@ -51,8 +51,8 @@ static isc_once_t init_once = ISC_ONCE_INIT; static isc_once_t shut_once = ISC_ONCE_INIT; -static atomic_bool init_done = ATOMIC_VAR_INIT(false); -static atomic_bool shut_done = ATOMIC_VAR_INIT(false); +static atomic_bool init_done = false; +static atomic_bool shut_done = false; #if OPENSSL_VERSION_NUMBER < 0x10100000L static isc_mutex_t *locks = NULL; diff --git a/lib/ns/client.c b/lib/ns/client.c index a155243932..b0fa0c40e9 100644 --- a/lib/ns/client.c +++ b/lib/ns/client.c @@ -115,7 +115,7 @@ #define NS_CLIENT_DROPPORT 1 #endif /* ifndef NS_CLIENT_DROPPORT */ -atomic_uint_fast64_t ns_client_requests = ATOMIC_VAR_INIT(0); +atomic_uint_fast64_t ns_client_requests = 0; static void clientmgr_attach(ns_clientmgr_t *source, ns_clientmgr_t **targetp); diff --git a/lib/ns/tests/nstest.c b/lib/ns/tests/nstest.c index 9990363c48..84a822bdd1 100644 --- a/lib/ns/tests/nstest.c +++ b/lib/ns/tests/nstest.c @@ -67,7 +67,7 @@ ns_server_t *sctx = NULL; bool app_running = false; int ncpus; bool debug_mem_record = true; -static atomic_bool run_managers = ATOMIC_VAR_INIT(false); +static atomic_bool run_managers = false; static bool dst_active = false; static bool test_running = false; @@ -156,7 +156,7 @@ matchview(isc_netaddr_t *srcaddr, isc_netaddr_t *destaddr, /* * These need to be shut down from a running task. */ -static atomic_bool shutdown_done = ATOMIC_VAR_INIT(false); +static atomic_bool shutdown_done = false; static void shutdown_managers(isc_task_t *task, isc_event_t *event) { UNUSED(task);