diff mbox

[iproute] ip exit, ip and tc line number

Message ID 4B8D58D9.7050202@unipex.it
State Rejected, archived
Delegated to: stephen hemminger
Headers show

Commit Message

Michele Petrazzo - Unipex March 2, 2010, 6:28 p.m. UTC
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

Comments

stephen hemminger March 4, 2010, 12:30 a.m. UTC | #1
On Tue, 02 Mar 2010 19:28:41 +0100
Michele Petrazzo - Unipex <michele.petrazzo@unipex.it> wrote:

> 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.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

commit 805fac22865d50b561643e58f5c2c001439a6a7d
Author: Michele Petrazzo <michele.petrazzo@unipex.it>
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
    
    Signed-off-by: Michele Petrazzo <michele.petrazzo@unipex.it>

diff --git a/ip/ip.c b/ip/ip.c
index ace8cc6..b8c4914 100644
--- a/ip/ip.c
+++ b/ip/ip.c
@@ -125,6 +125,9 @@  static int batch(const char *name)
 			if (!force)
 				break;
 		}
+        else {
+            lineno++;
+        }
 	}
 	if (line)
 		free(line);
diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index e9256d9..8ec6cfd 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -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;
 }
diff --git a/tc/tc.c b/tc/tc.c
index 8e362d2..ce78621 100644
--- a/tc/tc.c
+++ b/tc/tc.c
@@ -250,6 +250,11 @@  static int batch(const char *name)
 			if (!force)
 				break;
 		}
+        else {
+            cmdlineno++;
+        }
+           
+
 	}
 	if (line)
 		free(line);