From: Dan Carpenter <dan.carpenter@oracle.com>
To: Jonathan Lemon <jonathan.lemon@gmail.com>
Cc: Jonathan Lemon <jonathan.lemon@gmail.com>,
netdev@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [PATCH v2 net-next] ptp: ocp: use snprintf() in ptp_ocp_verify()
Date: Fri, 18 Mar 2022 10:47:23 +0300 [thread overview]
Message-ID: <20220318074723.GA6617@kili> (raw)
This code is fine, but it's easier to review if we use snprintf()
instead of sprintf().
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
v2: re-spin the patch based on the latest tree. It turns out that the
code is not buggy so don't make the buffer larger and don't add a Fixes
tag.
drivers/ptp/ptp_ocp.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
index d64a1ce5f5bc..c3d0fcf609e3 100644
--- a/drivers/ptp/ptp_ocp.c
+++ b/drivers/ptp/ptp_ocp.c
@@ -972,7 +972,7 @@ ptp_ocp_verify(struct ptp_clock_info *ptp_info, unsigned pin,
switch (func) {
case PTP_PF_NONE:
- sprintf(buf, "IN: None");
+ snprintf(buf, sizeof(buf), "IN: None");
break;
case PTP_PF_EXTTS:
/* Allow timestamps, but require sysfs configuration. */
@@ -982,9 +982,9 @@ ptp_ocp_verify(struct ptp_clock_info *ptp_info, unsigned pin,
* channels 1..4 are the frequency generators.
*/
if (chan)
- sprintf(buf, "OUT: GEN%d", chan);
+ snprintf(buf, sizeof(buf), "OUT: GEN%d", chan);
else
- sprintf(buf, "OUT: PHC");
+ snprintf(buf, sizeof(buf), "OUT: PHC");
break;
default:
return -EOPNOTSUPP;
--
2.20.1
next reply other threads:[~2022-03-18 7:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-18 7:47 Dan Carpenter [this message]
2022-03-18 16:33 ` [PATCH v2 net-next] ptp: ocp: use snprintf() in ptp_ocp_verify() Jonathan Lemon
2022-03-19 4:50 ` patchwork-bot+netdevbpf
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=20220318074723.GA6617@kili \
--to=dan.carpenter@oracle.com \
--cc=jonathan.lemon@gmail.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/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).