Skip to contentSkip to conversation

staging: lustre: ptlrpc: Remove useless return variables

PATCH In review Bhaktipriya Shridhar 2 participants 3 messages Feb 26, 2016 – Mar 2, 2016 Staging

lore
Share & tools
lore
#0 lore raw

PATCH v4 5/5 staging: lustre: ptlrpc: Remove useless return variables

This patch removes unnecessary return variables and compresses the return logic.
The coccinelle script that finds and fixes this issue is:
@@ type T; identifier i,f; constant C; @@
- T i;
...when != i
when strict
( return -C;
|
- i =
+ return
f(...);
- return i;
)

---
Changes in v4:
-Corrected typo lusture in the subject. Made it to lustre

 drivers/staging/lustre/lustre/ptlrpc/client.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/staging/lustre/lustre/ptlrpc/client.c +1 -4
index 9b89068..031502e 100644
@@ -421,10 +421,7 @@ void ptlrpc_request_cache_fini(void)
 
 struct ptlrpc_request *ptlrpc_request_cache_alloc(gfp_t flags)
 {
-	struct ptlrpc_request *req;
-
-	req = kmem_cache_alloc(request_cache, flags | __GFP_ZERO);
-	return req;
+	return kmem_cache_alloc(request_cache, flags | __GFP_ZERO);
 }
 
 void ptlrpc_request_cache_free(struct ptlrpc_request *req)

--
2.1.4

maintainer
#1 lore raw
Quoted 29 lines · Bhaktipriya Shridhar

This patch removes unnecessary return variables and compresses the return logic.
The coccinelle script that finds and fixes this issue is:
@@ type T; identifier i,f; constant C; @@
- T i;
...when != i
when strict
( return -C;
|
- i =
+ return
f(...);
- return i;
)

---
Changes in v4:
-Corrected typo lusture in the subject. Made it to lustre

 drivers/staging/lustre/lustre/ptlrpc/client.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/staging/lustre/lustre/ptlrpc/client.c +0 -0
index 9b89068..031502e 100644
@@ -421,10 +421,7 @@ void ptlrpc_request_cache_fini(void)
 

drivers/staging/lustre/lustre/ptlrpc/client.c void ptlrpc_request_cache_fini(void) · line 427

Quoted 10 lines
drivers/staging/lustre/lustre/ptlrpc/client.c +1 -4
 struct ptlrpc_request *ptlrpc_request_cache_alloc(gfp_t flags)
 {
-	struct ptlrpc_request *req;
-
-	req = kmem_cache_alloc(request_cache, flags | __GFP_ZERO);
-	return req;
+	return kmem_cache_alloc(request_cache, flags | __GFP_ZERO);
 }
 
 void ptlrpc_request_cache_free(struct ptlrpc_request *req)

This patch didn't apply :(

maintainer
#2 lore raw
In reply to Bhaktipriya Shridhar
Quoted 29 lines · Bhaktipriya Shridhar

This patch removes unnecessary return variables and compresses the return logic.
The coccinelle script that finds and fixes this issue is:
@@ type T; identifier i,f; constant C; @@
- T i;
...when != i
when strict
( return -C;
|
- i =
+ return
f(...);
- return i;
)

---
Changes in v4:
-Corrected typo lusture in the subject. Made it to lustre

 drivers/staging/lustre/lustre/ptlrpc/client.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/staging/lustre/lustre/ptlrpc/client.c +0 -0
index 9b89068..031502e 100644
@@ -421,10 +421,7 @@ void ptlrpc_request_cache_fini(void)
 

drivers/staging/lustre/lustre/ptlrpc/client.c void ptlrpc_request_cache_fini(void) · line 427

Quoted 10 lines
drivers/staging/lustre/lustre/ptlrpc/client.c +1 -4
 struct ptlrpc_request *ptlrpc_request_cache_alloc(gfp_t flags)
 {
-	struct ptlrpc_request *req;
-
-	req = kmem_cache_alloc(request_cache, flags | __GFP_ZERO);
-	return req;
+	return kmem_cache_alloc(request_cache, flags | __GFP_ZERO);
 }
 
 void ptlrpc_request_cache_free(struct ptlrpc_request *req)

This patch didn't apply :(