svn commit: r318678 - head/sys/boot/common

Mariusz Zaborski oshogbo at FreeBSD.org
Mon May 22 20:11:42 UTC 2017


Author: oshogbo
Date: Mon May 22 20:11:40 2017
New Revision: 318678
URL: https://svnweb.freebsd.org/changeset/base/318678

Log:
  Replacing iterating over rootpath by strsep(3).
  
  Submitted by:	kczekirda
  Reviewed by:	tsoome, bapt, jhb, oshogbo
  MFC after:	3 weeks
  Sponsored by:	Oktawave
  Differential Revision:	https://reviews.freebsd.org/D10726

Modified:
  head/sys/boot/common/dev_net.c

Modified: head/sys/boot/common/dev_net.c
==============================================================================
--- head/sys/boot/common/dev_net.c	Mon May 22 20:00:01 2017	(r318677)
+++ head/sys/boot/common/dev_net.c	Mon May 22 20:11:40 2017	(r318678)
@@ -387,16 +387,14 @@ net_print(int verbose)
 uint32_t
 net_parse_rootpath()
 {
-	int i;
 	n_long addr = INADDR_NONE;
+	char *ptr;
 
-	for (i = 0; rootpath[i] != '\0' && i < FNAME_SIZE; i++)
-		if (rootpath[i] == ':')
-			break;
-	if (i && i != FNAME_SIZE && rootpath[i] == ':') {
-		rootpath[i++] = '\0';
-		addr = inet_addr(&rootpath[0]);
-		bcopy(&rootpath[i], rootpath, strlen(&rootpath[i])+1);
+	ptr = rootpath;
+	(void)strsep(&ptr, ":");
+	if (ptr != NULL) {
+		addr = inet_addr(rootpath);
+		bcopy(ptr, rootpath, strlen(ptr) + 1);
 	}
 
 	return (addr);


More information about the svn-src-head mailing list