From 4ba20d4c211525fbc800eefea0b8f53b64bc48bf Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Mon, 15 Feb 2021 09:57:07 -0500 Subject: [PATCH] LU-9859 tracefile: convert list_for_each_entry_safe() to while(!list_empty()) These loops are removing all elements from a list. So using while(!list_empty()) makes the intent clearer. Linux-commit: fdafb01e2c70e6b5321d158a2ff1f20a13d9b365 Change-Id: Idda25888e424a1deaa4d7c6fad427d494b1f56e5 Signed-off-by: NeilBrown Reviewed-on: https://review.whamcloud.com/41670 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Yang Sheng Reviewed-by: Oleg Drokin --- libcfs/libcfs/tracefile.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/libcfs/libcfs/tracefile.c b/libcfs/libcfs/tracefile.c index 7acc5bb..d3a0803 100644 --- a/libcfs/libcfs/tracefile.c +++ b/libcfs/libcfs/tracefile.c @@ -858,12 +858,12 @@ void cfs_trace_flush_pages(void) { struct page_collection pc; struct cfs_trace_page *tage; - struct cfs_trace_page *tmp; pc.pc_want_daemon_pages = 1; collect_pages(&pc); - list_for_each_entry_safe(tage, tmp, &pc.pc_pages, linkage) { - + while (!list_empty(&pc.pc_pages)) { + tage = list_first_entry(&pc.pc_pages, + struct cfs_trace_page, linkage); __LASSERT_TAGE_INVARIANT(tage); list_del(&tage->linkage); @@ -1280,7 +1280,6 @@ static void trace_cleanup_on_all_cpus(void) { struct cfs_trace_cpu_data *tcd; struct cfs_trace_page *tage; - struct cfs_trace_page *tmp; int i, cpu; for_each_possible_cpu(cpu) { @@ -1290,7 +1289,10 @@ static void trace_cleanup_on_all_cpus(void) continue; tcd->tcd_shutting_down = 1; - list_for_each_entry_safe(tage, tmp, &tcd->tcd_pages, linkage) { + while (!list_empty(&tcd->tcd_pages)) { + tage = list_first_entry(&tcd->tcd_pages, + struct cfs_trace_page, + linkage); __LASSERT_TAGE_INVARIANT(tage); list_del(&tage->linkage); -- 1.8.3.1