public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Pranith Kumar <pranith@gatech.edu>
To: peterz@infradead.org
Cc: linux-kernel@vger.kernel.org, tim.c.chen@linux.intel.com,
	davidlohr@hp.com, mingo@redhat.com
Subject: [RFC PATCH 1/1] cleanup: use bool as return type for rwsem_is_locked
Date: Thu, 05 Jun 2014 16:49:37 -0400	[thread overview]
Message-ID: <5390D7E1.7060606@gatech.edu> (raw)

I see that there are functions like this which basically say:

return 1 if true else return 0. Is it worth cleaning them up? Or is there any reason why this convention is followed?

use bool as the return type. No reason for return type to be int.

Signed-off-by: Pranith Kumar <bobby.prani@gmail.com>
---
 include/linux/rwsem-spinlock.h  |    2 +-
 include/linux/rwsem.h           |    2 +-
 kernel/locking/rwsem-spinlock.c |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/linux/rwsem-spinlock.h b/include/linux/rwsem-spinlock.h
index d5b13bc..9026d2a 100644
--- a/include/linux/rwsem-spinlock.h
+++ b/include/linux/rwsem-spinlock.h
@@ -39,7 +39,7 @@ extern int __down_write_trylock(struct rw_semaphore *sem);
 extern void __up_read(struct rw_semaphore *sem);
 extern void __up_write(struct rw_semaphore *sem);
 extern void __downgrade_write(struct rw_semaphore *sem);
-extern int rwsem_is_locked(struct rw_semaphore *sem);
+extern bool rwsem_is_locked(struct rw_semaphore *sem);
 
 #endif /* __KERNEL__ */
 #endif /* _LINUX_RWSEM_SPINLOCK_H */
diff --git a/include/linux/rwsem.h b/include/linux/rwsem.h
index 091d993..04faf87 100644
--- a/include/linux/rwsem.h
+++ b/include/linux/rwsem.h
@@ -49,7 +49,7 @@ extern struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem);
 #include <asm/rwsem.h>
 
 /* In all implementations count != 0 means locked */
-static inline int rwsem_is_locked(struct rw_semaphore *sem)
+static inline bool rwsem_is_locked(struct rw_semaphore *sem)
 {
 	return sem->count != 0;
 }
diff --git a/kernel/locking/rwsem-spinlock.c b/kernel/locking/rwsem-spinlock.c
index 9be8a91..7374139 100644
--- a/kernel/locking/rwsem-spinlock.c
+++ b/kernel/locking/rwsem-spinlock.c
@@ -20,7 +20,7 @@ struct rwsem_waiter {
 	enum rwsem_waiter_type type;
 };
 
-int rwsem_is_locked(struct rw_semaphore *sem)
+bool rwsem_is_locked(struct rw_semaphore *sem)
 {
 	int ret = 1;
 	unsigned long flags;
-- 
1.7.9.5

             reply	other threads:[~2014-06-05 20:49 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-05 20:49 Pranith Kumar [this message]
2014-06-06  7:35 ` [RFC PATCH 1/1] cleanup: use bool as return type for rwsem_is_locked Peter Zijlstra
2014-06-06 17:53 ` Pranith Kumar
2014-06-06 17:56   ` Peter Zijlstra
2014-06-06 18:02     ` Pranith Kumar
2014-06-06 18:41     ` Davidlohr Bueso
2014-06-06 18:52       ` Pranith Kumar
2014-06-06 18:11   ` Pranith Kumar
2014-06-07  0:18     ` Dave Chinner
2014-06-07  0:59       ` Pranith Kumar
2014-06-07  1:41         ` Pranith Kumar
2014-06-07  2:39           ` Joe Perches
2014-06-07 23:44             ` Dave Chinner
2014-06-08  2:57               ` Pranith Kumar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5390D7E1.7060606@gatech.edu \
    --to=pranith@gatech.edu \
    --cc=davidlohr@hp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tim.c.chen@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox