From: Jarno Rajahalme Date: Mon, 21 Jul 2014 21:19:06 +0000 (-0700) Subject: lib/ovs-rcu: evaluate argument of ovsrcu_get only once. X-Git-Tag: v2.4.0~1766 X-Git-Url: http://git.cascardo.eti.br/?a=commitdiff_plain;h=2924cf52ca105415762dc2c8ea8ba30f88b63f89;p=cascardo%2Fovs.git lib/ovs-rcu: evaluate argument of ovsrcu_get only once. 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 Acked-by: Ben Pfaff --- diff --git a/lib/ovs-rcu.h b/lib/ovs-rcu.h index 2c7d1ea78..96b323365 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