summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJarno Rajahalme <jrajahalme@nicira.com>2014-07-21 14:19:06 -0700
committerJarno Rajahalme <jrajahalme@nicira.com>2014-07-21 14:19:06 -0700
commit2924cf52ca105415762dc2c8ea8ba30f88b63f89 (patch)
tree1462f6672173da9520e88d7af1011b9fa501fc04
parentdb73f7166a6baecbf07e8bb19451fb033954c5f6 (diff)
downloadopenvswitch-2924cf52ca105415762dc2c8ea8ba30f88b63f89.tar.gz
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 <jrajahalme@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
-rw-r--r--lib/ovs-rcu.h7
1 files changed, 4 insertions, 3 deletions
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