2022-01-27 07:20:00

by David Yang

[permalink] [raw]
Subject: [PATCH] ptp: replace snprintf with sysfs_emit

From: Yang Guang <[email protected]>

coccinelle report:
./drivers/ptp/ptp_sysfs.c:17:8-16:
WARNING: use scnprintf or sprintf
./drivers/ptp/ptp_sysfs.c:390:8-16:
WARNING: use scnprintf or sprintf

Use sysfs_emit instead of scnprintf or sprintf makes more sense.

Reported-by: Zeal Robot <[email protected]>
Signed-off-by: Yang Guang <[email protected]>
Signed-off-by: David Yang <[email protected]>
---
drivers/ptp/ptp_sysfs.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/ptp/ptp_sysfs.c b/drivers/ptp/ptp_sysfs.c
index 41b92dc2f011..9233bfedeb17 100644
--- a/drivers/ptp/ptp_sysfs.c
+++ b/drivers/ptp/ptp_sysfs.c
@@ -14,7 +14,7 @@ static ssize_t clock_name_show(struct device *dev,
struct device_attribute *attr, char *page)
{
struct ptp_clock *ptp = dev_get_drvdata(dev);
- return snprintf(page, PAGE_SIZE-1, "%s\n", ptp->info->name);
+ return sysfs_emit(page, "%s\n", ptp->info->name);
}
static DEVICE_ATTR_RO(clock_name);

@@ -387,7 +387,7 @@ static ssize_t ptp_pin_show(struct device *dev, struct device_attribute *attr,

mutex_unlock(&ptp->pincfg_mux);

- return snprintf(page, PAGE_SIZE, "%u %u\n", func, chan);
+ return sysfs_emit(page, "%u %u\n", func, chan);
}

static ssize_t ptp_pin_store(struct device *dev, struct device_attribute *attr,
--
2.30.2


2022-01-27 09:03:08

by Richard Cochran

[permalink] [raw]
Subject: Re: [PATCH] ptp: replace snprintf with sysfs_emit

On Thu, Jan 27, 2022 at 08:02:36AM +0800, [email protected] wrote:
> From: Yang Guang <[email protected]>
>
> coccinelle report:
> ./drivers/ptp/ptp_sysfs.c:17:8-16:
> WARNING: use scnprintf or sprintf
> ./drivers/ptp/ptp_sysfs.c:390:8-16:
> WARNING: use scnprintf or sprintf
>
> Use sysfs_emit instead of scnprintf or sprintf makes more sense.
>
> Reported-by: Zeal Robot <[email protected]>
> Signed-off-by: Yang Guang <[email protected]>
> Signed-off-by: David Yang <[email protected]>

Acked-by: Richard Cochran <[email protected]>

2022-01-28 04:57:53

by patchwork-bot+netdevbpf

[permalink] [raw]
Subject: Re: [PATCH] ptp: replace snprintf with sysfs_emit

Hello:

This patch was applied to netdev/net-next.git (master)
by David S. Miller <[email protected]>:

On Thu, 27 Jan 2022 08:02:36 +0800 you wrote:
> From: Yang Guang <[email protected]>
>
> coccinelle report:
> ./drivers/ptp/ptp_sysfs.c:17:8-16:
> WARNING: use scnprintf or sprintf
> ./drivers/ptp/ptp_sysfs.c:390:8-16:
> WARNING: use scnprintf or sprintf
>
> [...]

Here is the summary with links:
- ptp: replace snprintf with sysfs_emit
https://git.kernel.org/netdev/net-next/c/e2cf07654efb

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html