From ba24c1d230932a947324ea916cd2b932f2948f69 Mon Sep 17 00:00:00 2001 From: Nir Soffer Date: Aug 19 2014 16:16:14 +0000 Subject: reset: Improve error message when command is missing If some options were specified without any positional arguments, this confusing error message was displayed: $ sanlk-reset -i 42 lockspace_name is required Now more correct message is displayed: command is required Signed-off-by: Nir Soffer --- diff --git a/reset/sanlk_reset.c b/reset/sanlk_reset.c index 7093095..7a15ff9 100644 --- a/reset/sanlk_reset.c +++ b/reset/sanlk_reset.c @@ -553,12 +553,18 @@ int main(int argc, char *argv[]) } } + if (optind >= argc) { + fprintf(stderr, "command is required\n"); + exit(2); + } + + cmd = argv[optind]; + optind++; + ls_count = 0; for (i = optind; i < argc; i++) { - if (i == optind) { - cmd = argv[i]; - } else if (ls_count == MAX_LS) { + if (ls_count == MAX_LS) { fprintf(stderr, "ignore lockspace_name %s\n", argv[i]); } else { ls_names[ls_count] = argv[i];