diff mbox

[tip/core/rcu,08/14] rcu: Remove return value from rcu_assign_pointer()

Message ID 1339791195-26389-8-git-send-email-paulmck@linux.vnet.ibm.com
State Superseded
Headers show

Commit Message

Paul E. McKenney June 15, 2012, 8:13 p.m. UTC
From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>

The return value from rcu_assign_pointer() is not used, and using it
would be quite ugly, for example:

	q = rcu_assign_pointer(global_p, p);

To prevent this sort of ugliness from spreading, this commit wraps
rcu_assign_pointer() in a do-while loop.

Reported-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Reported-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
---
 include/linux/rcupdate.h |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

Comments

Josh Triplett June 15, 2012, 8:53 p.m. UTC | #1
On Fri, Jun 15, 2012 at 01:13:09PM -0700, Paul E. McKenney wrote:
> From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
> 
> The return value from rcu_assign_pointer() is not used, and using it
> would be quite ugly, for example:
> 
> 	q = rcu_assign_pointer(global_p, p);
> 
> To prevent this sort of ugliness from spreading, this commit wraps
> rcu_assign_pointer() in a do-while loop.
> 
> Reported-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
> Reported-by: Josh Triplett <josh@joshtriplett.org>
> Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>

Reviewed-by: Josh Triplett <josh@joshtriplett.org>

>  include/linux/rcupdate.h |    6 +++---
>  1 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
> index f2cca02..2f6ec55 100644
> --- a/include/linux/rcupdate.h
> +++ b/include/linux/rcupdate.h
> @@ -514,10 +514,10 @@ static inline void rcu_preempt_sleep_check(void)
>  		(_________p1); \
>  	})
>  #define __rcu_assign_pointer(p, v, space) \
> -	({ \
> +	do { \
>  		smp_wmb(); \
>  		(p) = (typeof(*v) __force space *)(v); \
> -	})
> +	} while (0)
>  
>  
>  /**
> @@ -852,7 +852,7 @@ static inline notrace void rcu_read_unlock_sched_notrace(void)
>   *
>   * Assigns the specified value to the specified RCU-protected
>   * pointer, ensuring that any concurrent RCU readers will see
> - * any prior initialization.  Returns the value assigned.
> + * any prior initialization.
>   *
>   * Inserts memory barriers on architectures that require them
>   * (which is most of them), and also prevents the compiler from
> -- 
> 1.7.8
>
diff mbox

Patch

diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
index f2cca02..2f6ec55 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -514,10 +514,10 @@  static inline void rcu_preempt_sleep_check(void)
 		(_________p1); \
 	})
 #define __rcu_assign_pointer(p, v, space) \
-	({ \
+	do { \
 		smp_wmb(); \
 		(p) = (typeof(*v) __force space *)(v); \
-	})
+	} while (0)
 
 
 /**
@@ -852,7 +852,7 @@  static inline notrace void rcu_read_unlock_sched_notrace(void)
  *
  * Assigns the specified value to the specified RCU-protected
  * pointer, ensuring that any concurrent RCU readers will see
- * any prior initialization.  Returns the value assigned.
+ * any prior initialization.
  *
  * Inserts memory barriers on architectures that require them
  * (which is most of them), and also prevents the compiler from