Skip to content

Commit 6d5b32d

Browse files
committed
CLEANUP: log: use strnlen2() in _lf_text_len() to compute string length
Thanks to previous commit, we can now use strnlen2() function to perform strnlen() portable equivalent instead of re-implementing the logic under _lf_text_len() function.
1 parent 24131de commit 6d5b32d

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

src/log.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2388,15 +2388,7 @@ static inline char *_lf_text_len(char *dst, const char *src,
23882388
* indefinite length text in cbor, because indefinite-length text
23892389
* has to be made of multiple chunks of known size as per RFC8949...
23902390
*/
2391-
{
2392-
int _len;
2393-
2394-
/* strnlen(src, len) portable equivalent: */
2395-
for (_len = 0; _len < len && src[_len]; _len++)
2396-
;
2397-
2398-
len = _len;
2399-
}
2391+
len = strnlen2(src, len);
24002392

24012393
ret = cbor_encode_text(&ctx->encode.cbor, dst, dst + size, src, len);
24022394
if (ret == NULL)

0 commit comments

Comments
 (0)