svn commit: trunk/busybox: networking

vda at busybox.net vda at busybox.net
Tue Dec 19 23:01:34 UTC 2006


Author: vda
Date: 2006-12-19 15:01:33 -0800 (Tue, 19 Dec 2006)
New Revision: 17009

Log:
ifupdown: parse() returning NULL and returning "" is not the same,
it turned out! wow... okay, fixing my buglet...


Modified:
   trunk/busybox/Makefile
   trunk/busybox/networking/ifupdown.c


Changeset:
Modified: trunk/busybox/Makefile
===================================================================
--- trunk/busybox/Makefile	2006-12-19 20:32:02 UTC (rev 17008)
+++ trunk/busybox/Makefile	2006-12-19 23:01:33 UTC (rev 17009)
@@ -573,7 +573,8 @@
       -Wl,--warn-common -Wl,--sort-common -Wl,--gc-sections \
       -Wl,--start-group $(busybox-all) -Wl,--end-group
 else
-      cmd_busybox__ ?= $(srctree)/scripts/trylink $(CC) -o $@ $(LDFLAGS) \
+      cmd_busybox__ ?= $(srctree)/scripts/trylink $(CC) $(LDFLAGS) \
+      -o $@ \
       -Wl,--warn-common -Wl,--sort-common -Wl,--gc-sections \
       -Wl,--start-group $(busybox-all) -Wl,--end-group
 endif

Modified: trunk/busybox/networking/ifupdown.c
===================================================================
--- trunk/busybox/networking/ifupdown.c	2006-12-19 20:32:02 UTC (rev 17008)
+++ trunk/busybox/networking/ifupdown.c	2006-12-19 23:01:33 UTC (rev 17009)
@@ -103,7 +103,7 @@
 #define FORCE (option_mask32 & OPT_force)
 #define NO_MAPPINGS (option_mask32 & OPT_no_mappings)
 
-static char **__myenviron;
+static char **my_environ;
 
 static char *startup_PATH;
 
@@ -187,7 +187,7 @@
 	size_t old_pos[MAX_OPT_DEPTH] = { 0 };
 	int okay[MAX_OPT_DEPTH] = { 1 };
 	int opt_depth = 1;
-	char *result = xstrdup("");
+	char *result = NULL;
 
 	while (*command) {
 		switch (*command) {
@@ -206,7 +206,7 @@
 			break;
 		case '[':
 			if (command[1] == '[' && opt_depth < MAX_OPT_DEPTH) {
-				old_pos[opt_depth] = strlen(result);
+				old_pos[opt_depth] = result ? strlen(result) : 0;
 				okay[opt_depth] = 1;
 				opt_depth++;
 				command += 2;
@@ -290,7 +290,7 @@
 	int ret;
 
 	out = parse(command, ifd);
-	if (!out || !out[0]) {
+	if (!out) {
 		return 0;
 	}
 	ret = (*exec)(out);
@@ -871,15 +871,15 @@
 	const int n_env_entries = iface->n_options + 5;
 	char **ppch;
 
-	if (__myenviron != NULL) {
-		for (ppch = __myenviron; *ppch; ppch++) {
+	if (my_environ != NULL) {
+		for (ppch = my_environ; *ppch; ppch++) {
 			free(*ppch);
 			*ppch = NULL;
 		}
-		free(__myenviron);
+		free(my_environ);
 	}
-	__myenviron = xzalloc(sizeof(char *) * (n_env_entries + 1 /* for final NULL */ ));
-	environend = __myenviron;
+	my_environ = xzalloc(sizeof(char *) * (n_env_entries + 1 /* for final NULL */ ));
+	environend = my_environ;
 
 	for (i = 0; i < iface->n_options; i++) {
 		if (strcmp(iface->option[i].name, "up") == 0
@@ -903,6 +903,9 @@
 	if (option_mask32 & (OPT_no_act|OPT_verbose)) {
 		puts(str);
 	}
+	/* FIXME: is it true that we can reach this place with str = ""? */
+	/* how? in execute() parse() may return "", then we do (*exec)(""); */
+	/* Please add a comment... */
 	if (!(option_mask32 & OPT_no_act)) {
 		pid_t child;
 		int status;
@@ -912,7 +915,7 @@
 		case -1: /* failure */
 			return 0;
 		case 0: /* child */
-			execle(DEFAULT_SHELL, DEFAULT_SHELL, "-c", str, NULL, __myenviron);
+			execle(DEFAULT_SHELL, DEFAULT_SHELL, "-c", str, NULL, my_environ);
 			exit(127);
 		}
 		waitpid(child, &status, 0);
@@ -1206,7 +1209,7 @@
 				okay = 1;
 				currif->iface = iface;
 
-				debug_noise("\nZ Configuring interface %s (%s)\n", liface, currif->address_family->name);
+				debug_noise("\nConfiguring interface %s (%s)\n", liface, currif->address_family->name);
 
 				/* Call the cmds function pointer, does either iface_up() or iface_down() */
 				cmds_ret = cmds(currif);




More information about the busybox-cvs mailing list