[PATCH] remove obsolete(?) code that handles net if aliases

Robert P. J. Day rpjday at mindspring.com
Tue Jun 20 09:21:51 PDT 2006


  this patch simply wipes out the code in interface.c/get_name() that
handles an optional alias portion after the interface name in the file
/proc/net/dev.  it would *seem* that, according to an earlier
commenter, that code hasn't been necessary in a while, but i'm quite
willing to be overruled.

rday

p.s.  of course, the current code is technically correct but why waste
the bytes?
-------------- next part --------------
diff -pru busybox/networking/interface.c busybox.new/networking/interface.c
--- busybox/networking/interface.c	2006-06-20 12:13:38.000000000 -0400
+++ busybox.new/networking/interface.c	2006-06-20 12:15:54.000000000 -0400
@@ -444,22 +444,16 @@ static int if_readconf(void)
 
 static char *get_name(char *name, char *p)
 {
-	/* Extract <name>[:<alias>] from nul-terminated p where p matches
-	   <name>[:<alias>]: after leading whitespace.
+	/* Extract <name> from nul-terminated p where p matches
+	   <name>: after leading whitespace.
 	   If match is not made, set name empty and return unchanged p */
-	int namestart=0, nameend=0, aliasend;
+	int namestart=0, nameend=0;
 	while (isspace(p[namestart]))
 		namestart++;
 	nameend=namestart;
 	while (p[nameend] && p[nameend]!=':' && !isspace(p[nameend]))
 		nameend++;
 	if (p[nameend]==':') {
-		aliasend=nameend+1;
-		while (p[aliasend] && isdigit(p[aliasend]))
-			aliasend++;
-		if (p[aliasend]==':') {
-			nameend=aliasend;
-		}
 		if ((nameend-namestart)<IFNAMSIZ) {
 			memcpy(name,&p[namestart],nameend-namestart);
 			name[nameend-namestart]='\0';
@@ -469,7 +463,7 @@ static char *get_name(char *name, char *
 			name[0]='\0';
 		}
 	} else {
-		/* first ':' not found - return empty */
+		/* trailing ':' not found - return empty */
 		name[0]='\0';
 	}
 	return p + 1;


More information about the busybox mailing list