Skip to content

Commit

Permalink
target/riscv: Consistent data type for trigger indexes
Browse files Browse the repository at this point in the history
Cosmetic detail: Use `unsigned int` to index triggers
(as opposed to riscv_reg_t), which corresponds to
the data type of `trigger_count` in `struct riscv_info_t`.

Change-Id: I83539abdffa41aec2060fbd0c81496ab9607c9ea
Signed-off-by: Jan Matyas <[email protected]>
  • Loading branch information
Jan Matyas committed Oct 3, 2024
1 parent 841b61a commit 5dae5ef
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/target/riscv/riscv.c
Original file line number Diff line number Diff line change
Expand Up @@ -5023,9 +5023,9 @@ static COMMAND_HELPER(report_reserved_triggers, struct target *target)
if (riscv_enumerate_triggers(target) != ERROR_OK)
return ERROR_FAIL;
const char *separator = "";
for (riscv_reg_t t = 0; t < r->trigger_count; ++t) {
for (unsigned int t = 0; t < r->trigger_count; ++t) {
if (r->reserved_triggers[t]) {
command_print_sameline(CMD, "%s%" PRIu64, separator, t);
command_print_sameline(CMD, "%s%u", separator, t);
separator = " ";
}
}
Expand All @@ -5042,8 +5042,8 @@ COMMAND_HANDLER(handle_reserve_trigger)
if (CMD_ARGC != 2)
return ERROR_COMMAND_SYNTAX_ERROR;

riscv_reg_t t;
COMMAND_PARSE_NUMBER(u64, CMD_ARGV[0], t);
unsigned int t;
COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], t);

if (riscv_enumerate_triggers(target) != ERROR_OK)
return ERROR_FAIL;
Expand All @@ -5053,15 +5053,15 @@ COMMAND_HANDLER(handle_reserve_trigger)
return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
}
if (t >= r->trigger_count) {
command_print(CMD, "Error: trigger with index %" PRIu64
command_print(CMD, "Error: trigger with index %u"
" does not exist. There are only %u triggers"
" on the target (with indexes 0 .. %u).",
t, r->trigger_count, r->trigger_count - 1);
return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
}
if (r->trigger_unique_id[t] != -1) {
command_print(CMD, "Error: trigger with index %" PRIu64
" is already in use and can not be reserved.", t);
command_print(CMD, "Error: trigger with index %u"
" is already in use and cannot be reserved.", t);
return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
}
COMMAND_PARSE_ON_OFF(CMD_ARGV[1], r->reserved_triggers[t]);
Expand Down

0 comments on commit 5dae5ef

Please sign in to comment.