Skip to content

Commit

Permalink
target: use boolean values for 'valid' and 'dirty' flags
Browse files Browse the repository at this point in the history
Convert to boolean the remaining numeric assignment and comparison

Change-Id: Idc25221d93e85236185aab9ee36f0a379939c89c
Signed-off-by: Antonio Borneo <[email protected]>
Reviewed-on: https://review.openocd.org/c/openocd/+/7961
Reviewed-by: zapb <[email protected]>
Tested-by: jenkins
  • Loading branch information
borneoa committed Nov 18, 2023
1 parent 5587710 commit b39072f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
10 changes: 5 additions & 5 deletions src/target/arc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1265,8 +1265,8 @@ static int arc_resume(struct target *target, int current, target_addr_t address,
/* current = 1: continue on current PC, otherwise continue at <address> */
if (!current) {
target_buffer_set_u32(target, pc->value, address);
pc->dirty = 1;
pc->valid = 1;
pc->dirty = true;
pc->valid = true;
LOG_DEBUG("Changing the value of current PC to 0x%08" TARGET_PRIxADDR, address);
}

Expand All @@ -1281,7 +1281,7 @@ static int arc_resume(struct target *target, int current, target_addr_t address,
resume_pc, pc->dirty, pc->valid);

/* check if GDB tells to set our PC where to continue from */
if ((pc->valid == 1) && (resume_pc == target_buffer_get_u32(target, pc->value))) {
if (pc->valid && resume_pc == target_buffer_get_u32(target, pc->value)) {
value = target_buffer_get_u32(target, pc->value);
LOG_DEBUG("resume Core (when start-core) with PC @:0x%08" PRIx32, value);
CHECK_RETVAL(arc_jtag_write_aux_reg_one(&arc->jtag_info, AUX_PC_REG, value));
Expand Down Expand Up @@ -2007,8 +2007,8 @@ static int arc_step(struct target *target, int current, target_addr_t address,
/* current = 1: continue on current pc, otherwise continue at <address> */
if (!current) {
buf_set_u32(pc->value, 0, 32, address);
pc->dirty = 1;
pc->valid = 1;
pc->dirty = true;
pc->valid = true;
}

LOG_DEBUG("Target steps one instruction from PC=0x%" PRIx32,
Expand Down
4 changes: 2 additions & 2 deletions src/target/etm.c
Original file line number Diff line number Diff line change
Expand Up @@ -552,8 +552,8 @@ static int etm_set_reg(struct reg *reg, uint32_t value)
}

buf_set_u32(reg->value, 0, reg->size, value);
reg->valid = 1;
reg->dirty = 0;
reg->valid = true;
reg->dirty = false;

return ERROR_OK;
}
Expand Down
16 changes: 8 additions & 8 deletions src/target/mips64.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,8 @@ static int mips64_set_core_reg(struct reg *reg, uint8_t *buf)
return ERROR_TARGET_NOT_HALTED;

buf_set_u64(reg->value, 0, 64, value);
reg->dirty = 1;
reg->valid = 1;
reg->dirty = true;
reg->valid = true;

return ERROR_OK;
}
Expand All @@ -265,8 +265,8 @@ static int mips64_read_core_reg(struct target *target, int num)

reg_value = mips64->core_regs[num];
buf_set_u64(mips64->core_cache->reg_list[num].value, 0, 64, reg_value);
mips64->core_cache->reg_list[num].valid = 1;
mips64->core_cache->reg_list[num].dirty = 0;
mips64->core_cache->reg_list[num].valid = true;
mips64->core_cache->reg_list[num].dirty = false;

return ERROR_OK;
}
Expand All @@ -284,8 +284,8 @@ static int mips64_write_core_reg(struct target *target, int num)
reg_value = buf_get_u64(mips64->core_cache->reg_list[num].value, 0, 64);
mips64->core_regs[num] = reg_value;
LOG_DEBUG("write core reg %i value 0x%" PRIx64 "", num, reg_value);
mips64->core_cache->reg_list[num].valid = 1;
mips64->core_cache->reg_list[num].dirty = 0;
mips64->core_cache->reg_list[num].valid = true;
mips64->core_cache->reg_list[num].dirty = false;

return ERROR_OK;
}
Expand All @@ -297,8 +297,8 @@ int mips64_invalidate_core_regs(struct target *target)
unsigned int i;

for (i = 0; i < mips64->core_cache->num_regs; i++) {
mips64->core_cache->reg_list[i].valid = 0;
mips64->core_cache->reg_list[i].dirty = 0;
mips64->core_cache->reg_list[i].valid = false;
mips64->core_cache->reg_list[i].dirty = false;
}

return ERROR_OK;
Expand Down
8 changes: 4 additions & 4 deletions src/target/mips_mips64.c
Original file line number Diff line number Diff line change
Expand Up @@ -625,8 +625,8 @@ static int mips_mips64_resume(struct target *target, int current,
/* current = 1: continue on current pc, otherwise continue at <address> */
if (!current) {
buf_set_u64(pc->value, 0, 64, address);
pc->dirty = 1;
pc->valid = 1;
pc->dirty = true;
pc->valid = true;
}

resume_pc = buf_get_u64(pc->value, 0, 64);
Expand Down Expand Up @@ -717,8 +717,8 @@ static int mips_mips64_step(struct target *target, int current,
* <address> */
if (!current) {
buf_set_u64(pc->value, 0, 64, address);
pc->dirty = 1;
pc->valid = 1;
pc->dirty = true;
pc->valid = true;
}

/* the front-end may request us not to handle breakpoints */
Expand Down

0 comments on commit b39072f

Please sign in to comment.