f2fs: fix sparse warnings
authorEric Biggers <ebiggers@google.com>
Tue, 11 Oct 2016 17:36:12 +0000 (10:36 -0700)
committerJaegeuk Kim <jaegeuk@google.com>
Mon, 25 Sep 2017 22:04:55 +0000 (15:04 -0700)
commit 0c0b471e43e7acf0747c6eb410863bf78c14750d upstream.

f2fs contained a number of endianness conversion bugs.

Also, one function should have been 'static'.

Found with sparse by running 'make C=2 CF=-D__CHECK_ENDIAN__ fs/f2fs/'

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/dir.c
fs/f2fs/inline.c
fs/f2fs/node.c
fs/f2fs/node.h

index c0dba11519cfb7779a4e6517633e531a84756d9f..7136dc1ade11b40989ec1f5164044086bd839df1 100644 (file)
@@ -136,7 +136,7 @@ struct f2fs_dir_entry *find_target_dentry(struct fscrypt_name *fname,
 
                /* show encrypted name */
                if (fname->hash) {
-                       if (de->hash_code == fname->hash)
+                       if (de->hash_code == cpu_to_le32(fname->hash))
                                goto found;
                } else if (de_name.len == name->len &&
                        de->hash_code == namehash &&
index a1acbc67d82769c71f7f0deb3d098cb04e2d94e0..56363c18489a3051498fd90421213b054f25b852 100644 (file)
@@ -438,7 +438,7 @@ static int f2fs_add_inline_entries(struct inode *dir,
                }
 
                new_name.name = d.filename[bit_pos];
-               new_name.len = de->name_len;
+               new_name.len = le16_to_cpu(de->name_len);
 
                ino = le32_to_cpu(de->ino);
                fake_mode = get_de_type(de) << S_SHIFT;
index bc38e5a92b4bf59d7af0cdac5a3dd4977d0548a0..d2ba37a84f8e826f57eea4791ed5d83280ebee52 100644 (file)
@@ -270,8 +270,9 @@ static void cache_nat_entry(struct f2fs_sb_info *sbi, nid_t nid,
                e = grab_nat_entry(nm_i, nid);
                node_info_from_raw_nat(&e->ni, ne);
        } else {
-               f2fs_bug_on(sbi, nat_get_ino(e) != ne->ino ||
-                               nat_get_blkaddr(e) != ne->block_addr ||
+               f2fs_bug_on(sbi, nat_get_ino(e) != le32_to_cpu(ne->ino) ||
+                               nat_get_blkaddr(e) !=
+                                       le32_to_cpu(ne->block_addr) ||
                                nat_get_version(e) != ne->version);
        }
 }
index 868bec65e51c216290e00dbcb391d92aecfd7f47..cfdcf98516a1f911ebd60f158c073b40e16f6bc3 100644 (file)
@@ -313,7 +313,7 @@ static inline bool is_recoverable_dnode(struct page *page)
                                ((unsigned char *)ckpt + crc_offset)));
                cp_ver |= (crc << 32);
        }
-       return cpu_to_le64(cp_ver) == cpver_of_node(page);
+       return cp_ver == cpver_of_node(page);
 }
 
 /*