From: Tobias Brunner Date: Fri, 22 Jun 2018 08:25:25 +0000 (+0200) Subject: atomics: Use type of destination in CAS implementation X-Git-Tag: 5.7.0dr5~20^2~67 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2afdb92dd0f58a4f28afff21988e3c9c38b34f5b;p=thirdparty%2Fstrongswan.git 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. --- diff --git a/src/libstrongswan/utils/utils/atomics.h b/src/libstrongswan/utils/utils/atomics.h index 4b530ebbf9..c23b361ec1 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)