yaffs: Sort out issues raised by Coverity
[yaffs2.git] / yaffs_vfs_single.c
index 2cd604769db07aad88d20a5f52cfa69bce1ed148..1893125d338f4322ec27bde53a4e1839b1b67cc5 100644 (file)
@@ -783,11 +783,9 @@ static void yaffs_remove_obj_callback(struct yaffs_obj *obj)
         * the search context to the next object to prevent a hanging pointer.
         */
        list_for_each(i, search_contexts) {
-               if (i) {
-                       sc = list_entry(i, struct yaffs_search_context, others);
-                       if (sc->next_return == obj)
-                               yaffs_search_advance(sc);
-               }
+               sc = list_entry(i, struct yaffs_search_context, others);
+               if (sc->next_return == obj)
+                       yaffs_search_advance(sc);
        }
 
 }
@@ -1376,6 +1374,13 @@ static ssize_t yaffs_file_write(struct file *f, const char *buf, size_t n,
 
        obj = yaffs_dentry_to_obj(f->f_dentry);
 
+       if (!obj) {
+               /* This should not happen */
+               yaffs_trace(YAFFS_TRACE_OS,
+                       "yaffs_file_write: hey obj is null!");
+                return -ENINVAL;
+        }
+
        dev = obj->my_dev;
 
        yaffs_gross_lock(dev);
@@ -1387,13 +1392,9 @@ static ssize_t yaffs_file_write(struct file *f, const char *buf, size_t n,
        else
                ipos = *pos;
 
-       if (!obj)
-               yaffs_trace(YAFFS_TRACE_OS,
-                       "yaffs_file_write: hey obj is null!");
-       else
-               yaffs_trace(YAFFS_TRACE_OS,
-                       "yaffs_file_write about to write writing %u(%x) bytes to object %d at %d(%x)",
-                       (unsigned)n, (unsigned)n, obj->obj_id, ipos, ipos);
+       yaffs_trace(YAFFS_TRACE_OS,
+               "yaffs_file_write about to write writing %u(%x) bytes to object %d at %d(%x)",
+               (unsigned)n, (unsigned)n, obj->obj_id, ipos, ipos);
 
        n_written = yaffs_wr_file(obj, buf, ipos, n, 0);
 
@@ -2027,6 +2028,11 @@ static struct super_block *yaffs_internal_read_super(int yaffs_version,
        struct yaffs_linux_context *context_iterator;
        struct list_head *l;
 
+       if (!sb) {
+               printk(KERN_INFO "yaffs: sb is NULL\n");
+               return NULL;
+        }
+
        sb->s_magic = YAFFS_MAGIC;
        sb->s_op = &yaffs_super_ops;
        sb->s_flags |= MS_NOATIME;
@@ -2035,9 +2041,7 @@ static struct super_block *yaffs_internal_read_super(int yaffs_version,
 
        sb->s_export_op = &yaffs_export_ops;
 
-       if (!sb)
-               printk(KERN_INFO "yaffs: sb is NULL\n");
-       else if (!sb->s_dev)
+       if (!sb->s_dev)
                printk(KERN_INFO "yaffs: sb->s_dev is NULL\n");
        else if (!yaffs_devname(sb, devname_buf))
                printk(KERN_INFO "yaffs: devname is NULL\n");