Skip to content

Commit

Permalink
Fix a bug in arg parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
viega committed Sep 7, 2023
1 parent 168089e commit 1c66f8b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tests/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@
#define HATRACK_DEFAULT_OPS 100000
#define HATRACK_DEFAULT_NUM_KEYS 1000

enum
{
enum {
OPT_DEFAULT,
OPT_YES,
OPT_NO
Expand Down Expand Up @@ -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();
}

Expand All @@ -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':
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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];
Expand Down

0 comments on commit 1c66f8b

Please sign in to comment.