xfs: Remove unnecessary free()'s
authorPaulo Alcantara <pcacjr@zytor.com>
Tue, 22 Jan 2013 03:54:09 +0000 (01:54 -0200)
committerPaulo Alcantara <pcacjr@zytor.com>
Tue, 22 Jan 2013 03:54:09 +0000 (01:54 -0200)
Those freed memories are all now cached and need to get flushed at some
point.

Signed-off-by: Paulo Alcantara <pcacjr@zytor.com>
core/fs/xfs/xfs.c
core/fs/xfs/xfs_dir2.c
core/fs/xfs/xfs_readdir.c

index 4d60c08..b6a396a 100644 (file)
@@ -58,8 +58,6 @@ static inline int xfs_fmt_extents_readdir(struct file *file,
        /* Node Directory */
        return xfs_readdir_dir2_node(file, dirent, core);
     }
-
-    return -1;
 }
 
 static int xfs_readdir(struct file *file, struct dirent *dirent)
@@ -202,8 +200,6 @@ static inline struct inode *xfs_fmt_extents_find_entry(const char *dname,
        /* Node Directory */
        return xfs_dir2_node_find_entry(dname, parent, core);
     }
-
-    return NULL;
 }
 
 static inline struct inode *xfs_fmt_btree_find_entry(const char *dname,
@@ -233,11 +229,6 @@ static struct inode *xfs_iget(const char *dname, struct inode *parent)
         inode = xfs_fmt_extents_find_entry(dname, parent, core);
     } else if (core->di_format == XFS_DINODE_FMT_BTREE) {
         inode = xfs_fmt_btree_find_entry(dname, parent, core);
-    } else {
-       xfs_debug("format %hhu", core->di_format);
-       xfs_debug("TODO: format \"local\" and \"extents\" are the only "
-                 "supported ATM");
-       goto out;
     }
 
     if (!inode) {
index 81b8c24..39a586b 100644 (file)
@@ -433,8 +433,6 @@ struct inode *xfs_dir2_leaf_find_entry(const char *dname, struct inode *parent,
     }
 
 out:
-    free(leaf);
-
     return NULL;
 
 found:
@@ -471,13 +469,10 @@ found:
 
     xfs_debug("entry inode's number %lu", ino);
 
-    free(leaf);
-
     return ip;
 
 failed:
     free(ip);
-    free(leaf);
 
     return ip;
 }
@@ -673,7 +668,6 @@ struct inode *xfs_dir2_node_find_entry(const char *dname, struct inode *parent,
             goto out;
         }
 
-        free(node);
         node = (xfs_da_intnode_t *)xfs_dir2_dirblks_get_cached(parent->fs,
                                                               fsblkno, 1);
     } while(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC);
@@ -747,8 +741,6 @@ struct inode *xfs_dir2_node_find_entry(const char *dname, struct inode *parent,
     }
 
 out:
-    free(node);
-
     return NULL;
 
 found:
@@ -780,13 +772,10 @@ found:
 
     xfs_debug("entry inode's number %lu", ino);
 
-    free(node);
-
     return ip;
 
 failed:
     free(ip);
-    free(node);
 
     return NULL;
 }
index e99ea71..952f33b 100644 (file)
@@ -255,13 +255,9 @@ int xfs_readdir_dir2_leaf(struct file *file, struct dirent *dirent,
     if (retval)
        xfs_error("Failed to fill in dirent structure");
 
-    free(leaf);
-
     return retval;
 
 out:
-    free(leaf);
-
     return -1;
 }
 
@@ -316,14 +312,13 @@ try_next_btree:
     leaf = (xfs_dir2_leaf_t*)xfs_dir2_dirblks_get_cached(fs, fsblkno, 1);
     if (be16_to_cpu(leaf->hdr.info.magic) != XFS_DIR2_LEAFN_MAGIC) {
         xfs_error("Leaf's magic number does not match!");
-        goto out1;
+        goto out;
     }
 
     if (!leaf->hdr.count ||
        XFS_PVT(inode)->i_leaf_ent_offset >= be16_to_cpu(leaf->hdr.count)) {
        XFS_PVT(inode)->i_btree_offset++;
        XFS_PVT(inode)->i_leaf_ent_offset = 0;
-       free(leaf);
        goto try_next_btree;
     }
 
@@ -337,7 +332,6 @@ try_next_btree:
     if (XFS_PVT(inode)->i_leaf_ent_offset == be16_to_cpu(leaf->hdr.count)) {
        XFS_PVT(inode)->i_btree_offset++;
        XFS_PVT(inode)->i_leaf_ent_offset = 0;
-       free(leaf);
        goto try_next_btree;
     } else {
        XFS_PVT(inode)->i_leaf_ent_offset++;
@@ -348,14 +342,14 @@ try_next_btree:
     fsblkno = xfs_dir2_get_right_blk(fs, core, db, &error);
     if (error) {
        xfs_error("Cannot find data block!");
-       goto out1;
+       goto out;
     }
 
     buf = xfs_dir2_dirblks_get_cached(fs, fsblkno, 1);
     data_hdr = (xfs_dir2_data_hdr_t *)buf;
     if (be32_to_cpu(data_hdr->magic) != XFS_DIR2_DATA_MAGIC) {
        xfs_error("Leaf directory's data magic No. does not match!");
-       goto out1;
+       goto out;
     }
 
     offset = xfs_dir2_dataptr_to_off(fs, be32_to_cpu(lep->address));
@@ -370,17 +364,9 @@ try_next_btree:
     if (retval)
        xfs_error("Failed to fill in dirent structure");
 
-    free(leaf);
-    free(node);
-
     return retval;
 
-out1:
-    free(leaf);
-
 out:
-    free(node);
-
     XFS_PVT(inode)->i_btree_offset = 0;
     XFS_PVT(inode)->i_leaf_ent_offset = 0;