Skip to contentSkip to conversation

macintosh: ams: replace snprintf in show functions with sysfs_emit

PATCH New Qing Wang 1 participant 1 message Oct 15, 2021 Linux for power macintosh

lore
Share & tools
lore

Qing Wang

author
#0 lore raw

PATCH 1/1 macintosh: ams: 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/macintosh/ams/ams-core.c:53: WARNING: use scnprintf or sprintf.

Use sysfs_emit instead of scnprintf or sprintf makes more sense.

---
 drivers/macintosh/ams/ams-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/macintosh/ams/ams-core.c +1 -1
index 01eeb23..877e8cb 100644
@@ -50,7 +50,7 @@ static ssize_t ams_show_current(struct device *dev,
 	ams_sensors(&x, &y, &z);
 	mutex_unlock(&ams_info.lock);
 
-	return snprintf(buf, PAGE_SIZE, "%d %d %d\n", x, y, z);
+	return sysfs_emit(buf, "%d %d %d\n", x, y, z);
 }
 
 static DEVICE_ATTR(current, S_IRUGO, ams_show_current, NULL);
Signature · 1 line
2.7.4