f2fs: Use sysfs_emit_at() to simplify code
Chao Yu
maintainerPATCH RESEND 1/1 f2fs: Use sysfs_emit_at() to simplify code
From: Christophe JAILLET <[email protected]>
This file already uses sysfs_emit(). So be consistent and also use sysfs_emit_at().
This slightly simplifies the code and makes it more readable.
Reviewed-by Chao Yu <[email protected]>
Signed-off-by Christophe JAILLET <[email protected]>
--- fs/f2fs/sysfs.c | 45 +++++++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 24 deletions(-)
fs/f2fs/sysfs.c +21 -24
@@ -188,50 +188,50 @@ static ssize_t features_show(struct f2fs_attr *a,int len =0 ;if (f2fs_sb_has_encrypt (sbi)) - len +=scnprintf (buf,PAGE_SIZE - len,"%s" , + len +=sysfs_emit_at (buf, len,"%s" ,"encryption" );if (f2fs_sb_has_blkzoned (sbi)) - len +=scnprintf (buf + len,PAGE_SIZE - len,"%s%s" , + len +=sysfs_emit_at (buf, len,"%s%s" , len ?", " :"" ,"blkzoned" );if (f2fs_sb_has_extra_attr (sbi)) - len +=scnprintf (buf + len,PAGE_SIZE - len,"%s%s" , + len +=sysfs_emit_at (buf, len,"%s%s" , len ?", " :"" ,"extra_attr" );if (f2fs_sb_has_project_quota (sbi)) - len +=scnprintf (buf + len,PAGE_SIZE - len,"%s%s" , + len +=sysfs_emit_at (buf, len,"%s%s" , len ?", " :"" ,"projquota" );if (f2fs_sb_has_inode_chksum (sbi)) - len +=scnprintf (buf + len,PAGE_SIZE - len,"%s%s" , + len +=sysfs_emit_at (buf, len,"%s%s" , len ?", " :"" ,"inode_checksum" );if (f2fs_sb_has_flexible_inline_xattr (sbi)) - len +=scnprintf (buf + len,PAGE_SIZE - len,"%s%s" , + len +=sysfs_emit_at (buf, len,"%s%s" , len ?", " :"" ,"flexible_inline_xattr" );if (f2fs_sb_has_quota_ino (sbi)) - len +=scnprintf (buf + len,PAGE_SIZE - len,"%s%s" , + len +=sysfs_emit_at (buf, len,"%s%s" , len ?", " :"" ,"quota_ino" );if (f2fs_sb_has_inode_crtime (sbi)) - len +=scnprintf (buf + len,PAGE_SIZE - len,"%s%s" , + len +=sysfs_emit_at (buf, len,"%s%s" , len ?", " :"" ,"inode_crtime" );if (f2fs_sb_has_lost_found (sbi)) - len +=scnprintf (buf + len,PAGE_SIZE - len,"%s%s" , + len +=sysfs_emit_at (buf, len,"%s%s" , len ?", " :"" ,"lost_found" );if (f2fs_sb_has_verity (sbi)) - len +=scnprintf (buf + len,PAGE_SIZE - len,"%s%s" , + len +=sysfs_emit_at (buf, len,"%s%s" , len ?", " :"" ,"verity" );if (f2fs_sb_has_sb_chksum (sbi)) - len +=scnprintf (buf + len,PAGE_SIZE - len,"%s%s" , + len +=sysfs_emit_at (buf, len,"%s%s" , len ?", " :"" ,"sb_checksum" );if (f2fs_sb_has_casefold (sbi)) - len +=scnprintf (buf + len,PAGE_SIZE - len,"%s%s" , + len +=sysfs_emit_at (buf, len,"%s%s" , len ?", " :"" ,"casefold" );if (f2fs_sb_has_readonly (sbi)) - len +=scnprintf (buf + len,PAGE_SIZE - len,"%s%s" , + len +=sysfs_emit_at (buf, len,"%s%s" , len ?", " :"" ,"readonly" );if (f2fs_sb_has_compression (sbi)) - len +=scnprintf (buf + len,PAGE_SIZE - len,"%s%s" , + len +=sysfs_emit_at (buf, len,"%s%s" , len ?", " :"" ,"compression" ); - len +=scnprintf (buf + len,PAGE_SIZE - len,"%s%s" , + len +=sysfs_emit_at (buf, len,"%s%s" , len ?", " :"" ,"pin_file" ); - len +=scnprintf (buf + len,PAGE_SIZE - len,"\n" ); + len +=sysfs_emit_at (buf, len,"\n" );return len; }
@@ -329,17 +329,14 @@ static ssize_t f2fs_sbi_show(struct f2fs_attr *a,int hot_count = sbi->raw_super->hot_ext_count;int len =0 , i; - len +=scnprintf (buf + len,PAGE_SIZE - len, -"cold file extension:\n" ); + len +=sysfs_emit_at (buf, len,"cold file extension:\n" );for (i =0 ; i < cold_count; i++) - len +=scnprintf (buf + len,PAGE_SIZE - len,"%s\n" , - extlist[i]); + len +=sysfs_emit_at (buf, len,"%s\n" , extlist[i]); - len +=scnprintf (buf + len,PAGE_SIZE - len, -"hot file extension:\n" ); + len +=sysfs_emit_at (buf, len,"hot file extension:\n" );for (i = cold_count; i < cold_count + hot_count; i++) - len +=scnprintf (buf + len,PAGE_SIZE - len,"%s\n" , - extlist[i]); + len +=sysfs_emit_at (buf, len,"%s\n" , extlist[i]); +return len; }
Signature · 1 line
2.40.1
This patch was applied to jaegeuk/f2fs.git (dev) by Jaegeuk Kim <[email protected]>:
Hello:
This patch was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <[email protected]>:
Quoted 8 lines · On Thu, 15 Aug 2024 08:47:28 +0800 you wrote:
From: Christophe JAILLET <[email protected]>
This file already uses
sysfs_emit(). So be consistent and also usesysfs_emit_at().This slightly simplifies the code and makes it more readable.
[...]
Here is the summary with links:
- [f2fs-dev,RESEND] f2fs: Use sysfs_emit_at() to simplify code
https://git.kernel.org/jaegeuk/f2fs/c/f7a678bbe5a8
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html