]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsmem: cleanup for --summary=only
authorKarel Zak <kzak@redhat.com>
Fri, 4 Nov 2016 09:50:06 +0000 (10:50 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 9 Nov 2016 09:02:32 +0000 (10:02 +0100)
* don't fill scols table
* check for collision with raw,pairs and json options

Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/lsmem.c

index 3ac1fd3bea3a13c91a928534f468d17f14d3402f..8ffd40975d99a46f27ecd1db15ed267f4f27ea81 100644 (file)
@@ -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
         */