diff options
author | James Clarke <jrtc27@jrtc27.com> | 2020-01-07 19:19:22 +0000 |
---|---|---|
committer | James Clarke <jrtc27@jrtc27.com> | 2020-01-07 19:29:33 +0000 |
commit | fc43d5c7a02babe6865a51a7f2d4c94b3843db15 (patch) | |
tree | f48becb6730d7610b45d0b9e257533f0beec4e05 /c_emulator/riscv_sim.c | |
parent | a0180105233873505f9a1f264eb7888f28994030 (diff) | |
download | sail-riscv-fc43d5c7a02babe6865a51a7f2d4c94b3843db15.zip sail-riscv-fc43d5c7a02babe6865a51a7f2d4c94b3843db15.tar.gz sail-riscv-fc43d5c7a02babe6865a51a7f2d4c94b3843db15.tar.bz2 |
Fix parsing long options in the C emulator for RVFI-DII
idx, passed as longindex to getopt_long, is updated every time a long
option is parsed to be the index of that option in the options array,
not argv. We should instead use optind as in the non-RVFI-DII case, and
we can remove the variable to avoid confusion since it is unused.
Diffstat (limited to 'c_emulator/riscv_sim.c')
-rw-r--r-- | c_emulator/riscv_sim.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/c_emulator/riscv_sim.c b/c_emulator/riscv_sim.c index 2996011..686e3b4 100644 --- a/c_emulator/riscv_sim.c +++ b/c_emulator/riscv_sim.c @@ -193,7 +193,7 @@ static void read_dtb(const char *path) char *process_args(int argc, char **argv) { - int c, idx = 1; + int c; uint64_t ram_size = 0; while(true) { c = getopt_long(argc, argv, @@ -214,7 +214,7 @@ char *process_args(int argc, char **argv) "V::" "v::" "l:" - , options, &idx); + , options, NULL); if (c == -1) break; switch (c) { case 'a': @@ -299,7 +299,7 @@ char *process_args(int argc, char **argv) } if (do_dump_dts) dump_dts(); #ifdef RVFI_DII - if (idx > argc || (idx == argc && !rvfi_dii)) print_usage(argv[0], 0); + if (optind > argc || (optind == argc && !rvfi_dii)) print_usage(argv[0], 0); #else if (optind >= argc) { fprintf(stderr, "No elf file provided.\n"); |