Skip to contentSkip to conversation

ocfs2: remove deadcode on variable tmp_oh check

PATCH In review Colin King 2 participants 2 messages Sep 2, 2019

Subsystems (2)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH v2 1/1 ocfs2: remove deadcode on variable tmp_oh check

From: Colin Ian King <[email protected]>

At the end of ocfs2_inode_lock_tracker tmp_oh is true because an earlier check on tmp_oh being false returns out of the function. Since tmp_oh is true, the function will always return 1 so remove the redundant check and return of 0.

Also update description in comment, return -EINVAL and not -1.

Addresses-Coverity: ("Logically dead code")

---

V2: Fix typo of function name in description.
Update description in comment as noted by Joseph Qi

---
 fs/ocfs2/dlmglue.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
fs/ocfs2/dlmglue.c +3 -2
index ad594fef2ab0..640eee2bb903 100644
@@ -2626,7 +2626,8 @@ void ocfs2_inode_unlock(struct inode *inode,
  *
  * return < 0 on error, return = 0 if there's no lock holder on the stack
  * before this call, return = 1 if this call would be a recursive locking.
- * return = -1 if this lock attempt will cause an upgrade which is forbidden.
+ * return = -EINVAL if this lock attempt will cause an upgrade which is
+ * forbidden.
  *
  * When taking lock levels into account,we face some different situations.
  *
@@ -2712,7 +2713,7 @@ int ocfs2_inode_lock_tracker(struct inode *inode,
 			return status;
 		}
 	}
-	return tmp_oh ? 1 : 0;
+	return 1;
 }
 
 void ocfs2_inode_unlock_tracker(struct inode *inode,
Signature · 1 line
2.20.1
maintainer Reviewed-by on v2 1/1
#1 lore raw
Quoted 11 lines · Colin King

From: Colin Ian King <[email protected]>

At the end of ocfs2_inode_lock_tracker tmp_oh is true because an earlier check on tmp_oh being false returns out of the function. Since tmp_oh is true, the function will always return 1 so remove the redundant check and return of 0.

Also update description in comment, return -EINVAL and not -1.

Addresses-Coverity: ("Logically dead code")

Quoted 33 lines

---

V2: Fix typo of function name in description.
Update description in comment as noted by Joseph Qi

---
 fs/ocfs2/dlmglue.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
fs/ocfs2/dlmglue.c +3 -2
index ad594fef2ab0..640eee2bb903 100644
@@ -2626,7 +2626,8 @@ void ocfs2_inode_unlock(struct inode *inode,
  *
  * return < 0 on error, return = 0 if there's no lock holder on the stack
  * before this call, return = 1 if this call would be a recursive locking.
- * return = -1 if this lock attempt will cause an upgrade which is forbidden.
+ * return = -EINVAL if this lock attempt will cause an upgrade which is
+ * forbidden.
  *
  * When taking lock levels into account,we face some different situations.
  *
@@ -2712,7 +2713,7 @@ int ocfs2_inode_lock_tracker(struct inode *inode,
 			return status;
 		}
 	}
-	return tmp_oh ? 1 : 0;
+	return 1;
 }
 
 void ocfs2_inode_unlock_tracker(struct inode *inode,