[Ocfs2-tools-devel] [patch] mkfs.c: code cleanup in write_directory_data

Coly Li i at coly.li
Mon Sep 24 03:29:55 PDT 2012


In write_directory_data() we check dir->buf twice, and always
calling write_metadata() no matter whether dir->buf is NULL.
The patch cleans up the redundant code.

Signed-off-by: Coly Li <i at coly.li>
Cc: Joel Becker <jlbec at evilplan.org>
---
 mkfs.ocfs2/mkfs.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/mkfs.ocfs2/mkfs.c b/mkfs.ocfs2/mkfs.c
index 7abea73..c7bafeb 100644
--- a/mkfs.ocfs2/mkfs.c
+++ b/mkfs.ocfs2/mkfs.c
@@ -2701,11 +2701,11 @@ write_directory_data(State *s, DirData *dir)
 	if (!dir->record->extent_len)
 		return;
 
-	if (dir->buf)
+	if (dir->buf) {
 		mkfs_swap_dir_from_cpu(s, dir);
-	write_metadata(s, dir->record, dir->buf);
-	if (dir->buf)
+		write_metadata(s, dir->record, dir->buf);
 		mkfs_swap_dir_to_cpu(s, dir);
+	}
 }
 
 static void



More information about the Ocfs2-tools-devel mailing list