LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Anand Jain <anand.jain@oracle.com>
Cc: Qing Wang <wangqing@vivo.com>, Chris Mason <clm@fb.com>,
Josef Bacik <josef@toxicpanda.com>,
David Sterba <dsterba@suse.com>,
linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] btrfs: replace snprintf in show functions with sysfs_emit
Date: Wed, 13 Oct 2021 12:36:42 +0200 [thread overview]
Message-ID: <20211013103642.GC9286@twin.jikos.cz> (raw)
In-Reply-To: <6f03e790-6f21-703f-c761-a034575f465e@oracle.com>
On Wed, Oct 13, 2021 at 03:51:33PM +0800, Anand Jain wrote:
> On 13/10/2021 11:28, Qing Wang wrote:
> > coccicheck complains about the use of snprintf() in sysfs show functions.
>
> It looks like the reason is snprintf() unaware of the PAGE_SIZE
> max_limit of the buf.
>
> > Fix the following coccicheck warning:
> > fs/btrfs/sysfs.c:335:8-16: WARNING: use scnprintf or sprintf.
>
> Hm. We use snprintf() at quite a lot more places in sysfs.c and, I don't
> see them getting this fix. Why?
I guess the patch is only addressing the warning for snprintf, reading
the sources would show how many more conversions could have been done of
scnprintf calls.
> > Use sysfs_emit instead of scnprintf or sprintf makes more sense.
>
> Below commit has added it. Nice.
>
> commit 2efc459d06f1630001e3984854848a5647086232
> Date: Wed Sep 16 13:40:38 2020 -0700
>
> sysfs: Add sysfs_emit and sysfs_emit_at to format sysfs out
The conversion to the standard helper is good, but should be done
in the entire file.
next prev parent reply other threads:[~2021-10-13 10:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-13 3:28 Qing Wang
2021-10-13 7:51 ` Anand Jain
2021-10-13 10:36 ` David Sterba [this message]
2021-10-13 10:49 ` Qu Wenruo
[not found] ` <ADsAzABEEmLRWHzgUOl4Sqr5.9.1634122164687.Hmail.wangqing@vivo.com>
2021-10-13 11:01 ` 回复: " 王擎
2021-10-13 11:08 ` Qu Wenruo
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=20211013103642.GC9286@twin.jikos.cz \
--to=dsterba@suse.cz \
--cc=anand.jain@oracle.com \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=josef@toxicpanda.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=wangqing@vivo.com \
--subject='Re: [PATCH] btrfs: replace snprintf in show functions with sysfs_emit' \
/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
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).