lkml.org 
[lkml]   [2021]   [Oct]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] xfs: replace snprintf in show functions with sysfs_emit
From
Date
On Tue, 2021-10-12 at 20:29 -0700, Qing Wang wrote:
> coccicheck complains about the use of snprintf() in sysfs show functions.
>
> Fix the coccicheck warning:
> WARNING: use scnprintf or sprintf.
>
> Use sysfs_emit instead of scnprintf or sprintf makes more sense.
[]
> diff --git a/fs/xfs/xfs_sysfs.c b/fs/xfs/xfs_sysfs.c
[]
> @@ -104,7 +104,7 @@ bug_on_assert_show(
>   struct kobject *kobject,
>   char *buf)
>  {
> - return snprintf(buf, PAGE_SIZE, "%d\n", xfs_globals.bug_on_assert ? 1 : 0);
> + return sysfs_emit(buf, "%d\n", xfs_globals.bug_on_assert ? 1 : 0);

trivia:

The ?: is not necessary as xfs_globals.bug_on_assert is a bool
and would have an implicit cast done.

return sysfs_emit(buf, "%d\n", xfs_globals.bug_on_assert);


\
 
 \ /
  Last update: 2021-10-14 18:52    [W:0.067 / U:0.084 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site