1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

riotboot: don't always return error in riotboot_flashwrite_finish_raw()

If `CONFIG_RIOTBOOT_FLASHWRITE_RAW` is not set, `riotboot_flashwrite_finish_raw()`
will always return `-1` as `res` is not set anywhere else.

Fix this by only returning -1 in the error case.
This commit is contained in:
Benjamin Valentin 2020-11-18 16:13:47 +01:00
parent 34c252d0e6
commit e697d93e02

View File

@ -155,8 +155,6 @@ int riotboot_flashwrite_finish_raw(riotboot_flashwrite_t *state,
{
assert(len <= FLASHPAGE_SIZE);
int res = -1;
uint8_t *slot_start = (uint8_t *)riotboot_slot_get_hdr(state->target_slot);
#if CONFIG_RIOTBOOT_FLASHWRITE_RAW
@ -179,11 +177,11 @@ int riotboot_flashwrite_finish_raw(riotboot_flashwrite_t *state,
int flashpage = flashpage_page((void *)slot_start);
if (flashpage_write_and_verify(flashpage, firstpage) == FLASHPAGE_OK) {
LOG_INFO(LOG_PREFIX "riotboot flashing completed successfully\n");
res = 0;
}
else {
LOG_WARNING(LOG_PREFIX "re-flashing first block failed!\n");
return -1;
}
#endif /* !CONFIG_RIOTBOOT_FLASHWRITE_RAW */
return res;
return 0;
}