Skip to contentSkip to conversation

ip exit, ip and tc line number

PATCH In review Michele Petrazzo - Unipex 2 participants 3 messages Mar 2, 2010 – Mar 6, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ip exit, ip and tc line number

Hi,
I create a small patch that solve an annoying problem that I found on "ip -batch" usage, so the command exits without end the parsing of the batch file also if I specify the -force switch. Also add the shown of the right line number where batch file fail for both ip and tc

Michele

commit 805fac22865d50b561643e58f5c2c001439a6a7d

Author: Michele Petrazzo <[email protected]>
Date:   Tue Mar 2 19:12:50 2010 +0100

Resolving "ip" exit on batch usage and add to ip and tc commands the right line number on the output message then use with batch switch

ip/ip.c +3 -0
index ace8cc6..b8c4914 100644
@@ -125,6 +125,9 @@ static int batch(const char *name)
 			if (!force)
 				break;
 		}
+        else {
+            lineno++;
+        }
 	}
 	if (line)
 		free(line);
ip/ipaddress.c +2 -2
index e9256d9..8ec6cfd 100644
@@ -1014,7 +1014,7 @@ static int ipaddr_modify(int cmd, int flags, int argc, char **argv)
 	}
 	if (l && matches(d, l) != 0) {
 		fprintf(stderr, "\"dev\" (%s) must match \"label\" (%s).\n", d, l);
-		exit(1);
+		return -1;
 	}
 
 	if (peer_len == 0 && local_len) {
@@ -1079,7 +1079,7 @@ static int ipaddr_modify(int cmd, int flags, int argc, char **argv)
 	}
 
 	if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0)
-		exit(2);
+		return -2;
 
 	return 0;
 }
tc/tc.c +5 -0
index 8e362d2..ce78621 100644
@@ -250,6 +250,11 @@ static int batch(const char *name)
 			if (!force)
 				break;
 		}
+        else {
+            cmdlineno++;
+        }
+           
+
 	}
 	if (line)
 		free(line);
#1 lore raw
Quoted 8 lines · On Tue, 02 Mar 2010 19:28:41 +0100 Michele Petrazzo - Unipex…

Hi,
I create a small patch that solve an annoying problem that I found on "ip -batch" usage, so the command exits without end the parsing of the batch file also if I specify the -force switch.
Also add the shown of the right line number where batch file fail for both ip and tc

Michele

The line number stuff is wrong, but the real problem was that ip was counting lineno rather than using cmdlineno which is done by getcmdline(). I will fix that.

The force issue is a different problem so please split out that part and resubmit.

#2 lore raw
Quoted 2 lines · Stephen Hemminger

The force issue is a different problem so please split out that part and resubmit.

Attached.

Michele

commit b1875eb9564da302ba79c01746ec9cf391d0d593

Author: Michele Petrazzo <[email protected]>
Date:   Sat Mar 6 19:45:27 2010 +0100

Allow ip to process all the file passed with the -batch argument when is passed also the -force switch

ip/ipaddress.c +2 -2
index e9256d9..8ec6cfd 100644
@@ -1014,7 +1014,7 @@ static int ipaddr_modify(int cmd, int flags, int argc, char **argv)
 	}
 	if (l && matches(d, l) != 0) {
 		fprintf(stderr, "\"dev\" (%s) must match \"label\" (%s).\n", d, l);
-		exit(1);
+		return -1;
 	}
 
 	if (peer_len == 0 && local_len) {
@@ -1079,7 +1079,7 @@ static int ipaddr_modify(int cmd, int flags, int argc, char **argv)
 	}
 
 	if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0)
-		exit(2);
+		return -2;
 
 	return 0;
 }