aboutsummaryrefslogtreecommitdiff
path: root/test/unicode_ut.c
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@linaro.org>2023-07-27 10:12:58 +0300
committerTom Rini <trini@konsulko.com>2023-08-08 17:41:52 -0400
commitbe5f9a77f8bc83a3f93d26a50acc047d2bbee908 (patch)
tree032c0ee471ae53f081bd2976d6fd524e2e2ee523 /test/unicode_ut.c
parentbb34bc0c96168857d6b5127d3487223b0ea8cfa5 (diff)
downloadu-boot-be5f9a77f8bc83a3f93d26a50acc047d2bbee908.zip
u-boot-be5f9a77f8bc83a3f93d26a50acc047d2bbee908.tar.gz
u-boot-be5f9a77f8bc83a3f93d26a50acc047d2bbee908.tar.bz2
test: unicode: fix a sizeof() vs ARRAY_SIZE() bug
The u16_strlcat() is in units of u16 not bytes. So the limit needs to be ARRAY_SIZE() instead of sizeof(). Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Diffstat (limited to 'test/unicode_ut.c')
-rw-r--r--test/unicode_ut.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/test/unicode_ut.c b/test/unicode_ut.c
index a9356e2..1d0d90c 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(0, 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(4, 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(5, ret);
ut_assert(!unicode_test_u16_strcmp(buf, dest, 40));