Skip to content

Commit ece1827

Browse files
committed
target/riscv: avoid config modification on jim_getopt_obj() failure
Currently, `jim_getopt_obj()` only fails if `goi->argc` is zero, Link: https://github.com/riscv-collab/riscv-openocd/blob/41a225460c3b9a6c1f61a0777f101ff009f56007/src/helper/jim-nvp.c#L174-L185 so the check at the start of `jim_configure_ebreak()` Link: https://github.com/riscv-collab/riscv-openocd/blob/41a225460c3b9a6c1f61a0777f101ff009f56007/src/target/riscv/riscv.c#L526-L530 guarantees that the call will succeed. However, the modification makes the code more robust and future-proof. Change-Id: Ic8c2e057a285bf679d26e21bda138a1d2ae5d5ce Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com>
1 parent 41a2254 commit ece1827

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/target/riscv/riscv.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,9 +534,12 @@ static int jim_configure_ebreak(struct riscv_private_config *config, struct jim_
534534
/* Here a common "ebreak" action is processed, e.g:
535535
* "riscv.cpu configure -ebreak halt"
536536
*/
537+
int res = jim_getopt_obj(goi, NULL);
538+
if (res != JIM_OK)
539+
return res;
537540
for (int ebreak_ctl_i = 0; ebreak_ctl_i < N_RISCV_MODE; ++ebreak_ctl_i)
538541
config->dcsr_ebreak_fields[ebreak_ctl_i] = common_mode_nvp->value;
539-
return jim_getopt_obj(goi, NULL);
542+
return JIM_OK;
540543
}
541544

542545
/* Here a "ebreak" action for a specific execution mode is processed, e.g:

0 commit comments

Comments
 (0)