public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: maximilian attems <janitor@sternwelten.at>
To: viro@math.psu.edu
Cc: linux-kernel@vger.kernel.org
Subject: [patch-kj] use list_for_each()/list_for_each_save() in fs/dcache.c
Date: Fri, 23 Jul 2004 17:52:18 +0200	[thread overview]
Message-ID: <20040723155218.GP1795@stro.at> (raw)


Use list_for_each() where applicable
- for (list = ymf_devs.next; list != &ymf_devs; list = list->next) {
+ list_for_each(list, &ymf_devs) {
pure cosmetic change, defined as a preprocessor macro in:
include/linux/list.h

applies cleanly to 2.6.8-rc2

From: Domen Puncer <domen@coderock.org>
Signed-off-by: Maximilian Attems <janitor@sternwelten.at>



---

 linux-2.6.7-bk20-max/fs/dcache.c |   21 +++++----------------
 1 files changed, 5 insertions(+), 16 deletions(-)

diff -puN fs/dcache.c~list_for_each-fs-dcache fs/dcache.c
--- linux-2.6.7-bk20/fs/dcache.c~list_for_each-fs-dcache	2004-07-11 14:40:57.000000000 +0200
+++ linux-2.6.7-bk20-max/fs/dcache.c	2004-07-11 14:40:57.000000000 +0200
@@ -288,15 +288,11 @@ struct dentry * dget_locked(struct dentr
 
 struct dentry * d_find_alias(struct inode *inode)
 {
-	struct list_head *head, *next, *tmp;
+	struct list_head *tmp, *next;
 	struct dentry *alias, *discon_alias=NULL;
 
 	spin_lock(&dcache_lock);
-	head = &inode->i_dentry;
-	next = inode->i_dentry.next;
-	while (next != head) {
-		tmp = next;
-		next = tmp->next;
+	list_for_each_safe(tmp, next, &inode->i_dentry) {
 		prefetch(next);
 		alias = list_entry(tmp, struct dentry, d_alias);
  		if (!d_unhashed(alias)) {
@@ -324,8 +320,7 @@ void d_prune_aliases(struct inode *inode
 	struct list_head *tmp, *head = &inode->i_dentry;
 restart:
 	spin_lock(&dcache_lock);
-	tmp = head;
-	while ((tmp = tmp->next) != head) {
+	list_for_each(tmp, head) {
 		struct dentry *dentry = list_entry(tmp, struct dentry, d_alias);
 		if (!atomic_read(&dentry->d_count)) {
 			__dget_locked(dentry);
@@ -442,10 +437,7 @@ void shrink_dcache_sb(struct super_block
 	 * superblock to the most recent end of the unused list.
 	 */
 	spin_lock(&dcache_lock);
-	next = dentry_unused.next;
-	while (next != &dentry_unused) {
-		tmp = next;
-		next = tmp->next;
+	list_for_each_safe(tmp, next, &dentry_unused) {
 		dentry = list_entry(tmp, struct dentry, d_lru);
 		if (dentry->d_sb != sb)
 			continue;
@@ -457,10 +449,7 @@ void shrink_dcache_sb(struct super_block
 	 * Pass two ... free the dentries for this superblock.
 	 */
 repeat:
-	next = dentry_unused.next;
-	while (next != &dentry_unused) {
-		tmp = next;
-		next = tmp->next;
+	list_for_each_safe(tmp, next, &dentry_unused) {
 		dentry = list_entry(tmp, struct dentry, d_lru);
 		if (dentry->d_sb != sb)
 			continue;



                 reply	other threads:[~2004-07-23 16:07 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040723155218.GP1795@stro.at \
    --to=janitor@sternwelten.at \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@math.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox