[PATCH 39/42] drivers/scsi/scsi_transport_sas: Convert snprintf to sysfs_emit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxx>
CC: "Martin K. Petersen" <martin.petersen@xxxxxxxxxx>
CC: linux-scsi@xxxxxxxxxxxxxxx
Signed-off-by: Li Zhijian <lizhijian@xxxxxxxxxxx>
---
 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





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux