linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] make iunique use a do/while loop rather than its obscure goto loop
@ 2007-01-30 15:45 Jeffrey Layton
  2007-01-31  8:16 ` Christoph Hellwig
  0 siblings, 1 reply; 7+ messages in thread
From: Jeffrey Layton @ 2007-01-30 15:45 UTC (permalink / raw)
  To: linux-fsdevel, linux-kernel; +Cc: hch

While working on a case, Christoph mentioned that he thought that iunique
ought to be cleaned up to use a more conventional loop construct. This patch
does that, turning the strange goto loop into a do/while.

Signed-off-by: Jeff Layton <jlayton@redhat.com>

diff --git a/fs/inode.c b/fs/inode.c
index 23fc1fd..90e7587 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -689,21 +689,18 @@ ino_t iunique(struct super_block *sb, ino_t max_reserved)
 	struct inode *inode;
 	struct hlist_head * head;
 	ino_t res;
+
 	spin_lock(&inode_lock);
-retry:
-	if (counter > max_reserved) {
-		head = inode_hashtable + hash(sb,counter);
+	do {
+		if (counter <= max_reserved)
+			counter = max_reserved + 1;
 		res = counter++;
+		head = inode_hashtable + hash(sb, res);
 		inode = find_inode_fast(sb, head, res);
-		if (!inode) {
-			spin_unlock(&inode_lock);
-			return res;
-		}
-	} else {
-		counter = max_reserved + 1;
-	}
-	goto retry;
-	
+	} while (inode != NULL);
+	spin_unlock(&inode_lock);
+
+	return res;
 }
 
 EXPORT_SYMBOL(iunique);

^ permalink raw reply related	[flat|nested] 7+ messages in thread
* [PATCH] make iunique use a do/while loop rather than its obscure goto loop
@ 2007-04-11 21:58 Jeffrey Layton
  2007-04-13 18:42 ` Andrew Morton
  2007-06-23  8:08 ` Christoph Hellwig
  0 siblings, 2 replies; 7+ messages in thread
From: Jeffrey Layton @ 2007-04-11 21:58 UTC (permalink / raw)
  To: akpm; +Cc: hch, linux-kernel, linux-fsdevel

A while back, Christoph mentioned that he thought that iunique ought to be
cleaned up to use a more conventional loop construct. This patch does that,
turning the strange goto loop into a do/while.

Signed-off-by: Jeff Layton <jlayton@redhat.com>

diff --git a/fs/inode.c b/fs/inode.c
index 23fc1fd..90e7587 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -689,21 +689,18 @@ ino_t iunique(struct super_block *sb, ino_t max_reserved)
 	struct inode *inode;
 	struct hlist_head * head;
 	ino_t res;
+
 	spin_lock(&inode_lock);
-retry:
-	if (counter > max_reserved) {
-		head = inode_hashtable + hash(sb,counter);
+	do {
+		if (counter <= max_reserved)
+			counter = max_reserved + 1;
 		res = counter++;
+		head = inode_hashtable + hash(sb, res);
 		inode = find_inode_fast(sb, head, res);
-		if (!inode) {
-			spin_unlock(&inode_lock);
-			return res;
-		}
-	} else {
-		counter = max_reserved + 1;
-	}
-	goto retry;
-	
+	} while (inode != NULL);
+	spin_unlock(&inode_lock);
+
+	return res;
 }
 
 EXPORT_SYMBOL(iunique);

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2007-06-23  8:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-01-30 15:45 [PATCH] make iunique use a do/while loop rather than its obscure goto loop Jeffrey Layton
2007-01-31  8:16 ` Christoph Hellwig
  -- strict thread matches above, loose matches on Subject: below --
2007-04-11 21:58 Jeffrey Layton
2007-04-13 18:42 ` Andrew Morton
2007-04-13 19:08   ` Jeff Layton
2007-04-13 19:55     ` Andrew Morton
2007-06-23  8:08 ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).