From mboxrd@z Thu Jan 1 00:00:00 1970 From: James Simmons Date: Thu, 2 Aug 2018 04:05:55 +0100 (BST) Subject: [lustre-devel] [PATCH 11/22] Revert "staging: lustre: lnet: lib-move: Use list_for_each_entry_safe" In-Reply-To: <153292186104.13840.12696227873574036682.stgit@noble> References: <153292153459.13840.17465048403476297915.stgit@noble> <153292186104.13840.12696227873574036682.stgit@noble> Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: lustre-devel@lists.lustre.org > This reverts commit 24f695909440b79b04bb75205384c9772e4c7d0a. > > These loops really want to remove everything, and using a > while(!list_empty()) > loop makes this more obvious. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lnet/lnet/lib-move.c | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) > > diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c > index e8092b1b6b27..2756e91b34bb 100644 > --- a/drivers/staging/lustre/lnet/lnet/lib-move.c > +++ b/drivers/staging/lustre/lnet/lnet/lib-move.c > @@ -49,7 +49,6 @@ int > lnet_fail_nid(lnet_nid_t nid, unsigned int threshold) > { > struct lnet_test_peer *tp; > - struct lnet_test_peer *temp; > struct list_head *el; > struct list_head *next; > struct list_head cull; > @@ -88,7 +87,9 @@ lnet_fail_nid(lnet_nid_t nid, unsigned int threshold) > > lnet_net_unlock(0); > > - list_for_each_entry_safe(tp, temp, &cull, tp_list) { > + while (!list_empty(&cull)) { > + tp = list_entry(cull.next, struct lnet_test_peer, tp_list); > + > list_del(&tp->tp_list); > kfree(tp); > } > @@ -99,7 +100,6 @@ static int > fail_peer(lnet_nid_t nid, int outgoing) > { > struct lnet_test_peer *tp; > - struct lnet_test_peer *temp; > struct list_head *el; > struct list_head *next; > struct list_head cull; > @@ -146,7 +146,8 @@ fail_peer(lnet_nid_t nid, int outgoing) > > lnet_net_unlock(0); > > - list_for_each_entry_safe(tp, temp, &cull, tp_list) { > + while (!list_empty(&cull)) { > + tp = list_entry(cull.next, struct lnet_test_peer, tp_list); > list_del(&tp->tp_list); > > kfree(tp); > > >