[syslinux:elflink] xfs: Remove unnecessary free()'s

syslinux-bot for Paulo Alcantara pcacjr at zytor.com
Thu Jan 24 09:45:07 PST 2013


Commit-ID:  2be24375ed6af881405d23483aebe81ce3dcb3b7
Gitweb:     http://www.syslinux.org/commit/2be24375ed6af881405d23483aebe81ce3dcb3b7
Author:     Paulo Alcantara <pcacjr at zytor.com>
AuthorDate: Tue, 22 Jan 2013 01:54:09 -0200
Committer:  Paulo Alcantara <pcacjr at zytor.com>
CommitDate: Tue, 22 Jan 2013 01:54:09 -0200

xfs: Remove unnecessary free()'s

Those freed memories are all now cached and need to get flushed at some
point.

Signed-off-by: Paulo Alcantara <pcacjr at zytor.com>

---
 core/fs/xfs/xfs.c         |  9 ---------
 core/fs/xfs/xfs_dir2.c    | 11 -----------
 core/fs/xfs/xfs_readdir.c | 20 +++-----------------
 3 files changed, 3 insertions(+), 37 deletions(-)

diff --git a/core/fs/xfs/xfs.c b/core/fs/xfs/xfs.c
index 4d60c08..b6a396a 100644
--- a/core/fs/xfs/xfs.c
+++ b/core/fs/xfs/xfs.c
@@ -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) {
diff --git a/core/fs/xfs/xfs_dir2.c b/core/fs/xfs/xfs_dir2.c
index 81b8c24..39a586b 100644
--- a/core/fs/xfs/xfs_dir2.c
+++ b/core/fs/xfs/xfs_dir2.c
@@ -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;
 }
diff --git a/core/fs/xfs/xfs_readdir.c b/core/fs/xfs/xfs_readdir.c
index e99ea71..952f33b 100644
--- a/core/fs/xfs/xfs_readdir.c
+++ b/core/fs/xfs/xfs_readdir.c
@@ -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;
 


More information about the Syslinux-commits mailing list