From: Andreas Dilger Date: Fri, 8 Feb 2019 00:59:42 +0000 Subject: [lustre-devel] [PATCH 07/21] lustre: use list_first_entry() in lnet/klnds subdirectory. In-Reply-To: <154949781297.10620.13452862524706335326.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781297.10620.13452862524706335326.stgit@noble.brown> Message-ID: <1F487FF7-BF02-4FD7-9026-51CBD34610FE@whamcloud.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: lustre-devel@lists.lustre.org On Feb 6, 2019, at 17:03, NeilBrown wrote: > > Convert > list_entry(foo->next .....) > to > list_first_entry(foo, ....) > > in 'lnet/klnds > > In several cases the call is combined with a list_empty() test and > list_first_entry_or_null() is used > > Signed-off-by: NeilBrown > > @@ -1853,8 +1855,9 @@ static void kiblnd_destroy_pool_list(struct list_head *head) > { > struct kib_pool *pool; > > - while (!list_empty(head)) { > - pool = list_entry(head->next, struct kib_pool, po_list); > + while ((pool = list_first_entry_or_null(head, > + struct kib_pool, > + po_list)) != NULL) { > list_del(&pool->po_list); > > LASSERT(pool->po_owner); > @@ -1869,7 +1872,7 @@ static void kiblnd_fail_poolset(struct kib_poolset *ps, struct list_head *zombie > > spin_lock(&ps->ps_lock); > while (!list_empty(&ps->ps_pool_list)) { > - struct kib_pool *po = list_entry(ps->ps_pool_list.next, > + struct kib_pool *po = list_first_entry(&ps->ps_pool_list, > struct kib_pool, po_list); > po->po_failed = 1; > list_del(&po->po_list); Why not use the same style as elsewhere in the code: while ((po = list_first_entry_or_null(&ps->ps_pool_list, struct kib_pool, po_list)) != NULL) { ? Cheers, Andreas --- Andreas Dilger Principal Lustre Architect Whamcloud