Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 25 Sep 2014 22:22:58 +0000 (UTC)
From:      Xin LI <delphij@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r272143 - head/contrib/hyperv/tools
Message-ID:  <201409252222.s8PMMwMX036412@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: delphij
Date: Thu Sep 25 22:22:57 2014
New Revision: 272143
URL: http://svnweb.freebsd.org/changeset/base/272143

Log:
  Use a char * as iterator over a bounded string.
  
  MFC after:	1 week

Modified:
  head/contrib/hyperv/tools/hv_kvp_daemon.c

Modified: head/contrib/hyperv/tools/hv_kvp_daemon.c
==============================================================================
--- head/contrib/hyperv/tools/hv_kvp_daemon.c	Thu Sep 25 22:22:54 2014	(r272142)
+++ head/contrib/hyperv/tools/hv_kvp_daemon.c	Thu Sep 25 22:22:57 2014	(r272143)
@@ -601,8 +601,7 @@ kvp_mac_to_if_name(char *mac)
 	struct ifaddrs *head_ifaddrs_ptr;
 	struct sockaddr_dl *sdl;
 	int status;
-	size_t i;
-	char *buf_ptr;
+	char *buf_ptr, *p;
 
 	status = getifaddrs(&ifaddrs_ptr);
 
@@ -613,8 +612,8 @@ kvp_mac_to_if_name(char *mac)
 			if (sdl->sdl_type == IFT_ETHER) {
 				buf_ptr = strdup(ether_ntoa((struct ether_addr *)(LLADDR(sdl))));
 				if (buf_ptr != NULL) {
-					for (i = 0; i < strlen(buf_ptr); i++)
-						buf_ptr[i] = toupper(buf_ptr[i]);
+					for (p = buf_ptr; *p != '\0'; p++)
+						*p = toupper(*p);
 
 					if (strncmp(buf_ptr, mac, strlen(mac)) == 0) {
 						/* Caller will free the memory */



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