yaffs2: rework yaffs_new_obj_id
PATCH 1/1 yaffs2: rework yaffs_new_obj_id
The iterator variable of list_for_each is never NULL. if (1 || A) is always true.
Remove superfluous while.
Signed-off-by Heinrich Schuchardt <[email protected]>
--- fs/yaffs2/yaffs_guts.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-)
fs/yaffs2/yaffs_guts.c +4 -13
@@ -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; }
Signature · 1 line
2.14.2
PATCH v2 1/1 yaffs2: rework yaffs_new_obj_id
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 <[email protected]>
---
v2
Avoid changing logic.
--- fs/yaffs2/yaffs_guts.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
fs/yaffs2/yaffs_guts.c +6 -7
@@ -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 ; } } }
Signature · 1 line
2.14.2
PATCH v2 1/1 yaffs2: rework yaffs_new_obj_id
Quoted 5 lines · Heinrich Schuchardt
The iterator variable of
list_for_eachis never NULL. if (1 || A) is always true.
Use break if entry found.Signed-off-by Heinrich Schuchardt <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
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>