lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1443611918-3921-1-git-send-email-bywxiaobai@163.com>
Date:	Wed, 30 Sep 2015 19:18:38 +0800
From:	Yaowei Bai <bywxiaobai@....com>
To:	peterz@...radead.org, mingo@...hat.com
Cc:	linux-kernel@...r.kernel.org
Subject: [PATCH] kernel/locking: lock_is_held can be boolean

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@....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


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ