From 2afdb92dd0f58a4f28afff21988e3c9c38b34f5b Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Fri, 22 Jun 2018 10:25:25 +0200 Subject: [PATCH] atomics: Use type of destination in CAS implementation The type of the value was incorrect (void**) if NULL was passed to cas_ptr() as expected value, which caused a compiler warning with Clang because __atomic_compare_exchange_n() expects the types of the first two arguments to be the same. --- src/libstrongswan/utils/utils/atomics.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstrongswan/utils/utils/atomics.h b/src/libstrongswan/utils/utils/atomics.h index 4b530ebbf..c23b361ec 100644 --- a/src/libstrongswan/utils/utils/atomics.h +++ b/src/libstrongswan/utils/utils/atomics.h @@ -53,7 +53,7 @@ typedef u_int refcount_t; #define ref_put(ref) (!__atomic_sub_fetch(ref, 1, __ATOMIC_ACQ_REL)) #define ref_cur(ref) __atomic_load_n(ref, __ATOMIC_RELAXED) -#define _cas_impl(ptr, oldval, newval) ({ typeof(oldval) _old = oldval; \ +#define _cas_impl(ptr, oldval, newval) ({ typeof(*ptr) _old = oldval; \ __atomic_compare_exchange_n(ptr, &_old, newval, FALSE, \ __ATOMIC_SEQ_CST, __ATOMIC_RELAXED); }) #define cas_bool(ptr, oldval, newval) _cas_impl(ptr, oldval, newval)