mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] firewire: replace snprintf in show functions with sysfs_emit
@ 2021-10-15  6:46 Qing Wang
  0 siblings, 0 replies; only message in thread
From: Qing Wang @ 2021-10-15  6:46 UTC (permalink / raw)
  To: Stefan Richter, linux1394-devel, linux-kernel; +Cc: Qing Wang

show() must not use snprintf() when formatting the value to be
returned to user space.

Fix the following coccicheck warning:
drivers/firewire/core-device.c:377: WARNING: use scnprintf or sprintf.
drivers/firewire/core-device.c:408: WARNING: use scnprintf or sprintf.

Signed-off-by: Qing Wang <wangqing@vivo.com>
---
 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 6821698..31b9e50 100644
--- a/drivers/firewire/core-device.c
+++ b/drivers/firewire/core-device.c
@@ -374,7 +374,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",
+	return sysfs_emit(buf, "%d\n",
 			(int)(unit->directory - device->config_rom));
 }
 
@@ -405,7 +405,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",
+	ret = sysfs_emit(buf, "0x%08x%08x\n",
 		       device->config_rom[3], device->config_rom[4]);
 	up_read(&fw_device_rwsem);
 
-- 
2.7.4


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-10-15  6:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-15  6:46 [PATCH] firewire: replace snprintf in show functions with sysfs_emit Qing Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®