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>
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);
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);
}