Merge pull request #978 from riscv/static_checks
Clean up clang static analyzer complaints.
This commit is contained in:
commit
feff8e0054
|
@ -425,6 +425,8 @@ static dbus_status_t dbus_scan(struct target *target, uint16_t *address_in,
|
||||||
.out_value = out,
|
.out_value = out,
|
||||||
.in_value = in
|
.in_value = in
|
||||||
};
|
};
|
||||||
|
if (address_in)
|
||||||
|
*address_in = 0;
|
||||||
|
|
||||||
if (info->addrbits == 0) {
|
if (info->addrbits == 0) {
|
||||||
LOG_TARGET_ERROR(target, "Can't access DMI because addrbits=0.");
|
LOG_TARGET_ERROR(target, "Can't access DMI because addrbits=0.");
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
static int riscv013_on_step_or_resume(struct target *target, bool step);
|
static int riscv013_on_step_or_resume(struct target *target, bool step);
|
||||||
static int riscv013_step_or_resume_current_hart(struct target *target,
|
static int riscv013_step_or_resume_current_hart(struct target *target,
|
||||||
bool step);
|
bool step);
|
||||||
static void riscv013_clear_abstract_error(struct target *target);
|
static int riscv013_clear_abstract_error(struct target *target);
|
||||||
|
|
||||||
/* Implementations of the functions in struct riscv_info. */
|
/* Implementations of the functions in struct riscv_info. */
|
||||||
static int riscv013_get_register(struct target *target,
|
static int riscv013_get_register(struct target *target,
|
||||||
|
@ -907,11 +907,11 @@ static riscv_reg_t read_abstract_arg(struct target *target, unsigned index,
|
||||||
LOG_TARGET_ERROR(target, "Unsupported size: %d bits", size_bits);
|
LOG_TARGET_ERROR(target, "Unsupported size: %d bits", size_bits);
|
||||||
return ~0;
|
return ~0;
|
||||||
case 64:
|
case 64:
|
||||||
dm_read(target, &v, DM_DATA0 + offset + 1);
|
if (dm_read(target, &v, DM_DATA0 + offset + 1) == ERROR_OK)
|
||||||
value |= ((uint64_t) v) << 32;
|
value |= ((uint64_t)v) << 32;
|
||||||
/* falls through */
|
/* falls through */
|
||||||
case 32:
|
case 32:
|
||||||
dm_read(target, &v, DM_DATA0 + offset);
|
if (dm_read(target, &v, DM_DATA0 + offset) == ERROR_OK)
|
||||||
value |= v;
|
value |= v;
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
|
@ -1181,9 +1181,14 @@ static int prep_for_register_access(struct target *target,
|
||||||
{
|
{
|
||||||
assert(orig_mstatus);
|
assert(orig_mstatus);
|
||||||
|
|
||||||
if (!is_fpu_reg(regno) && !is_vector_reg(regno))
|
if (!is_fpu_reg(regno) && !is_vector_reg(regno)) {
|
||||||
|
/* If we don't assign orig_mstatus, clang static analysis
|
||||||
|
* complains when this value is passed to
|
||||||
|
* cleanup_after_register_access(). */
|
||||||
|
*orig_mstatus = 0;
|
||||||
/* No special preparation needed */
|
/* No special preparation needed */
|
||||||
return ERROR_OK;
|
return ERROR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
LOG_TARGET_DEBUG(target, "Preparing mstatus to access %s",
|
LOG_TARGET_DEBUG(target, "Preparing mstatus to access %s",
|
||||||
gdb_regno_name(target, regno));
|
gdb_regno_name(target, regno));
|
||||||
|
@ -2999,11 +3004,11 @@ static target_addr_t sb_read_address(struct target *target)
|
||||||
target_addr_t address = 0;
|
target_addr_t address = 0;
|
||||||
uint32_t v;
|
uint32_t v;
|
||||||
if (sbasize > 32) {
|
if (sbasize > 32) {
|
||||||
dm_read(target, &v, DM_SBADDRESS1);
|
if (dm_read(target, &v, DM_SBADDRESS1) == ERROR_OK)
|
||||||
address |= v;
|
address |= v;
|
||||||
address <<= 32;
|
address <<= 32;
|
||||||
}
|
}
|
||||||
dm_read(target, &v, DM_SBADDRESS0);
|
if (dm_read(target, &v, DM_SBADDRESS0) == ERROR_OK)
|
||||||
address |= v;
|
address |= v;
|
||||||
return address;
|
return address;
|
||||||
}
|
}
|
||||||
|
@ -5076,8 +5081,10 @@ static int riscv013_write_debug_buffer(struct target *target, unsigned int index
|
||||||
static riscv_insn_t riscv013_read_debug_buffer(struct target *target, unsigned int index)
|
static riscv_insn_t riscv013_read_debug_buffer(struct target *target, unsigned int index)
|
||||||
{
|
{
|
||||||
uint32_t value;
|
uint32_t value;
|
||||||
dm_read(target, &value, DM_PROGBUF0 + index);
|
if (dm_read(target, &value, DM_PROGBUF0 + index) == ERROR_OK)
|
||||||
return value;
|
return value;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int riscv013_invalidate_cached_debug_buffer(struct target *target)
|
static int riscv013_invalidate_cached_debug_buffer(struct target *target)
|
||||||
|
@ -5229,24 +5236,12 @@ static int riscv013_step_or_resume_current_hart(struct target *target,
|
||||||
return ERROR_FAIL;
|
return ERROR_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void riscv013_clear_abstract_error(struct target *target)
|
static int riscv013_clear_abstract_error(struct target *target)
|
||||||
{
|
{
|
||||||
/* Wait for busy to go away. */
|
|
||||||
time_t start = time(NULL);
|
|
||||||
uint32_t abstractcs;
|
uint32_t abstractcs;
|
||||||
dm_read(target, &abstractcs, DM_ABSTRACTCS);
|
int result = wait_for_idle(target, &abstractcs);
|
||||||
while (get_field(abstractcs, DM_ABSTRACTCS_BUSY)) {
|
/* Clear the error status, even if busy is still set. */
|
||||||
dm_read(target, &abstractcs, DM_ABSTRACTCS);
|
if (dm_write(target, DM_ABSTRACTCS, DM_ABSTRACTCS_CMDERR) != ERROR_OK)
|
||||||
|
result = ERROR_FAIL;
|
||||||
if (time(NULL) - start > riscv_command_timeout_sec) {
|
return result;
|
||||||
LOG_TARGET_ERROR(target, "abstractcs.busy is not going low after %d seconds "
|
|
||||||
"(abstractcs=0x%x). The target is either really slow or "
|
|
||||||
"broken. You could increase the timeout with riscv "
|
|
||||||
"set_command_timeout_sec.",
|
|
||||||
riscv_command_timeout_sec, abstractcs);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* Clear the error status. */
|
|
||||||
dm_write(target, DM_ABSTRACTCS, DM_ABSTRACTCS_CMDERR);
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue