ip a flush: unnecessarily chatty when there's nothing to flush

On tis, 2008-07-22 at 20:21 +0200, martin f krafft wrote:
> piper:~|master|% sudo ip a flush dev eth0 >/dev/null
> Nothing to flush.
>
> It should just shut up, shouldn't it? :)

The patch below makes the "Nothing to flush" only visible when show
statistics flag is given, and then only to stdout rather then stderr.

$ sudo ./ip/ip -s addr flush dev skif
Nothing to flush.
$ sudo ./ip/ip addr flush dev skif
$

(See http://bugs.debian.org/492196 )
This commit is contained in:
Andreas Henriksson 2008-08-29 19:52:48 +02:00 committed by Stephen Hemminger
parent 2ca4abdcb8
commit f0b34d2d98
3 changed files with 18 additions and 13 deletions

View File

@ -697,10 +697,12 @@ static int ipaddr_list_or_flush(int argc, char **argv, int flush)
exit(1); exit(1);
} }
if (filter.flushed == 0) { if (filter.flushed == 0) {
if (round == 0) { if (show_stats) {
fprintf(stderr, "Nothing to flush.\n"); if (round == 0)
} else if (show_stats) printf("Nothing to flush.\n");
printf("*** Flush is complete after %d round%s ***\n", round, round>1?"s":""); else
printf("*** Flush is complete after %d round%s ***\n", round, round>1?"s":"");
}
fflush(stdout); fflush(stdout);
return 0; return 0;
} }

View File

@ -402,10 +402,12 @@ int do_show_or_flush(int argc, char **argv, int flush)
exit(1); exit(1);
} }
if (filter.flushed == 0) { if (filter.flushed == 0) {
if (round == 0) { if (show_stats) {
fprintf(stderr, "Nothing to flush.\n"); if (round == 0)
} else if (show_stats) printf("Nothing to flush.\n");
printf("*** Flush is complete after %d round%s ***\n", round, round>1?"s":""); else
printf("*** Flush is complete after %d round%s ***\n", round, round>1?"s":"");
}
fflush(stdout); fflush(stdout);
return 0; return 0;
} }

View File

@ -1209,11 +1209,12 @@ static int iproute_list_or_flush(int argc, char **argv, int flush)
exit(1); exit(1);
} }
if (filter.flushed == 0) { if (filter.flushed == 0) {
if (round == 0) { if (show_stats) {
if (!filter.cloned || do_ipv6 == AF_INET6) if (round == 0 && (!filter.cloned || do_ipv6 == AF_INET6))
fprintf(stderr, "Nothing to flush.\n"); printf("Nothing to flush.\n");
} else if (show_stats) else
printf("*** Flush is complete after %d round%s ***\n", round, round>1?"s":""); printf("*** Flush is complete after %d round%s ***\n", round, round>1?"s":"");
}
fflush(stdout); fflush(stdout);
return 0; return 0;
} }