Fix some clang static checker complaints. (#464)
The OpenOCD project looks at this, so once in a while I go through and make sure our code is OK. Change-Id: I50032c847f30e93604d83d6366cfad85918d6e66
This commit is contained in:
parent
60eccb2967
commit
3967f48843
|
@ -496,7 +496,7 @@ static int fespi_write(struct flash_bank *bank, const uint8_t *buffer,
|
|||
{
|
||||
struct target *target = bank->target;
|
||||
struct fespi_flash_bank *fespi_info = bank->driver_priv;
|
||||
uint32_t cur_count, page_size, page_offset;
|
||||
uint32_t cur_count, page_size;
|
||||
int sector;
|
||||
int retval = ERROR_OK;
|
||||
|
||||
|
@ -548,21 +548,22 @@ static int fespi_write(struct flash_bank *bank, const uint8_t *buffer,
|
|||
algorithm_wa->address, retval);
|
||||
target_free_working_area(target, algorithm_wa);
|
||||
algorithm_wa = NULL;
|
||||
}
|
||||
|
||||
data_wa_size = MIN(target->working_area_size - algorithm_wa->size, count);
|
||||
while (1) {
|
||||
if (data_wa_size < 128) {
|
||||
LOG_WARNING("Couldn't allocate data working area.");
|
||||
target_free_working_area(target, algorithm_wa);
|
||||
algorithm_wa = NULL;
|
||||
}
|
||||
if (target_alloc_working_area_try(target, data_wa_size, &data_wa) ==
|
||||
ERROR_OK) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
data_wa_size = MIN(target->working_area_size - algorithm_wa->size, count);
|
||||
while (1) {
|
||||
if (data_wa_size < 128) {
|
||||
LOG_WARNING("Couldn't allocate data working area.");
|
||||
target_free_working_area(target, algorithm_wa);
|
||||
algorithm_wa = NULL;
|
||||
}
|
||||
if (target_alloc_working_area_try(target, data_wa_size, &data_wa) ==
|
||||
ERROR_OK) {
|
||||
break;
|
||||
}
|
||||
|
||||
data_wa_size = data_wa_size * 3 / 4;
|
||||
data_wa_size = data_wa_size * 3 / 4;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
LOG_WARNING("Couldn't allocate %zd-byte working area.", bin_size);
|
||||
|
@ -621,7 +622,6 @@ static int fespi_write(struct flash_bank *bank, const uint8_t *buffer,
|
|||
goto err;
|
||||
}
|
||||
|
||||
page_offset = 0;
|
||||
buffer += cur_count;
|
||||
offset += cur_count;
|
||||
count -= cur_count;
|
||||
|
@ -642,7 +642,7 @@ static int fespi_write(struct flash_bank *bank, const uint8_t *buffer,
|
|||
if (retval != ERROR_OK)
|
||||
goto err;
|
||||
|
||||
page_offset = offset % page_size;
|
||||
uint32_t page_offset = offset % page_size;
|
||||
/* central part, aligned words */
|
||||
while (count > 0) {
|
||||
/* clip block at page boundary */
|
||||
|
|
|
@ -524,6 +524,8 @@ static dmi_status_t dmi_scan(struct target *target, uint32_t *address_in,
|
|||
int retval = jtag_execute_queue();
|
||||
if (retval != ERROR_OK) {
|
||||
LOG_ERROR("dmi_scan failed jtag scan");
|
||||
if (data_in)
|
||||
*data_in = ~0;
|
||||
return DMI_STATUS_FAILED;
|
||||
}
|
||||
|
||||
|
@ -1094,6 +1096,8 @@ static int prep_for_register_access(struct target *target, uint64_t *mstatus,
|
|||
set_field(*mstatus, MSTATUS_VS, 1)) != ERROR_OK)
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
} else {
|
||||
*mstatus = 0;
|
||||
}
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
@ -1220,7 +1224,7 @@ static int scratch_read64(struct target *target, scratch_mem_t *scratch,
|
|||
break;
|
||||
case SPACE_DMI_RAM:
|
||||
{
|
||||
uint8_t buffer[8];
|
||||
uint8_t buffer[8] = {0};
|
||||
if (read_memory(target, scratch->debug_address, 4, 2, buffer) != ERROR_OK)
|
||||
return ERROR_FAIL;
|
||||
*value = buffer[0] |
|
||||
|
|
Loading…
Reference in New Issue