]> rtime.felk.cvut.cz Git - lisovros/iproute2_canprio.git/commitdiff
ip a flush: unnecessarily chatty when there's nothing to flush
authorAndreas Henriksson <andreas@fatal.se>
Fri, 29 Aug 2008 17:52:48 +0000 (19:52 +0200)
committerStephen Hemminger <stephen.hemminger@vyatta.com>
Mon, 15 Sep 2008 20:57:12 +0000 (13:57 -0700)
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 )

ip/ipaddress.c
ip/ipneigh.c
ip/iproute.c

index 373312f2c4e128c29478a9282e0c0df3d8922a98..51471e86d3006eddc0a509d892a51bc2a44ef0ac 100644 (file)
@@ -697,10 +697,12 @@ static int ipaddr_list_or_flush(int argc, char **argv, int flush)
                                exit(1);
                        }
                        if (filter.flushed == 0) {
-                               if (round == 0) {
-                                       fprintf(stderr, "Nothing to flush.\n");
-                               } else if (show_stats)
-                                       printf("*** Flush is complete after %d round%s ***\n", round, round>1?"s":"");
+                               if (show_stats) {
+                                       if (round == 0)
+                                               printf("Nothing to flush.\n");
+                                       else 
+                                               printf("*** Flush is complete after %d round%s ***\n", round, round>1?"s":"");
+                               }
                                fflush(stdout);
                                return 0;
                        }
index fa0e41dc07b434aae4a98e0b82ca3d2885ee06b5..30c7c72dbd822e6c069029fe84b286dee4143bcf 100644 (file)
@@ -402,10 +402,12 @@ int do_show_or_flush(int argc, char **argv, int flush)
                                exit(1);
                        }
                        if (filter.flushed == 0) {
-                               if (round == 0) {
-                                       fprintf(stderr, "Nothing to flush.\n");
-                               } else if (show_stats)
-                                       printf("*** Flush is complete after %d round%s ***\n", round, round>1?"s":"");
+                               if (show_stats) {
+                                       if (round == 0)
+                                               printf("Nothing to flush.\n");
+                                       else
+                                               printf("*** Flush is complete after %d round%s ***\n", round, round>1?"s":"");
+                               }
                                fflush(stdout);
                                return 0;
                        }
index 2a8f3f839458486256d42f03e3f46504ab920830..6a2ea05f18bac186fdae0ac8c29c219920e1be18 100644 (file)
@@ -1209,11 +1209,12 @@ static int iproute_list_or_flush(int argc, char **argv, int flush)
                                exit(1);
                        }
                        if (filter.flushed == 0) {
-                               if (round == 0) {
-                                       if (!filter.cloned || do_ipv6 == AF_INET6)
-                                               fprintf(stderr, "Nothing to flush.\n");
-                               } else if (show_stats)
-                                       printf("*** Flush is complete after %d round%s ***\n", round, round>1?"s":"");
+                               if (show_stats) {
+                                       if (round == 0 && (!filter.cloned || do_ipv6 == AF_INET6))
+                                               printf("Nothing to flush.\n");
+                                       else
+                                               printf("*** Flush is complete after %d round%s ***\n", round, round>1?"s":"");
+                               }
                                fflush(stdout);
                                return 0;
                        }