Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 13 Feb 2018 19:17:48 +0000 (UTC)
From:      Ed Maste <emaste@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r329237 - head/sys/libkern
Message-ID:  <201802131917.w1DJHmso047463@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: emaste
Date: Tue Feb 13 19:17:48 2018
New Revision: 329237
URL: https://svnweb.freebsd.org/changeset/base/329237

Log:
  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

Modified:
  head/sys/libkern/strcmp.c
  head/sys/libkern/strncat.c
  head/sys/libkern/strncpy.c
  head/sys/libkern/strsep.c
  head/sys/libkern/strstr.c

Modified: head/sys/libkern/strcmp.c
==============================================================================
--- head/sys/libkern/strcmp.c	Tue Feb 13 19:17:33 2018	(r329236)
+++ head/sys/libkern/strcmp.c	Tue Feb 13 19:17:48 2018	(r329237)
@@ -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));
 }

Modified: head/sys/libkern/strncat.c
==============================================================================
--- head/sys/libkern/strncat.c	Tue Feb 13 19:17:33 2018	(r329236)
+++ head/sys/libkern/strncat.c	Tue Feb 13 19:17:48 2018	(r329237)
@@ -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);
 }

Modified: head/sys/libkern/strncpy.c
==============================================================================
--- head/sys/libkern/strncpy.c	Tue Feb 13 19:17:33 2018	(r329236)
+++ head/sys/libkern/strncpy.c	Tue Feb 13 19:17:48 2018	(r329237)
@@ -49,10 +49,10 @@ strncpy(char * __restrict dst, const char * __restrict
 		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);

Modified: head/sys/libkern/strsep.c
==============================================================================
--- head/sys/libkern/strsep.c	Tue Feb 13 19:17:33 2018	(r329236)
+++ head/sys/libkern/strsep.c	Tue Feb 13 19:17:48 2018	(r329237)
@@ -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 */
 }

Modified: head/sys/libkern/strstr.c
==============================================================================
--- head/sys/libkern/strstr.c	Tue Feb 13 19:17:33 2018	(r329236)
+++ head/sys/libkern/strstr.c	Tue Feb 13 19:17:48 2018	(r329237)
@@ -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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201802131917.w1DJHmso047463>