From 1c66f8b0f485d2b0d9e09bd075e6d2c16d46414e Mon Sep 17 00:00:00 2001 From: John Viega Date: Thu, 7 Sep 2023 17:53:03 -0400 Subject: [PATCH] Fix a bug in arg parsing --- tests/config.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/config.c b/tests/config.c index 8df84b1..7b5bb5f 100644 --- a/tests/config.c +++ b/tests/config.c @@ -49,8 +49,7 @@ #define HATRACK_DEFAULT_OPS 100000 #define HATRACK_DEFAULT_NUM_KEYS 1000 -enum -{ +enum { OPT_DEFAULT, OPT_YES, OPT_NO @@ -315,6 +314,7 @@ try_parse_seed_arg(char *p, char *flag_name, bool *b, __int128_t *seedp) } if (*p++ != '=') { + printf("Bad seed; no arg to flag"); usage(); } @@ -323,6 +323,7 @@ try_parse_seed_arg(char *p, char *flag_name, bool *b, __int128_t *seedp) do { switch (*p) { case 0: + printf("Bad seed value, must be hex.\n"); usage(); // Only runs for the first iteration. case '0': case '1': @@ -421,8 +422,7 @@ try_parse_int_arg(char *p, char *flag_name, bool *b, unsigned int *var) } ensure_unspecd(b, flag_name); - - *var = parse_int(p); + *var = parse_int(s); return true; } @@ -515,6 +515,7 @@ parse_args(int argc, char *argv[]) usage(); } if (cur_len < 3 || cur[1] != '-') { + fprintf(stderr, "Long flags require a double dash."); usage(); } p = &cur[2];