Here is the diff: I apologize for not being able to send the file itself

diff --git a/games/arithmetic/arithmetic.c b/games/arithmetic/arithmetic.c
index 3b872ae1b03..d54894f9dbc 100644
--- a/games/arithmetic/arithmetic.c
+++ b/games/arithmetic/arithmetic.c
@@ -130,7 +130,7 @@ main(int argc, char *argv[])

        /* Now ask the questions. */
        for (;;) {
-               for (cnt = NQUESTS; cnt--;)
+               for (cnt = NQUESTS; cnt; cnt--)
                        if (problem() == EOF)
                                intr(0);   /* Print score and exit */
                showstats();
diff --git a/lib/libc/string/memccpy.3 b/lib/libc/string/memccpy.3
index 98326d68713..f471702ef01 100644
--- a/lib/libc/string/memccpy.3
+++ b/lib/libc/string/memccpy.3
@@ -38,7 +38,7 @@
 .Sh SYNOPSIS
 .In string.h
 .Ft void *
-.Fn memccpy "void *dst" "const void *src" "int c" "size_t len"
+.Fn memccpy "void * restrict dst" "const void * restrict src" "int c"
"size_t len"
 .Sh DESCRIPTION
 The
 .Fn memccpy
diff --git a/lib/libc/string/memccpy.c b/lib/libc/string/memccpy.c
index 635061b8cb9..ce5fbd38dc6 100644
--- a/lib/libc/string/memccpy.c
+++ b/lib/libc/string/memccpy.c
@@ -32,18 +32,18 @@
 #include <string.h>

 void *
-memccpy(void *t, const void *f, int c, size_t n)
+memccpy(void * __restrict t, const void * __restrict f, int c, size_t n)
 {

        if (n) {
                unsigned char *tp = t;
                const unsigned char *fp = f;
-               unsigned char uc = c;
+               const unsigned char uc = (unsigned char)c;
                do {
                        if ((*tp++ = *fp++) == uc)
                                return (tp);
                } while (--n != 0);
        }
-       return (0);
+       return (NULL);
 }
 DEF_WEAK(memccpy);
diff --git a/lib/libc/string/memchr.c b/lib/libc/string/memchr.c
index a6a4bd60d03..4ec8f4b36dd 100644
--- a/lib/libc/string/memchr.c
+++ b/lib/libc/string/memchr.c
@@ -38,10 +38,12 @@ memchr(const void *s, int c, size_t n)
 {
        if (n != 0) {
                const unsigned char *p = s;
+               const unsigned char uc = (unsigned char)c;

                do {
-                       if (*p++ == (unsigned char)c)
-                               return ((void *)(p - 1));
+                       if (*p == uc)
+                               return ((void *)p);
+                       p++;
                } while (--n != 0);
        }
        return (NULL);
diff --git a/lib/libc/string/memcmp.c b/lib/libc/string/memcmp.c
index 0df2c54d2af..32c332a6ec2 100644
--- a/lib/libc/string/memcmp.c
+++ b/lib/libc/string/memcmp.c
@@ -43,8 +43,9 @@ memcmp(const void *s1, const void *s2, size_t n)
                const unsigned char *p1 = s1, *p2 = s2;

                do {
-                       if (*p1++ != *p2++)
-                               return (*--p1 - *--p2);
+                       if (*p1 != *p2)
+                               return (*p1 - *p2);
+                       p1++, p2++;
                } while (--n != 0);
        }
        return (0);
diff --git a/lib/libc/string/memcpy.3 b/lib/libc/string/memcpy.3
index 8df2a785b99..92bbdb5829e 100644
--- a/lib/libc/string/memcpy.3
+++ b/lib/libc/string/memcpy.3
@@ -40,7 +40,7 @@
 .Sh SYNOPSIS
 .In string.h
 .Ft void *
-.Fn memcpy "void *dst" "const void *src" "size_t len"
+.Fn memcpy "void * restrict dst" "const void * restrict src" "size_t len"
 .Sh DESCRIPTION
 The
 .Fn memcpy
@@ -69,7 +69,7 @@ function returns the original value of
 The
 .Fn memcpy
 function conforms to
-.St -ansiC .
+.St -isoC-99.
 .Sh HISTORY
 The
 .Fn memcpy
diff --git a/lib/libc/string/memcpy.c b/lib/libc/string/memcpy.c
index 19fddc0ab5f..6f4fc748c39 100644
--- a/lib/libc/string/memcpy.c
+++ b/lib/libc/string/memcpy.c
@@ -39,7 +39,7 @@
  * sizeof(word) MUST BE A POWER OF TWO
  * SO THAT wmask BELOW IS ALL ONES
  */
-typedef        long word;              /* "word" used for optimal copy speed */
+typedef        unsigned long word;             /* "word" used for optimal copy 
speed */

 #define        wsize   sizeof(word)
 #define        wmask   (wsize - 1)
@@ -50,10 +50,10 @@ static const char backwards_msg[] = ": backwards memcpy";
  * Copy a block of memory, not handling overlap.
  */
 void *
-memcpy(void *dst0, const void *src0, size_t length)
+memcpy(void * __restrict dst0, const void * __restrict src0, size_t length)
 {
-       char *dst = dst0;
-       const char *src = src0;
+       char *dst = (char *)dst0;
+       const char *src = (const char *)src0;
        size_t t;

        if (length == 0 || dst == src)          /* nothing to do */
@@ -83,13 +83,13 @@ memcpy(void *dst0, const void *src0, size_t length)
        /*
         * Copy forward.
         */
-       t = (long)src;  /* only need low bits */
-       if ((t | (long)dst) & wmask) {
+       t = (word)src;  /* only need low bits */
+       if ((t | (word)dst) & wmask) {
                /*
                 * Try to align operands.  This cannot be done
                 * unless the low bits match.
                 */
-               if ((t ^ (long)dst) & wmask || length < wsize)
+               if ((t ^ (word)dst) & wmask || length < wsize)
                        t = length;
                else
                        t = wsize - (t & wmask);
diff --git a/lib/libc/string/memrchr.c b/lib/libc/string/memrchr.c
index e123bc1737d..092e548553b 100644
--- a/lib/libc/string/memrchr.c
+++ b/lib/libc/string/memrchr.c
@@ -25,12 +25,11 @@
 void *
 memrchr(const void *s, int c, size_t n)
 {
-       const unsigned char *cp;
-
        if (n != 0) {
-               cp = (unsigned char *)s + n;
+               const unsigned char *cp = (unsigned char *)s + n;
+               const unsigned char uc = (unsigned char)c;
                do {
-                       if (*(--cp) == (unsigned char)c)
+                       if (*(--cp) == uc)
                                return((void *)cp);
                } while (--n != 0);
        }
diff --git a/lib/libc/string/memset.c b/lib/libc/string/memset.c
index 0c261f0965a..de340fad880 100644
--- a/lib/libc/string/memset.c
+++ b/lib/libc/string/memset.c
@@ -38,9 +38,10 @@ memset(void *dst, int c, size_t n)
 {
        if (n != 0) {
                unsigned char *d = dst;
+               const unsigned char uc = (unsigned char)c;

                do
-                       *d++ = (unsigned char)c;
+                       *d++ = uc;
                while (--n != 0);
        }
        return (dst);
diff --git a/lib/libc/string/stpcpy.3 b/lib/libc/string/stpcpy.3
index 973eebecdde..0c82691f439 100644
--- a/lib/libc/string/stpcpy.3
+++ b/lib/libc/string/stpcpy.3
@@ -41,9 +41,9 @@
 .Sh SYNOPSIS
 .In string.h
 .Ft char *
-.Fn stpcpy "char *dst" "const char *src"
+.Fn stpcpy "char * restrict dst" "const char * restrict src"
 .Ft char *
-.Fn stpncpy "char *dst" "const char *src" "size_t len"
+.Fn stpncpy "char * restrict dst" "const char * restrict src" "size_t len"
 .Sh DESCRIPTION
 The
 .Fn stpcpy
diff --git a/lib/libc/string/stpcpy.c b/lib/libc/string/stpcpy.c
index 5a86541f080..28ac169e864 100644
--- a/lib/libc/string/stpcpy.c
+++ b/lib/libc/string/stpcpy.c
@@ -37,7 +37,7 @@ __warn_references(stpcpy,
 #endif

 char *
-stpcpy(char *to, const char *from)
+stpcpy(char * restrict to, const char * restrict from)
 {
        for (; (*to = *from) != '\0'; ++from, ++to);
        return(to);
diff --git a/lib/libc/string/stpncpy.c b/lib/libc/string/stpncpy.c
index 6bdee5de164..9c2307777aa 100644
--- a/lib/libc/string/stpncpy.c
+++ b/lib/libc/string/stpncpy.c
@@ -35,7 +35,7 @@
 #include <string.h>

 char *
-stpncpy(char *dst, const char *src, size_t n)
+stpncpy(char * restrict dst, const char * restrict src, size_t n)
 {
        if (n != 0) {
                char *d = dst;
diff --git a/lib/libc/string/strcat.3 b/lib/libc/string/strcat.3
index 76032c8e8f3..08936c3a919 100644
--- a/lib/libc/string/strcat.3
+++ b/lib/libc/string/strcat.3
@@ -40,7 +40,7 @@
 .Sh SYNOPSIS
 .In string.h
 .Ft char *
-.Fn strcat "char *dst" "const char *append"
+.Fn strcat "char * restrict dst" "const char * restrict append"
 .Sh DESCRIPTION
 The
 .Fn strcat
@@ -69,7 +69,7 @@ function return the pointer
 The
 .Fn strcat
 function conforms to
-.St -ansiC .
+.St -iso-c99 .
 .Sh HISTORY
 The
 .Fn strcat
diff --git a/lib/libc/string/strcat.c b/lib/libc/string/strcat.c
index 73da22f75da..df73bcbee77 100644
--- a/lib/libc/string/strcat.c
+++ b/lib/libc/string/strcat.c
@@ -37,11 +37,11 @@ __warn_references(strcat,
 #endif

 char *
-strcat(char *s, const char *append)
+strcat(char * __restrict s, const char * __restrict append)
 {
-       char *save = s;
+       char * const save = s;

-       for (; *s; ++s);
-       while ((*s++ = *append++) != '\0');
+       for (; *s != '\0'; ++s);
+       while ((*s = *append) != '\0') s++, append++;
        return(save);
 }
diff --git a/lib/libc/string/strchr.c b/lib/libc/string/strchr.c
index 8bfa7ac3aa0..5e14872272c 100644
--- a/lib/libc/string/strchr.c
+++ b/lib/libc/string/strchr.c
@@ -38,7 +38,7 @@ strchr(const char *p, int ch)
        for (;; ++p) {
                if (*p == (char) ch)
                        return((char *)p);
-               if (!*p)
+               if (*p == '\0')
                        return((char *)NULL);
        }
        /* NOTREACHED */
diff --git a/lib/libc/string/strcmp.c b/lib/libc/string/strcmp.c
index be175563d47..87e042a9a47 100644
--- a/lib/libc/string/strcmp.c
+++ b/lib/libc/string/strcmp.c
@@ -40,9 +40,11 @@
 int
 strcmp(const char *s1, const char *s2)
 {
-       while (*s1 == *s2++)
-               if (*s1++ == 0)
-                       return (0);
-       return (*(unsigned char *)s1 - *(unsigned char *)--s2);
+       while (*s1 != '\0') {
+               if (*s1 != *s2)
+                       return (*(const unsigned char *)s1 - *(const unsigned 
char *)s2);
+               s1++, s2++;
+       }
+       return (0);
 }
 DEF_STRONG(strcmp);
diff --git a/lib/libc/string/strcpy.3 b/lib/libc/string/strcpy.3
index 7174f7c963c..fc1efe665be 100644
--- a/lib/libc/string/strcpy.3
+++ b/lib/libc/string/strcpy.3
@@ -40,7 +40,7 @@
 .Sh SYNOPSIS
 .In string.h
 .Ft char *
-.Fn strcpy "char *dst" "const char *src"
+.Fn strcpy "char * restrict dst" "const char * restrict src"
 .Sh DESCRIPTION
 The
 .Fn strcpy
@@ -75,7 +75,7 @@ function returns
 The
 .Fn strcpy
 function conforms to
-.St -ansiC .
+.St -iso-c99 .
 .Sh HISTORY
 The
 .Fn strcpy
diff --git a/lib/libc/string/strcpy.c b/lib/libc/string/strcpy.c
index 290eefeabf5..2f189bf25d8 100644
--- a/lib/libc/string/strcpy.c
+++ b/lib/libc/string/strcpy.c
@@ -37,7 +37,7 @@ __warn_references(strcpy,
 #endif

 char *
-strcpy(char *to, const char *from)
+strcpy(char * restrict to, const char * restrict from)
 {
        char *save = to;

diff --git a/lib/libc/string/strlcat.c b/lib/libc/string/strlcat.c
index aa3db7ab378..3e344b3b0c6 100644
--- a/lib/libc/string/strlcat.c
+++ b/lib/libc/string/strlcat.c
@@ -31,21 +31,20 @@ strlcat(char *dst, const char *src, size_t dsize)
 {
        const char *odst = dst;
        const char *osrc = src;
-       size_t n = dsize;
+       size_t n;
        size_t dlen;

        /* Find the end of dst and adjust bytes left but don't go past end. */
-       while (n-- != 0 && *dst != '\0')
+       for (n = dsize; n != 0 && *dst != '\0'; n--)
                dst++;
        dlen = dst - odst;
        n = dsize - dlen;

-       if (n-- == 0)
+       if (n == 0)
                return(dlen + strlen(src));
        while (*src != '\0') {
-               if (n != 0) {
+               if (--n != 0) {
                        *dst++ = *src;
-                       n--;
                }
                src++;
        }
diff --git a/lib/libc/string/strlcpy.3 b/lib/libc/string/strlcpy.3
index a14145e199f..91293cb6bc0 100644
--- a/lib/libc/string/strlcpy.3
+++ b/lib/libc/string/strlcpy.3
@@ -24,9 +24,9 @@
 .Sh SYNOPSIS
 .In string.h
 .Ft size_t
-.Fn strlcpy "char *dst" "const char *src" "size_t dstsize"
+.Fn strlcpy "char * restrict dst" "const char * restrict src" "size_t dstsize"
 .Ft size_t
-.Fn strlcat "char *dst" "const char *src" "size_t dstsize"
+.Fn strlcat "char * restrict dst" "const char * restrict src" "size_t dstsize"
 .Sh DESCRIPTION
 The
 .Fn strlcpy
diff --git a/lib/libc/string/strlcpy.c b/lib/libc/string/strlcpy.c
index 7e3b9aef6f6..f694ba25398 100644
--- a/lib/libc/string/strlcpy.c
+++ b/lib/libc/string/strlcpy.c
@@ -25,22 +25,22 @@
  * Returns strlen(src); if retval >= dsize, truncation occurred.
  */
 size_t
-strlcpy(char *dst, const char *src, size_t dsize)
+strlcpy(char * __restrict dst, const char * __restrict src, size_t dsize)
 {
-       const char *osrc = src;
-       size_t nleft = dsize;
+       const char * const osrc = src;
+       const size_t odsize = dsize;

        /* Copy as many bytes as will fit. */
-       if (nleft != 0) {
-               while (--nleft != 0) {
+       if (dsize != 0) {
+               while (--dsize != 0) {
                        if ((*dst++ = *src++) == '\0')
                                break;
                }
        }

        /* Not enough room in dst, add NUL and traverse rest of src. */
-       if (nleft == 0) {
-               if (dsize != 0)
+       if (dsize == 0) {
+               if (odsize != 0)
                        *dst = '\0';            /* NUL-terminate dst */
                while (*src++)
                        ;
diff --git a/lib/libc/string/strncat.3 b/lib/libc/string/strncat.3
index d314a9999a1..893d80ed9c5 100644
--- a/lib/libc/string/strncat.3
+++ b/lib/libc/string/strncat.3
@@ -40,7 +40,7 @@
 .Sh SYNOPSIS
 .In string.h
 .Ft char *
-.Fn strncat "char *dst" "const char *append" "size_t count"
+.Fn strncat "char * restrict dst" "const char * restrict append" "size_t count"
 .Sh DESCRIPTION
 The
 .Fn strncat
@@ -124,7 +124,7 @@ if (snprintf(buf, sizeof(buf), "%s%s",
 The
 .Fn strncat
 function conforms to
-.St -ansiC .
+.St -iso-c99 .
 .Sh HISTORY
 The
 .Fn strncat
diff --git a/lib/libc/string/strncat.c b/lib/libc/string/strncat.c
index b3388accf37..6cd71cb8151 100644
--- a/lib/libc/string/strncat.c
+++ b/lib/libc/string/strncat.c
@@ -38,7 +38,7 @@
  * are written at dst (at most n+1 bytes being appended).  Return dst.
  */
 char *
-strncat(char *dst, const char *src, size_t n)
+strncat(char * restrict dst, const char * restrict src, size_t n)
 {
        if (n != 0) {
                char *d = dst;
@@ -47,11 +47,11 @@ strncat(char *dst, const char *src, size_t n)
                while (*d != 0)
                        d++;
                do {
-                       if ((*d = *s++) == 0)
+                       if ((*d = *s++) == '\0')
                                break;
                        d++;
                } while (--n != 0);
-               *d = 0;
+               *d = '\0';
        }
        return (dst);
 }
diff --git a/lib/libc/string/strncpy.3 b/lib/libc/string/strncpy.3
index 3a68a0bd5b8..03e617cca20 100644
--- a/lib/libc/string/strncpy.3
+++ b/lib/libc/string/strncpy.3
@@ -40,7 +40,7 @@
 .Sh SYNOPSIS
 .In string.h
 .Ft char *
-.Fn strncpy "char *dst" "const char *src" "size_t len"
+.Fn strncpy "char * restrict dst" "const char * restrict src" "size_t len"
 .Sh DESCRIPTION
 The
 .Fn strncpy
@@ -130,7 +130,7 @@ if (strlcpy(buf, input, sizeof(buf)) >= sizeof(buf))
 The
 .Fn strncpy
 function conforms to
-.St -ansiC .
+.St -iso-c99 .
 .Sh HISTORY
 The
 .Fn strncpy
diff --git a/lib/libc/string/strncpy.c b/lib/libc/string/strncpy.c
index d6d8647fc76..42df842836b 100644
--- a/lib/libc/string/strncpy.c
+++ b/lib/libc/string/strncpy.c
@@ -46,10 +46,10 @@ strncpy(char *dst, const char *src, size_t n)
                const char *s = src;

                do {
-                       if ((*d++ = *s++) == 0) {
+                       if ((*d++ = *s++) == '\0') {
                                /* NUL pad the remaining n-1 bytes */
                                while (--n != 0)
-                                       *d++ = 0;
+                                       *d++ = '\0';
                                break;
                        }
                } while (--n != 0);
diff --git a/lib/libc/string/strtok.3 b/lib/libc/string/strtok.3
index 0f1f359ec48..0cb3cfc98cc 100644
--- a/lib/libc/string/strtok.3
+++ b/lib/libc/string/strtok.3
@@ -41,9 +41,9 @@
 .Sh SYNOPSIS
 .In string.h
 .Ft char *
-.Fn strtok "char *str" "const char *sep"
+.Fn strtok "char * restrict str" "const char * restrict sep"
 .Ft char *
-.Fn strtok_r "char *str" "const char *sep" "char **last"
+.Fn strtok_r "char * restrict str" "const char * restrict sep" "char
** restrict last"
 .Sh DESCRIPTION
 .Bf -symbolic
 This interface is obsoleted by
@@ -138,7 +138,7 @@ will point to
 The
 .Fn strtok
 function conforms to
-.St -ansiC .
+.St -isoC-99.
 The
 .Fn strtok_r
 function conforms to
diff --git a/lib/libc/string/strtok.c b/lib/libc/string/strtok.c
index c5765756fcd..d1046c6c068 100644
--- a/lib/libc/string/strtok.c
+++ b/lib/libc/string/strtok.c
@@ -30,7 +30,7 @@
 #include <string.h>

 char *
-strtok(char *s, const char *delim)
+strtok(char * restrict s, const char * restrict delim)
 {
        static char *last;

@@ -39,7 +39,7 @@ strtok(char *s, const char *delim)
 DEF_STRONG(strtok);

 char *
-strtok_r(char *s, const char *delim, char **last)
+strtok_r(char * restrict s, const char * restrict delim, char ** restrict last)
 {
        const char *spanp;
        int c, sc;
diff --git a/lib/libc/string/strxfrm.3 b/lib/libc/string/strxfrm.3
index dab3673f38a..f8f19180e32 100644
--- a/lib/libc/string/strxfrm.3
+++ b/lib/libc/string/strxfrm.3
@@ -42,9 +42,9 @@
 .Sh SYNOPSIS
 .In string.h
 .Ft size_t
-.Fn strxfrm "char *dst" "const char *src" "size_t n"
+.Fn strxfrm "char * restrict dst" "const char * restrict src" "size_t n"
 .Ft size_t
-.Fn strxfrm_l "char *dst" "const char *src" "size_t n" "locale_t locale"
+.Fn strxfrm_l "char * restrict dst" "const char * restrict src"
"size_t n" "locale_t locale"
 .Sh DESCRIPTION
 The idea of
 .Fn strxfrm
diff --git a/lib/libc/string/strxfrm.c b/lib/libc/string/strxfrm.c
index 97df097b296..f7c589ea16e 100644
--- a/lib/libc/string/strxfrm.c
+++ b/lib/libc/string/strxfrm.c
@@ -39,7 +39,7 @@
  * on the original untransformed strings would return.
  */
 size_t
-strxfrm(char *dst, const char *src, size_t n)
+strxfrm(char * restrict dst, const char * restrict src, size_t n)
 {

        /*
diff --git a/lib/libc/string/strxfrm_l.c b/lib/libc/string/strxfrm_l.c
index ff77947953b..e46274998be 100644
--- a/lib/libc/string/strxfrm_l.c
+++ b/lib/libc/string/strxfrm_l.c
@@ -7,7 +7,7 @@
 #include <string.h>

 size_t
-strxfrm_l(char *dst, const char *src, size_t n,
+strxfrm_l(char * restrict dst, const char * restrict src, size_t n,
     locale_t locale __attribute__((__unused__)))
 {
        return strxfrm(dst, src, n);
diff --git a/lib/libc/string/wcscat.c b/lib/libc/string/wcscat.c
index 0525c3cb142..f9c9e4becfb 100644
--- a/lib/libc/string/wcscat.c
+++ b/lib/libc/string/wcscat.c
@@ -37,7 +37,7 @@ __warn_references(wcscat,
 #endif

 wchar_t *
-wcscat(wchar_t *s1, const wchar_t *s2)
+wcscat(wchar_t * restrict s1, const wchar_t * restrict s2)
 {
        wchar_t *p;
        wchar_t *q;
diff --git a/lib/libc/string/wcscpy.c b/lib/libc/string/wcscpy.c
index f7727524135..b8d40d5ae9d 100644
--- a/lib/libc/string/wcscpy.c
+++ b/lib/libc/string/wcscpy.c
@@ -37,7 +37,7 @@ __warn_references(wcscpy,
 #endif

 wchar_t *
-wcscpy(wchar_t *s1, const wchar_t *s2)
+wcscpy(wchar_t * restrict s1, const wchar_t * restrict s2)
 {
        wchar_t *p;
        const wchar_t *q;
diff --git a/lib/libc/string/wcslcat.c b/lib/libc/string/wcslcat.c
index 9949057df4e..38e514c6518 100644
--- a/lib/libc/string/wcslcat.c
+++ b/lib/libc/string/wcslcat.c
@@ -27,25 +27,24 @@
  * If retval >= siz, truncation occurred.
  */
 size_t
-wcslcat(wchar_t *dst, const wchar_t *src, size_t dsize)
+wcslcat(wchar_t * __restrict dst, const wchar_t * __restrict src, size_t dsize)
 {
        const wchar_t *odst = dst;
        const wchar_t *osrc = src;
-       size_t n = dsize;
+       size_t n;
        size_t dlen;

        /* Find the end of dst and adjust bytes left but don't go past end. */
-       while (n-- != 0 && *dst != L'\0')
+       for (n = dsize; n-- != 0 && *dst != L'\0'; n--)
                dst++;
        dlen = dst - odst;
        n = dsize - dlen;

-       if (n-- == 0)
+       if (n == 0)
                return(dlen + wcslen(src));
        while (*src != L'\0') {
-               if (n != 0) {
+               if (--n != 0) {
                        *dst++ = *src;
-                       n--;
                }
                src++;
        }
diff --git a/lib/libc/string/wcslcpy.c b/lib/libc/string/wcslcpy.c
index 9c433c83dc6..5b0057d254d 100644
--- a/lib/libc/string/wcslcpy.c
+++ b/lib/libc/string/wcslcpy.c
@@ -25,7 +25,7 @@
  * Returns wcslen(src); if retval >= dsize, truncation occurred.
  */
 size_t
-wcslcpy(wchar_t *dst, const wchar_t *src, size_t dsize)
+wcslcpy(wchar_t * __restrict dst, const wchar_t * __restrict src, size_t dsize)
 {
        const wchar_t *osrc = src;
        size_t nleft = dsize;
diff --git a/lib/libc/string/wcsncat.c b/lib/libc/string/wcsncat.c
index 2b4b9f0d491..f0d2d4e0a43 100644
--- a/lib/libc/string/wcsncat.c
+++ b/lib/libc/string/wcsncat.c
@@ -32,7 +32,7 @@
 #include <wchar.h>

 wchar_t *
-wcsncat(wchar_t *s1, const wchar_t *s2, size_t n)
+wcsncat(wchar_t * __restrict s1, const wchar_t * __restrict s2, size_t n)
 {
        wchar_t *p;
        wchar_t *q;
diff --git a/lib/libc/string/wcsncpy.c b/lib/libc/string/wcsncpy.c
index 1be482b1140..ef2b1672568 100644
--- a/lib/libc/string/wcsncpy.c
+++ b/lib/libc/string/wcsncpy.c
@@ -32,20 +32,19 @@
 #include <wchar.h>

 wchar_t *
-wcsncpy(wchar_t *s1, const wchar_t *s2, size_t n)
+wcsncpy(wchar_t * __restrict s1, const wchar_t * __restrict s2, size_t n)
 {
-       wchar_t *p;
+       wchar_t * const p = s1;

-       p = s1;
        while (n && *s2) {
-               *p++ = *s2++;
+               *s1++ = *s2++;
                n--;
        }
        while (n) {
-               *p++ = L'\0';
+               *s1++ = L'\0';
                n--;
        }

-       return s1;
+       return p;
 }
 DEF_STRONG(wcsncpy);
diff --git a/lib/libc/string/wmemcpy.c b/lib/libc/string/wmemcpy.c
index cf02ab9d566..2936090b6e4 100644
--- a/lib/libc/string/wmemcpy.c
+++ b/lib/libc/string/wmemcpy.c
@@ -33,7 +33,7 @@
 #include <wchar.h>

 wchar_t *
-wmemcpy(wchar_t *d, const wchar_t *s, size_t n)
+wmemcpy(wchar_t * __restrict d, const wchar_t * __restrict s, size_t n)
 {

        return (wchar_t *)memcpy(d, s, n * sizeof(wchar_t));
diff --git a/lib/libc/string/wmemset.c b/lib/libc/string/wmemset.c
index a2d3295170e..fb7a2875d65 100644
--- a/lib/libc/string/wmemset.c
+++ b/lib/libc/string/wmemset.c
@@ -34,14 +34,12 @@
 wchar_t        *
 wmemset(wchar_t *s, wchar_t c, size_t n)
 {
-       size_t i;
-       wchar_t *p;
+       wchar_t * const p = s;

-       p = s;
-       for (i = 0; i < n; i++) {
-               *p = c;
-               p++;
+       for (; n != 0; n--) {
+               *s++ = c;
        }
-       return s;
+
+       return p;
 }
 DEF_STRONG(wmemset);

Reply via email to