diff options
author | Fangrui Song <maskray@google.com> | 2023-02-28 18:30:56 -0800 |
---|---|---|
committer | Ilya Maximets <i.maximets@ovn.org> | 2023-03-06 19:27:19 +0100 |
commit | 71ca8393b7005d4705336ad1bc1be9ce9ae49ef9 (patch) | |
tree | 431a8b4d9c7854093cfb655fe6adea9aa63758c8 /lib | |
parent | e3c821f8ca866508b8aba70b08ed016898a06625 (diff) | |
download | openvswitch-71ca8393b7005d4705336ad1bc1be9ce9ae49ef9.tar.gz |
treewide: Remove uses of ATOMIC_VAR_INIT.
ATOMIC_VAR_INIT has a trivial definition
`#define ATOMIC_VAR_INIT(value) (value)`,
is deprecated in C17/C++20, and will be removed in newer standards in
newer GCC/Clang (e.g. https://reviews.llvm.org/D144196).
Signed-off-by: Fangrui Song <maskray@google.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/dpdk.c | 2 | ||||
-rw-r--r-- | lib/mpsc-queue.h | 6 | ||||
-rw-r--r-- | lib/ovs-atomic-clang.h | 2 | ||||
-rw-r--r-- | lib/ovs-atomic-gcc4+.h | 1 | ||||
-rw-r--r-- | lib/ovs-atomic-gcc4.7+.h | 1 | ||||
-rw-r--r-- | lib/ovs-atomic-i586.h | 1 | ||||
-rw-r--r-- | lib/ovs-atomic-msvc.h | 1 | ||||
-rw-r--r-- | lib/ovs-atomic-pthreads.h | 1 | ||||
-rw-r--r-- | lib/ovs-atomic-x86_64.h | 1 | ||||
-rw-r--r-- | lib/ovs-atomic.h | 5 | ||||
-rw-r--r-- | lib/ovs-rcu.h | 4 | ||||
-rw-r--r-- | lib/ovs-replay.c | 2 | ||||
-rw-r--r-- | lib/versions.h | 2 | ||||
-rw-r--r-- | lib/vlog.c | 2 |
14 files changed, 11 insertions, 20 deletions
diff --git a/lib/dpdk.c b/lib/dpdk.c index 240babc03..d76d53f8f 100644 --- a/lib/dpdk.c +++ b/lib/dpdk.c @@ -47,7 +47,7 @@ VLOG_DEFINE_THIS_MODULE(dpdk); static FILE *log_stream = NULL; /* Stream for DPDK log redirection */ /* Indicates successful initialization of DPDK. */ -static atomic_bool dpdk_initialized = ATOMIC_VAR_INIT(false); +static atomic_bool dpdk_initialized = false; static bool args_contains(const struct svec *args, const char *value) diff --git a/lib/mpsc-queue.h b/lib/mpsc-queue.h index 8c7109621..70c2d7a01 100644 --- a/lib/mpsc-queue.h +++ b/lib/mpsc-queue.h @@ -116,9 +116,9 @@ struct mpsc_queue { }; #define MPSC_QUEUE_INITIALIZER(Q) { \ - .head = ATOMIC_VAR_INIT(&(Q)->stub), \ - .tail = ATOMIC_VAR_INIT(&(Q)->stub), \ - .stub = { .next = ATOMIC_VAR_INIT(NULL) }, \ + .head = &(Q)->stub, \ + .tail = &(Q)->stub, \ + .stub = { .next = NULL }, \ .read_lock = OVS_MUTEX_INITIALIZER, \ } diff --git a/lib/ovs-atomic-clang.h b/lib/ovs-atomic-clang.h index cdf02a512..0fc643c8a 100644 --- a/lib/ovs-atomic-clang.h +++ b/lib/ovs-atomic-clang.h @@ -23,8 +23,6 @@ #define ATOMIC(TYPE) _Atomic(TYPE) -#define ATOMIC_VAR_INIT(VALUE) (VALUE) - #define atomic_init(OBJECT, VALUE) __c11_atomic_init(OBJECT, VALUE) /* Clang hard-codes these exact values internally but does not appear to diff --git a/lib/ovs-atomic-gcc4+.h b/lib/ovs-atomic-gcc4+.h index f9accde1a..1917df690 100644 --- a/lib/ovs-atomic-gcc4+.h +++ b/lib/ovs-atomic-gcc4+.h @@ -43,7 +43,6 @@ typedef enum { #define IS_LOCKLESS_ATOMIC(OBJECT) (sizeof(OBJECT) <= sizeof(void *)) -#define ATOMIC_VAR_INIT(VALUE) VALUE #define atomic_init(OBJECT, VALUE) (*(OBJECT) = (VALUE), (void) 0) static inline void diff --git a/lib/ovs-atomic-gcc4.7+.h b/lib/ovs-atomic-gcc4.7+.h index 846e05775..9680e546f 100644 --- a/lib/ovs-atomic-gcc4.7+.h +++ b/lib/ovs-atomic-gcc4.7+.h @@ -30,7 +30,6 @@ typedef enum { memory_order_seq_cst = __ATOMIC_SEQ_CST } memory_order; -#define ATOMIC_VAR_INIT(VALUE) (VALUE) #define atomic_init(OBJECT, VALUE) (*(OBJECT) = (VALUE), (void) 0) #define atomic_thread_fence __atomic_thread_fence diff --git a/lib/ovs-atomic-i586.h b/lib/ovs-atomic-i586.h index 35a0959ff..2b6518652 100644 --- a/lib/ovs-atomic-i586.h +++ b/lib/ovs-atomic-i586.h @@ -119,7 +119,6 @@ typedef enum { #define IS_LOCKLESS_ATOMIC(OBJECT) \ (sizeof(OBJECT) <= 8 && IS_POW2(sizeof(OBJECT))) -#define ATOMIC_VAR_INIT(VALUE) VALUE #define atomic_init(OBJECT, VALUE) (*(OBJECT) = (VALUE), (void) 0) /* diff --git a/lib/ovs-atomic-msvc.h b/lib/ovs-atomic-msvc.h index fb8cd03bd..3a71f61ae 100644 --- a/lib/ovs-atomic-msvc.h +++ b/lib/ovs-atomic-msvc.h @@ -59,7 +59,6 @@ typedef enum { #define IS_LOCKLESS_ATOMIC(OBJECT) \ (sizeof(OBJECT) <= 8 && IS_POW2(sizeof(OBJECT))) -#define ATOMIC_VAR_INIT(VALUE) (VALUE) #define atomic_init(OBJECT, VALUE) (*(OBJECT) = (VALUE), (void) 0) static inline void diff --git a/lib/ovs-atomic-pthreads.h b/lib/ovs-atomic-pthreads.h index 570a67fe4..0e4263fe2 100644 --- a/lib/ovs-atomic-pthreads.h +++ b/lib/ovs-atomic-pthreads.h @@ -42,7 +42,6 @@ typedef enum { memory_order_seq_cst } memory_order; -#define ATOMIC_VAR_INIT(VALUE) (VALUE) #define atomic_init(OBJECT, VALUE) (*(OBJECT) = (VALUE), (void) 0) static inline void diff --git a/lib/ovs-atomic-x86_64.h b/lib/ovs-atomic-x86_64.h index 3bdaf2f08..2f538699f 100644 --- a/lib/ovs-atomic-x86_64.h +++ b/lib/ovs-atomic-x86_64.h @@ -120,7 +120,6 @@ typedef enum { #define IS_LOCKLESS_ATOMIC(OBJECT) \ (sizeof(OBJECT) <= 8 && IS_POW2(sizeof(OBJECT))) -#define ATOMIC_VAR_INIT(VALUE) VALUE #define atomic_init(OBJECT, VALUE) (*(OBJECT) = (VALUE), (void) 0) /* diff --git a/lib/ovs-atomic.h b/lib/ovs-atomic.h index 8fdce0cf8..ab9ce6b2e 100644 --- a/lib/ovs-atomic.h +++ b/lib/ovs-atomic.h @@ -91,10 +91,9 @@ * Life Cycle * ========== * - * To initialize an atomic variable at its point of definition, use - * ATOMIC_VAR_INIT: + * To initialize an atomic variable at its point of definition, use: * - * static atomic_int ai = ATOMIC_VAR_INIT(123); + * static atomic_int ai = 123; * * To initialize an atomic variable in code, use atomic_init(): * diff --git a/lib/ovs-rcu.h b/lib/ovs-rcu.h index 8b397b7fb..a1c15c126 100644 --- a/lib/ovs-rcu.h +++ b/lib/ovs-rcu.h @@ -175,7 +175,7 @@ #if __GNUC__ #define OVSRCU_TYPE(TYPE) struct { ATOMIC(TYPE) p; } -#define OVSRCU_INITIALIZER(VALUE) { ATOMIC_VAR_INIT(VALUE) } +#define OVSRCU_INITIALIZER(VALUE) { VALUE } #define ovsrcu_get__(TYPE, VAR, ORDER) \ ({ \ TYPE value__; \ @@ -207,7 +207,7 @@ #else /* not GNU C */ struct ovsrcu_pointer { ATOMIC(void *) p; }; #define OVSRCU_TYPE(TYPE) struct ovsrcu_pointer -#define OVSRCU_INITIALIZER(VALUE) { ATOMIC_VAR_INIT(VALUE) } +#define OVSRCU_INITIALIZER(VALUE) { VALUE } static inline void * ovsrcu_get__(const struct ovsrcu_pointer *pointer, memory_order order) { diff --git a/lib/ovs-replay.c b/lib/ovs-replay.c index f386246c7..551c7f56d 100644 --- a/lib/ovs-replay.c +++ b/lib/ovs-replay.c @@ -34,7 +34,7 @@ static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(10, 25); static struct ovs_mutex replay_mutex = OVS_MUTEX_INITIALIZER; static int replay_seqno OVS_GUARDED_BY(replay_mutex) = 0; -static atomic_int replay_state = ATOMIC_VAR_INIT(OVS_REPLAY_NONE); +static atomic_int replay_state = OVS_REPLAY_NONE; static char *dirname = NULL; diff --git a/lib/versions.h b/lib/versions.h index d92f0a319..724880cb7 100644 --- a/lib/versions.h +++ b/lib/versions.h @@ -36,7 +36,7 @@ struct versions { }; #define VERSIONS_INITIALIZER(ADD, REMOVE) \ - (struct versions){ ADD, ATOMIC_VAR_INIT(REMOVE) } + (struct versions){ ADD, REMOVE } static inline void versions_set_remove_version(struct versions *versions, ovs_version_t version) diff --git a/lib/vlog.c b/lib/vlog.c index 0a615bb66..9ddea48b8 100644 --- a/lib/vlog.c +++ b/lib/vlog.c @@ -118,7 +118,7 @@ static struct ovs_list vlog_modules OVS_GUARDED_BY(log_file_mutex) static int syslog_fd OVS_GUARDED_BY(pattern_rwlock) = -1; /* Log facility configuration. */ -static atomic_int log_facility = ATOMIC_VAR_INIT(0); +static atomic_int log_facility = 0; /* Facility name and its value. */ struct vlog_facility { |