Julius Werner has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/33787 )
Change subject: libpayload/libc: Correct strlcat return value ......................................................................
Patch Set 3:
(2 comments)
https://review.coreboot.org/#/c/33787/1/payloads/libpayload/libc/string.c File payloads/libpayload/libc/string.c:
https://review.coreboot.org/#/c/33787/1/payloads/libpayload/libc/string.c@25... PS1, Line 257: int dl = strlen(d); Honestly, this whole implementation is kinda gnarly. We iterate each string twice and in the end I'd say it's still harder to read than a single-pass solution. Maybe we want to replace it completely? Something like
for (i = 0; i < n; i++) if (d[i] == '\0') break;
if (i >= n) return i;
for (; i < n - 1; i++) { d[i] = *s++; if (d[i] == '\0') break; }
d[i] = '\0';
return i;
should work?
https://review.coreboot.org/#/c/33787/1/payloads/libpayload/libc/string.c@26... PS1, Line 267: return sl + dl; This is incorrect if the result was truncated.