1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-22 14:28:07 +00:00

refactor(core/embed): replace ensure(secfalse,... with error_shutdown

[no changelog]
This commit is contained in:
cepetr 2024-06-13 14:49:56 +02:00 committed by cepetr
parent 0f1cac9695
commit ba56ff8483
7 changed files with 13 additions and 13 deletions

View File

@ -136,9 +136,9 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_trezorutils_memcpy_obj, 4, 5,
STATIC mp_obj_t mod_trezorutils_halt(size_t n_args, const mp_obj_t *args) {
mp_buffer_info_t msg = {0};
if (n_args > 0 && mp_get_buffer(args[0], &msg, MP_BUFFER_READ)) {
ensure(secfalse, msg.buf);
error_shutdown(msg.buf);
} else {
ensure(secfalse, "halt");
error_shutdown("halt");
}
return mp_const_none;
}

View File

@ -204,7 +204,7 @@ void check_and_replace_bootloader(void) {
(new_bld_hdr->hw_model != 0)) {
// reject non-model T bootloader
// 0 represents pre-model check bootloader
ensure(secfalse, "Incompatible embedded bootloader");
error_shutdown("Incompatible embedded bootloader");
}
}
// at this point, due to the previous check_image_model call, we know that the
@ -213,7 +213,7 @@ void check_and_replace_bootloader(void) {
// against the firmware hw_model.
else if (board_name != HW_MODEL) {
// reject incompatible bootloader
ensure(secfalse, "Incompatible embedded bootloader");
error_shutdown("Incompatible embedded bootloader");
}
ensure(flash_area_erase(&BOOTLOADER_AREA, NULL), NULL);

View File

@ -79,7 +79,7 @@ static secbool startswith(const char *s, const char *prefix) {
static void vcp_intr(void) {
display_clear();
ensure(secfalse, "vcp_intr");
error_shutdown("vcp_intr");
}
static char vcp_getchar(void) {

View File

@ -74,7 +74,7 @@ void i2c_init_instance(uint16_t idx, i2c_instance_t *instance) {
i2c_handle[idx].Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
if (HAL_OK != HAL_I2C_Init(&i2c_handle[idx])) {
ensure(secfalse, "I2C was not loaded properly.");
error_shutdown("I2C was not loaded properly.");
return;
}
}

View File

@ -99,7 +99,7 @@ void i2c_init_instance(uint16_t idx, i2c_instance_t *instance) {
i2c_handle[idx].Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
if (HAL_OK != HAL_I2C_Init(&i2c_handle[idx])) {
ensure(secfalse, "I2C was not loaded properly.");
error_shutdown("I2C was not loaded properly.");
return;
}
}

View File

@ -118,7 +118,7 @@ void display_deinit(void) {
void display_init(void) {
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
printf("%s\n", SDL_GetError());
ensure(secfalse, "SDL_Init error");
error_shutdown("SDL_Init error");
}
atexit(display_deinit);
@ -143,13 +143,13 @@ void display_init(void) {
free(window_title_alloc);
if (!WINDOW) {
printf("%s\n", SDL_GetError());
ensure(secfalse, "SDL_CreateWindow error");
error_shutdown("SDL_CreateWindow error");
}
RENDERER = SDL_CreateRenderer(WINDOW, -1, SDL_RENDERER_SOFTWARE);
if (!RENDERER) {
printf("%s\n", SDL_GetError());
SDL_DestroyWindow(WINDOW);
ensure(secfalse, "SDL_CreateRenderer error");
error_shutdown("SDL_CreateRenderer error");
}
SDL_SetRenderDrawColor(RENDERER, 0, 0, 0, 255);
SDL_RenderClear(RENDERER);

View File

@ -83,7 +83,7 @@ void display_init(void) {
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
printf("%s\n", SDL_GetError());
ensure(secfalse, "SDL_Init error");
error_shutdown("SDL_Init error");
}
atexit(display_deinit);
@ -108,13 +108,13 @@ void display_init(void) {
free(window_title_alloc);
if (!drv->window) {
printf("%s\n", SDL_GetError());
ensure(secfalse, "SDL_CreateWindow error");
error_shutdown("SDL_CreateWindow error");
}
drv->renderer = SDL_CreateRenderer(drv->window, -1, SDL_RENDERER_SOFTWARE);
if (!drv->renderer) {
printf("%s\n", SDL_GetError());
SDL_DestroyWindow(drv->window);
ensure(secfalse, "SDL_CreateRenderer error");
error_shutdown("SDL_CreateRenderer error");
}
SDL_SetRenderDrawColor(drv->renderer, 0, 0, 0, 255);
SDL_RenderClear(drv->renderer);