lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <202503261522574184L3W31Wv9IlTfjF1W9Eh8@zte.com.cn>
Date: Wed, 26 Mar 2025 15:22:57 +0800 (CST)
From: <xu.xin16@....com.cn>
To: <xie.ludan@....com.cn>, <davem@...emloft.net>, <horms@...nel.org>
Cc: <gerhard@...leder-embedded.com>, <edumazet@...gle.com>, <kuba@...nel.org>,
        <pabeni@...hat.com>, <horms@...nel.org>, <xie.ludan@....com.cn>,
        <netdev@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
        <yang.yang29@....com.cn>, <ye.xingchen@....com.cn>
Subject: Re: [PATCH linux-next v2] net: atm: use sysfs_emit()/sysfs_emit_at() instead of scnprintf().

>From: XieLudan <xie.ludan@....com.cn>
>
>Follow the advice in Documentation/filesystems/sysfs.rst:
>show() should only use sysfs_emit() or sysfs_emit_at() when formatting
>the value to be returned to user space.
>
>Signed-off-by: XieLudan <xie.ludan@....com.cn>
>---
>v2:
>    - adapting the alignment of argument lines
> net/atm/atm_sysfs.c | 24 +++++++++++-------------
> 1 file changed, 11 insertions(+), 13 deletions(-)
>
>diff --git a/net/atm/atm_sysfs.c b/net/atm/atm_sysfs.c
>index 54e7fb1a4ee5..726398fa848e 100644
>--- a/net/atm/atm_sysfs.c
>+++ b/net/atm/atm_sysfs.c
>@@ -16,7 +16,7 @@ static ssize_t type_show(struct device *cdev,
> {
> 	struct atm_dev *adev = to_atm_dev(cdev);
>
>-	return scnprintf(buf, PAGE_SIZE, "%s\n", adev->type);
>+	return sysfs_emit(buf, "%s\n", adev->type);
> }
>

Generally LGTM. Thanks.

Reviewed-by: xu xin <xu.xin16@....com.cn>

> static ssize_t address_show(struct device *cdev,
>@@ -24,7 +24,7 @@ static ssize_t address_show(struct device *cdev,
> {
> 	struct atm_dev *adev = to_atm_dev(cdev);
>
>-	return scnprintf(buf, PAGE_SIZE, "%pM\n", adev->esi);
>+	return sysfs_emit(buf, "%pM\n", adev->esi);
> }
>
> static ssize_t atmaddress_show(struct device *cdev,
>@@ -37,13 +37,12 @@ static ssize_t atmaddress_show(struct device *cdev,
>
> 	spin_lock_irqsave(&adev->lock, flags);
> 	list_for_each_entry(aaddr, &adev->local, entry) {
>-		count += scnprintf(buf + count, PAGE_SIZE - count,
>-				   "%1phN.%2phN.%10phN.%6phN.%1phN\n",
>-				   &aaddr->addr.sas_addr.prv[0],
>-				   &aaddr->addr.sas_addr.prv[1],
>-				   &aaddr->addr.sas_addr.prv[3],
>-				   &aaddr->addr.sas_addr.prv[13],
>-				   &aaddr->addr.sas_addr.prv[19]);
>+		count += sysfs_emit_at(buf, count, "%1phN.%2phN.%10phN.%6phN.%1phN\n",
>+				       &aaddr->addr.sas_addr.prv[0],
>+				       &aaddr->addr.sas_addr.prv[1],
>+				       &aaddr->addr.sas_addr.prv[3],
>+				       &aaddr->addr.sas_addr.prv[13],
>+				       &aaddr->addr.sas_addr.prv[19]);
> 	}
> 	spin_unlock_irqrestore(&adev->lock, flags);
>
>@@ -55,7 +54,7 @@ static ssize_t atmindex_show(struct device *cdev,
> {
> 	struct atm_dev *adev = to_atm_dev(cdev);
>
>-	return scnprintf(buf, PAGE_SIZE, "%d\n", adev->number);
>+	return sysfs_emit(buf, "%d\n", adev->number);
> }
>
> static ssize_t carrier_show(struct device *cdev,
>@@ -63,8 +62,7 @@ static ssize_t carrier_show(struct device *cdev,
> {
> 	struct atm_dev *adev = to_atm_dev(cdev);
>
>-	return scnprintf(buf, PAGE_SIZE, "%d\n",
>-			 adev->signal == ATM_PHY_SIG_LOST ? 0 : 1);
>+	return sysfs_emit(buf, "%d\n", adev->signal == ATM_PHY_SIG_LOST ? 0 : 1);
> }
>
> static ssize_t link_rate_show(struct device *cdev,
>@@ -87,7 +85,7 @@ static ssize_t link_rate_show(struct device *cdev,
> 	default:
> 		link_rate = adev->link_rate * 8 * 53;
> 	}
>-	return scnprintf(buf, PAGE_SIZE, "%d\n", link_rate);
>+	return sysfs_emit(buf, "%d\n", link_rate);
> }
>
> static DEVICE_ATTR_RO(address);
>-- 
>2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ