Skip to contentSkip to conversation

SUNRPC: remove an unnecessary if statement

PACTH net-next wangweidong 2 participants 2 messages Oct 24, 2013

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

If req allocated failed just goto out_free, no need to check the 'i < num_prealloc'. There is just code simplification, no functional changes.

---
 net/sunrpc/xprt.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
net/sunrpc/xprt.c +1 -3
index 095363e..a8e20de 100644
@@ -1087,11 +1087,9 @@ struct rpc_xprt *xprt_alloc(struct net *net, size_t size,
 	for (i = 0; i < num_prealloc; i++) {
 		req = kzalloc(sizeof(struct rpc_rqst), GFP_KERNEL);
 		if (!req)
-			break;
+			goto out_free;
 		list_add(&req->rq_list, &xprt->free);
 	}
-	if (i < num_prealloc)
-		goto out_free;
 	if (max_alloc > num_prealloc)
 		xprt->max_reqs = max_alloc;
 	else

-- 1.7.12

Acked-by
#1 lore raw
Quoted 19 lines · wangweidong

If req allocated failed just goto out_free, no need to check the 'i < num_prealloc'. There is just code simplification, no functional changes.

---
 net/sunrpc/xprt.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
net/sunrpc/xprt.c +0 -0
index 095363e..a8e20de 100644
@@ -1087,11 +1087,9 @@ struct rpc_xprt *xprt_alloc(struct net *net, size_t size,
 	for (i = 0; i < num_prealloc; i++) {
 		req = kzalloc(sizeof(struct rpc_rqst), GFP_KERNEL);
 		if (!req)

net/sunrpc/xprt.c struct rpc_xprt *xprt_alloc(struct net *net, size_t size,

Quoted 10 lines
net/sunrpc/xprt.c +1 -4
-			break;
+			goto out_free;
 		list_add(&req->rq_list, &xprt->free);
 	}
-	if (i < num_prealloc)
-		goto out_free;
 	if (max_alloc > num_prealloc)
 		xprt->max_reqs = max_alloc;
 	else
-- 1.7.12
Quoted 4 lines

.