diff --git a/embed/boardloader/main.c b/embed/boardloader/main.c index dc9a512f1..78f8f79c9 100644 --- a/embed/boardloader/main.c +++ b/embed/boardloader/main.c @@ -151,13 +151,13 @@ int main(void) clear_otg_hs_memory(); periph_init(); - trassert(0 == display_init(), NULL); - trassert(0 == flash_init(), NULL); - trassert(0 == sdcard_init(), NULL); + ensure(0 == display_init(), NULL); + ensure(0 == flash_init(), NULL); + ensure(0 == sdcard_init(), NULL); if (check_sdcard()) { if (!copy_sdcard()) { - trassert(true == copy_sdcard(), NULL); + ensure(true == copy_sdcard(), NULL); } else { for (;;); } @@ -165,7 +165,7 @@ int main(void) check_and_jump(); - trassert(0, "halt"); + ensure(0, "halt"); return 0; } diff --git a/embed/bootloader/main.c b/embed/bootloader/main.c index e76787a0e..4166ed466 100644 --- a/embed/bootloader/main.c +++ b/embed/bootloader/main.c @@ -128,17 +128,17 @@ int usb_init_all(void) { .report_desc = hid_report_desc, }; - trassert(0 == usb_init(&dev_info), NULL); - trassert(0 == usb_hid_add(&hid_info), NULL); - trassert(0 == usb_start(), NULL); + ensure(0 == usb_init(&dev_info), NULL); + ensure(0 == usb_hid_add(&hid_info), NULL); + ensure(0 == usb_start(), NULL); return 0; } void mainloop(void) { - trassert(0 == flash_init(), NULL); - trassert(0 == usb_init_all(), NULL); + ensure(0 == flash_init(), NULL); + ensure(0 == usb_init_all(), NULL); display_clear(); @@ -149,7 +149,7 @@ void mainloop(void) if (r != USB_PACKET_SIZE) { continue; } - trassert(r == USB_PACKET_SIZE, NULL); + ensure(r == USB_PACKET_SIZE, NULL); uint16_t msg_id; uint32_t msg_size; if (!msg_parse_header(buf, &msg_id, &msg_size)) { @@ -190,12 +190,12 @@ void check_bootloader_version(void) bits[i / 8] |= (1 << (7 - (i % 8))); } } - trassert(true == flash_otp_write(BOOTLOADER_VERSION_OTP_BLOCK, 0, bits, FLASH_OTP_BLOCK_SIZE), NULL); + ensure(true == flash_otp_write(BOOTLOADER_VERSION_OTP_BLOCK, 0, bits, FLASH_OTP_BLOCK_SIZE), NULL); uint8_t bits2[FLASH_OTP_BLOCK_SIZE]; - trassert(true == flash_otp_read(BOOTLOADER_VERSION_OTP_BLOCK, 0, bits2, FLASH_OTP_BLOCK_SIZE), NULL); + ensure(true == flash_otp_read(BOOTLOADER_VERSION_OTP_BLOCK, 0, bits2, FLASH_OTP_BLOCK_SIZE), NULL); - trassert(0 == memcmp(bits, bits2, FLASH_OTP_BLOCK_SIZE), "Bootloader downgraded"); + ensure(0 == memcmp(bits, bits2, FLASH_OTP_BLOCK_SIZE), "Bootloader downgraded"); } int main(void) @@ -212,7 +212,7 @@ int main(void) display_orientation(0); display_backlight(255); - trassert(0 == touch_init(), NULL); + ensure(0 == touch_init(), NULL); uint32_t touched = 0; for (int i = 0; i < 10; i++) { @@ -225,7 +225,7 @@ int main(void) check_and_jump(); } - trassert(0, "halt"); + ensure(0, "halt"); return 0; } diff --git a/embed/extmod/modtrezorutils/modtrezorutils.c b/embed/extmod/modtrezorutils/modtrezorutils.c index 2e809c844..a5ffdf2f2 100644 --- a/embed/extmod/modtrezorutils/modtrezorutils.c +++ b/embed/extmod/modtrezorutils/modtrezorutils.c @@ -86,9 +86,9 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_trezorutils_memcpy_obj, 5, 5, mod STATIC mp_obj_t mod_trezorutils_halt(size_t n_args, const mp_obj_t *args) { mp_buffer_info_t msg; if (n_args > 0 && mp_get_buffer(args[0], &msg, MP_BUFFER_READ)) { - trassert(0, msg.buf); + ensure(0, msg.buf); } else { - trassert(0, "halt"); + ensure(0, "halt"); } return mp_const_none; } diff --git a/embed/firmware/main.c b/embed/firmware/main.c index b62d45fea..66b2ada2b 100644 --- a/embed/firmware/main.c +++ b/embed/firmware/main.c @@ -33,9 +33,9 @@ int main(void) display_orientation(0); display_backlight(255); - trassert(0 == flash_init(), NULL); - trassert(0 == sdcard_init(), NULL); - trassert(0 == touch_init(), NULL); + ensure(0 == flash_init(), NULL); + ensure(0 == sdcard_init(), NULL); + ensure(0 == touch_init(), NULL); for (;;) { printf("CORE: Starting main loop\n"); @@ -75,7 +75,7 @@ int main(void) // MicroPython default exception handler void __attribute__((noreturn)) nlr_jump_fail(void *val) { - trassert(0, "uncaught exception"); + ensure(0, "uncaught exception"); } void PendSV_Handler(void) { diff --git a/embed/firmware/mphalport.c b/embed/firmware/mphalport.c index 979843835..74986fb45 100644 --- a/embed/firmware/mphalport.c +++ b/embed/firmware/mphalport.c @@ -6,7 +6,7 @@ static int vcp_iface_num = -1; int mp_hal_stdin_rx_chr(void) { - trassert(vcp_iface_num >= 0, "vcp stdio is not configured"); + ensure(vcp_iface_num >= 0, "vcp stdio is not configured"); #define VCP_READ_TIMEOUT 25 uint8_t c = 0; diff --git a/embed/trezorhal/common.c b/embed/trezorhal/common.c index f141fa1d1..8f881751d 100644 --- a/embed/trezorhal/common.c +++ b/embed/trezorhal/common.c @@ -34,7 +34,7 @@ uint32_t __stack_chk_guard; void __attribute__((noreturn)) __stack_chk_fail(void) { - trassert(0, "Stack smashing detected"); + ensure(0, "Stack smashing detected"); } #ifndef NDEBUG diff --git a/embed/trezorhal/common.h b/embed/trezorhal/common.h index bab22eabe..d59f15105 100644 --- a/embed/trezorhal/common.h +++ b/embed/trezorhal/common.h @@ -14,7 +14,7 @@ void periph_init(void); void __attribute__((noreturn)) __fatal_error(const char *expr, const char *msg, const char *file, int line, const char *func); -#define trassert(expr, msg) ((expr) ? (void)0 : __fatal_error(#expr, msg, __FILE__, __LINE__, __func__)) +#define ensure(expr, msg) ((expr) ? (void)0 : __fatal_error(#expr, msg, __FILE__, __LINE__, __func__)) void jump_to(uint32_t address); diff --git a/embed/unix/common.h b/embed/unix/common.h index 43c219d84..1fa0d689b 100644 --- a/embed/unix/common.h +++ b/embed/unix/common.h @@ -3,6 +3,6 @@ void __attribute__((noreturn)) __fatal_error(const char *expr, const char *msg, const char *file, int line, const char *func); -#define trassert(expr, msg) ((expr) ? (void)0 : __fatal_error(#expr, msg, __FILE__, __LINE__, __func__)) +#define ensure(expr, msg) ((expr) ? (void)0 : __fatal_error(#expr, msg, __FILE__, __LINE__, __func__)) #endif