Skip to contentSkip to conversation

list_for_each_entry: fs-dquot.c

PATCH In review [email protected] 2 participants 3 messages Jan 10, 2005 – Jan 11, 2005 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 list_for_each_entry: fs-dquot.c

Make code more readable with list_for_each_entry_safe. (Didn't compile before, doesn't compile now)

---

 kj-domen/fs/dquot.c |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)
fs/dquot.c renamed from fs/dquot.c~list-for-each-entry-safe-fs_dquot +2 -5
diff -puN fs/dquot.c~list-for-each-entry-safe-fs_dquot fs/dquot.c
@@ -406,13 +406,10 @@ out_dqlock:
  * for this sb+type at all. */
 static void invalidate_dquots(struct super_block *sb, int type)
 {
-	struct dquot *dquot;
-	struct list_head *head;
+	struct dquot *dquot, *tmp;
 
 	spin_lock(&dq_list_lock);
-	for (head = inuse_list.next; head != &inuse_list;) {
-		dquot = list_entry(head, struct dquot, dq_inuse);
-		head = head->next;
+	list_for_each_entry_safe(dquot, tmp, &inuse_list, dq_inuse) {
 		if (dquot->dq_sb != sb)
 			continue;
 		if (dquot->dq_type != type)

_

reviewer
#1 lore raw

Hello,

Quoted 2 lines

Make code more readable with list_for_each_entry_safe. (Didn't compile before, doesn't compile now)

What do you mean by "didn't compile before"? Which kernel have you
tried?

Quoted 17 lines

---

 kj-domen/fs/dquot.c |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)

diff -puN fs/dquot.c~list-for-each-entry-safe-fs_dquot fs/dquot.c

fs/dquot.c renamed from fs/dquot.c~list-for-each-entry-safe-fs_dquot +0 -2
@@ -406,13 +406,10 @@ out_dqlock:
  * for this sb+type at all. */
 static void invalidate_dquots(struct super_block *sb, int type)
 {
-	struct dquot *dquot;
-	struct list_head *head;

fs/dquot.c out_dqlock: · line 415

Quoted 10 lines
fs/dquot.c renamed from fs/dquot.c~list-for-each-entry-safe-fs_dquot +2 -3
+	struct dquot *dquot, *tmp;
 
 	spin_lock(&dq_list_lock);
-	for (head = inuse_list.next; head != &inuse_list;) {
-		dquot = list_entry(head, struct dquot, dq_inuse);
-		head = head->next;
+	list_for_each_entry_safe(dquot, tmp, &inuse_list, dq_inuse) {
 		if (dquot->dq_sb != sb)
 			continue;
 		if (dquot->dq_type != type)

Honza

Signature · 2 lines
Jan Kara <[email protected]>
SuSE CR Labs
#2 lore raw
Quoted 6 lines · Jan Kara

Hello,

Quoted 2 lines

Make code more readable with list_for_each_entry_safe. (Didn't compile before, doesn't compile now)

What do you mean by "didn't compile before"? Which kernel have you
tried?

It seems like it was compile tested with quotas disabled. It compiles fine when i enable quotas, duh. Sorry.

Domen