From 2b9d5bdbad34a989d10de2d93a2b7c05d5305c21 Mon Sep 17 00:00:00 2001 From: zhenwei pi Date: Tue, 30 May 2023 16:54:51 +0800 Subject: [PATCH] iscsi-perf: Add -h/--help Add -h/--help to show usage without "Unrecognized option". Signed-off-by: zhenwei pi --- utils/iscsi-perf.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/utils/iscsi-perf.c b/utils/iscsi-perf.c index f91496d..86bf11a 100644 --- a/utils/iscsi-perf.c +++ b/utils/iscsi-perf.c @@ -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 \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();