]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
strnlen: Fix compilation error (regression 2025-11-18).
authorBruno Haible <bruno@clisp.org>
Fri, 21 Nov 2025 02:02:22 +0000 (03:02 +0100)
committerBruno Haible <bruno@clisp.org>
Fri, 21 Nov 2025 02:02:22 +0000 (03:02 +0100)
Reported by Po Lu <luangruo@yahoo.com> in
<https://lists.gnu.org/archive/html/bug-gnulib/2025-11/msg00217.html>.

* lib/strnlen.c (strnlen): Revert last change.

ChangeLog
lib/strnlen.c

index e84cd50da36e5cf3c25402cf15382f11fc1369db..4eadd88f1212f7e4f2e0b2e4543b2407630504b7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2025-11-20  Bruno Haible  <bruno@clisp.org>
+
+       strnlen: Fix compilation error (regression 2025-11-18).
+       Reported by Po Lu <luangruo@yahoo.com> in
+       <https://lists.gnu.org/archive/html/bug-gnulib/2025-11/msg00217.html>.
+       * lib/strnlen.c (strnlen): Revert last change.
+
 2025-11-19  Bruno Haible  <bruno@clisp.org>
 
        nstrftime, fprintftime: Reduce link requirements on macOS.
index 5a03d7ec9427b3d7aaf961a0bb6c3bb40de7e1b9..f69904157622aa1f95878b4ba06acfc73b6c86ca 100644 (file)
@@ -27,7 +27,8 @@ strnlen (const char *s, size_t maxlen)
 {
   /* Do not use memchr, because on some platforms memchr has
      undefined behavior if MAXLEN exceeds the number of bytes in S.  */
-  for (size_t i = 0; i < maxlen && s[i]; i++)
+  size_t i;
+  for (i = 0; i < maxlen && s[i]; i++)
     continue;
   return i;
 }