linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: ipa: use sysfs_emit() to instead of scnprintf()
@ 2022-12-02  8:42 ye.xingchen
  2022-12-02 22:20 ` Alex Elder
  0 siblings, 1 reply; 3+ messages in thread
From: ye.xingchen @ 2022-12-02  8:42 UTC (permalink / raw)
  To: davem; +Cc: elder, edumazet, kuba, pabeni, netdev, linux-kernel

From: ye xingchen <ye.xingchen@zte.com.cn>

Follow the advice of the Documentation/filesystems/sysfs.rst and show()
should only use sysfs_emit() or sysfs_emit_at() when formatting the
value to be returned to user space.

Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
---
 drivers/net/ipa/ipa_sysfs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ipa/ipa_sysfs.c b/drivers/net/ipa/ipa_sysfs.c
index 5cbc15a971f9..14bd2f903045 100644
--- a/drivers/net/ipa/ipa_sysfs.c
+++ b/drivers/net/ipa/ipa_sysfs.c
@@ -46,7 +46,7 @@ version_show(struct device *dev, struct device_attribute *attr, char *buf)
 {
 	struct ipa *ipa = dev_get_drvdata(dev);

-	return scnprintf(buf, PAGE_SIZE, "%s\n", ipa_version_string(ipa));
+	return sysfs_emit(buf, "%s\n", ipa_version_string(ipa));
 }

 static DEVICE_ATTR_RO(version);
@@ -70,7 +70,7 @@ static ssize_t rx_offload_show(struct device *dev,
 {
 	struct ipa *ipa = dev_get_drvdata(dev);

-	return scnprintf(buf, PAGE_SIZE, "%s\n", ipa_offload_string(ipa));
+	return sysfs_emit(buf, "%s\n", ipa_offload_string(ipa));
 }

 static DEVICE_ATTR_RO(rx_offload);
@@ -80,7 +80,7 @@ static ssize_t tx_offload_show(struct device *dev,
 {
 	struct ipa *ipa = dev_get_drvdata(dev);

-	return scnprintf(buf, PAGE_SIZE, "%s\n", ipa_offload_string(ipa));
+	return sysfs_emit(buf, "%s\n", ipa_offload_string(ipa));
 }

 static DEVICE_ATTR_RO(tx_offload);
-- 
2.25.1

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

* Re: [PATCH] net: ipa: use sysfs_emit() to instead of scnprintf()
  2022-12-02  8:42 [PATCH] net: ipa: use sysfs_emit() to instead of scnprintf() ye.xingchen
@ 2022-12-02 22:20 ` Alex Elder
  2022-12-07  2:53   ` Jakub Kicinski
  0 siblings, 1 reply; 3+ messages in thread
From: Alex Elder @ 2022-12-02 22:20 UTC (permalink / raw)
  To: ye.xingchen, davem; +Cc: elder, edumazet, kuba, pabeni, netdev, linux-kernel

On 12/2/22 2:42 AM, ye.xingchen@zte.com.cn wrote:
> From: ye xingchen <ye.xingchen@zte.com.cn>
> 
> Follow the advice of the Documentation/filesystems/sysfs.rst and show()
> should only use sysfs_emit() or sysfs_emit_at() when formatting the
> value to be returned to user space.

The buffer passed is non-null and the existing code properly
limits the buffer to PAGE_SIZE.

But... OK.

Reviewed-by: Alex Elder <elder@linaro.org>

> 
> Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
> ---
>   drivers/net/ipa/ipa_sysfs.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/ipa/ipa_sysfs.c b/drivers/net/ipa/ipa_sysfs.c
> index 5cbc15a971f9..14bd2f903045 100644
> --- a/drivers/net/ipa/ipa_sysfs.c
> +++ b/drivers/net/ipa/ipa_sysfs.c
> @@ -46,7 +46,7 @@ version_show(struct device *dev, struct device_attribute *attr, char *buf)
>   {
>   	struct ipa *ipa = dev_get_drvdata(dev);
> 
> -	return scnprintf(buf, PAGE_SIZE, "%s\n", ipa_version_string(ipa));
> +	return sysfs_emit(buf, "%s\n", ipa_version_string(ipa));
>   }
> 
>   static DEVICE_ATTR_RO(version);
> @@ -70,7 +70,7 @@ static ssize_t rx_offload_show(struct device *dev,
>   {
>   	struct ipa *ipa = dev_get_drvdata(dev);
> 
> -	return scnprintf(buf, PAGE_SIZE, "%s\n", ipa_offload_string(ipa));
> +	return sysfs_emit(buf, "%s\n", ipa_offload_string(ipa));
>   }
> 
>   static DEVICE_ATTR_RO(rx_offload);
> @@ -80,7 +80,7 @@ static ssize_t tx_offload_show(struct device *dev,
>   {
>   	struct ipa *ipa = dev_get_drvdata(dev);
> 
> -	return scnprintf(buf, PAGE_SIZE, "%s\n", ipa_offload_string(ipa));
> +	return sysfs_emit(buf, "%s\n", ipa_offload_string(ipa));
>   }
> 
>   static DEVICE_ATTR_RO(tx_offload);


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

* Re: [PATCH] net: ipa: use sysfs_emit() to instead of scnprintf()
  2022-12-02 22:20 ` Alex Elder
@ 2022-12-07  2:53   ` Jakub Kicinski
  0 siblings, 0 replies; 3+ messages in thread
From: Jakub Kicinski @ 2022-12-07  2:53 UTC (permalink / raw)
  To: Alex Elder
  Cc: ye.xingchen, davem, elder, edumazet, pabeni, netdev, linux-kernel

On Fri, 2 Dec 2022 16:20:16 -0600 Alex Elder wrote:
> On 12/2/22 2:42 AM, ye.xingchen@zte.com.cn wrote:
> > From: ye xingchen <ye.xingchen@zte.com.cn>
> > 
> > Follow the advice of the Documentation/filesystems/sysfs.rst and show()
> > should only use sysfs_emit() or sysfs_emit_at() when formatting the
> > value to be returned to user space.  
> 
> The buffer passed is non-null and the existing code properly
> limits the buffer to PAGE_SIZE.
> 
> But... OK.
> 
> Reviewed-by: Alex Elder <elder@linaro.org>
> 

Thanks! 38db82e2940 in net-next.

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

end of thread, other threads:[~2022-12-07  2:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-02  8:42 [PATCH] net: ipa: use sysfs_emit() to instead of scnprintf() ye.xingchen
2022-12-02 22:20 ` Alex Elder
2022-12-07  2:53   ` Jakub Kicinski

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