[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <c8ee50d4bc36ff9d38e0ffe4cd8e28be0424918b.camel@perches.com>
Date: Thu, 14 Oct 2021 09:51:58 -0700
From: Joe Perches <joe@...ches.com>
To: Qing Wang <wangqing@...o.com>,
"Darrick J. Wong" <djwong@...nel.org>, linux-xfs@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] xfs: replace snprintf in show functions with sysfs_emit
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);
Powered by blists - more mailing lists