From: Sami Kerola Date: Wed, 6 Aug 2014 09:35:30 +0000 (+0100) Subject: zramctl: improve option combination error messaging X-Git-Tag: v2.26-rc1~535 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1fa6c3e0b963ef5da43607fcec682541b40dcab1;p=thirdparty%2Futil-linux.git zramctl: improve option combination error messaging Use of --algorithm or --streams is not expected to work without reseting device, that happens when --size is specified, so ensure the former options to be combined with the later. [kzak@redhat.com: - make it more generic] Signed-off-by: Sami Kerola Signed-off-by: Karel Zak --- diff --git a/sys-utils/zramctl.c b/sys-utils/zramctl.c index 63c2c131ae..961dba1d06 100644 --- a/sys-utils/zramctl.c +++ b/sys-utils/zramctl.c @@ -505,11 +505,12 @@ int main(int argc, char **argv) if (act != A_RESET && optind + 1 < argc) errx(EXIT_FAILURE, _("only one at a time is allowed")); + if ((act == A_STATUS || act == A_FINDONLY) && (algorithm || nstreams)) + errx(EXIT_FAILURE, _("options --algorithm and --streams " + "must be combined with --size")); + switch (act) { case A_STATUS: - if (algorithm || find || nstreams) - errx(EXIT_FAILURE, _("options --algorithm, --find and " - "--streams are mutually exclusive")); if (!ncolumns) { /* default columns */ columns[ncolumns++] = COL_NAME; columns[ncolumns++] = COL_ALGORITHM;