From: Johan Hovold <johan@kernel.org>
To: cgel.zte@gmail.com
Cc: andrew@aj.id.au, fancer.lancer@gmail.com,
gregkh@linuxfoundation.org, jirislaby@kernel.org,
joe@perches.com, linux-kernel@vger.kernel.org,
linux-serial@vger.kernel.org, macro@orcam.me.uk, pali@kernel.org,
yao.jing2@zte.com.cn, zealci@zte.com.cn
Subject: Re: [PATCH v3] serial: 8250: replace snprintf in show functions with sysfs_emit
Date: Mon, 8 Nov 2021 10:54:15 +0100 [thread overview]
Message-ID: <YYjzxzJAqVen8z+7@hovoldconsulting.com> (raw)
In-Reply-To: <20211104114754.30983-1-yao.jing2@zte.com.cn>
On Thu, Nov 04, 2021 at 11:47:54AM +0000, cgel.zte@gmail.com wrote:
> From: Jing Yao <yao.jing2@zte.com.cn>
>
> coccicheck complains about the use of snprintf() in sysfs show
> functions:
> WARNING use scnprintf or sprintf
>
> Use sysfs_emit instead of scnprintf or sprintf makes more sense.
>
> Reported-by: Zeal Robot <zealci@zte.com.cn>
> Signed-off-by: Jing Yao <yao.jing2@zte.com.cn>
> ---
>
> Changes since v1 & v2:
> - Remove excess and wrong parameter 'PAGE_SIZE' in sysfs_emit function.
> - Revise the wrong patch Subject.
Looks like there are a few more cases in
drivers/tty/serial/8250/8250_aspeed_vuart.c
which you could convert in a follow up patch.
> drivers/tty/serial/8250/8250_port.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
> index 5775cbff8f6e..3d58f383152e 100644
> --- a/drivers/tty/serial/8250/8250_port.c
> +++ b/drivers/tty/serial/8250/8250_port.c
> @@ -3099,7 +3099,7 @@ static ssize_t rx_trig_bytes_show(struct device *dev,
> if (rxtrig_bytes < 0)
> return rxtrig_bytes;
>
> - return snprintf(buf, PAGE_SIZE, "%d\n", rxtrig_bytes);
> + return sysfs_emit(buf, "%d\n", rxtrig_bytes);
> }
>
> static int do_set_rxtrig(struct tty_port *port, unsigned char bytes)
This one looks good as is now:
Reviewed-by: Johan Hovold <johan@kernel.org>
Johan
prev parent reply other threads:[~2021-11-08 9:54 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-28 10:13 [PATCH] drivers: tty: replace snprintf in show functions with sysfs_emit cgel.zte
2021-10-28 12:22 ` Johan Hovold
2021-10-28 12:49 ` Maciej W. Rozycki
2021-10-28 20:57 ` kernel test robot
2021-10-28 23:49 ` kernel test robot
2021-10-29 5:44 ` Greg KH
2021-10-31 15:34 ` Joe Perches
2021-11-02 6:52 ` [PATCH v2] " cgel.zte
2021-11-02 7:44 ` Johan Hovold
2021-11-04 11:47 ` [PATCH v3] serial: 8250: " cgel.zte
2021-11-08 9:54 ` Johan Hovold [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=YYjzxzJAqVen8z+7@hovoldconsulting.com \
--to=johan@kernel.org \
--cc=andrew@aj.id.au \
--cc=cgel.zte@gmail.com \
--cc=fancer.lancer@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=jirislaby@kernel.org \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=macro@orcam.me.uk \
--cc=pali@kernel.org \
--cc=yao.jing2@zte.com.cn \
--cc=zealci@zte.com.cn \
/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).