From d4625442c7f0974b32a81f56c2e96dd71c2be184 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Fri, 4 Nov 2016 10:50:06 +0100 Subject: lsmem: cleanup for --summary=only * don't fill scols table * check for collision with raw,pairs and json options Signed-off-by: Karel Zak --- sys-utils/lsmem.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'sys-utils/lsmem.c') diff --git a/sys-utils/lsmem.c b/sys-utils/lsmem.c index 3ac1fd3be..8ffd40975 100644 --- a/sys-utils/lsmem.c +++ b/sys-utils/lsmem.c @@ -493,6 +493,17 @@ int main(int argc, char **argv) if (argc != optind) lsmem_usage(stderr); + if (lsmem->want_table + lsmem->want_summary == 0) + errx(EXIT_FAILURE, _("options --{raw,json,pairs} and --summary=only are mutually exclusive")); + + /* Shortcut to avoid scols machinery on --summary=only */ + if (lsmem->want_table == 0 && lsmem->want_summary) { + read_basic_info(lsmem); + read_info(lsmem); + print_summary(lsmem); + return EXIT_SUCCESS; + } + /* * Default columns */ -- cgit v1.2.3-55-g7522