]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: log: use strnlen2() in _lf_text_len() to compute string length
authorAurelien DARRAGON <adarragon@haproxy.com>
Fri, 25 Oct 2024 15:06:30 +0000 (17:06 +0200)
committerAurelien DARRAGON <adarragon@haproxy.com>
Mon, 28 Oct 2024 13:59:42 +0000 (14:59 +0100)
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.

src/log.c

index 71ce020b794f069ac68f50492db4c2ebdaca1eeb..42e7663496a4c2fe8c2ed9b5f14f980c0140315d 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -2388,15 +2388,7 @@ static inline char *_lf_text_len(char *dst, const char *src,
                         * indefinite length text in cbor, because indefinite-length text
                         * has to be made of multiple chunks of known size as per RFC8949...
                         */
-                       {
-                               int _len;
-
-                               /* strnlen(src, len) portable equivalent: */
-                               for (_len = 0; _len < len && src[_len]; _len++)
-                                       ;
-
-                               len = _len;
-                       }
+                       len = strnlen2(src, len);
 
                        ret = cbor_encode_text(&ctx->encode.cbor, dst, dst + size, src, len);
                        if (ret == NULL)