]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Remove usage of deprecated ATOMIC_VAR_INIT() macro
authorOndřej Surý <ondrej@isc.org>
Tue, 8 Mar 2022 22:55:10 +0000 (23:55 +0100)
committerOndřej Surý <ondrej@isc.org>
Tue, 8 Mar 2022 22:55:10 +0000 (23:55 +0100)
The C17 standard deprecated ATOMIC_VAR_INIT() macro (see [1]).  Follow
the suite and remove the ATOMIC_VAR_INIT() usage in favor of simple
assignment of the value as this is what all supported stdatomic.h
implementations do anyway:

  * MacOSX.plaform: #define ATOMIC_VAR_INIT(__v) {__v}
  * Gcc stdatomic.h: #define ATOMIC_VAR_INIT(VALUE) (VALUE)

1. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1138r0.pdf

18 files changed:
bin/dig/dig.c
bin/dig/dighost.c
bin/rndc/rndc.c
lib/dns/rbtdb.c
lib/dns/tests/dispatch_test.c
lib/isc/app.c
lib/isc/include/isc/stdatomic.h
lib/isc/mem.c
lib/isc/netmgr/tcp.c
lib/isc/netmgr/tcpdns.c
lib/isc/netmgr/tlsdns.c
lib/isc/tests/doh_test.c
lib/isc/tests/netmgr_test.c
lib/isc/tests/quota_test.c
lib/isc/tests/uv_wrap.h
lib/isc/tls.c
lib/ns/client.c
lib/ns/tests/nstest.c

index c268e35218c8adfadd98f041fa3583db7e9e4755..7b4fd41274613abebb341dccca3a67b514b83343 100644 (file)
@@ -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;
index c736a3357a4391e252ab8c4a7b711f50a5f4d04e..10bf24fc1358e8fe3322eb3bcd96dfc55439bbd1 100644 (file)
@@ -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;
index f25db5a80adf3ab656d859fa4ecbce23658368cd..949ab609a30c6df9f0c3b31fbed8acb5b2504254 100644 (file)
@@ -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];
index 1f3be609d6eb5b87f6ce99d18ec3089de13cbb27..df79f5de6426ced05ad40840a75043fdf541ae94 100644 (file)
@@ -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)) {
index c264ade13db7a791505bf7dc955c9f648c96f6b0..89a4c2e0839faac49cdc5cedb982d2ea868f67a0 100644 (file)
@@ -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) {
index 90f5d161f2ec0241a207ecbac466329b55c9574f..d5bf097e99bb3c1ddba76a9adc272930990921c8 100644 (file)
@@ -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.
index cd3c99bc55716529d494652e81c8d920348842dc..7c2e21caa52ffe263d6eb05f9c610240df129355 100644 (file)
@@ -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,
index 890b4dd0abe3286d5c1b568033db9a25bf2aff84..f21954b65af189485213599185346e4ad9719902 100644 (file)
@@ -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) {
index c924c25e6cc5a6794179c53dd00dacfa629ed777..43761b633790181ee32f4139db428e2acdd1b850 100644 (file)
@@ -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) {
index d57e2a149d05fb95c6afa7171c5f50ad75966d92..fd5a1b6781cd98ca474303e48f77eaa1e8a7e989 100644 (file)
@@ -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) {
index 1e93a92c5e0b9589ec024b6f8646fabcbb77f543..cea2041f9ed4e9ddc7963a72cd406a350a8b2fa2 100644 (file)
@@ -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);
index 179c5fba97d49688631e4dc9e6d9e9164378f34a..0a8a045f657ad4717dee1f8e449988913d28a844 100644 (file)
@@ -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;
 
index 50cf0d9e446ae4d1ef9519af984e7b8ab6acb7eb..1acaca5e903ab61c5110161277900bb201957588 100644 (file)
@@ -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;
index 28668cf99e222ff3af576455313ee774adcce40a..854afd92b59eff20db527f44cd14055397a795d5 100644 (file)
@@ -139,7 +139,7 @@ isc_quota_soft_test(void **state) {
        isc_quota_destroy(&quota);
 }
 
-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];
 
index 50b4e5ad4311553273126883b4b1f731d96968cc..5c557b89883ce60f48e011fb4d7c19c8b5992245 100644 (file)
@@ -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) {
index 349e026ea0afc623e26df4085987998faa4f0be3..a726d94aeb32640f752f50b5e6f71860056d65ba 100644 (file)
@@ -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;
index a155243932ef5ab5e20e137418956e8e8501d59e..b0fa0c40e99ac81bf041db7a6f6a1427566fef50 100644 (file)
 #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);
index 9990363c48f992a75b15a491d290ae5a6240c730..84a822bdd17f8e44013c7a457c2fc5a75343fd59 100644 (file)
@@ -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);