firewire: Convert snprintf/sprintf to sysfs_emit
authorLi Zhijian <lizhijian@fujitsu.com>
Mon, 22 Jan 2024 05:39:42 +0000 (13:39 +0800)
committerTakashi Sakamoto <o-takashi@sakamocchi.jp>
Mon, 11 Mar 2024 01:38:13 +0000 (10:38 +0900)
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@fujitsu.com>
Link: https://lore.kernel.org/r/20240122053942.80648-2-lizhijian@fujitsu.com
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
drivers/firewire/core-device.c

index 3a1a2bf1717ccf4d6802b9a85ab777dbd9f44905..a802c6d4f4fdf03c922605c2d98908317f86b050 100644 (file)
@@ -322,7 +322,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)                              \
@@ -482,7 +482,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)