diff mbox series

[f2fs-dev,1/4] fsck.f2fs: wrap openned codes into fsck_sanity_check_nid()

Message ID 20230512100354.4072489-1-chao@kernel.org (mailing list archive)
State New
Headers show
Series [f2fs-dev,1/4] fsck.f2fs: wrap openned codes into fsck_sanity_check_nid() | expand

Commit Message

Chao Yu May 12, 2023, 10:03 a.m. UTC
read_all_xattrs() is the only user of fsck_sanity_check_nid(), wrap
openned codes of read_all_xattrs() into fsck_sanity_check_nid().

Then fsck_sanity_check_nid() can be reused later.

Signed-off-by: Chao Yu <chao@kernel.org>
---
 fsck/fsck.c  | 16 ++++++++++++----
 fsck/fsck.h  |  3 +--
 fsck/xattr.c | 12 +-----------
 3 files changed, 14 insertions(+), 17 deletions(-)
diff mbox series

Patch

diff --git a/fsck/fsck.c b/fsck/fsck.c
index 324c3d5..64db1e5 100644
--- a/fsck/fsck.c
+++ b/fsck/fsck.c
@@ -515,11 +515,19 @@  static int sanity_check_nid(struct f2fs_sb_info *sbi, u32 nid,
 }
 
 int fsck_sanity_check_nid(struct f2fs_sb_info *sbi, u32 nid,
-			struct f2fs_node *node_blk,
-			enum FILE_TYPE ftype, enum NODE_TYPE ntype,
-			struct node_info *ni)
+			enum FILE_TYPE ftype, enum NODE_TYPE ntype)
 {
-	return sanity_check_nid(sbi, nid, node_blk, ftype, ntype, ni);
+	struct f2fs_node *node_blk = NULL;
+	struct node_info ni;
+	int ret;
+
+	node_blk = (struct f2fs_node *)calloc(BLOCK_SZ, 1);
+	ASSERT(node_blk != NULL);
+
+	ret = sanity_check_nid(sbi, nid, node_blk, ftype, ntype, &ni);
+
+	free(node_blk);
+	return ret;
 }
 
 static int fsck_chk_xattr_blk(struct f2fs_sb_info *sbi, u32 ino,
diff --git a/fsck/fsck.h b/fsck/fsck.h
index dabd8b9..02dcff8 100644
--- a/fsck/fsck.h
+++ b/fsck/fsck.h
@@ -166,8 +166,7 @@  extern int fsck_chk_orphan_node(struct f2fs_sb_info *);
 extern int fsck_chk_quota_node(struct f2fs_sb_info *);
 extern int fsck_chk_quota_files(struct f2fs_sb_info *);
 extern int fsck_sanity_check_nid(struct f2fs_sb_info *, u32,
-			struct f2fs_node *, enum FILE_TYPE, enum NODE_TYPE,
-			struct node_info *);
+					enum FILE_TYPE, enum NODE_TYPE);
 extern int fsck_chk_node_blk(struct f2fs_sb_info *, struct f2fs_inode *, u32,
 		enum FILE_TYPE, enum NODE_TYPE, u32 *,
 		struct f2fs_compr_blk_cnt *, struct child_info *);
diff --git a/fsck/xattr.c b/fsck/xattr.c
index 8e66873..04c2879 100644
--- a/fsck/xattr.c
+++ b/fsck/xattr.c
@@ -25,17 +25,7 @@  void *read_all_xattrs(struct f2fs_sb_info *sbi, struct f2fs_node *inode)
 	nid_t xnid = le32_to_cpu(inode->i.i_xattr_nid);
 
 	if (c.func == FSCK && xnid) {
-		struct f2fs_node *node_blk = NULL;
-		struct node_info ni;
-		int ret;
-
-		node_blk = (struct f2fs_node *)calloc(BLOCK_SZ, 1);
-		ASSERT(node_blk != NULL);
-
-		ret = fsck_sanity_check_nid(sbi, xnid, node_blk,
-					F2FS_FT_XATTR, TYPE_XATTR, &ni);
-		free(node_blk);
-		if (ret)
+		if (fsck_sanity_check_nid(sbi, xnid, F2FS_FT_XATTR, TYPE_XATTR))
 			return NULL;
 	}