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 <nsoffer(a)redhat.com>
---
reset/sanlk_reset.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/reset/sanlk_reset.c b/reset/sanlk_reset.c
index 56cada3..267fe8e 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];
--
1.8.3.1
Show replies by thread