Skip to content

Commit 0337caa

Browse files
committed
Simplify file descriptor handling
1 parent a36f35e commit 0337caa

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ This feature can be utilized for tests involving the emulator, such as compiler
179179
You can also combine this option with `-q` to directly use the output.
180180
For example, if you want to read the register x10 (a0), then run the following command:
181181
```shell
182-
$ build/rv32emu -d - out.elf -q | jq .x10
182+
$ build/rv32emu -d - -q out.elf | jq .x10
183183
```
184184

185185
## RISC-V Instructions/Registers Usage Statistics

src/emulate.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,13 +1038,7 @@ void ecall_handler(riscv_t *rv)
10381038

10391039
void dump_registers(riscv_t *rv, char *out_file_path)
10401040
{
1041-
FILE *f;
1042-
if (!strncmp(out_file_path, "-", 1)) {
1043-
f = stdout;
1044-
} else {
1045-
f = fopen(out_file_path, "w");
1046-
}
1047-
1041+
FILE *f = out_file_path[0] == '-' ? stdout : fopen(out_file_path, "w");
10481042
if (!f) {
10491043
fprintf(stderr, "Cannot open registers output file.\n");
10501044
return;

0 commit comments

Comments
 (0)