Skip to contentSkip to conversation

staging: lusture: ptlrpc: Remove useless return variables

PATCH Superseded Bhaktipriya Shridhar 2 participants 2 messages Feb 24, 2016 Staging

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 8/8 staging: lusture: 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;
)

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

#1 lore raw
Quoted 25 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;
)

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

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

Quoted 8 lines
drivers/staging/lustre/lustre/ptlrpc/client.c +1 -4
@@ -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);

Not related to this change, but this call would be better as using kmem_cache_zalloc, whih takes care of the | __GFP_ZERO. One could also consider whether this function and the next one could just be unfolded and dropped entirely.

julia

Quoted 13 lines
drivers/staging/lustre/lustre/ptlrpc/client.c +0 -1
 }
 
 void ptlrpc_request_cache_free(struct ptlrpc_request *req)
--

2.1.4

Signature · 5 lines
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20160224202858.GA23036%40Karyakshetra.
For more options, visit https://groups.google.com/d/optout.