Messages in this thread Patch in this message | | | From | Yaowei Bai <> | Subject | [PATCH] kernel/locking: lock_is_held can be boolean | Date | Wed, 30 Sep 2015 19:18:38 +0800 |
| |
This patch makes lock_is_held return bool to improve readability due to this particular function only using either one or zero as its return value.
No functional change.
Signed-off-by: Yaowei Bai <bywxiaobai@163.com> --- include/linux/lockdep.h | 2 +- kernel/locking/lockdep.c | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h index 70400dc..98aafb5 100644 --- a/include/linux/lockdep.h +++ b/include/linux/lockdep.h @@ -339,7 +339,7 @@ extern void lock_release(struct lockdep_map *lock, int nested, #define lockdep_is_held(lock) lock_is_held(&(lock)->dep_map) -extern int lock_is_held(struct lockdep_map *lock); +extern bool lock_is_held(struct lockdep_map *lock); extern void lock_set_class(struct lockdep_map *lock, const char *name, struct lock_class_key *key, unsigned int subclass, diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index 4e49cc4..18c80c5 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -3059,7 +3059,7 @@ print_lock_nested_lock_not_held(struct task_struct *curr, return 0; } -static int __lock_is_held(struct lockdep_map *lock); +static bool __lock_is_held(struct lockdep_map *lock); /* * This gets called for every mutex_lock*()/spin_lock*() operation. @@ -3447,7 +3447,7 @@ found_it: return 1; } -static int __lock_is_held(struct lockdep_map *lock) +static bool __lock_is_held(struct lockdep_map *lock) { struct task_struct *curr = current; int i; @@ -3456,10 +3456,10 @@ static int __lock_is_held(struct lockdep_map *lock) struct held_lock *hlock = curr->held_locks + i; if (match_held_lock(hlock, lock)) - return 1; + return true; } - return 0; + return false; } static void __lock_pin_lock(struct lockdep_map *lock) @@ -3608,13 +3608,13 @@ void lock_release(struct lockdep_map *lock, int nested, } EXPORT_SYMBOL_GPL(lock_release); -int lock_is_held(struct lockdep_map *lock) +bool lock_is_held(struct lockdep_map *lock) { unsigned long flags; - int ret = 0; + bool ret = false; if (unlikely(current->lockdep_recursion)) - return 1; /* avoid false negative lockdep_assert_held() */ + return true; /* avoid false negative lockdep_assert_held() */ raw_local_irq_save(flags); check_flags(flags); -- 1.9.1
| |