diff options
author | Matthias Schiffer | 2023-07-14 13:24:51 +0200 |
---|---|---|
committer | Tom Rini | 2023-08-08 17:05:43 -0400 |
commit | 7c00b80d48cbb28e5f6dfc232c344526e28f7176 (patch) | |
tree | 25c497c3509934e0c691ac0384f82deee75dc87e /test | |
parent | 615828721abfe8c73b5103d4436402ecbf9b9897 (diff) |
lib/charset: fix u16_strlcat() return value
strlcat returns min(strlen(dest), count)+strlen(src). Make u16_strlcat's
behaviour the same for consistency.
Fixes: eca08ce94ceb ("lib/charset: add u16_strlcat() function")
Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/unicode_ut.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/test/unicode_ut.c b/test/unicode_ut.c index b27d7116b9e..a9356e2b60d 100644 --- a/test/unicode_ut.c +++ b/test/unicode_ut.c @@ -808,12 +808,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)); - ut_asserteq(1, ret); + ut_asserteq(0, ret); /* dest is empty string */ memset(buf, 0, sizeof(buf)); ret = u16_strlcat(buf, src, sizeof(buf)); - ut_asserteq(5, ret); + ut_asserteq(4, ret); ut_assert(!unicode_test_u16_strcmp(buf, src, 40)); /* src is empty string */ @@ -821,14 +821,14 @@ static int unicode_test_u16_strlcat(struct unit_test_state *uts) buf[39] = 0; memcpy(buf, dest, sizeof(dest)); ret = u16_strlcat(buf, &null_src, sizeof(buf)); - ut_asserteq(6, ret); + ut_asserteq(5, ret); ut_assert(!unicode_test_u16_strcmp(buf, dest, 40)); for (i = 0; i <= 40; i++) { memset(buf, 0xCD, (sizeof(buf) - sizeof(u16))); buf[39] = 0; memcpy(buf, dest, sizeof(dest)); - expected = 10; + expected = min(5, i) + 4; ret = u16_strlcat(buf, src, i); ut_asserteq(expected, ret); if (i <= 6) { |