* [PATCH] zorro: sysfs: replace sprintf with sysfs_emit
@ 2026-04-06 17:25 Stefan Pedratscher
2026-04-08 10:06 ` Daniel Palmer
2026-04-27 11:51 ` Geert Uytterhoeven
0 siblings, 2 replies; 3+ messages in thread
From: Stefan Pedratscher @ 2026-04-06 17:25 UTC (permalink / raw)
To: geert; +Cc: linux-m68k, linux-kernel, Stefan Pedratscher
Convert sysfs show functions from sprintf to sysfs_emit as recommended
by Documentation/filesystems/sysfs.rst. This ensures proper buffer
handling and avoids potential buffer overflows.
Signed-off-by: Stefan Pedratscher <pedratscher.stefan@gmail.com>
---
drivers/zorro/zorro-sysfs.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/drivers/zorro/zorro-sysfs.c b/drivers/zorro/zorro-sysfs.c
index 4e967754d8ad..f9a9bcb59e62 100644
--- a/drivers/zorro/zorro-sysfs.c
+++ b/drivers/zorro/zorro-sysfs.c
@@ -15,6 +15,7 @@
#include <linux/zorro.h>
#include <linux/stat.h>
#include <linux/string.h>
+#include <linux/sysfs.h>
#include <asm/byteorder.h>
@@ -29,7 +30,7 @@ static ssize_t name##_show(struct device *dev, \
struct zorro_dev *z; \
\
z = to_zorro_dev(dev); \
- return sprintf(buf, format_string, z->field); \
+ return sysfs_emit(buf, format_string, z->field); \
} \
static DEVICE_ATTR_RO(name);
@@ -44,7 +45,7 @@ static ssize_t serial_show(struct device *dev, struct device_attribute *attr,
struct zorro_dev *z;
z = to_zorro_dev(dev);
- return sprintf(buf, "0x%08x\n", be32_to_cpu(z->rom.er_SerialNumber));
+ return sysfs_emit(buf, "0x%08x\n", be32_to_cpu(z->rom.er_SerialNumber));
}
static DEVICE_ATTR_RO(serial);
@@ -53,10 +54,10 @@ static ssize_t resource_show(struct device *dev, struct device_attribute *attr,
{
struct zorro_dev *z = to_zorro_dev(dev);
- return sprintf(buf, "0x%08lx 0x%08lx 0x%08lx\n",
- (unsigned long)zorro_resource_start(z),
- (unsigned long)zorro_resource_end(z),
- zorro_resource_flags(z));
+ return sysfs_emit(buf, "0x%08lx 0x%08lx 0x%08lx\n",
+ (unsigned long)zorro_resource_start(z),
+ (unsigned long)zorro_resource_end(z),
+ zorro_resource_flags(z));
}
static DEVICE_ATTR_RO(resource);
@@ -65,7 +66,7 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
{
struct zorro_dev *z = to_zorro_dev(dev);
- return sprintf(buf, ZORRO_DEVICE_MODALIAS_FMT "\n", z->id);
+ return sysfs_emit(buf, ZORRO_DEVICE_MODALIAS_FMT "\n", z->id);
}
static DEVICE_ATTR_RO(modalias);
--
2.25.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] zorro: sysfs: replace sprintf with sysfs_emit
2026-04-06 17:25 [PATCH] zorro: sysfs: replace sprintf with sysfs_emit Stefan Pedratscher
@ 2026-04-08 10:06 ` Daniel Palmer
2026-04-27 11:51 ` Geert Uytterhoeven
1 sibling, 0 replies; 3+ messages in thread
From: Daniel Palmer @ 2026-04-08 10:06 UTC (permalink / raw)
To: Stefan Pedratscher; +Cc: geert, linux-m68k, linux-kernel
Hi Stefan,
On Tue, 7 Apr 2026 at 02:26, Stefan Pedratscher
<pedratscher.stefan@gmail.com> wrote:
>
> Convert sysfs show functions from sprintf to sysfs_emit as recommended
> by Documentation/filesystems/sysfs.rst. This ensures proper buffer
> handling and avoids potential buffer overflows.
Build, boot and poked around in /sys/bus/zorro tested on my Amiga
4000. Amiga is still in one piece so:
Tested-by: Daniel Palmer <daniel@thingy.jp>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] zorro: sysfs: replace sprintf with sysfs_emit
2026-04-06 17:25 [PATCH] zorro: sysfs: replace sprintf with sysfs_emit Stefan Pedratscher
2026-04-08 10:06 ` Daniel Palmer
@ 2026-04-27 11:51 ` Geert Uytterhoeven
1 sibling, 0 replies; 3+ messages in thread
From: Geert Uytterhoeven @ 2026-04-27 11:51 UTC (permalink / raw)
To: Stefan Pedratscher; +Cc: linux-m68k, linux-kernel
Hi Stefan,
On Mon, 6 Apr 2026 at 19:26, Stefan Pedratscher
<pedratscher.stefan@gmail.com> wrote:
> Convert sysfs show functions from sprintf to sysfs_emit as recommended
> by Documentation/filesystems/sysfs.rst. This ensures proper buffer
> handling and avoids potential buffer overflows.
>
> Signed-off-by: Stefan Pedratscher <pedratscher.stefan@gmail.com>
Thanks for your patch!
> --- a/drivers/zorro/zorro-sysfs.c
> +++ b/drivers/zorro/zorro-sysfs.c
> @@ -53,10 +54,10 @@ static ssize_t resource_show(struct device *dev, struct device_attribute *attr,
> {
> struct zorro_dev *z = to_zorro_dev(dev);
>
> - return sprintf(buf, "0x%08lx 0x%08lx 0x%08lx\n",
> - (unsigned long)zorro_resource_start(z),
> - (unsigned long)zorro_resource_end(z),
> - zorro_resource_flags(z));
> + return sysfs_emit(buf, "0x%08lx 0x%08lx 0x%08lx\n",
> + (unsigned long)zorro_resource_start(z),
> + (unsigned long)zorro_resource_end(z),
> + zorro_resource_flags(z));
Wrong indentation.
> }
> static DEVICE_ATTR_RO(resource);
>
The rest LGTM, so
Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
i.e. will queue in the m68k tree for v7.2, with the above fixed.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-04-27 11:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-04-06 17:25 [PATCH] zorro: sysfs: replace sprintf with sysfs_emit Stefan Pedratscher
2026-04-08 10:06 ` Daniel Palmer
2026-04-27 11:51 ` Geert Uytterhoeven
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®