* [patch] [iproute] ip exit, ip and tc line number
@ 2010-03-02 18:28 Michele Petrazzo - Unipex
2010-03-04 0:30 ` Stephen Hemminger
0 siblings, 1 reply; 3+ messages in thread
From: Michele Petrazzo - Unipex @ 2010-03-02 18:28 UTC (permalink / raw)
To: netdev
[-- Attachment #1: Type: text/plain, Size: 290 bytes --]
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
[-- Attachment #2: iproute.diff --]
[-- Type: text/x-diff, Size: 1476 bytes --]
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);
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [patch] [iproute] ip exit, ip and tc line number
2010-03-02 18:28 [patch] [iproute] ip exit, ip and tc line number Michele Petrazzo - Unipex
@ 2010-03-04 0:30 ` Stephen Hemminger
2010-03-06 18:56 ` Michele Petrazzo - Unipex
0 siblings, 1 reply; 3+ messages in thread
From: Stephen Hemminger @ 2010-03-04 0:30 UTC (permalink / raw)
To: Michele Petrazzo - Unipex; +Cc: netdev
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch] [iproute] ip exit, ip and tc line number
2010-03-04 0:30 ` Stephen Hemminger
@ 2010-03-06 18:56 ` Michele Petrazzo - Unipex
0 siblings, 0 replies; 3+ messages in thread
From: Michele Petrazzo - Unipex @ 2010-03-06 18:56 UTC (permalink / raw)
To: netdev
[-- Attachment #1: Type: text/plain, Size: 133 bytes --]
Stephen Hemminger wrote:
> The force issue is a different problem so please split out that part
> and resubmit.
Attached.
Michele
[-- Attachment #2: iproute.diff --]
[-- Type: text/x-diff, Size: 900 bytes --]
commit b1875eb9564da302ba79c01746ec9cf391d0d593
Author: Michele Petrazzo <michele.petrazzo@unipex.it>
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
Signed-off-by: Michele Petrazzo <michele.petrazzo@unipex.it>
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;
}
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-03-06 18:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-02 18:28 [patch] [iproute] ip exit, ip and tc line number Michele Petrazzo - Unipex
2010-03-04 0:30 ` Stephen Hemminger
2010-03-06 18:56 ` Michele Petrazzo - Unipex
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).