u-boot.lists.denx.de archive mirror
 help / color / mirror / Atom feed
From: Heinrich Schuchardt <xypron.glpk@gmx.de>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>,
	u-boot@lists.denx.de,
	Masahisa Kojima <masahisa.kojima@linaro.org>
Subject: Re: [PATCH] test: unicode: fix a sizeof() vs ARRAY_SIZE() bug
Date: Thu, 27 Jul 2023 10:50:41 +0200	[thread overview]
Message-ID: <b6bd1cfd-d266-cd51-14a0-d05bfcdaafe8@gmx.de> (raw)
In-Reply-To: <c102edd0-86b8-401a-831f-ddd07349a3a8@moroto.mountain>

On 7/27/23 09:12, Dan Carpenter wrote:
> The u16_strlcat() is in units of u16 not bytes.  So the limit needs to
> be ARRAY_SIZE() instead of sizeof().
>

Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
>   test/unicode_ut.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/test/unicode_ut.c b/test/unicode_ut.c
> index b27d7116b9ee..62ff5d10bf94 100644
> --- a/test/unicode_ut.c
> +++ b/test/unicode_ut.c
> @@ -807,12 +807,12 @@ static int unicode_test_u16_strlcat(struct unit_test_state *uts)
>
>   	/* dest and src are empty string */
>   	memset(buf, 0, sizeof(buf));
> -	ret = u16_strlcat(buf, &null_src, sizeof(buf));
> +	ret = u16_strlcat(buf, &null_src, ARRAY_SIZE(buf));
>   	ut_asserteq(1, ret);
>
>   	/* dest is empty string */
>   	memset(buf, 0, sizeof(buf));
> -	ret = u16_strlcat(buf, src, sizeof(buf));
> +	ret = u16_strlcat(buf, src, ARRAY_SIZE(buf));
>   	ut_asserteq(5, ret);
>   	ut_assert(!unicode_test_u16_strcmp(buf, src, 40));
>
> @@ -820,7 +820,7 @@ static int unicode_test_u16_strlcat(struct unit_test_state *uts)
>   	memset(buf, 0xCD, (sizeof(buf) - sizeof(u16)));
>   	buf[39] = 0;
>   	memcpy(buf, dest, sizeof(dest));
> -	ret = u16_strlcat(buf, &null_src, sizeof(buf));
> +	ret = u16_strlcat(buf, &null_src, ARRAY_SIZE(buf));
>   	ut_asserteq(6, ret);
>   	ut_assert(!unicode_test_u16_strcmp(buf, dest, 40));
>


  reply	other threads:[~2023-07-27  8:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-27  7:12 [PATCH] test: unicode: fix a sizeof() vs ARRAY_SIZE() bug Dan Carpenter
2023-07-27  8:50 ` Heinrich Schuchardt [this message]
2023-08-09  1:40 ` Tom Rini

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=b6bd1cfd-d266-cd51-14a0-d05bfcdaafe8@gmx.de \
    --to=xypron.glpk@gmx.de \
    --cc=dan.carpenter@linaro.org \
    --cc=ilias.apalodimas@linaro.org \
    --cc=masahisa.kojima@linaro.org \
    --cc=u-boot@lists.denx.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).