[gPXE-devel] [PATCH 30/31] [ipv6] convert a for loop to a while loop and remove a variable that isn't needed in inet6_ntoa

matthew at theiselins.net matthew at theiselins.net
Fri Jul 8 10:28:39 EDT 2011


From: Matthew Iselin <matthew at theiselins.net>

Signed-off-by: Matthew Iselin <matthew at theiselins.net>
---
 src/net/ipv6.c |   13 +++++--------
 1 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/src/net/ipv6.c b/src/net/ipv6.c
index fe8c7af..bfd78ca 100644
--- a/src/net/ipv6.c
+++ b/src/net/ipv6.c
@@ -542,18 +542,12 @@ char * inet6_ntoa ( struct in6_addr in6 ) {
 int inet6_aton ( const char *cp, struct in6_addr *inp ) {
 	char convbuf[40];
 	char *tmp = convbuf, *next = convbuf;
-	size_t i = 0, len = strlen ( cp );
+	size_t i = 0;
 	int ok;
 	char c;
 	
 	/* Verify a valid address. */
-	if ( ! len ) {
-		return 0;
-	}
-	
-	for ( ; i < len; i++ ) {
-		c = cp[i];
-		
+	while ( ( c = cp[i++] ) ) {
 		ok = c == ':';
 		ok = ok || ( ( c >= '0' ) && ( c <= '9' ) );
 		ok = ok || ( ( c >= 'a' ) && ( c <= 'f' ) );
@@ -563,6 +557,9 @@ int inet6_aton ( const char *cp, struct in6_addr *inp ) {
 			return 0;
 		}
 	}
+	if ( ! i ) {
+		return 0;
+	}
 	
 	strcpy ( convbuf, cp );
 	
-- 
1.7.2.5



More information about the gPXE-devel mailing list