netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ptp: ocp: Fix the wrong format specifier
@ 2024-11-20  6:26 zhangjiao2
  2024-11-20 13:05 ` Vadim Fedorenko
  2024-11-21  8:28 ` Paolo Abeni
  0 siblings, 2 replies; 3+ messages in thread
From: zhangjiao2 @ 2024-11-20  6:26 UTC (permalink / raw)
  To: jonathan.lemon
  Cc: vadim.fedorenko, richardcochran, netdev, linux-kernel, zhang jiao

From: zhang jiao <zhangjiao2@cmss.chinamobile.com>

Use '%u' instead of '%d' for unsigned int.

Signed-off-by: zhang jiao <zhangjiao2@cmss.chinamobile.com>
---
 drivers/ptp/ptp_ocp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
index 5feecaadde8e..52e46fee8e5e 100644
--- a/drivers/ptp/ptp_ocp.c
+++ b/drivers/ptp/ptp_ocp.c
@@ -1455,7 +1455,7 @@ ptp_ocp_verify(struct ptp_clock_info *ptp_info, unsigned pin,
 		 * channels 1..4 are the frequency generators.
 		 */
 		if (chan)
-			snprintf(buf, sizeof(buf), "OUT: GEN%d", chan);
+			snprintf(buf, sizeof(buf), "OUT: GEN%u", chan);
 		else
 			snprintf(buf, sizeof(buf), "OUT: PHC");
 		break;
-- 
2.33.0




^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ptp: ocp: Fix the wrong format specifier
  2024-11-20  6:26 [PATCH] ptp: ocp: Fix the wrong format specifier zhangjiao2
@ 2024-11-20 13:05 ` Vadim Fedorenko
  2024-11-21  8:28 ` Paolo Abeni
  1 sibling, 0 replies; 3+ messages in thread
From: Vadim Fedorenko @ 2024-11-20 13:05 UTC (permalink / raw)
  To: zhangjiao2, jonathan.lemon; +Cc: richardcochran, netdev, linux-kernel

On 19/11/2024 22:26, zhangjiao2 wrote:
> From: zhang jiao <zhangjiao2@cmss.chinamobile.com>
> 
> Use '%u' instead of '%d' for unsigned int.
> 
> Signed-off-by: zhang jiao <zhangjiao2@cmss.chinamobile.com>

This is net-next material, but the merge window has started and
therefore net-next is closed, please repost in 2 weeks.

> ---
>   drivers/ptp/ptp_ocp.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
> index 5feecaadde8e..52e46fee8e5e 100644
> --- a/drivers/ptp/ptp_ocp.c
> +++ b/drivers/ptp/ptp_ocp.c
> @@ -1455,7 +1455,7 @@ ptp_ocp_verify(struct ptp_clock_info *ptp_info, unsigned pin,
>   		 * channels 1..4 are the frequency generators.
>   		 */
>   		if (chan)
> -			snprintf(buf, sizeof(buf), "OUT: GEN%d", chan);
> +			snprintf(buf, sizeof(buf), "OUT: GEN%u", chan);
>   		else
>   			snprintf(buf, sizeof(buf), "OUT: PHC");
>   		break;


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ptp: ocp: Fix the wrong format specifier
  2024-11-20  6:26 [PATCH] ptp: ocp: Fix the wrong format specifier zhangjiao2
  2024-11-20 13:05 ` Vadim Fedorenko
@ 2024-11-21  8:28 ` Paolo Abeni
  1 sibling, 0 replies; 3+ messages in thread
From: Paolo Abeni @ 2024-11-21  8:28 UTC (permalink / raw)
  To: zhangjiao2, jonathan.lemon
  Cc: vadim.fedorenko, richardcochran, netdev, linux-kernel



On 11/20/24 07:26, zhangjiao2 wrote:
> From: zhang jiao <zhangjiao2@cmss.chinamobile.com>
> 
> Use '%u' instead of '%d' for unsigned int.
> 
> Signed-off-by: zhang jiao <zhangjiao2@cmss.chinamobile.com>
> ---
>  drivers/ptp/ptp_ocp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
> index 5feecaadde8e..52e46fee8e5e 100644
> --- a/drivers/ptp/ptp_ocp.c
> +++ b/drivers/ptp/ptp_ocp.c
> @@ -1455,7 +1455,7 @@ ptp_ocp_verify(struct ptp_clock_info *ptp_info, unsigned pin,
>  		 * channels 1..4 are the frequency generators.
>  		 */
>  		if (chan)
> -			snprintf(buf, sizeof(buf), "OUT: GEN%d", chan);
> +			snprintf(buf, sizeof(buf), "OUT: GEN%u", chan);

Note that the above would still cause a warning, as the formatted string
could be theoretically truncated:

../drivers/ptp/ptp_ocp.c:1458:61: warning: ‘%u’ directive output may be
truncated writing between 1 and 10 bytes into a region of size 8
[-Wformat-truncation=]
                         snprintf(buf, sizeof(buf), "OUT: GEN%u", chan);

Since 'chan' range is [1,4] you can probably safely cast it an unsigned
byte, and update the format string accordingly.

/P


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-11-21  8:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-20  6:26 [PATCH] ptp: ocp: Fix the wrong format specifier zhangjiao2
2024-11-20 13:05 ` Vadim Fedorenko
2024-11-21  8:28 ` Paolo Abeni

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).