All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/1] yaffs2: rework yaffs_new_obj_id
@ 2017-11-08 22:30 Heinrich Schuchardt
  2017-11-09  0:26 ` [U-Boot] [PATCH v2 " Heinrich Schuchardt
  0 siblings, 1 reply; 3+ messages in thread
From: Heinrich Schuchardt @ 2017-11-08 22:30 UTC (permalink / raw)
  To: u-boot

The iterator variable of list_for_each is never NULL.
if (1 || A) is always true.
Remove superfluous while.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
 fs/yaffs2/yaffs_guts.c | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/fs/yaffs2/yaffs_guts.c b/fs/yaffs2/yaffs_guts.c
index 32e6ff2a04..509e9839f1 100644
--- a/fs/yaffs2/yaffs_guts.c
+++ b/fs/yaffs2/yaffs_guts.c
@@ -1859,26 +1859,17 @@ static int yaffs_find_nice_bucket(struct yaffs_dev *dev)
 static int yaffs_new_obj_id(struct yaffs_dev *dev)
 {
 	int bucket = yaffs_find_nice_bucket(dev);
-	int found = 0;
 	struct list_head *i;
 	u32 n = (u32) bucket;
 
 	/* Now find an object value that has not already been taken
 	 * by scanning the list.
 	 */
-
-	while (!found) {
-		found = 1;
+	n += YAFFS_NOBJECT_BUCKETS;
+	list_for_each(i, &dev->obj_bucket[bucket].list) {
+		if (list_entry(i, struct yaffs_obj, hash_link)->obj_id != n)
+			break;
 		n += YAFFS_NOBJECT_BUCKETS;
-		if (1 || dev->obj_bucket[bucket].count > 0) {
-			list_for_each(i, &dev->obj_bucket[bucket].list) {
-				/* If there is already one in the list */
-				if (i && list_entry(i, struct yaffs_obj,
-						    hash_link)->obj_id == n) {
-					found = 0;
-				}
-			}
-		}
 	}
 	return n;
 }
-- 
2.14.2

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

* [U-Boot] [PATCH v2 1/1] yaffs2: rework yaffs_new_obj_id
  2017-11-08 22:30 [U-Boot] [PATCH 1/1] yaffs2: rework yaffs_new_obj_id Heinrich Schuchardt
@ 2017-11-09  0:26 ` Heinrich Schuchardt
  2017-11-21 13:05   ` [U-Boot] [U-Boot,v2,1/1] " Tom Rini
  0 siblings, 1 reply; 3+ messages in thread
From: Heinrich Schuchardt @ 2017-11-09  0:26 UTC (permalink / raw)
  To: u-boot

The iterator variable of list_for_each is never NULL.
if (1 || A) is always true.
Use break if entry found.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
v2
	Avoid changing logic.
---
 fs/yaffs2/yaffs_guts.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/fs/yaffs2/yaffs_guts.c b/fs/yaffs2/yaffs_guts.c
index 32e6ff2a04..bbe0d700fb 100644
--- a/fs/yaffs2/yaffs_guts.c
+++ b/fs/yaffs2/yaffs_guts.c
@@ -1870,13 +1870,12 @@ static int yaffs_new_obj_id(struct yaffs_dev *dev)
 	while (!found) {
 		found = 1;
 		n += YAFFS_NOBJECT_BUCKETS;
-		if (1 || dev->obj_bucket[bucket].count > 0) {
-			list_for_each(i, &dev->obj_bucket[bucket].list) {
-				/* If there is already one in the list */
-				if (i && list_entry(i, struct yaffs_obj,
-						    hash_link)->obj_id == n) {
-					found = 0;
-				}
+		list_for_each(i, &dev->obj_bucket[bucket].list) {
+			/* If there is already one in the list */
+			if (i && list_entry(i, struct yaffs_obj,
+					    hash_link)->obj_id == n) {
+				found = 0;
+				break;
 			}
 		}
 	}
-- 
2.14.2

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

* [U-Boot] [U-Boot,v2,1/1] yaffs2: rework yaffs_new_obj_id
  2017-11-09  0:26 ` [U-Boot] [PATCH v2 " Heinrich Schuchardt
@ 2017-11-21 13:05   ` Tom Rini
  0 siblings, 0 replies; 3+ messages in thread
From: Tom Rini @ 2017-11-21 13:05 UTC (permalink / raw)
  To: u-boot

On Thu, Nov 09, 2017 at 01:26:43AM +0100, Heinrich Schuchardt wrote:

> The iterator variable of list_for_each is never NULL.
> if (1 || A) is always true.
> Use break if entry found.
> 
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20171121/e4089ab9/attachment.sig>

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

end of thread, other threads:[~2017-11-21 13:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-08 22:30 [U-Boot] [PATCH 1/1] yaffs2: rework yaffs_new_obj_id Heinrich Schuchardt
2017-11-09  0:26 ` [U-Boot] [PATCH v2 " Heinrich Schuchardt
2017-11-21 13:05   ` [U-Boot] [U-Boot,v2,1/1] " Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.