From: Nikolay Aleksandrov <razor@blackwall.org>
To: David Corvaglia <david@corvaglia.dev>, idosch@nvidia.com
Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, horms@kernel.org, bridge@lists.linux.dev,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next] net: bridge: use sysfs_emit instead of sprintf
Date: Sun, 1 Feb 2026 10:29:14 +0200 [thread overview]
Message-ID: <076bd8aa-e06c-4b0f-a659-d35de0319b55@blackwall.org> (raw)
In-Reply-To: <0100019c14f90490-950ddd9b-1897-4111-bddd-0d4b8abf380a-000000@email.amazonses.com>
On 31/01/2026 18:53, David Corvaglia wrote:
> Replace sprintf with sysfs_emit in sysfs show() methods as outlined in
> Documentation/filesystems/sysfs.rst. sysfs_emit is preferred to sprintf
> in sysfs show() methods as it is safer with buffer handling.
>
> Signed-off-by: David Corvaglia <david@corvaglia.dev>
> ---
> This is my first patch to the kernel! I've been able to build and boot
> with the patch. I also tested the sysfs reads and they seem to be
> correct. Any feedback is appreciated.
>
> net/bridge/br_stp_if.c | 2 +-
> net/bridge/br_sysfs_br.c | 84 ++++++++++++++++++++--------------------
> net/bridge/br_sysfs_if.c | 32 +++++++--------
> 3 files changed, 59 insertions(+), 59 deletions(-)
>
Hi,
IIUC it is safer because it takes into account the provided buffer's size (PAGE_SIZE).
I'm saying it for the curious as I only found in Documentation/filesystems/sysfs.rst:
"- New implementations of show() methods should only use sysfs_emit() or
sysfs_emit_at() when formatting the value to be returned to user space."
Which does say "new implementations", also most of these are numbers
and cannot really fill the provided buffer, there is one instance of a string
but it is an interface name, so that is limited as well.
That being said, I'm ok with switching to sysfs_emit() and the patch looks good
to me so:
Acked-by: Nikolay Aleksandrov <razor@blackwall.org>
Thanks,
Nik
next prev parent reply other threads:[~2026-02-01 8:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-31 16:53 [PATCH net-next] net: bridge: use sysfs_emit instead of sprintf David Corvaglia
2026-02-01 8:29 ` Nikolay Aleksandrov [this message]
2026-02-01 15:19 ` Ido Schimmel
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=076bd8aa-e06c-4b0f-a659-d35de0319b55@blackwall.org \
--to=razor@blackwall.org \
--cc=bridge@lists.linux.dev \
--cc=davem@davemloft.net \
--cc=david@corvaglia.dev \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=idosch@nvidia.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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