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: <20240116045151.3940401-37-lizhijian@fujitsu.com>
Date: Tue, 16 Jan 2024 12:51:48 +0800
From: Li Zhijian <lizhijian@...itsu.com>
To: linux-kernel@...r.kernel.org
Cc: Li Zhijian <lizhijian@...itsu.com>,
	"James E.J. Bottomley" <jejb@...ux.ibm.com>,
	"Martin K. Petersen" <martin.petersen@...cle.com>,
	linux-scsi@...r.kernel.org
Subject: [PATCH 39/42] drivers/scsi/scsi_transport_sas: Convert snprintf to sysfs_emit

Per filesystems/sysfs.rst, show() should only use sysfs_emit()
or sysfs_emit_at() when formatting the value to be returned to user space.

coccinelle complains that there are still a couple of functions that use
snprintf(). Convert them to sysfs_emit().

> ./drivers/scsi/scsi_transport_sas.c:1180:9-17: WARNING: please use sysfs_emit
> ./drivers/scsi/scsi_transport_sas.c:525:9-17: WARNING: please use sysfs_emit
> ./drivers/scsi/scsi_transport_sas.c:572:8-16: WARNING: please use sysfs_emit

No functional change intended

CC: "James E.J. Bottomley" <jejb@...ux.ibm.com>
CC: "Martin K. Petersen" <martin.petersen@...cle.com>
CC: linux-scsi@...r.kernel.org
Signed-off-by: Li Zhijian <lizhijian@...itsu.com>
---
 drivers/scsi/scsi_transport_sas.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/scsi/scsi_transport_sas.c b/drivers/scsi/scsi_transport_sas.c
index d704c484a251..f679034e1048 100644
--- a/drivers/scsi/scsi_transport_sas.c
+++ b/drivers/scsi/scsi_transport_sas.c
@@ -427,7 +427,7 @@ show_sas_phy_##name(struct device *dev, 				\
 {									\
 	struct sas_phy *phy = transport_class_to_phy(dev);		\
 									\
-	return snprintf(buf, 20, format_string, cast phy->field);	\
+	return sysfs_emit(buf, format_string, cast phy->field);	\
 }
 
 #define sas_phy_simple_attr(field, name, format_string, type)		\
@@ -442,7 +442,7 @@ show_sas_phy_##name(struct device *dev, 				\
 	struct sas_phy *phy = transport_class_to_phy(dev);		\
 									\
 	if (!phy->field)						\
-		return snprintf(buf, 20, "none\n");			\
+		return sysfs_emit(buf, "none\n");			\
 	return get_sas_protocol_names(phy->field, buf);		\
 }
 
@@ -507,7 +507,7 @@ show_sas_phy_##field(struct device *dev, 				\
 	error = i->f->get_linkerrors ? i->f->get_linkerrors(phy) : 0;	\
 	if (error)							\
 		return error;						\
-	return snprintf(buf, 20, "%u\n", phy->field);			\
+	return sysfs_emit(buf, "%u\n", phy->field);			\
 }
 
 #define sas_phy_linkerror_attr(field)					\
@@ -522,7 +522,7 @@ show_sas_device_type(struct device *dev,
 	struct sas_phy *phy = transport_class_to_phy(dev);
 
 	if (!phy->identify.device_type)
-		return snprintf(buf, 20, "none\n");
+		return sysfs_emit(buf, "none\n");
 	return get_sas_device_type_names(phy->identify.device_type, buf);
 }
 static DEVICE_ATTR(device_type, S_IRUGO, show_sas_device_type, NULL);
@@ -569,7 +569,7 @@ show_sas_phy_enable(struct device *dev, struct device_attribute *attr,
 {
 	struct sas_phy *phy = transport_class_to_phy(dev);
 
-	return snprintf(buf, 20, "%d\n", phy->enabled);
+	return sysfs_emit(buf, "%d\n", phy->enabled);
 }
 
 static DEVICE_ATTR(enable, S_IRUGO | S_IWUSR, show_sas_phy_enable,
@@ -798,7 +798,7 @@ show_sas_port_##name(struct device *dev, 				\
 {									\
 	struct sas_port *port = transport_class_to_sas_port(dev);	\
 									\
-	return snprintf(buf, 20, format_string, cast port->field);	\
+	return sysfs_emit(buf, format_string, cast port->field);	\
 }
 
 #define sas_port_simple_attr(field, name, format_string, type)		\
@@ -1145,7 +1145,7 @@ show_sas_rphy_##name(struct device *dev, 				\
 {									\
 	struct sas_rphy *rphy = transport_class_to_rphy(dev);		\
 									\
-	return snprintf(buf, 20, format_string, cast rphy->field);	\
+	return sysfs_emit(buf, format_string, cast rphy->field);	\
 }
 
 #define sas_rphy_simple_attr(field, name, format_string, type)		\
@@ -1161,7 +1161,7 @@ show_sas_rphy_##name(struct device *dev, 				\
 	struct sas_rphy *rphy = transport_class_to_rphy(dev);		\
 									\
 	if (!rphy->field)					\
-		return snprintf(buf, 20, "none\n");			\
+		return sysfs_emit(buf, "none\n");			\
 	return get_sas_protocol_names(rphy->field, buf);	\
 }
 
@@ -1177,7 +1177,7 @@ show_sas_rphy_device_type(struct device *dev,
 	struct sas_rphy *rphy = transport_class_to_rphy(dev);
 
 	if (!rphy->identify.device_type)
-		return snprintf(buf, 20, "none\n");
+		return sysfs_emit(buf, "none\n");
 	return get_sas_device_type_names(
 			rphy->identify.device_type, buf);
 }
@@ -1280,7 +1280,7 @@ show_sas_end_dev_##name(struct device *dev, 				\
 	struct sas_rphy *rphy = transport_class_to_rphy(dev);		\
 	struct sas_end_device *rdev = rphy_to_end_device(rphy);		\
 									\
-	return snprintf(buf, 20, format_string, cast rdev->field);	\
+	return sysfs_emit(buf, format_string, cast rdev->field);	\
 }
 
 #define sas_end_dev_simple_attr(field, name, format_string, type)	\
@@ -1309,7 +1309,7 @@ show_sas_expander_##name(struct device *dev, 				\
 	struct sas_rphy *rphy = transport_class_to_rphy(dev);		\
 	struct sas_expander_device *edev = rphy_to_expander_device(rphy); \
 									\
-	return snprintf(buf, 20, format_string, cast edev->field);	\
+	return sysfs_emit(buf, format_string, cast edev->field);	\
 }
 
 #define sas_expander_simple_attr(field, name, format_string, type)	\
-- 
2.29.2


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ