aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/rcu/srcu.c
diff options
context:
space:
mode:
authorNicholas Mc Guire <hofrat@osadl.org>2015-05-27 02:56:25 -0400
committerPaul E. McKenney <paulmck@linux.vnet.ibm.com>2015-07-15 17:43:53 -0400
commitf765d1130700878c2275bc1ea09eed428f870a2a (patch)
tree76a7baeb60e484fe1b6a587251632fc5b852c471 /kernel/rcu/srcu.c
parentd5671f6bf2a672cfa72ef2cbac5cc53a4539690d (diff)
rcu: Change return type to bool
Type-checking coccinelle spatches are being used to locate type mismatches between function signatures and return values in this case this produced: ./kernel/rcu/srcu.c:271 WARNING: return of wrong type int != unsigned long, srcu_readers_active() returns an int that is the sum of per_cpu unsigned long but the only user is cleanup_srcu_struct() which is using it as a boolean (condition) to see if there is any readers rather than actually using the approximate number of readers. The theoretically possible unsigned long overflow case does not need to be handled explicitly - if we had 4G++ readers then something else went wrong a long time ago. proposal: change the return type to boolean. The function name is left unchanged as it fits the naming expectation for a boolean. patch was compile tested for x86_64_defconfig (implies CONFIG_SRCU=y) patch is against 4.1-rc5 (localversion-next is -next-20150525) Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org> Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Diffstat (limited to 'kernel/rcu/srcu.c')
-rw-r--r--kernel/rcu/srcu.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/kernel/rcu/srcu.c b/kernel/rcu/srcu.c
index fb33d35ee0b7..de35087c92a5 100644
--- a/kernel/rcu/srcu.c
+++ b/kernel/rcu/srcu.c
@@ -252,14 +252,15 @@ static bool srcu_readers_active_idx_check(struct srcu_struct *sp, int idx)
252} 252}
253 253
254/** 254/**
255 * srcu_readers_active - returns approximate number of readers. 255 * srcu_readers_active - returns true if there are readers. and false
256 * otherwise
256 * @sp: which srcu_struct to count active readers (holding srcu_read_lock). 257 * @sp: which srcu_struct to count active readers (holding srcu_read_lock).
257 * 258 *
258 * Note that this is not an atomic primitive, and can therefore suffer 259 * Note that this is not an atomic primitive, and can therefore suffer
259 * severe errors when invoked on an active srcu_struct. That said, it 260 * severe errors when invoked on an active srcu_struct. That said, it
260 * can be useful as an error check at cleanup time. 261 * can be useful as an error check at cleanup time.
261 */ 262 */
262static int srcu_readers_active(struct srcu_struct *sp) 263static bool srcu_readers_active(struct srcu_struct *sp)
263{ 264{
264 int cpu; 265 int cpu;
265 unsigned long sum = 0; 266 unsigned long sum = 0;