Commit Graph

24 Commits

Author SHA1 Message Date
Matteo Croce
8589eb4efd treewide: refactor help messages
Every tool in the iproute2 package have one or more function to show
an help message to the user. Some of these functions print the help
line by line with a series of printf call, e.g. ip/xfrm_state.c does
60 fprintf calls.
If we group all the calls to a single one and just concatenate strings,
we save a lot of libc calls and thus object size. The size difference
of the compiled binaries calculated with bloat-o-meter is:

        ip/ip:
        add/remove: 0/0 grow/shrink: 5/15 up/down: 103/-4796 (-4693)
        Total: Before=672591, After=667898, chg -0.70%
        ip/rtmon:
        add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-54 (-54)
        Total: Before=48879, After=48825, chg -0.11%
        tc/tc:
        add/remove: 0/2 grow/shrink: 31/10 up/down: 882/-6133 (-5251)
        Total: Before=351912, After=346661, chg -1.49%
        bridge/bridge:
        add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-459 (-459)
        Total: Before=70502, After=70043, chg -0.65%
        misc/lnstat:
        add/remove: 0/1 grow/shrink: 1/0 up/down: 48/-486 (-438)
        Total: Before=9960, After=9522, chg -4.40%
        tipc/tipc:
        add/remove: 0/0 grow/shrink: 1/1 up/down: 18/-62 (-44)
        Total: Before=79182, After=79138, chg -0.06%

While at it, indent some strings which were starting at column 0,
and use tabs where possible, to have a consistent style across helps.

Signed-off-by: Matteo Croce <mcroce@redhat.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
2019-05-20 14:35:07 -07:00
Phil Sutter
f89bb0210f Replace malloc && memset by calloc
This only replaces occurrences where the newly allocated memory is
cleared completely afterwards, as in other cases it is a theoretical
performance hit although code would be cleaner this way.

Signed-off-by: Phil Sutter <phil@nwl.cc>
Acked-by: David Ahern <dsa@cumulusnetworks.com>
2016-07-20 12:05:24 -07:00
Stephen Hemminger
acd1e437be misc: fix style issues
More checkpatch spring cleaning
2016-03-21 11:56:36 -07:00
Phil Sutter
fdb347f7fd lnstat: fix header displaying mechanism
The algorithm depends on the loop counter ('i') to increment by one in
each iteration. Though if running endlessly (count==0), the counter was
not incremented at all.

Also change formatting of the header printing conditional a bit so it's
hopefully easier to read.

Fixes: e7e2913 ("lnstat: run indefinitely by default")
Signed-off-by: Phil Sutter <phil@nwl.cc>
2015-11-23 15:54:05 -08:00
Phil Sutter
869fcabecc lnstat: describe -s option in help output
Signed-off-by: Phil Sutter <phil@nwl.cc>
2015-11-23 15:54:05 -08:00
Stephen Hemminger
1473bda921 misc: cleanup extra whitespace
No blank lines at end of file
2015-10-23 15:44:30 -07:00
Stephen Hemminger
fcc16c2287 provide common json output formatter
Formatting JSON is moderately painful.
Provide a simple API to do the syntax formatting.
2015-08-23 10:05:29 -07:00
Pavel Šimerda
b1410e0ab1 lnstat: dump to stdout, not stderr
See also:

 * https://bugzilla.redhat.com/show_bug.cgi?id=736332

Signed-off-by: Pavel Šimerda <psimerda@redhat.com>
2015-04-20 09:58:46 -07:00
Pavel Šimerda
e7e2913fe4 lnstat: run indefinitely by default
See also:

 * https://bugzilla.redhat.com/show_bug.cgi?id=977845

Signed-off-by: Pavel Šimerda <psimerda@redhat.com>
2015-04-20 09:58:11 -07:00
Stephen Hemminger
3d0b7439df whitespace cleanup
Remove all trailing whitespace and space before tabs.
2014-12-20 15:47:17 -08:00
Stephen Hemminger
468dec75a5 Fix non-literal string format warnings
The lnstat program was building a format string, then using it.
This was safe, but simpler to just use format character * to
get width.
2014-05-29 10:49:55 -07:00
Stephen Hemminger
a4f9e8df37 lnstat: add json output format 2013-09-24 11:55:27 -07:00
Kamil Rytarowski
824c843556 iproute2 patch against GCC 4.8.0
Hello!

I'm attaching a patch [1] "Feed GCC 4.8.0 against new warning that is
shipped with -Wall: -Wsizeof-pointer-memaccess.".

More details: http://gcc.gnu.org/gcc-4.8/porting_to.html

Regards,

[1] 0001-Feed-GCC-4.8.0-against-new-warning-that-is-shipped-w.patch

>From 1f3ea01fe2ff61cbbca6474f7d9903a0756a4f44 Mon Sep 17 00:00:00 2001
From: Kamil Rytarowski <n54@gmx.com>
Date: Fri, 3 May 2013 18:43:38 +0200
Subject: [PATCH] Feed GCC 4.8.0 against new warning that is shipped with
 -Wall: -Wsizeof-pointer-memaccess.
2013-05-03 12:10:09 -07:00
Petr Sabata
7e8bd80e38 iproute2: lnstat - fix typos
Signed-off-by: Petr Sabata <contyk@redhat.com>
2011-10-06 08:25:05 -07:00
Stephen Hemminger
f309d0ae43 Add warning message when MAX_FIELDS reached
Don't just silently drop.
2008-06-30 11:57:13 -07:00
Stephen Hemminger
f493dc3009 Fix array out of bounds problem
The current kernel generates 71 possible header fields, but
MAX_FIELDS in lnstat is only 64. This leads to referencing outside
of the array. To fix, increase size of array and chop off parsing
at MAX_FIELDS - 1.
2008-06-30 10:37:28 -07:00
Eric Dumazet
f50332c57a lnstat : force a flush before sleep
Hi Stephen

This small patch allows to use lnstat/rtstat with a pipe output, without a full bufferisation.

Thank you
Eric

Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
2007-10-11 12:40:15 -07:00
Stephen Hemminger
ae665a522b Remove trailing whitespace
Go through source files and remove all trailing whitespace

Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
2006-12-05 10:10:22 -08:00
shemminger
49843e291d Set default count for lnstat 2006-03-10 23:19:03 +00:00
osdl.net!shemminger
e796b9587a Fix compile warning.
(Logical change 1.172)
2005-03-18 19:40:19 +00:00
osdl.net!shemminger
627c228ef5 Style change
2005/03/10 12:26:43-08:00 net[shemminger]!shemminger
Import patch iproute-batch.1.050209.patch

(Logical change 1.164)
2005-03-14 19:04:49 +00:00
osdl.net!shemminger
0bb187ca0e Add const on strings and make sure not to crash
when there is no slash in argv[0]

(Logical change 1.102)
2004-10-19 20:47:13 +00:00
osdl.net!shemminger
8b3c3abb63 Initial revision 2004-10-19 20:21:14 +00:00
osdl.net!shemminger
056eb9d8dd (Logical change 1.98) 2004-10-19 20:21:14 +00:00