diff mbox series

[U-Boot,1/1] yaffs2: iterator variable cannot be NULL

Message ID 20180308215229.27104-1-xypron.glpk@gmx.de
State Accepted
Commit 428e60e079ba700dad3d883ec12653f1a5cedea6
Delegated to: Tom Rini
Headers show
Series [U-Boot,1/1] yaffs2: iterator variable cannot be NULL | expand

Commit Message

Heinrich Schuchardt March 8, 2018, 9:52 p.m. UTC
The iterator of list_for_each() is never NULL.

Identified with coccinelle.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
 fs/yaffs2/yaffs_guts.c | 4 ++--
 fs/yaffs2/yaffsfs.c    | 9 +++------
 2 files changed, 5 insertions(+), 8 deletions(-)

Comments

Tom Rini March 9, 2018, 6:29 p.m. UTC | #1
On Thu, Mar 08, 2018 at 10:52:29PM +0100, Heinrich Schuchardt wrote:

> The iterator of list_for_each() is never NULL.
> 
> Identified with coccinelle.
> 
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/fs/yaffs2/yaffs_guts.c b/fs/yaffs2/yaffs_guts.c
index bbe0d700fb..c8b27adda9 100644
--- a/fs/yaffs2/yaffs_guts.c
+++ b/fs/yaffs2/yaffs_guts.c
@@ -1872,8 +1872,8 @@  static int yaffs_new_obj_id(struct yaffs_dev *dev)
 		n += YAFFS_NOBJECT_BUCKETS;
 		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) {
+			if (list_entry(i, struct yaffs_obj,
+				       hash_link)->obj_id == n) {
 				found = 0;
 				break;
 			}
diff --git a/fs/yaffs2/yaffsfs.c b/fs/yaffs2/yaffsfs.c
index ba76a5ccdb..47abc6beda 100644
--- a/fs/yaffs2/yaffsfs.c
+++ b/fs/yaffs2/yaffsfs.c
@@ -2847,12 +2847,9 @@  static void yaffsfs_RemoveObjectCallback(struct yaffs_obj *obj)
 	 * the next one to prevent a hanging ptr.
 	 */
 	list_for_each(i, &search_contexts) {
-		if (i) {
-			dsc = list_entry(i, struct yaffsfs_DirSearchContxt,
-					 others);
-			if (dsc->nextReturn == obj)
-				yaffsfs_DirAdvance(dsc);
-		}
+		dsc = list_entry(i, struct yaffsfs_DirSearchContxt, others);
+		if (dsc->nextReturn == obj)
+			yaffsfs_DirAdvance(dsc);
 	}
 
 }