[PATCH 2/2] firewire: Convert snprintf/sprintf to sysfs_emit
From: Li Zhijian
Date: Mon Jan 22 2024 - 00:40:23 EST
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/firewire/core-device.c:326:8-16: WARNING: please use sysfs_emit or sysfs_emit_at
No functional change intended
Signed-off-by: Li Zhijian <lizhijian@xxxxxxxxxxx>
---
"[PATCH 00/42] Fix coccicheck warnings"[1] is trying to fix all warnings
reported by coccicheck. firewire introduce newly abused snprintf case.
[1] https://lore.kernel.org/lkml/20240116041129.3937800-1-lizhijian@xxxxxxxxxxx/
---
drivers/firewire/core-device.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
index 47d6cb3dc916..790985479ff3 100644
--- a/drivers/firewire/core-device.c
+++ b/drivers/firewire/core-device.c
@@ -323,7 +323,7 @@ static ssize_t show_immediate(struct device *dev,
if (value < 0)
return -ENOENT;
- return snprintf(buf, PAGE_SIZE, "0x%06x\n", value);
+ return sysfs_emit(buf, "0x%06x\n", value);
}
#define IMMEDIATE_ATTR(name, key) \
@@ -474,7 +474,7 @@ static ssize_t is_local_show(struct device *dev,
{
struct fw_device *device = fw_device(dev);
- return sprintf(buf, "%u\n", device->is_local);
+ return sysfs_emit(buf, "%u\n", device->is_local);
}
static int units_sprintf(char *buf, const u32 *directory)
--
2.29.2