[Midnightbsd-cvs] src [9875] trunk/sys/boot/common/util.c: update

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Wed May 23 09:29:07 EDT 2018


Revision: 9875
          http://svnweb.midnightbsd.org/src/?rev=9875
Author:   laffer1
Date:     2018-05-23 09:29:06 -0400 (Wed, 23 May 2018)
Log Message:
-----------
update

Modified Paths:
--------------
    trunk/sys/boot/common/util.c

Modified: trunk/sys/boot/common/util.c
===================================================================
--- trunk/sys/boot/common/util.c	2018-05-23 13:28:46 UTC (rev 9874)
+++ trunk/sys/boot/common/util.c	2018-05-23 13:29:06 UTC (rev 9875)
@@ -68,9 +68,9 @@
 strncmp(const char *s1, const char *s2, size_t len)
 {
 
-	for (; *s1 == *s2 && *s1 != '\0' && len > 0; len--, s1++, s2++)
+	for (; len > 0 && *s1 == *s2 && *s1 != '\0'; len--, s1++, s2++)
 		;
-	return ((unsigned char)*s1 - (unsigned char)*s2);
+	return (len == 0 ? 0 : (unsigned char)*s1 - (unsigned char)*s2);
 }
 
 void



More information about the Midnightbsd-cvs mailing list