* [PATCH] firewire: convert sysfs sprintf/snprintf family to sysfs_emit
@ 2021-02-04 6:50 Jiapeng Chong
2021-02-04 7:05 ` Joe Perches
0 siblings, 1 reply; 2+ messages in thread
From: Jiapeng Chong @ 2021-02-04 6:50 UTC (permalink / raw)
To: stefanr; +Cc: linux1394-devel, linux-kernel, Jiapeng Chong
Fix the following coccicheck warning:
./drivers/firewire/core-device.c:375:8-16: WARNING: use scnprintf or
sprintf.
Reported-by: Abaci Robot<abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
---
drivers/firewire/core-device.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
index 80db43a..795f69e 100644
--- a/drivers/firewire/core-device.c
+++ b/drivers/firewire/core-device.c
@@ -372,8 +372,7 @@ static ssize_t rom_index_show(struct device *dev,
struct fw_device *device = fw_device(dev->parent);
struct fw_unit *unit = fw_unit(dev);
- return snprintf(buf, PAGE_SIZE, "%d\n",
- (int)(unit->directory - device->config_rom));
+ return sysfs_emit(buf, "%d\n", (int)(unit->directory - device->config_rom));
}
static struct device_attribute fw_unit_attributes[] = {
@@ -403,8 +402,7 @@ static ssize_t guid_show(struct device *dev,
int ret;
down_read(&fw_device_rwsem);
- ret = snprintf(buf, PAGE_SIZE, "0x%08x%08x\n",
- device->config_rom[3], device->config_rom[4]);
+ ret = sysfs_emit(buf, "0x%08x%08x\n", device->config_rom[3], device->config_rom[4]);
up_read(&fw_device_rwsem);
return ret;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] firewire: convert sysfs sprintf/snprintf family to sysfs_emit
2021-02-04 6:50 [PATCH] firewire: convert sysfs sprintf/snprintf family to sysfs_emit Jiapeng Chong
@ 2021-02-04 7:05 ` Joe Perches
0 siblings, 0 replies; 2+ messages in thread
From: Joe Perches @ 2021-02-04 7:05 UTC (permalink / raw)
To: Jiapeng Chong, stefanr; +Cc: linux1394-devel, linux-kernel
On Thu, 2021-02-04 at 14:50 +0800, Jiapeng Chong wrote:
> Fix the following coccicheck warning:
>
> ./drivers/firewire/core-device.c:375:8-16: WARNING: use scnprintf or
> sprintf.
[]
> diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
[]
> @@ -372,8 +372,7 @@ static ssize_t rom_index_show(struct device *dev,
> struct fw_device *device = fw_device(dev->parent);
> struct fw_unit *unit = fw_unit(dev);
>
>
> - return snprintf(buf, PAGE_SIZE, "%d\n",
> - (int)(unit->directory - device->config_rom));
> + return sysfs_emit(buf, "%d\n", (int)(unit->directory - device->config_rom));
Perhaps this should use the ptrdiff_t qualifier '%td' instead:
return sysfs_emit(buf, "%td\n", unit->directory - device->config_rom);
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-02-04 7:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-04 6:50 [PATCH] firewire: convert sysfs sprintf/snprintf family to sysfs_emit Jiapeng Chong
2021-02-04 7:05 ` Joe Perches
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.