As ovsrcu_get() looks like a function call, it is reasonable for the callers to expect that the arguments are evaluated only once. CONST_CAST expands its 'POINTER' argument multiple times, and the exact effect of this turned out to be compiler dependent. Fix this by expanding the macro argument before CONST_CAST, and removing unnecessary CONST_CASTs.
VMware-BZ: #1287651 Signed-off-by: Jarno Rajahalme <jrajaha...@nicira.com> --- lib/ovs-rcu.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/ovs-rcu.h b/lib/ovs-rcu.h index 2c7d1ea..96b3233 100644 --- a/lib/ovs-rcu.h +++ b/lib/ovs-rcu.h @@ -123,16 +123,17 @@ #define ovsrcu_get__(TYPE, VAR, ORDER) \ ({ \ TYPE value__; \ + typeof(VAR) ovsrcu_var = (VAR); \ \ - atomic_read_explicit(CONST_CAST(ATOMIC(TYPE) *, &(VAR)->p), \ + atomic_read_explicit(CONST_CAST(ATOMIC(TYPE) *, &ovsrcu_var->p), \ &value__, ORDER); \ \ value__; \ }) #define ovsrcu_get(TYPE, VAR) \ - CONST_CAST(TYPE, ovsrcu_get__(TYPE, VAR, memory_order_consume)) + ovsrcu_get__(TYPE, VAR, memory_order_consume) #define ovsrcu_get_protected(TYPE, VAR) \ - CONST_CAST(TYPE, ovsrcu_get__(TYPE, VAR, memory_order_relaxed)) + ovsrcu_get__(TYPE, VAR, memory_order_relaxed) /* 'VALUE' may be an atomic operation, which must be evaluated before * any of the body of the atomic_store_explicit. Since the type of -- 1.7.10.4 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev