summaryrefslogtreecommitdiffstats
path: root/drivers/staging/lustre
diff options
context:
space:
mode:
authorBhaktipriya Shridhar2016-03-11 21:05:29 +0100
committerGreg Kroah-Hartman2016-03-12 07:09:09 +0100
commitc997866cd27495ae28bc07596457e2bd83fb3275 (patch)
treea51c0fb47dae3bf9876b7ff4c58c4fbb27218d7e /drivers/staging/lustre
parentstaging: lustre: lnet: peer: Use list_for_each_entry_safe (diff)
downloadkernel-qcow2-linux-c997866cd27495ae28bc07596457e2bd83fb3275.tar.gz
kernel-qcow2-linux-c997866cd27495ae28bc07596457e2bd83fb3275.tar.xz
kernel-qcow2-linux-c997866cd27495ae28bc07596457e2bd83fb3275.zip
staging: lustre: lnet: api-ni: Use list_for_each_entry_safe
Doubly linked lists which are iterated using list_empty and list_entry macros have been replaced with list_for_each_entry_safe macro. This makes the iteration simpler and more readable. This patch replaces the while loop containing list_empty and list_entry with list_for_each_entry_safe. This was done with Coccinelle. @@ expression E1; identifier I1, I2; type T; iterator name list_for_each_entry_safe; @@ T *I1; + T *tmp; ... - while (list_empty(&E1) == 0) + list_for_each_entry_safe (I1, tmp, &E1, I2) { ...when != T *I1; - I1 = list_entry(E1.next, T, I2); ... } Signed-off-by: Bhaktipriya Shridhar <bhaktipriya96@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/lustre')
-rw-r--r--drivers/staging/lustre/lnet/lnet/api-ni.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c
index 6c7579e42b88..8764755544c9 100644
--- a/drivers/staging/lustre/lnet/lnet/api-ni.c
+++ b/drivers/staging/lustre/lnet/lnet/api-ni.c
@@ -1086,18 +1086,17 @@ lnet_clear_zombies_nis_locked(void)
int i;
int islo;
lnet_ni_t *ni;
+ lnet_ni_t *temp;
/*
* Now wait for the NI's I just nuked to show up on ln_zombie_nis
* and shut them down in guaranteed thread context
*/
i = 2;
- while (!list_empty(&the_lnet.ln_nis_zombie)) {
+ list_for_each_entry_safe(ni, temp, &the_lnet.ln_nis_zombie, ni_list) {
int *ref;
int j;
- ni = list_entry(the_lnet.ln_nis_zombie.next,
- lnet_ni_t, ni_list);
list_del_init(&ni->ni_list);
cfs_percpt_for_each(ref, j, ni->ni_refs) {
if (!*ref)
@@ -1147,6 +1146,7 @@ static void
lnet_shutdown_lndnis(void)
{
lnet_ni_t *ni;
+ lnet_ni_t *temp;
int i;
/* NB called holding the global mutex */
@@ -1160,9 +1160,7 @@ lnet_shutdown_lndnis(void)
the_lnet.ln_shutdown = 1; /* flag shutdown */
/* Unlink NIs from the global table */
- while (!list_empty(&the_lnet.ln_nis)) {
- ni = list_entry(the_lnet.ln_nis.next,
- lnet_ni_t, ni_list);
+ list_for_each_entry_safe(ni, temp, &the_lnet.ln_nis, ni_list) {
lnet_ni_unlink_locked(ni);
}