From: Joe Perches <joe@perches.com>
To: Qing Wang <wangqing@vivo.com>,
"Darrick J. Wong" <djwong@kernel.org>,
linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] xfs: replace snprintf in show functions with sysfs_emit
Date: Thu, 14 Oct 2021 09:51:58 -0700 [thread overview]
Message-ID: <c8ee50d4bc36ff9d38e0ffe4cd8e28be0424918b.camel@perches.com> (raw)
In-Reply-To: <1634095771-4671-1-git-send-email-wangqing@vivo.com>
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);
prev parent reply other threads:[~2021-10-14 16:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-13 3:29 [PATCH] xfs: replace snprintf in show functions with sysfs_emit Qing Wang
2021-10-14 16:37 ` Darrick J. Wong
2021-10-14 16:51 ` Joe Perches [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c8ee50d4bc36ff9d38e0ffe4cd8e28be0424918b.camel@perches.com \
--to=joe@perches.com \
--cc=djwong@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=wangqing@vivo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).