Skip to contentSkip to conversation

staging: lustre: lnet: Remove an else after an if-return

PATCH In review Anchal Jain 2 participants 2 messages Nov 1, 2015 – Nov 4, 2015 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: lustre: lnet: Remove an else after an if-return

The original motivation of the patch was to remove an else after an if branch that ends in a return. This removal required the removal of a list of other things. That are needed to make the code either correct or acceptable to checkpatch, for example:removing a blank line, removing braces, etc.

Remove unnecessary use of else that required the removal of corresponding braces. And then the declaration of hash was movedup to the beginning of the function is required, but the initialization was left where it was. And it also required remove the blank line and add some new lines before the if and below the declaration of hash.

---
 drivers/staging/lustre/lnet/lnet/lib-ptl.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)
drivers/staging/lustre/lnet/lnet/lib-ptl.c +7 -9
index b4f573a..aec06f9 100644
@@ -357,16 +357,14 @@ lnet_mt_match_head(struct lnet_match_table *mtable,
 		   lnet_process_id_t id, __u64 mbits)
 {
 	struct lnet_portal *ptl = the_lnet.ln_portals[mtable->mt_portal];
-
-	if (lnet_ptl_is_wildcard(ptl)) {
+	 unsigned long hash;
+	if (lnet_ptl_is_wildcard(ptl))
 		return &mtable->mt_mhash[mbits & LNET_MT_HASH_MASK];
-	} else {
-		unsigned long hash = mbits + id.nid + id.pid;
-
-		LASSERT(lnet_ptl_is_unique(ptl));
-		hash = hash_long(hash, LNET_MT_HASH_BITS);
-		return &mtable->mt_mhash[hash];
-	}
+	hash = mbits + id.nid + id.pid;
+		
+	LASSERT(lnet_ptl_is_unique(ptl));
+	hash = hash_long(hash, LNET_MT_HASH_BITS);
+	return &mtable->mt_mhash[hash];
 }
 
 int
Signature · 1 line
1.9.1
maintainer
#1 lore raw
Quoted 26 lines · Anchal Jain

The original motivation of the patch was to remove an else after an if branch that ends in a return. This removal required the removal of a list of other things. That are needed to make the code either correct or acceptable to checkpatch, for example:removing a blank line, removing braces, etc.

Remove unnecessary use of else that required the removal of corresponding braces. And then the declaration of hash was movedup to the beginning of the function is required, but the initialization was left where it was. And it also required remove the blank line and add some new lines before the if and below the declaration of hash.

---
 drivers/staging/lustre/lnet/lnet/lib-ptl.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)
drivers/staging/lustre/lnet/lnet/lib-ptl.c +0 -0
index b4f573a..aec06f9 100644

drivers/staging/lustre/lnet/lnet/lib-ptl.c lnet_mt_match_head(struct lnet_match_table *mtable, · line 360

Quoted 6 lines
drivers/staging/lustre/lnet/lnet/lib-ptl.c +1 -2
@@ -357,16 +357,14 @@ lnet_mt_match_head(struct lnet_match_table *mtable,
 		   lnet_process_id_t id, __u64 mbits)
 {
 	struct lnet_portal *ptl = the_lnet.ln_portals[mtable->mt_portal];
-
-	if (lnet_ptl_is_wildcard(ptl)) {
+	 unsigned long hash;

Very odd indentation :(