diff mbox series

jffs2: deubg: list_for_each() -> list_for_each_entry()

Message ID 1582436775-14367-1-git-send-email-qiwuchen55@gmail.com
State New
Delegated to: David Woodhouse
Headers show
Series jffs2: deubg: list_for_each() -> list_for_each_entry() | expand

Commit Message

qiwuchen55@gmail.com Feb. 23, 2020, 5:46 a.m. UTC
From: chenqiwu <chenqiwu@xiaomi.com>

Use list_for_each_entry() instead of list_for_each() to
simplify code.

Signed-off-by: chenqiwu <chenqiwu@xiaomi.com>
---
 fs/jffs2/debug.c | 65 +++++++++++++++++++-------------------------------------
 1 file changed, 22 insertions(+), 43 deletions(-)
diff mbox series

Patch

diff --git a/fs/jffs2/debug.c b/fs/jffs2/debug.c
index 9d26b1b9..6bef692 100644
--- a/fs/jffs2/debug.c
+++ b/fs/jffs2/debug.c
@@ -498,12 +498,11 @@  void __jffs2_dbg_superblock_counts(struct jffs2_sb_info *c)
 	if (list_empty(&c->clean_list)) {
 		printk(JFFS2_DBG "clean_list: empty\n");
 	} else {
-		struct list_head *this;
 		int numblocks = 0;
 		uint32_t dirty = 0;
+		struct jffs2_eraseblock *jeb;
 
-		list_for_each(this, &c->clean_list) {
-			struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list);
+		list_for_each_entry(jeb, &c->clean_list, list) {
 			numblocks ++;
 			dirty += jeb->wasted_size;
 			if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) {
@@ -520,13 +519,11 @@  void __jffs2_dbg_superblock_counts(struct jffs2_sb_info *c)
 	if (list_empty(&c->very_dirty_list)) {
 		printk(JFFS2_DBG "very_dirty_list: empty\n");
 	} else {
-		struct list_head *this;
 		int numblocks = 0;
 		uint32_t dirty = 0;
+		struct jffs2_eraseblock *jeb;
 
-		list_for_each(this, &c->very_dirty_list) {
-			struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list);
-
+		list_for_each_entry(jeb, &c->very_dirty_list, list) {
 			numblocks ++;
 			dirty += jeb->dirty_size;
 			if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) {
@@ -543,13 +540,11 @@  void __jffs2_dbg_superblock_counts(struct jffs2_sb_info *c)
 	if (list_empty(&c->dirty_list)) {
 		printk(JFFS2_DBG "dirty_list: empty\n");
 	} else {
-		struct list_head *this;
 		int numblocks = 0;
 		uint32_t dirty = 0;
+		struct jffs2_eraseblock *jeb;
 
-		list_for_each(this, &c->dirty_list) {
-			struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list);
-
+		list_for_each_entry(jeb, &c->dirty_list, list) {
 			numblocks ++;
 			dirty += jeb->dirty_size;
 			if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) {
@@ -566,11 +561,9 @@  void __jffs2_dbg_superblock_counts(struct jffs2_sb_info *c)
 	if (list_empty(&c->erasable_list)) {
 		printk(JFFS2_DBG "erasable_list: empty\n");
 	} else {
-		struct list_head *this;
-
-		list_for_each(this, &c->erasable_list) {
-			struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list);
+		struct jffs2_eraseblock *jeb;
 
+		list_for_each_entry(jeb, &c->erasable_list, list) {
 			if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) {
 				printk(JFFS2_DBG "erasable_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, unchecked %#08x, free %#08x)\n",
 					jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size,
@@ -582,11 +575,9 @@  void __jffs2_dbg_superblock_counts(struct jffs2_sb_info *c)
 	if (list_empty(&c->erasing_list)) {
 		printk(JFFS2_DBG "erasing_list: empty\n");
 	} else {
-		struct list_head *this;
-
-		list_for_each(this, &c->erasing_list) {
-			struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list);
+		struct jffs2_eraseblock *jeb;
 
+		list_for_each_entry(jeb, &c->erasing_list, list) {
 			if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) {
 				printk(JFFS2_DBG "erasing_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, unchecked %#08x, free %#08x)\n",
 					jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size,
@@ -597,11 +588,9 @@  void __jffs2_dbg_superblock_counts(struct jffs2_sb_info *c)
 	if (list_empty(&c->erase_checking_list)) {
 		printk(JFFS2_DBG "erase_checking_list: empty\n");
 	} else {
-		struct list_head *this;
-
-		list_for_each(this, &c->erase_checking_list) {
-			struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list);
+		struct jffs2_eraseblock *jeb;
 
+		list_for_each_entry(jeb, &c->erase_checking_list, list) {
 			if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) {
 				printk(JFFS2_DBG "erase_checking_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, unchecked %#08x, free %#08x)\n",
 					jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size,
@@ -613,11 +602,9 @@  void __jffs2_dbg_superblock_counts(struct jffs2_sb_info *c)
 	if (list_empty(&c->erase_pending_list)) {
 		printk(JFFS2_DBG "erase_pending_list: empty\n");
 	} else {
-		struct list_head *this;
-
-		list_for_each(this, &c->erase_pending_list) {
-			struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list);
+		struct jffs2_eraseblock *jeb;
 
+		list_for_each_entry(jeb, &c->erase_pending_list, list) {
 			if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) {
 				printk(JFFS2_DBG "erase_pending_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, unchecked %#08x, free %#08x)\n",
 					jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size,
@@ -629,11 +616,9 @@  void __jffs2_dbg_superblock_counts(struct jffs2_sb_info *c)
 	if (list_empty(&c->erasable_pending_wbuf_list)) {
 		printk(JFFS2_DBG "erasable_pending_wbuf_list: empty\n");
 	} else {
-		struct list_head *this;
-
-		list_for_each(this, &c->erasable_pending_wbuf_list) {
-			struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list);
+		struct jffs2_eraseblock *jeb;
 
+		list_for_each_entry(jeb, &c->erasable_pending_wbuf_list, list) {
 			if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) {
 				printk(JFFS2_DBG "erasable_pending_wbuf_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, unchecked %#08x, free %#08x)\n",
 					jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size,
@@ -645,11 +630,9 @@  void __jffs2_dbg_superblock_counts(struct jffs2_sb_info *c)
 	if (list_empty(&c->free_list)) {
 		printk(JFFS2_DBG "free_list: empty\n");
 	} else {
-		struct list_head *this;
-
-		list_for_each(this, &c->free_list) {
-			struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list);
+		struct jffs2_eraseblock *jeb;
 
+		list_for_each_entry(jeb, &c->free_list, list) {
 			if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) {
 				printk(JFFS2_DBG "free_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, unchecked %#08x, free %#08x)\n",
 					jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size,
@@ -661,11 +644,9 @@  void __jffs2_dbg_superblock_counts(struct jffs2_sb_info *c)
 	if (list_empty(&c->bad_list)) {
 		printk(JFFS2_DBG "bad_list: empty\n");
 	} else {
-		struct list_head *this;
-
-		list_for_each(this, &c->bad_list) {
-			struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list);
+		struct jffs2_eraseblock *jeb;
 
+		list_for_each_entry(jeb, &c->bad_list, list) {
 			if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) {
 				printk(JFFS2_DBG "bad_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, unchecked %#08x, free %#08x)\n",
 					jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size,
@@ -677,11 +658,9 @@  void __jffs2_dbg_superblock_counts(struct jffs2_sb_info *c)
 	if (list_empty(&c->bad_used_list)) {
 		printk(JFFS2_DBG "bad_used_list: empty\n");
 	} else {
-		struct list_head *this;
-
-		list_for_each(this, &c->bad_used_list) {
-			struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list);
+		struct jffs2_eraseblock *jeb;
 
+		list_for_each_entry(jeb, &c->bad_used_list, list) {
 			if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) {
 				printk(JFFS2_DBG "bad_used_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, unchecked %#08x, free %#08x)\n",
 					jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size,