diff mbox series

[v2,net-next] ptp: ocp: use snprintf() in ptp_ocp_verify()

Message ID 20220318074723.GA6617@kili (mailing list archive)
State Accepted
Commit d5f497b889794161facc1522d86720b587d1c0b7
Delegated to: Netdev Maintainers
Headers show
Series [v2,net-next] ptp: ocp: use snprintf() in ptp_ocp_verify() | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 1 maintainers not CCed: richardcochran@gmail.com
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 19 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Dan Carpenter March 18, 2022, 7:47 a.m. UTC
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(-)

Comments

Jonathan Lemon March 18, 2022, 4:33 p.m. UTC | #1
On Fri, Mar 18, 2022 at 10:47:23AM +0300, Dan Carpenter wrote:
> 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>
Acked-by: Jonathan Lemon <jonathan.lemon@gmail.com>
patchwork-bot+netdevbpf@kernel.org March 19, 2022, 4:50 a.m. UTC | #2
Hello:

This patch was applied to netdev/net-next.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Fri, 18 Mar 2022 10:47:23 +0300 you wrote:
> 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.
> 
> [...]

Here is the summary with links:
  - [v2,net-next] ptp: ocp: use snprintf() in ptp_ocp_verify()
    https://git.kernel.org/netdev/net-next/c/d5f497b88979

You are awesome, thank you!
diff mbox series

Patch

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;