yaffs2: iterator variable cannot be NULL
authorHeinrich Schuchardt <xypron.glpk@gmx.de>
Thu, 8 Mar 2018 21:52:29 +0000 (22:52 +0100)
committerTom Rini <trini@konsulko.com>
Fri, 9 Mar 2018 17:31:06 +0000 (12:31 -0500)
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
fs/yaffs2/yaffsfs.c

index bbe0d700fb63e8d7754d37163dbbaef45745daa3..c8b27adda91dee49989013366bc3de98bc42868d 100644 (file)
@@ -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;
                        }
index ba76a5ccdbdb65ab9b5d6a410c81add5f919e7ef..47abc6bedae7bf85c7eaea34dfdf1705065f297b 100644 (file)
@@ -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);
        }
 
 }