From cbe9216ee4ec190db04a8896acc91966dd2e1183 Mon Sep 17 00:00:00 2001 From: Paul Luse Date: Tue, 17 Oct 2017 13:42:00 -0700 Subject: [PATCH] blobcli: fix incorrect error message If a config file is specified an error message would incorrectly print. Change-Id: I532762f6e6ed26bd213255b0e67663035fc1620e Signed-off-by: Paul Luse Reviewed-on: https://review.gerrithub.io/382876 Reviewed-by: Jim Harris Tested-by: SPDK Automated Test System --- examples/blob/cli/blobcli.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/blob/cli/blobcli.c b/examples/blob/cli/blobcli.c index 6da9d82bf..f9d714e8a 100644 --- a/examples/blob/cli/blobcli.c +++ b/examples/blob/cli/blobcli.c @@ -958,12 +958,14 @@ cmd_parser(int argc, char **argv, struct cli_context_t *cli_context) int op; int cmd_chosen = 0; char resp; + bool cfg_specified = false; while ((op = getopt(argc, argv, "c:d:f:hil:m:n:p:r:s:ST:Xx:")) != -1) { switch (op) { case 'c': if (cli_context->app_started == false) { cmd_chosen++; + cfg_specified = true; cli_context->config_file = optarg; } else { usage(cli_context, "ERROR: -c option not valid during shell mode.\n"); @@ -1086,10 +1088,8 @@ cmd_parser(int argc, char **argv, struct cli_context_t *cli_context) usage(cli_context, "ERROR: invalid option\n"); } /* config file is the only option that can be combined */ - if (op != 'c') { - if (cmd_chosen > 1) { - usage(cli_context, "Error: Please choose only one command\n"); - } + if (cfg_specified == false && cmd_chosen > 1) { + usage(cli_context, "Error: Please choose only one command\n"); } }