From adb4ef6fb828baea8947d8e2d82c8f5a88b9ba82 Mon Sep 17 00:00:00 2001 From: emaste Date: Tue, 13 Feb 2018 19:17:48 +0000 Subject: [PATCH] libkern: use nul for terminating char rather than 0 Akin to the change made in r188080 for lib/libc/string/. Reported by: bde Sponsored by: The FreeBSD Foundation --- sys/libkern/strcmp.c | 2 +- sys/libkern/strncat.c | 4 ++-- sys/libkern/strncpy.c | 4 ++-- sys/libkern/strsep.c | 6 +++--- sys/libkern/strstr.c | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/sys/libkern/strcmp.c b/sys/libkern/strcmp.c index 2eb2c8232c24..fadbd30779ad 100644 --- a/sys/libkern/strcmp.c +++ b/sys/libkern/strcmp.c @@ -44,7 +44,7 @@ int strcmp(const char *s1, const char *s2) { while (*s1 == *s2++) - if (*s1++ == 0) + if (*s1++ == '\0') return (0); return (*(const unsigned char *)s1 - *(const unsigned char *)(s2 - 1)); } diff --git a/sys/libkern/strncat.c b/sys/libkern/strncat.c index 95d0ef963bdd..af73248ad5fe 100644 --- a/sys/libkern/strncat.c +++ b/sys/libkern/strncat.c @@ -53,11 +53,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/sys/libkern/strncpy.c b/sys/libkern/strncpy.c index db1eafbf8f26..9c73cb69ffcb 100644 --- a/sys/libkern/strncpy.c +++ b/sys/libkern/strncpy.c @@ -49,10 +49,10 @@ strncpy(char * __restrict dst, const char * __restrict 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/sys/libkern/strsep.c b/sys/libkern/strsep.c index fcc62a4ddd4f..bf44858c329f 100644 --- a/sys/libkern/strsep.c +++ b/sys/libkern/strsep.c @@ -64,14 +64,14 @@ strsep(char **stringp, const char *delim) spanp = delim; do { if ((sc = *spanp++) == c) { - if (c == 0) + if (c == '\0') s = NULL; else - s[-1] = 0; + s[-1] = '\0'; *stringp = s; return (tok); } - } while (sc != 0); + } while (sc != '\0'); } /* NOTREACHED */ } diff --git a/sys/libkern/strstr.c b/sys/libkern/strstr.c index 1454fbe0c705..4a9bafd1edeb 100644 --- a/sys/libkern/strstr.c +++ b/sys/libkern/strstr.c @@ -51,7 +51,7 @@ strstr(const char *s, const char *find) len = strlen(find); do { do { - if ((sc = *s++) == 0) + if ((sc = *s++) == '\0') return (NULL); } while (sc != c); } while (strncmp(s, find, len) != 0);