[f2fs-dev] [PATCH] f2fs: Fix multiple sparse warnings

Bart Van Assche via Linux-f2fs-devel <[email protected]> Fri, 7 Aug 2026 10:10:56 -0700
Newsgroups net.sourceforge.lists.linux-f2fs-devel
Message-ID <31b06883a88b8169f2d9be8ac7303bfe14cf1530.1786122586.git.bvanassche@acm.org>
Fix the following sparse warnings:

fs/f2fs/file.c:3738:36: warning: incorrect type in argument 1 (different base types)
fs/f2fs/file.c:3738:36:    expected unsigned short const [usertype] *pwcs
fs/f2fs/file.c:3738:36:    got restricted __le16 *
fs/f2fs/file.c:3774:28: warning: incorrect type in argument 4 (different base types)
fs/f2fs/file.c:3774:28:    expected unsigned short [usertype] *pwcs
fs/f2fs/file.c:3774:28:    got restricted __le16 *

fs/f2fs/super.c:489:19: warning: symbol 'f2fs_cf_name_slab' was not declared. Should it be static?

fs/f2fs/data.c:2553:39: warning: Using plain integer as NULL pointer

fs/f2fs/xattr.c:851:1: warning: no newline at end of file

fs/f2fs/compress.c:1921:39: warning: symbol 'f2fs_compress_aops' was not declared. Should it be static?

No functionality has been modified.

Signed-off-by: Bart Van Assche <[email protected]>
---
 fs/f2fs/data.c              | 2 +-
 fs/f2fs/f2fs.h              | 7 +++++++
 fs/f2fs/file.c              | 8 ++++----
 fs/f2fs/inode.c             | 4 ----
 fs/f2fs/super.c             | 1 -
 fs/f2fs/xattr.c             | 2 +-
 include/trace/events/f2fs.h | 3 ++-
 7 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index ac1cf4de3d62..2d24c38ad116 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -2550,7 +2550,7 @@ static int f2fs_read_data_large_folio(struct inode *inode,
 {
 	struct bio *bio = NULL;
 	sector_t last_block_in_bio = 0;
-	struct f2fs_map_blocks map = {0, };
+	struct f2fs_map_blocks map = {};
 	pgoff_t index, offset, next_pgofs = 0;
 	unsigned max_nr_pages = rac ? readahead_count(rac) :
 				folio_nr_pages(folio);
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index f1774d4e18d2..a4a299591c65 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -654,6 +654,10 @@ struct f2fs_filename {
 #endif
 };
 
+#if IS_ENABLED(CONFIG_UNICODE)
+extern struct kmem_cache *f2fs_cf_name_slab;
+#endif
+
 struct f2fs_dentry_ptr {
 	struct inode *inode;
 	void *bitmap;
@@ -4652,6 +4656,9 @@ enum cluster_check_type {
 	CLUSTER_COMPR_BLKS, /* return # of compressed blocks in a cluster */
 	CLUSTER_RAW_BLKS    /* return # of raw blocks in a cluster */
 };
+
+extern const struct address_space_operations f2fs_compress_aops;
+
 bool f2fs_is_compressed_page(struct folio *folio);
 struct folio *f2fs_compress_control_folio(struct folio *folio);
 int f2fs_prepare_compress_overwrite(struct inode *inode,
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 4b52c56d71f0..a20bc791774a 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -3735,9 +3735,9 @@ static int f2fs_ioc_getfslabel(struct file *filp, unsigned long arg)
 		return -ENOMEM;
 
 	f2fs_down_read(&sbi->sb_lock);
-	count = utf16s_to_utf8s(sbi->raw_super->volume_name,
-			ARRAY_SIZE(sbi->raw_super->volume_name),
-			UTF16_LITTLE_ENDIAN, vbuf, MAX_VOLUME_NAME);
+	count = utf16s_to_utf8s((__force wchar_t *)sbi->raw_super->volume_name,
+				ARRAY_SIZE(sbi->raw_super->volume_name),
+				UTF16_LITTLE_ENDIAN, vbuf, MAX_VOLUME_NAME);
 	f2fs_up_read(&sbi->sb_lock);
 
 	if (copy_to_user((char __user *)arg, vbuf,
@@ -3771,7 +3771,7 @@ static int f2fs_ioc_setfslabel(struct file *filp, unsigned long arg)
 	memset(sbi->raw_super->volume_name, 0,
 			sizeof(sbi->raw_super->volume_name));
 	utf8s_to_utf16s(vbuf, strlen(vbuf), UTF16_LITTLE_ENDIAN,
-			sbi->raw_super->volume_name,
+			(__force wchar_t *)sbi->raw_super->volume_name,
 			ARRAY_SIZE(sbi->raw_super->volume_name));
 
 	err = f2fs_commit_super(sbi, false);
diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c
index c95e0b126da4..65758c60632a 100644
--- a/fs/f2fs/inode.c
+++ b/fs/f2fs/inode.c
@@ -20,10 +20,6 @@
 
 #include <trace/events/f2fs.h>
 
-#ifdef CONFIG_F2FS_FS_COMPRESSION
-extern const struct address_space_operations f2fs_compress_aops;
-#endif
-
 void f2fs_mark_inode_dirty_sync(struct inode *inode, bool sync)
 {
 	if (is_inode_flag_set(inode, FI_NEW_INODE))
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index a87ec20d3363..09123894394d 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -486,7 +486,6 @@ f2fs_sb_read_encoding(const struct f2fs_super_block *sb)
 	return NULL;
 }
 
-struct kmem_cache *f2fs_cf_name_slab;
 static int __init f2fs_create_casefold_cache(void)
 {
 	f2fs_cf_name_slab = f2fs_kmem_cache_create("f2fs_casefolded_name",
diff --git a/fs/f2fs/xattr.c b/fs/f2fs/xattr.c
index ed33e5110f2a..0129800af0bb 100644
--- a/fs/f2fs/xattr.c
+++ b/fs/f2fs/xattr.c
@@ -848,4 +848,4 @@ int __init f2fs_init_xattr_cache(void)
 void f2fs_destroy_xattr_cache(void)
 {
 	kmem_cache_destroy(inline_xattr_slab);
-}
\ No newline at end of file
+}
diff --git a/include/trace/events/f2fs.h b/include/trace/events/f2fs.h
index 270c1a2c24c4..7f5ce92afe0f 100644
--- a/include/trace/events/f2fs.h
+++ b/include/trace/events/f2fs.h
@@ -1493,7 +1493,8 @@ DECLARE_EVENT_CLASS(f2fs_mmap,
 		show_dev_ino(__entry),
 		(unsigned long)__entry->index,
 		__print_flags(__entry->flags, "|", FAULT_FLAG_TRACE),
-		__print_flags(__entry->ret, "|", VM_FAULT_RESULT_TRACE))
+		__print_flags((__force unsigned long)__entry->ret, "|",
+			      VM_FAULT_RESULT_TRACE))
 );
 
 DEFINE_EVENT(f2fs_mmap, f2fs_filemap_fault,


_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel