From 9f113f8e61ba6fd8e66ceec1934635eb7d93966f Mon Sep 17 00:00:00 2001 From: Steve Lhomme Date: Mon, 29 Jan 2024 12:49:49 +0100 Subject: [PATCH] remove deprecated ATOMIC_VAR_INIT() usage It's deprecated in C17 [1]. Atomic initializers don't need this macro. Even with std=gnu11, clang 14+ would issue a warning it's deprecated. [1] https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2244.htm#dr_485 --- include/vlc_atomic.h | 2 +- include/vlc_threads.h | 8 ++++---- modules/codec/shine.c | 2 +- modules/gui/macosx/windows/video/VLCVideoOutputProvider.m | 2 +- modules/keystore/secret.c | 2 +- src/config/core.c | 2 +- src/misc/cpu.c | 2 +- src/misc/threads.h | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/vlc_atomic.h b/include/vlc_atomic.h index de30d1893c..07a9046b39 100644 --- a/include/vlc_atomic.h +++ b/include/vlc_atomic.h @@ -41,7 +41,7 @@ using std::memory_order_acq_rel; #include /* vlc_atomic_timedwait_daytime */ #define VLC_STATIC_RC { \ - .refs = ATOMIC_VAR_INIT(0) \ + .refs = 0 \ } typedef struct vlc_atomic_rc_t { diff --git a/include/vlc_threads.h b/include/vlc_threads.h index 1c02ccac3e..cffc0680ea 100644 --- a/include/vlc_threads.h +++ b/include/vlc_threads.h @@ -163,9 +163,9 @@ typedef struct * In C++, consider using a global ::vlc::threads::mutex instance instead. */ #define VLC_STATIC_MUTEX { \ - .value = ATOMIC_VAR_INIT(0), \ - .recursion = ATOMIC_VAR_INIT(0), \ - .owner = ATOMIC_VAR_INIT(0), \ + .value = 0, \ + .recursion = 0, \ + .owner = 0, \ } /** @@ -527,7 +527,7 @@ typedef struct /** * Static initializer for one-time initialization. */ -#define VLC_STATIC_ONCE { ATOMIC_VAR_INIT(0) } +#define VLC_STATIC_ONCE { 0 } /** * Begins a one-time initialization. diff --git a/modules/codec/shine.c b/modules/codec/shine.c index 2616b2e3d7..146a3aeb70 100644 --- a/modules/codec/shine.c +++ b/modules/codec/shine.c @@ -67,7 +67,7 @@ vlc_module_begin() set_callback( OpenEncoder ) vlc_module_end() -static atomic_bool busy = ATOMIC_VAR_INIT(false); +static atomic_bool busy = false; static int OpenEncoder( vlc_object_t *p_this ) { diff --git a/modules/gui/macosx/windows/video/VLCVideoOutputProvider.m b/modules/gui/macosx/windows/video/VLCVideoOutputProvider.m index e87aea77d7..918e89a6f3 100644 --- a/modules/gui/macosx/windows/video/VLCVideoOutputProvider.m +++ b/modules/gui/macosx/windows/video/VLCVideoOutputProvider.m @@ -151,7 +151,7 @@ static void WindowUnsetFullscreen(vlc_window_t *wnd) WindowSetFullscreen(wnd, &windowed); } -static atomic_bool b_intf_starting = ATOMIC_VAR_INIT(false); +static atomic_bool b_intf_starting = false; static const struct vlc_window_operations ops = { WindowEnable, diff --git a/modules/keystore/secret.c b/modules/keystore/secret.c index 524a41bedc..fb1e543f16 100644 --- a/modules/keystore/secret.c +++ b/modules/keystore/secret.c @@ -300,7 +300,7 @@ check_service_running(void) /* Cache the return of this function that may take up to 200ms. This atomic * doesn't prevent a cache miss (unlikely). This function can be called * safely from any threads. */ - static atomic_int cache_running = ATOMIC_VAR_INIT(0); + static atomic_int cache_running = 0; int running = atomic_load_explicit(&cache_running, memory_order_relaxed); if (running != 0) return running == 1 ? VLC_SUCCESS : VLC_EGENERIC; diff --git a/src/config/core.c b/src/config/core.c index 902e7b0f14..cd5fb073e7 100644 --- a/src/config/core.c +++ b/src/config/core.c @@ -41,7 +41,7 @@ #include "misc/rcu.h" static vlc_mutex_t config_lock = VLC_STATIC_MUTEX; -static atomic_bool config_dirty = ATOMIC_VAR_INIT(false); +static atomic_bool config_dirty = false; void config_Lock(void) { diff --git a/src/misc/cpu.c b/src/misc/cpu.c index ad21e6105d..b255494454 100644 --- a/src/misc/cpu.c +++ b/src/misc/cpu.c @@ -146,7 +146,7 @@ out: unsigned vlc_CPU(void) { - static atomic_uint cpu_flags = ATOMIC_VAR_INIT(-1U); + static atomic_uint cpu_flags = -1U; unsigned flags = atomic_load_explicit(&cpu_flags, memory_order_relaxed); if (unlikely(flags == -1U)) { diff --git a/src/misc/threads.h b/src/misc/threads.h index 2237c57f0c..90225513d2 100644 --- a/src/misc/threads.h +++ b/src/misc/threads.h @@ -51,7 +51,7 @@ typedef struct { atomic_ulong owner; } vlc_queuedmutex_t; -#define VLC_STATIC_QUEUEDMUTEX { ATOMIC_VAR_INIT(0), ATOMIC_VAR_INIT(0), ATOMIC_VAR_INIT(0) } +#define VLC_STATIC_QUEUEDMUTEX { 0, 0, 0 } void vlc_queuedmutex_init(vlc_queuedmutex_t *m);