Skip to contentSkip to conversation

mfd: replace snprintf in show functions with sysfs_emit

PATCH In review Qing Wang 2 participants 2 messages Oct 15, 2021 – Oct 21, 2021 Multifunction devices (MFD)

lore
Share & tools
lore

Qing Wang

author
#0 lore raw

PATCH 1/1 mfd: replace snprintf in show functions with sysfs_emit

show() must not use snprintf() when formatting the value to be returned to user space.

Fix the following coccicheck warning:
drivers/mfd/janz-cmodio.c:157: WARNING: use scnprintf or sprintf.

Use sysfs_emit instead of scnprintf or sprintf makes more sense.

---
 drivers/mfd/janz-cmodio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/janz-cmodio.c +1 -1
index 70eba4c..add3bc0 100644
@@ -154,7 +154,7 @@ static ssize_t modulbus_number_show(struct device *dev,
 {
 	struct cmodio_device *priv = dev_get_drvdata(dev);
 
-	return snprintf(buf, PAGE_SIZE, "%x\n", priv->hex);
+	return sysfs_emit(buf, "%x\n", priv->hex);
 }
 
 static DEVICE_ATTR_RO(modulbus_number);
Signature · 1 line
2.7.4
#1 lore raw
Quoted 6 lines · Qing Wang

show() must not use snprintf() when formatting the value to be returned to user space.

Fix the following coccicheck warning:
drivers/mfd/janz-cmodio.c:157: WARNING: use scnprintf or sprintf.

Quoted 6 lines

Use sysfs_emit instead of scnprintf or sprintf makes more sense.

---
 drivers/mfd/janz-cmodio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

I've fixed the subject line for you and applied, thanks.

Signature · 4 lines
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog