- Make sure that help is displayed and not just the message "Unknown option" when the options are incorrect. - Add -q to the man page and to the print_help() Signed-off-by: John Kacur <jkacur@xxxxxxxxxx> --- src/queuelat/queuelat.8 | 4 +++- src/queuelat/queuelat.c | 22 +++++++++++++--------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/queuelat/queuelat.8 b/src/queuelat/queuelat.8 index d68beb98bff7..f67a0bb7556e 100644 --- a/src/queuelat/queuelat.8 +++ b/src/queuelat/queuelat.8 @@ -52,7 +52,9 @@ TSC frequency in MHz. .TP .B \-t timeout Timeout in seconds to quit the program. - +.TP +.B \-q min_queue_len_to_print_trace +Minimum queue length to print in the trace .SH AUTHOR queuelat was written by Marcelo Tosatti <mtosatti@xxxxxxxxxx> diff --git a/src/queuelat/queuelat.c b/src/queuelat/queuelat.c index 98346f346f82..7e5e35768a8b 100644 --- a/src/queuelat/queuelat.c +++ b/src/queuelat/queuelat.c @@ -571,6 +571,7 @@ void print_help(void) printf("-p million-packet-per-sec (million packets per second) (float)\n"); printf("-f tsc-freq-mhz (TSC frequency in MHz) (float)\n"); printf("-t timeout (timeout, in seconds) (int)\n"); + printf("-q min_queue_len_to_print_trace (int)\n"); } int main(int argc, char **argv) @@ -616,22 +617,25 @@ int main(int argc, char **argv) return 0; case '?': if (optopt == 'm' || optopt == 'c' || optopt == 'p' || - optopt == 'f' || optopt == 't' || optopt == 'q') + optopt == 'f' || optopt == 't' || optopt == 'q') { printf ("Option -%c requires an argument.\n", optopt); - else if (isprint (optopt)) + } else if (isprint (optopt)) { printf ("Unknown option `-%c'.\n", optopt); - else - printf ( "Unknown option character `\\x%x'.\n", - -optopt); + print_help(); + return 1; + } else { + printf ( "Unknown option character `\\x%x'.\n", optopt); + print_help(); return 1; - default: - abort (); + } + break; + default: + abort (); } if (mvalue == NULL || cvalue == NULL || pvalue == NULL || fvalue == NULL) { - printf("options -m, -c, -p and -f required.\n"); + printf("options -m, -c, -p and -f are required.\n"); printf("usage: %s -m maxlatency -c cycles_per_packet -p mpps(million-packet-per-sec) -f tsc_freq_mhz [-t timeout (in secs)] [-q min_queue_len_to_print_trace]\n", argv[0]); return 1; } -- 2.20.1