From: kernel test robot <lkp(a)intel.com>
fs/afs/flock.c:243:2-5: WARNING: Use BUG_ON
fs/afs/flock.c:245:2-5: WARNING: Use BUG_ON
fs/afs/flock.c:143:3-6: WARNING: Use BUG_ON
fs/afs/flock.c:177:3-6: WARNING: Use BUG_ON
Use BUG_ON instead of a if condition followed by BUG.
Semantic patch information:
This makes an effort to find cases where BUG() follows an if
condition on an expression and replaces the if condition and BUG()
with a BUG_ON having the conditional expression of the if statement
as argument.
Generated by: scripts/coccinelle/misc/bugon.cocci
Fixes: 8214bf079208 ("scripts/dtc: Export YYLOC global declaration")
Reported-by: kernel test robot <lkp(a)intel.com>
Signed-off-by: kernel test robot <lkp(a)intel.com>
---
tree:
https://android.googlesource.com/kernel/goldfish android-3.18
head: dd54b61f1458c03f68fc019b4874d98f2f0ae3a5
commit: 8214bf079208b146e63cd0a3ce0ed335a87ce7b3 [396/1051] scripts/dtc: Export YYLOC
global declaration
:::::: branch date: 5 weeks ago
:::::: commit date: 3 months ago
Please take the patch only if it's a positive warning. Thanks!
flock.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
--- a/fs/afs/flock.c
+++ b/fs/afs/flock.c
@@ -139,8 +139,7 @@ void afs_lock_work(struct work_struct *w
if (!list_empty(&vnode->granted_locks)) {
_debug("extend");
- if (test_and_set_bit(AFS_VNODE_LOCKING, &vnode->flags))
- BUG();
+ BUG_ON(test_and_set_bit(AFS_VNODE_LOCKING, &vnode->flags));
fl = list_entry(vnode->granted_locks.next,
struct file_lock, fl_u.afs.link);
key = key_get(fl->fl_file->private_data);
@@ -173,8 +172,7 @@ void afs_lock_work(struct work_struct *w
if (!list_empty(&vnode->pending_locks)) {
_debug("get");
- if (test_and_set_bit(AFS_VNODE_LOCKING, &vnode->flags))
- BUG();
+ BUG_ON(test_and_set_bit(AFS_VNODE_LOCKING, &vnode->flags));
fl = list_entry(vnode->pending_locks.next,
struct file_lock, fl_u.afs.link);
key = key_get(fl->fl_file->private_data);
@@ -238,11 +236,8 @@ void afs_lock_work(struct work_struct *w
static void afs_defer_unlock(struct afs_vnode *vnode, struct key *key)
{
cancel_delayed_work(&vnode->lock_work);
- if (!test_and_clear_bit(AFS_VNODE_READLOCKED, &vnode->flags) &&
- !test_and_clear_bit(AFS_VNODE_WRITELOCKED, &vnode->flags))
- BUG();
- if (test_and_set_bit(AFS_VNODE_UNLOCKING, &vnode->flags))
- BUG();
+ BUG_ON(!test_and_clear_bit(AFS_VNODE_READLOCKED, &vnode->flags) &&
!test_and_clear_bit(AFS_VNODE_WRITELOCKED, &vnode->flags));
+ BUG_ON(test_and_set_bit(AFS_VNODE_UNLOCKING, &vnode->flags));
vnode->unlock_key = key_get(key);
afs_lock_may_be_available(vnode);
}