Remove usage of deprecated ATOMIC_VAR_INIT() macro

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
This commit is contained in:
Ondřej Surý 2022-03-08 23:55:10 +01:00
parent 0b68596c45
commit f251d69eba
18 changed files with 62 additions and 65 deletions

View 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;

View 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;

View 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];

View 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)) {

View 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) {

View 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.

View 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,

View 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) {

View 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) {

View 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) {

View 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);

View 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;

View 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;

View 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];

View 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) {

View 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;

View file

@ -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);

View 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);