Skip to content

Commit

Permalink
firewire: Convert snprintf/sprintf to sysfs_emit
Browse files Browse the repository at this point in the history
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 <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Takashi Sakamoto <[email protected]>
  • Loading branch information
zhijianli88 authored and takaswie committed Mar 11, 2024
1 parent 4a2b06c commit d4db89c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/firewire/core-device.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit d4db89c

Please sign in to comment.