* [PATCH v1 1/1] hwrng: core - Replace strlcat() with better alternative
@ 2026-05-04 13:02 Andy Shevchenko
2026-05-04 13:15 ` Thorsten Blum
2026-05-04 21:01 ` David Laight
0 siblings, 2 replies; 4+ messages in thread
From: Andy Shevchenko @ 2026-05-04 13:02 UTC (permalink / raw)
To: Herbert Xu, Lianjie Wang, linux-crypto, linux-kernel
Cc: Olivia Mackall, Thorsten Blum, Manuel Ebner, Andy Shevchenko
strlcpy() and strlcat() are confusing APIs and the former one already
gone from the kernel.
In preparation to kill strlcat() replace it with the better alternative.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/char/hw_random/core.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c
index aba92d777f72..c789699bd773 100644
--- a/drivers/char/hw_random/core.c
+++ b/drivers/char/hw_random/core.c
@@ -418,21 +418,21 @@ static ssize_t rng_available_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
+ int len = 0;
int err;
struct hwrng *rng;
err = mutex_lock_interruptible(&rng_mutex);
if (err)
return -ERESTARTSYS;
- buf[0] = '\0';
- list_for_each_entry(rng, &rng_list, list) {
- strlcat(buf, rng->name, PAGE_SIZE);
- strlcat(buf, " ", PAGE_SIZE);
- }
- strlcat(buf, "none\n", PAGE_SIZE);
+
+ list_for_each_entry(rng, &rng_list, list)
+ len += sysfs_emit_at(buf, len, "%s ", rng->name);
+ len += sysfs_emit_at(buf, len, "none\n");
+
mutex_unlock(&rng_mutex);
- return strlen(buf);
+ return len;
}
static ssize_t rng_selected_show(struct device *dev,
--
2.50.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v1 1/1] hwrng: core - Replace strlcat() with better alternative
2026-05-04 13:02 [PATCH v1 1/1] hwrng: core - Replace strlcat() with better alternative Andy Shevchenko
@ 2026-05-04 13:15 ` Thorsten Blum
2026-05-04 13:51 ` Andy Shevchenko
2026-05-04 21:01 ` David Laight
1 sibling, 1 reply; 4+ messages in thread
From: Thorsten Blum @ 2026-05-04 13:15 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Herbert Xu, Lianjie Wang, linux-crypto, linux-kernel,
Olivia Mackall, Manuel Ebner
On Mon, May 04, 2026 at 03:02:59PM +0200, Andy Shevchenko wrote:
> strlcpy() and strlcat() are confusing APIs and the former one already
> gone from the kernel.
>
> In preparation to kill strlcat() replace it with the better alternative.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
I already took care of this one a few days ago:
https://lore.kernel.org/lkml/20260430110047.248825-8-thorsten.blum@linux.dev/
Thanks,
Thorsten
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v1 1/1] hwrng: core - Replace strlcat() with better alternative
2026-05-04 13:15 ` Thorsten Blum
@ 2026-05-04 13:51 ` Andy Shevchenko
0 siblings, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2026-05-04 13:51 UTC (permalink / raw)
To: Thorsten Blum
Cc: Herbert Xu, Lianjie Wang, linux-crypto, linux-kernel,
Olivia Mackall, Manuel Ebner
On Mon, May 04, 2026 at 03:15:23PM +0200, Thorsten Blum wrote:
> On Mon, May 04, 2026 at 03:02:59PM +0200, Andy Shevchenko wrote:
> > strlcpy() and strlcat() are confusing APIs and the former one already
> > gone from the kernel.
> >
> > In preparation to kill strlcat() replace it with the better alternative.
> >
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>
> I already took care of this one a few days ago:
>
> https://lore.kernel.org/lkml/20260430110047.248825-8-thorsten.blum@linux.dev/
Very good, thanks!
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v1 1/1] hwrng: core - Replace strlcat() with better alternative
2026-05-04 13:02 [PATCH v1 1/1] hwrng: core - Replace strlcat() with better alternative Andy Shevchenko
2026-05-04 13:15 ` Thorsten Blum
@ 2026-05-04 21:01 ` David Laight
1 sibling, 0 replies; 4+ messages in thread
From: David Laight @ 2026-05-04 21:01 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Herbert Xu, Lianjie Wang, linux-crypto, linux-kernel,
Olivia Mackall, Thorsten Blum, Manuel Ebner
On Mon, 4 May 2026 15:02:59 +0200
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
> strlcpy() and strlcat() are confusing APIs and the former one already
> gone from the kernel.
>
> In preparation to kill strlcat() replace it with the better alternative.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: David Laight <david.laight.linux@gmail.com>
> ---
> drivers/char/hw_random/core.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c
> index aba92d777f72..c789699bd773 100644
> --- a/drivers/char/hw_random/core.c
> +++ b/drivers/char/hw_random/core.c
> @@ -418,21 +418,21 @@ static ssize_t rng_available_show(struct device *dev,
> struct device_attribute *attr,
> char *buf)
> {
> + int len = 0;
> int err;
> struct hwrng *rng;
>
> err = mutex_lock_interruptible(&rng_mutex);
> if (err)
> return -ERESTARTSYS;
> - buf[0] = '\0';
> - list_for_each_entry(rng, &rng_list, list) {
> - strlcat(buf, rng->name, PAGE_SIZE);
> - strlcat(buf, " ", PAGE_SIZE);
> - }
> - strlcat(buf, "none\n", PAGE_SIZE);
> +
> + list_for_each_entry(rng, &rng_list, list)
> + len += sysfs_emit_at(buf, len, "%s ", rng->name);
> + len += sysfs_emit_at(buf, len, "none\n");
> +
> mutex_unlock(&rng_mutex);
>
> - return strlen(buf);
> + return len;
> }
>
> static ssize_t rng_selected_show(struct device *dev,
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-05-04 21:01 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-04 13:02 [PATCH v1 1/1] hwrng: core - Replace strlcat() with better alternative Andy Shevchenko
2026-05-04 13:15 ` Thorsten Blum
2026-05-04 13:51 ` Andy Shevchenko
2026-05-04 21:01 ` David Laight
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox