Skip to contentSkip to conversation

f2fs: fix to use le32_to_cpu() in RAW_IS_INODE()

PATCH In review Chao Yu 2 participants 2 messages May 18, 2023 – May 24, 2023 F2FS file system

lore
Share & tools
lore

Chao Yu

author maintainer
#0 lore raw

PATCH 1/1 f2fs: fix to use le32_to_cpu() in RAW_IS_INODE()

__le32 type variable should be converted w/ le32_to_cpu() before access.

---
 fs/f2fs/f2fs.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
fs/f2fs/f2fs.h +5 -1
index 7f6c51a6b930..a4bff3b5b887 100644
@@ -2840,7 +2840,11 @@ static inline void f2fs_radix_tree_insert(struct radix_tree_root *root,
 		cond_resched();
 }
 
-#define RAW_IS_INODE(p)	((p)->footer.nid == (p)->footer.ino)
+static inline bool RAW_IS_INODE(struct f2fs_node *node)
+{
+	return le32_to_cpu(node->footer.ino) ==
+			le32_to_cpu(node->footer.nid);
+}
 
 static inline bool IS_INODE(struct page *page)
 {
Signature · 8 lines
2.40.1



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
maintainer
#1 lore raw
Quoted 12 lines · Chao Yu

__le32 type variable should be converted w/ le32_to_cpu() before access.

---
 fs/f2fs/f2fs.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
fs/f2fs/f2fs.h +0 -0
index 7f6c51a6b930..a4bff3b5b887 100644

fs/f2fs/f2fs.h static inline void f2fs_radix_tree_insert(struct radix_tree_root *root, · line 2843

Quoted 4 lines
fs/f2fs/f2fs.h +0 -1
@@ -2840,7 +2840,11 @@ static inline void f2fs_radix_tree_insert(struct radix_tree_root *root,
 		cond_resched();
 }
 
-#define RAW_IS_INODE(p)	((p)->footer.nid == (p)->footer.ino)

Does this compare the same __le32 types?

Quoted 10 lines
fs/f2fs/f2fs.h +5 -0
+static inline bool RAW_IS_INODE(struct f2fs_node *node)
+{
+	return le32_to_cpu(node->footer.ino) ==
+			le32_to_cpu(node->footer.nid);
+}
 
 static inline bool IS_INODE(struct page *page)
 {
Signature · 1 line
2.40.1