]> 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>
Thu, 17 Mar 2022 20:44:04 +0000 (21:44 +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

(cherry picked from commit f251d69ebad6f17190c890829897a2bc8f7d6783)

17 files changed:
bin/dig/dig.c
bin/rndc/rndc.c
lib/dns/rbtdb.c
lib/dns/tests/dispatch_test.c
lib/isc/app.c
lib/isc/include/isc/mutexatomic.h
lib/isc/mem.c
lib/isc/netmgr/tcp.c
lib/isc/netmgr/tcpdns.c
lib/isc/tests/netmgr_test.c
lib/isc/tests/quota_test.c
lib/isc/tests/uv_wrap.h
lib/isc/tls.c
lib/isc/unix/include/isc/stdatomic.h
lib/isc/win32/include/isc/stdatomic.h
lib/ns/client.c
lib/ns/tests/nstest.c

index 77d1536c9180d4f7f7ed0a7eda7f140c3af28a24..7648448d344c0a4339390d5f2e5ab5807675144d 100644 (file)
@@ -58,7 +58,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 6ce9d252f45ae425fa06e83ce79c30a5a8663ffa..49120a7767ff561216bd285bd9c58c67d6380705 100644 (file)
@@ -78,9 +78,9 @@ static isccc_region_t secret;
 static bool failed = false;
 static bool c_flag = false;
 static isc_mem_t *rndc_mctx;
-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;
 static char *args;
 static char program[256];
index e086510461a6e7d06b19bc57e94a4c8ef7d633ad..f58e57d87df38703e5d309d35aa7f0bc4a2b1312 100644 (file)
@@ -770,7 +770,7 @@ static char FILE_VERSION[32] = "\0";
  *      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
@@ -894,7 +894,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 28abc1a0babe9b95a42a06e97f40fa1d7207ba3d..9f9737b4041901bf7ae8a46db138eca5e8c22676 100644 (file)
@@ -217,7 +217,7 @@ nameserver(isc_task_t *task, isc_event_t *event) {
 
 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 isc_sockaddr_t local;
 static atomic_uint_fast32_t responses;
 
index d9c830e6f41329d475d9472616746a4bb4b02c92..6cfef17cf1a80d813e22cb4e03c70665c2584b87 100644 (file)
@@ -52,7 +52,7 @@
  */
 
 static isc_thread_t blockedthread;
-static atomic_bool is_running = ATOMIC_VAR_INIT(0);
+static atomic_bool is_running = 0;
 
 #ifdef WIN32
 /*
index d51f27038cfebcefcdec888c240ae9a775d9da4d..796519ddaad09bb3e5794cd41a9372db6c3108a8 100644 (file)
@@ -139,7 +139,7 @@ _TYPEDEF_T(uintmax);
 #undef _TYPEDEF_T
 #undef _TYPEDEF_O
 
-#define ATOMIC_VAR_INIT(arg)                             \
+#define arg                             \
        {                                                \
                .m = PTHREAD_MUTEX_INITIALIZER, .v = arg \
        }
index 9f9cb84948073823ec6db471915842cef5c87519..37c88bc73abb281018382d15126b533cb1ea4136 100644 (file)
@@ -1993,7 +1993,7 @@ print_contexts(FILE *file) {
        fflush(file);
 }
 
-static atomic_uintptr_t checkdestroyed = ATOMIC_VAR_INIT(0);
+static atomic_uintptr_t checkdestroyed = 0;
 
 void
 isc_mem_checkdestroyed(FILE *file) {
index 6e602666c998b063bd63b8acc87a7be275532120..17f5c76c8ab689d62b967e0d0bb7bc7710200cc8 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 e588527852dda035a1a064377cef561cf2aa55b0..ae6736f1eabbd097fe53537a7886cdadfa29716a 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 50890e0ab572ec85de38ab412d89014fbbed2768..c2d7fffb32e690366bdaffc50bce78271591d4bb 100644 (file)
@@ -68,20 +68,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 9114f60b9bc392c9d9bff0a2c143b34e177524b6..968a6244d1b03a811966157bda11826a42cbcb2b 100644 (file)
@@ -94,7 +94,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) {
@@ -104,7 +104,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,
@@ -115,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 = ATOMIC_VAR_INIT(0);
+static atomic_int __state_uv_udp_connect = 0;
 #if UV_VERSION_HEX >= UV_VERSION(1, 27, 0)
 int
 __wrap_uv_udp_connect(uv_udp_t *handle, const struct sockaddr *addr) {
@@ -126,7 +126,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 = ATOMIC_VAR_INIT(0);
+static atomic_int __state_uv_udp_getpeername = 0;
 #if UV_VERSION_HEX >= UV_VERSION(1, 27, 0)
 int
 __wrap_uv_udp_getpeername(const uv_udp_t *handle, struct sockaddr *name,
@@ -138,7 +138,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) {
@@ -148,7 +148,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,
@@ -159,7 +159,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) {
@@ -169,7 +169,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) {
@@ -178,7 +178,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) {
@@ -187,7 +187,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) {
@@ -197,7 +197,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) {
@@ -207,7 +207,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) {
@@ -217,7 +217,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) {
@@ -227,7 +227,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) {
@@ -236,7 +236,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) {
@@ -245,7 +245,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) {
@@ -254,7 +254,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) {
@@ -263,7 +263,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 ca3f6691aa0b8619d1327dedd8894f0d4fde0c44..859c73c9ae88c4f809d34cd2bf1e1e428361c57e 100644 (file)
@@ -34,8 +34,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 e2fcc33c4ca35b4bc9e5e70a3aa88cb8e0744f5c..f071b6a544e3a0d30808ed713d94af357fc2bb1b 100644 (file)
@@ -47,8 +47,6 @@
 #endif /* if __has_extension(c_atomic) || __has_extension(cxx_atomic) */
 #endif /* if !defined(__CLANG_ATOMICS) && !defined(__GNUC_ATOMICS) */
 
-#define ATOMIC_VAR_INIT(x) x
-
 #ifndef __ATOMIC_RELAXED
 #define __ATOMIC_RELAXED 0
 #endif /* ifndef __ATOMIC_RELAXED */
index dc6ba6085620b2bb098180adc51b52576bda7b84..f3e5bb18d78445fcaee34f1c6b4de5be21787273 100644 (file)
@@ -31,8 +31,6 @@
 
 #include <isc/util.h>
 
-#define ATOMIC_VAR_INIT(x) x
-
 #ifndef __ATOMIC_RELAXED
 #define __ATOMIC_RELAXED 0
 #endif /* ifndef __ATOMIC_RELAXED */
index 494bca7b2d22c3c451eb78f44154c246c2937ed2..75e05009fdbe9fb503c1030b312dee568b73b4a5 100644 (file)
  */
 
 #if defined(_WIN32) && !defined(_WIN64)
-LIBNS_EXTERNAL_DATA atomic_uint_fast32_t ns_client_requests =
-       ATOMIC_VAR_INIT(0);
+LIBNS_EXTERNAL_DATA atomic_uint_fast32_t ns_client_requests = 0;
 #else  /* if defined(_WIN32) && !defined(_WIN64) */
-LIBNS_EXTERNAL_DATA atomic_uint_fast64_t ns_client_requests =
-       ATOMIC_VAR_INIT(0);
+LIBNS_EXTERNAL_DATA atomic_uint_fast64_t ns_client_requests = 0;
 #endif /* if defined(_WIN32) && !defined(_WIN64) */
 
 static void
index 15a9bd27dcc2289f5bd31b5f6973e688324a5760..d9471b67188b0f3de33097826822f96ce8858582 100644 (file)
@@ -68,7 +68,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;
@@ -172,7 +172,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);