iscsi-perf: Add -h/--help

Add -h/--help to show usage without "Unrecognized option".

Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
This commit is contained in:
zhenwei pi
2023-05-30 16:54:51 +08:00
committed by Bart Van Assche
parent 22f7b26567
commit 2b9d5bdbad

View File

@@ -268,6 +268,7 @@ int main(int argc, char *argv[])
{"random-blocks", no_argument, NULL, 'R'},
{"logging", no_argument, NULL, 'l'},
{"ignore-errors", no_argument, NULL, 'n'},
{"help", no_argument, NULL, 'h'},
{0, 0, 0, 0}
};
int option_index;
@@ -279,7 +280,7 @@ int main(int argc, char *argv[])
printf("iscsi-perf version %s - (c) 2014-2015 by Peter Lieven <pl@ĸamp.de>\n\n", PERF_VERSION);
while ((c = getopt_long(argc, argv, "i:m:b:t:lnrRx:", long_options,
while ((c = getopt_long(argc, argv, "i:m:b:t:lnrRx:h", long_options,
&option_index)) != -1) {
switch (c) {
case 'i':
@@ -309,6 +310,9 @@ int main(int argc, char *argv[])
case 'x':
client.max_reconnects = atoi(optarg);
break;
case 'h':
usage();
break;
default:
fprintf(stderr, "Unrecognized option '%c'\n\n", c);
usage();