dm stats: Use list_for_each_entry() helper instead of list_for_each() and container_of()
PATCH 1/1 dm stats: Use list_for_each_entry() helper instead of list_for_each() and container_of()
Convert list_for_each() and container_of() to list_for_each_entry() so that the l list_head pointer and container_of() call are no longer needed, which can reduce a few lines of code. No functional changed.
Signed-off-by Jinjie Ruan <[email protected]>
--- drivers/md/dm-stats.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/md/dm-stats.c +1 -3
@@ -240,12 +240,10 @@ void dm_stats_cleanup(struct dm_stats *stats)static void dm_stats_recalc_precise_timestamps (struct dm_stats *stats) { -struct list_head *l;struct dm_stat *tmp_s;bool precise_timestamps = false; -list_for_each (l, &stats->list) { - tmp_s = container_of(l, struct dm_stat, list_entry); +list_for_each_entry (tmp_s, &stats->list, list_entry) {if (tmp_s->stat_flags &STAT_PRECISE_TIMESTAMPS ) { precise_timestamps = true;break ;
Signature · 6 lines
2.34.1 -- dm-devel mailing list [email protected] https://listman.redhat.com/mailman/listinfo/dm-devel