Skip to content

Commit 64f30dc

Browse files
committed
Clean up return type of riscv_progbuf_size() + related
SSIA Change-Id: I3e0b2fad84411c530f56cdbe33f3d8b4dbf81cf6 Signed-off-by: Jan Matyas <[email protected]>
1 parent b272470 commit 64f30dc

File tree

5 files changed

+11
-13
lines changed

5 files changed

+11
-13
lines changed

src/target/riscv/program.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ int riscv_program_init(struct riscv_program *p, struct target *target)
2020
p->target = target;
2121
p->instruction_count = 0;
2222

23-
for (size_t i = 0; i < RISCV_MAX_PROGBUF_SIZE; ++i)
23+
for (unsigned int i = 0; i < RISCV013_MAX_PROGBUF_SIZE; ++i)
2424
p->progbuf[i] = (uint32_t)(-1);
2525

2626
p->execution_result = RISCV_PROGBUF_EXEC_RESULT_NOT_EXECUTED;
@@ -47,9 +47,9 @@ int riscv_program_exec(struct riscv_program *p, struct target *t)
4747

4848
if (riscv_program_ebreak(p) != ERROR_OK) {
4949
LOG_TARGET_ERROR(t, "Unable to insert ebreak into program buffer");
50-
for (size_t i = 0; i < riscv_progbuf_size(p->target); ++i)
50+
for (unsigned int i = 0; i < riscv_progbuf_size(p->target); ++i)
5151
LOG_TARGET_ERROR(t, "progbuf[%02x]: DASM(0x%08" PRIx32 ") [0x%08" PRIx32 "]",
52-
(int)i, p->progbuf[i], p->progbuf[i]);
52+
i, p->progbuf[i], p->progbuf[i]);
5353
return ERROR_FAIL;
5454
}
5555

@@ -198,8 +198,8 @@ int riscv_program_insert(struct riscv_program *p, riscv_insn_t i)
198198
{
199199
if (p->instruction_count >= riscv_progbuf_size(p->target)) {
200200
LOG_TARGET_ERROR(p->target, "Unable to insert program into progbuf, "
201-
"capacity would be exceeded (progbufsize=%d).",
202-
(int)riscv_progbuf_size(p->target));
201+
"capacity would be exceeded (progbufsize=%u).",
202+
riscv_progbuf_size(p->target));
203203
return ERROR_FAIL;
204204
}
205205

src/target/riscv/program.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55

66
#include "riscv.h"
77

8-
#define RISCV_MAX_PROGBUF_SIZE 32
9-
#define RISCV_REGISTER_COUNT 32
10-
#define RISCV_DSCRATCH_COUNT 2
8+
#define RISCV013_MAX_PROGBUF_SIZE 16
119

1210
typedef enum {
1311
RISCV_PROGBUF_EXEC_RESULT_NOT_EXECUTED,
@@ -23,10 +21,10 @@ typedef enum {
2321
struct riscv_program {
2422
struct target *target;
2523

26-
uint32_t progbuf[RISCV_MAX_PROGBUF_SIZE];
24+
uint32_t progbuf[RISCV013_MAX_PROGBUF_SIZE];
2725

2826
/* Number of 32-bit instructions in the program. */
29-
size_t instruction_count;
27+
unsigned int instruction_count;
3028

3129
/* execution result of the program */
3230
/* TODO: remove this field. We should make it a parameter to riscv_program_exec */

src/target/riscv/riscv-013.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5338,7 +5338,7 @@ static enum riscv_halt_reason riscv013_halt_reason(struct target *target)
53385338

53395339
static int riscv013_write_progbuf(struct target *target, unsigned int index, riscv_insn_t data)
53405340
{
5341-
assert(index < RISCV_MAX_PROGBUF_SIZE);
5341+
assert(index < RISCV013_MAX_PROGBUF_SIZE);
53425342

53435343
dm013_info_t *dm = get_dm(target);
53445344
if (!dm)

src/target/riscv/riscv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6048,7 +6048,7 @@ static enum riscv_halt_reason riscv_halt_reason(struct target *target)
60486048
return r->halt_reason(target);
60496049
}
60506050

6051-
size_t riscv_progbuf_size(struct target *target)
6051+
unsigned int riscv_progbuf_size(struct target *target)
60526052
{
60536053
RISCV_INFO(r);
60546054
return r->get_progbufsize(target);

src/target/riscv/riscv.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ int riscv_get_hart_state(struct target *target, enum riscv_hart_state *state);
473473

474474
/* These helper functions let the generic program interface get target-specific
475475
* information. */
476-
size_t riscv_progbuf_size(struct target *target);
476+
unsigned int riscv_progbuf_size(struct target *target);
477477

478478
riscv_insn_t riscv_read_progbuf(struct target *target, int index);
479479
int riscv_write_progbuf(struct target *target, unsigned int index, riscv_insn_t insn);

0 commit comments

Comments
 (0)