summaryrefslogtreecommitdiffstats
path: root/drivers/staging/lustre
diff options
context:
space:
mode:
authorBhumika Goyal2016-03-06 15:38:44 +0100
committerGreg Kroah-Hartman2016-03-12 07:09:09 +0100
commit2d513ef6c3fc9cb09225d0ff3fc7a31e76924913 (patch)
treedd99a5ebcc7fa6005a3508a299de5dcc71bdca22 /drivers/staging/lustre
parentstaging: rtl8723au: hal: Remove useless return variables (diff)
downloadkernel-qcow2-linux-2d513ef6c3fc9cb09225d0ff3fc7a31e76924913.tar.gz
kernel-qcow2-linux-2d513ef6c3fc9cb09225d0ff3fc7a31e76924913.tar.xz
kernel-qcow2-linux-2d513ef6c3fc9cb09225d0ff3fc7a31e76924913.zip
Staging: lustre: lnet: Use list_first_entry_or_null
This patch replaces list_empty and list_entry with list_first_entry_or_null. Done using coccinelle: @@ expression e1,e2; statement S; @@ - if(!list_empty(...)){ e2= - list_entry(e1.next, + list_first_entry_or_null(&e1, ...); + if(e2){ ... } Signed-off-by: Bhumika Goyal <bhumirks@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/lustre')
-rw-r--r--drivers/staging/lustre/lnet/selftest/conrpc.c7
-rw-r--r--drivers/staging/lustre/lnet/selftest/framework.c7
2 files changed, 6 insertions, 8 deletions
diff --git a/drivers/staging/lustre/lnet/selftest/conrpc.c b/drivers/staging/lustre/lnet/selftest/conrpc.c
index 8a67f8903a4c..32970ef777e3 100644
--- a/drivers/staging/lustre/lnet/selftest/conrpc.c
+++ b/drivers/staging/lustre/lnet/selftest/conrpc.c
@@ -123,11 +123,10 @@ lstcon_rpc_prep(lstcon_node_t *nd, int service, unsigned feats,
spin_lock(&console_session.ses_rpc_lock);
- if (!list_empty(&console_session.ses_rpc_freelist)) {
- crpc = list_entry(console_session.ses_rpc_freelist.next,
- lstcon_rpc_t, crp_link);
+ crpc = list_first_entry_or_null(&console_session.ses_rpc_freelist,
+ lstcon_rpc_t, crp_link);
+ if (crpc)
list_del_init(&crpc->crp_link);
- }
spin_unlock(&console_session.ses_rpc_lock);
diff --git a/drivers/staging/lustre/lnet/selftest/framework.c b/drivers/staging/lustre/lnet/selftest/framework.c
index a2f94fa2aebd..b86db8dcf8dc 100644
--- a/drivers/staging/lustre/lnet/selftest/framework.c
+++ b/drivers/staging/lustre/lnet/selftest/framework.c
@@ -919,11 +919,10 @@ sfw_create_test_rpc(sfw_test_unit_t *tsu, lnet_process_id_t peer,
spin_lock(&tsi->tsi_lock);
LASSERT(sfw_test_active(tsi));
-
- if (!list_empty(&tsi->tsi_free_rpcs)) {
/* pick request from buffer */
- rpc = list_entry(tsi->tsi_free_rpcs.next,
- srpc_client_rpc_t, crpc_list);
+ rpc = list_first_entry_or_null(&tsi->tsi_free_rpcs,
+ srpc_client_rpc_t, crpc_list);
+ if (rpc) {
LASSERT(nblk == rpc->crpc_bulk.bk_niov);
list_del_init(&rpc->crpc_list);
}