* [PATCH] f2fs: replace snprintf in show functions with sysfs_emit
@ 2021-10-13 3:29 Qing Wang
2021-10-13 14:18 ` Chao Yu
0 siblings, 1 reply; 2+ messages in thread
From: Qing Wang @ 2021-10-13 3:29 UTC (permalink / raw)
To: Jaegeuk Kim, Chao Yu, linux-f2fs-devel, linux-kernel; +Cc: Qing Wang
coccicheck complains about the use of snprintf() in sysfs show functions.
Fix the following coccicheck warning:
fs/f2fs/sysfs.c:198:12-20: WARNING: use scnprintf or sprintf.
fs/f2fs/sysfs.c:247:8-16: WARNING: use scnprintf or sprintf.
Use sysfs_emit instead of scnprintf or sprintf makes more sense.
Signed-off-by: Qing Wang <wangqing@vivo.com>
---
fs/f2fs/sysfs.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
index 6642246..4ec3661 100644
--- a/fs/f2fs/sysfs.c
+++ b/fs/f2fs/sysfs.c
@@ -195,7 +195,7 @@ static ssize_t encoding_show(struct f2fs_attr *a,
struct super_block *sb = sbi->sb;
if (f2fs_sb_has_casefold(sbi))
- return snprintf(buf, PAGE_SIZE, "%s (%d.%d.%d)\n",
+ return sysfs_emit(buf, "%s (%d.%d.%d)\n",
sb->s_encoding->charset,
(sb->s_encoding->version >> 16) & 0xff,
(sb->s_encoding->version >> 8) & 0xff,
@@ -244,7 +244,7 @@ static ssize_t avg_vblocks_show(struct f2fs_attr *a,
static ssize_t main_blkaddr_show(struct f2fs_attr *a,
struct f2fs_sb_info *sbi, char *buf)
{
- return snprintf(buf, PAGE_SIZE, "%llu\n",
+ return sysfs_emit(buf, "%llu\n",
(unsigned long long)MAIN_BLKADDR(sbi));
}
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] f2fs: replace snprintf in show functions with sysfs_emit
2021-10-13 3:29 [PATCH] f2fs: replace snprintf in show functions with sysfs_emit Qing Wang
@ 2021-10-13 14:18 ` Chao Yu
0 siblings, 0 replies; 2+ messages in thread
From: Chao Yu @ 2021-10-13 14:18 UTC (permalink / raw)
To: Qing Wang, Jaegeuk Kim, linux-f2fs-devel, linux-kernel
On 2021/10/13 11:29, Qing Wang wrote:
> coccicheck complains about the use of snprintf() in sysfs show functions.
>
> Fix the following coccicheck warning:
> fs/f2fs/sysfs.c:198:12-20: WARNING: use scnprintf or sprintf.
> fs/f2fs/sysfs.c:247:8-16: WARNING: use scnprintf or sprintf.
>
> Use sysfs_emit instead of scnprintf or sprintf makes more sense.
>
> Signed-off-by: Qing Wang <wangqing@vivo.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Thanks,
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-10-13 14:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-13 3:29 [PATCH] f2fs: replace snprintf in show functions with sysfs_emit Qing Wang
2021-10-13 14:18 ` Chao Yu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).