Skip to contentSkip to conversation

mei: bus: use simple sprintf for sysfs

char-misc-next Tomas Winkler 2 participants 4 messages Nov 26, 2019 – Jan 9, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Replace scnprintf with simple sprintf for sysfs files. it is implicitly known that the buffer is big enough for the variables to fit in.

---
 drivers/misc/mei/bus.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/misc/mei/bus.c +5 -5
index a0a495c95e3c..8d468e0a950a 100644
@@ -765,7 +765,7 @@ static ssize_t uuid_show(struct device *dev, struct device_attribute *a,
 	struct mei_cl_device *cldev = to_mei_cl_device(dev);
 	const uuid_le *uuid = mei_me_cl_uuid(cldev->me_cl);
 
-	return scnprintf(buf, PAGE_SIZE, "%pUl", uuid);
+	return sprintf(buf, "%pUl", uuid);
 }
 static DEVICE_ATTR_RO(uuid);
 
@@ -775,7 +775,7 @@ static ssize_t version_show(struct device *dev, struct device_attribute *a,
 	struct mei_cl_device *cldev = to_mei_cl_device(dev);
 	u8 version = mei_me_cl_ver(cldev->me_cl);
 
-	return scnprintf(buf, PAGE_SIZE, "%02X", version);
+	return sprintf(buf, "%02X", version);
 }
 static DEVICE_ATTR_RO(version);
 
@@ -797,7 +797,7 @@ static ssize_t max_conn_show(struct device *dev, struct device_attribute *a,
 	struct mei_cl_device *cldev = to_mei_cl_device(dev);
 	u8 maxconn = mei_me_cl_max_conn(cldev->me_cl);
 
-	return scnprintf(buf, PAGE_SIZE, "%d", maxconn);
+	return sprintf(buf, "%d", maxconn);
 }
 static DEVICE_ATTR_RO(max_conn);
 
@@ -807,7 +807,7 @@ static ssize_t fixed_show(struct device *dev, struct device_attribute *a,
 	struct mei_cl_device *cldev = to_mei_cl_device(dev);
 	u8 fixed = mei_me_cl_fixed(cldev->me_cl);
 
-	return scnprintf(buf, PAGE_SIZE, "%d", fixed);
+	return sprintf(buf, "%d", fixed);
 }
 static DEVICE_ATTR_RO(fixed);
 
@@ -817,7 +817,7 @@ static ssize_t max_len_show(struct device *dev, struct device_attribute *a,
 	struct mei_cl_device *cldev = to_mei_cl_device(dev);
 	u32 maxlen = mei_me_cl_max_len(cldev->me_cl);
 
-	return scnprintf(buf, PAGE_SIZE, "%u", maxlen);
+	return sprintf(buf, "%u", maxlen);
 }
 static DEVICE_ATTR_RO(max_len);
 
Signature · 1 line
2.21.0
#1 lore raw
Quoted 5 lines

Replace scnprintf with simple sprintf for sysfs files.
it is implicitly known that the buffer is big enough for the variables to fit in.

Hi Greg, hope you have great holiday, has anything changed in the misc-char dev process, no patches were staged including this one?
Thanks
Tomas

Quoted 60 lines
---
 drivers/misc/mei/bus.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/misc/mei/bus.c index renamed from drivers/misc/mei/bus.c +0 -0

a0a495c95e3c..8d468e0a950a 100644

drivers/misc/mei/bus.c +5 -6
@@ -765,7 +765,7 @@ static ssize_t uuid_show(struct device *dev, struct
 device_attribute *a,
 	struct mei_cl_device *cldev = to_mei_cl_device(dev);
 	const uuid_le *uuid = mei_me_cl_uuid(cldev->me_cl);
 
-	return scnprintf(buf, PAGE_SIZE, "%pUl", uuid);
+	return sprintf(buf, "%pUl", uuid);
 }
 static DEVICE_ATTR_RO(uuid);
@@ -775,7 +775,7 @@ static ssize_t version_show(struct device *dev, struct
 device_attribute *a,
 	struct mei_cl_device *cldev = to_mei_cl_device(dev);
 	u8 version = mei_me_cl_ver(cldev->me_cl);
 
-	return scnprintf(buf, PAGE_SIZE, "%02X", version);
+	return sprintf(buf, "%02X", version);
 }
 static DEVICE_ATTR_RO(version);
@@ -797,7 +797,7 @@ static ssize_t max_conn_show(struct device *dev,
 struct device_attribute *a,
 	struct mei_cl_device *cldev = to_mei_cl_device(dev);
 	u8 maxconn = mei_me_cl_max_conn(cldev->me_cl);
 
-	return scnprintf(buf, PAGE_SIZE, "%d", maxconn);
+	return sprintf(buf, "%d", maxconn);
 }
 static DEVICE_ATTR_RO(max_conn);
@@ -807,7 +807,7 @@ static ssize_t fixed_show(struct device *dev, struct
 device_attribute *a,
 	struct mei_cl_device *cldev = to_mei_cl_device(dev);
 	u8 fixed = mei_me_cl_fixed(cldev->me_cl);
 
-	return scnprintf(buf, PAGE_SIZE, "%d", fixed);
+	return sprintf(buf, "%d", fixed);
 }
 static DEVICE_ATTR_RO(fixed);
@@ -817,7 +817,7 @@ static ssize_t max_len_show(struct device *dev, struct
 device_attribute *a,
 	struct mei_cl_device *cldev = to_mei_cl_device(dev);
 	u32 maxlen = mei_me_cl_max_len(cldev->me_cl);
 
-	return scnprintf(buf, PAGE_SIZE, "%u", maxlen);
+	return sprintf(buf, "%u", maxlen);
 }
 static DEVICE_ATTR_RO(max_len);
 
--

2.21.0

#2 lore raw
Quoted 8 lines · Tomas
Quoted 5 lines

Replace scnprintf with simple sprintf for sysfs files.
it is implicitly known that the buffer is big enough for the variables to fit in.

Hi Greg, hope you have great holiday, has anything changed in the misc-char dev process, no patches were staged including this one?

$ mdfrm -c ~/mail/todo
1430 messages in /home/gregkh/mail/todo

I am way behind due to the holidays, please give me a chance to catch up, especially for trivial stuff like this :)

thanks,

greg k-h

#3 lore raw
Quoted 9 lines · Tomas
Quoted 6 lines
Quoted 5 lines

Replace scnprintf with simple sprintf for sysfs files.
it is implicitly known that the buffer is big enough for the variables to fit in.

Quoted 8 lines
Quoted 2 lines

Hi Greg, hope you have great holiday, has anything changed in the misc-char dev process, no patches were staged including this one?

$ mdfrm -c ~/mail/todo
1430 messages in /home/gregkh/mail/todo

I am way behind due to the holidays, please give me a chance to catch up, especially for trivial stuff like this :)

No problem, just wanted to know.
Thanks.
Tomas.