All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Laight <david.laight.linux@gmail.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>,
	Lianjie Wang <karin0.zst@gmail.com>,
	linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org,
	Olivia Mackall <olivia@selenic.com>,
	Thorsten Blum <thorsten.blum@linux.dev>,
	Manuel Ebner <manuelebner@mailbox.org>
Subject: Re: [PATCH v1 1/1] hwrng: core - Replace strlcat() with better alternative
Date: Mon, 4 May 2026 22:01:50 +0100	[thread overview]
Message-ID: <20260504220150.5e6ce43e@pumpkin> (raw)
In-Reply-To: <20260504130259.473382-1-andriy.shevchenko@linux.intel.com>

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,


      parent reply	other threads:[~2026-05-04 21:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260504220150.5e6ce43e@pumpkin \
    --to=david.laight.linux@gmail.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=karin0.zst@gmail.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=manuelebner@mailbox.org \
    --cc=olivia@selenic.com \
    --cc=thorsten.blum@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.