fix(style): update C-style to be compliant with clang-format 21.1.8
What changed, and why it matters
This commit is purely a code-style cleanup. It updates the project's C source files so they match the formatting rules of a newer version of the clang-format tool (version 21.1.8 instead of 17.0.6). The changes are limited to whitespace, line breaks, comment placement, and how macros and attributes are laid out. No program logic, security checks, or behavior were changed.
No security action required. Treat as a normal style-only maintenance commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit modifies .clang-format to add DerivePointerAlignment: true and reformats 67 C/H files across core/embed, crypto, legacy, and storage. The diff shows only stylistic transformations: collapsing while/for loops with empty bodies onto one line, rewrapping attribute declarations, reindenting compound-literal and macro bodies, adding/removing spaces around pointer and arithmetic operators, and adding clang-format off/on guards around byte-array descriptors. There are no functional, semantic, or security-relevant changes.
Changed components
.clang-formatcore/embed C sources and headerscrypto/base58.ccrypto/ecdsa.ccrypto/nem.hcrypto/rand.clegacy C sources and headersstorage/tests/c0/norcow_config.hInspect captured patch +285 / −331
diff --git a/.clang-format b/.clang-format
index 55f81d47..a7c09f5c 100644
--- a/.clang-format
+++ b/.clang-format
@@ -8,9 +8,10 @@ ColumnLimit: 80
IncludeBlocks: Preserve
# Insert New line at EOF if missing
InsertNewlineAtEOF: true
-#Set EOL to LF unconditionally
+# Set EOL to LF unconditionally
LineEnding: LF
-
+# DerivePointerAligment should be changed/removed with future C-style adjustments. (TODO)
+DerivePointerAlignment: true
---
Language: Proto
AlignTrailingComments:
diff --git a/core/embed/io/display/bg_copy/stm32u5/bg_copy.c b/core/embed/io/display/bg_copy/stm32u5/bg_copy.c
index 07775a7f..23f91fbe 100644
--- a/core/embed/io/display/bg_copy/stm32u5/bg_copy.c
+++ b/core/embed/io/display/bg_copy/stm32u5/bg_copy.c
@@ -31,7 +31,7 @@ void HAL_DMA_XferCpltCallback(DMA_HandleTypeDef *hdma) {
: dma_transfer_remaining;
HAL_DMA_Start_IT(hdma,
- (uint32_t) & ((uint8_t *)data_src)[dma_data_transferred],
+ (uint32_t)&((uint8_t *)data_src)[dma_data_transferred],
(uint32_t)data_dst, data_to_send);
}
}
diff --git a/core/embed/io/display/fb_queue/fb_queue.c b/core/embed/io/display/fb_queue/fb_queue.c
index 8931d6f8..16925fd9 100644
--- a/core/embed/io/display/fb_queue/fb_queue.c
+++ b/core/embed/io/display/fb_queue/fb_queue.c
@@ -65,10 +65,7 @@ bool fb_queue_empty(fb_queue_t* queue) {
}
// Waits until the queue is not empty
-void fb_queue_wait(fb_queue_t* queue) {
- while (fb_queue_empty(queue))
- ;
-}
+void fb_queue_wait(fb_queue_t* queue) { while (fb_queue_empty(queue)); }
// Returns the head of the queue (or -1 if the queue is empty)
// Set peeked flag if the queue is not empty
diff --git a/core/embed/io/display/ltdc_dsi/display_driver.c b/core/embed/io/display/ltdc_dsi/display_driver.c
index 7ff3c8b4..91331936 100644
--- a/core/embed/io/display/ltdc_dsi/display_driver.c
+++ b/core/embed/io/display/ltdc_dsi/display_driver.c
@@ -53,8 +53,7 @@ static bool display_pll_init(void) {
/* Start and configure PLL3 */
__HAL_RCC_PLL3_DISABLE();
- while (__HAL_RCC_GET_FLAG(RCC_FLAG_PLL3RDY) != 0U)
- ;
+ while (__HAL_RCC_GET_FLAG(RCC_FLAG_PLL3RDY) != 0U);
__HAL_RCC_PLL3_CONFIG(RCC_PLLSOURCE_HSE, PLL3_M, PLL3_N, PLL3_P, PLL3_Q,
PLL3_R);
@@ -68,8 +67,7 @@ static bool display_pll_init(void) {
__HAL_RCC_PLL3_ENABLE();
/* Wait till PLL3 is ready */
- while (__HAL_RCC_GET_FLAG(RCC_FLAG_PLL3RDY) == 0U)
- ;
+ while (__HAL_RCC_GET_FLAG(RCC_FLAG_PLL3RDY) == 0U);
__HAL_RCC_DSI_CONFIG(RCC_DSICLKSOURCE_PLL3);
__HAL_RCC_LTDC_CONFIG(RCC_LTDCCLKSOURCE_PLL3);
diff --git a/core/embed/io/display/ltdc_dsi/display_fb.c b/core/embed/io/display/ltdc_dsi/display_fb.c
index 0cb42f48..af3333be 100644
--- a/core/embed/io/display/ltdc_dsi/display_fb.c
+++ b/core/embed/io/display/ltdc_dsi/display_fb.c
@@ -35,12 +35,14 @@
// Physical frame buffers in internal SRAM memory.
// Both frame buffers layers in the fixed addresses that
// are shared between bootloaders and the firmware.
-__attribute__((section(".fb1"), aligned(PHYSICAL_FRAME_BUFFER_ALIGNMENT)))
-uint8_t physical_frame_buffer_0[ALIGNED_PHYSICAL_FRAME_BUFFER_SIZE];
+__attribute__((section(".fb1"),
+ aligned(PHYSICAL_FRAME_BUFFER_ALIGNMENT))) uint8_t
+ physical_frame_buffer_0[ALIGNED_PHYSICAL_FRAME_BUFFER_SIZE];
#if (FRAME_BUFFER_COUNT > 1)
-__attribute__((section(".fb2"), aligned(PHYSICAL_FRAME_BUFFER_ALIGNMENT)))
-uint8_t physical_frame_buffer_1[ALIGNED_PHYSICAL_FRAME_BUFFER_SIZE];
+__attribute__((section(".fb2"),
+ aligned(PHYSICAL_FRAME_BUFFER_ALIGNMENT))) uint8_t
+ physical_frame_buffer_1[ALIGNED_PHYSICAL_FRAME_BUFFER_SIZE];
#endif
#ifdef USE_TRUSTZONE
diff --git a/core/embed/io/display/st-7789/display_fb.c b/core/embed/io/display/st-7789/display_fb.c
index 24b90d62..b0b73b1e 100644
--- a/core/embed/io/display/st-7789/display_fb.c
+++ b/core/embed/io/display/st-7789/display_fb.c
@@ -58,21 +58,21 @@ _Static_assert(FRAME_BUFFER_COUNT == 1 || FRAME_BUFFER_COUNT == 2);
#endif
// Size of the physical frame buffer in bytes
-#define PHYSICAL_FRAME_BUFFER_SIZE \
- ALIGN_UP_CONST(DISPLAY_RESX *DISPLAY_RESY * 2, \
+#define PHYSICAL_FRAME_BUFFER_SIZE \
+ ALIGN_UP_CONST(DISPLAY_RESX * DISPLAY_RESY * 2, \
PHYSICAL_FRAME_BUFFER_ALIGNMENT)
// Physical frame buffers in internal SRAM memory.
// Both frame buffers layers in the fixed addresses that
// are shared between bootloaders and the firmware.
-static
- __attribute__((section(".fb1"), aligned(PHYSICAL_FRAME_BUFFER_ALIGNMENT)))
- uint8_t physical_frame_buffer_0[PHYSICAL_FRAME_BUFFER_SIZE];
+static __attribute__((section(".fb1"),
+ aligned(PHYSICAL_FRAME_BUFFER_ALIGNMENT))) uint8_t
+ physical_frame_buffer_0[PHYSICAL_FRAME_BUFFER_SIZE];
#if (FRAME_BUFFER_COUNT > 1)
-static
- __attribute__((section(".fb2"), aligned(PHYSICAL_FRAME_BUFFER_ALIGNMENT)))
- uint8_t physical_frame_buffer_1[PHYSICAL_FRAME_BUFFER_SIZE];
+static __attribute__((section(".fb2"),
+ aligned(PHYSICAL_FRAME_BUFFER_ALIGNMENT))) uint8_t
+ physical_frame_buffer_1[PHYSICAL_FRAME_BUFFER_SIZE];
#endif
#ifdef USE_TRUSTZONE
diff --git a/core/embed/io/display/st-7789/display_nofb.c b/core/embed/io/display/st-7789/display_nofb.c
index 4ca6fddd..a39a650e 100644
--- a/core/embed/io/display/st-7789/display_nofb.c
+++ b/core/embed/io/display/st-7789/display_nofb.c
@@ -50,10 +50,8 @@ void display_wait_for_sync(void) {
if (id && (id != DISPLAY_ID_GC9307)) {
// synchronize with the panel synchronization signal
// in order to avoid visual tearing effects
- while (GPIO_PIN_SET == HAL_GPIO_ReadPin(DISPLAY_TE_PORT, DISPLAY_TE_PIN))
- ;
- while (GPIO_PIN_RESET == HAL_GPIO_ReadPin(DISPLAY_TE_PORT, DISPLAY_TE_PIN))
- ;
+ while (GPIO_PIN_SET == HAL_GPIO_ReadPin(DISPLAY_TE_PORT, DISPLAY_TE_PIN));
+ while (GPIO_PIN_RESET == HAL_GPIO_ReadPin(DISPLAY_TE_PORT, DISPLAY_TE_PIN));
}
#endif
}
diff --git a/core/embed/io/display/vg-2864/display_driver.c b/core/embed/io/display/vg-2864/display_driver.c
index 3f4896f3..e7895a79 100644
--- a/core/embed/io/display/vg-2864/display_driver.c
+++ b/core/embed/io/display/vg-2864/display_driver.c
@@ -52,9 +52,9 @@
#define FRAME_BUFFER_SIZE \
ALIGN_UP_CONST(DISPLAY_RESX *DISPLAY_RESY, PHYSICAL_FRAME_BUFFER_ALIGNMENT)
-static
- __attribute__((section(".fb1"), aligned(PHYSICAL_FRAME_BUFFER_ALIGNMENT)))
- uint8_t g_framebuf[FRAME_BUFFER_SIZE];
+static __attribute__((section(".fb1"),
+ aligned(PHYSICAL_FRAME_BUFFER_ALIGNMENT))) uint8_t
+ g_framebuf[FRAME_BUFFER_SIZE];
// Display driver context.
typedef struct {
@@ -148,8 +148,7 @@ static bool display_init_spi(display_driver_t *drv) {
static void display_send_bytes(display_driver_t *drv, const uint8_t *data,
size_t len) {
volatile int32_t timeout = 1000;
- for (int i = 0; i < timeout; i++)
- ;
+ for (int i = 0; i < timeout; i++);
if (HAL_OK != HAL_SPI_Transmit(&drv->spi, (uint8_t *)data, len, 1000)) {
// TODO: error
diff --git a/core/embed/io/gfx/jpegdec/stm32u5/jpegdec.c b/core/embed/io/gfx/jpegdec/stm32u5/jpegdec.c
index b4fa3147..d3c0d634 100644
--- a/core/embed/io/gfx/jpegdec/stm32u5/jpegdec.c
+++ b/core/embed/io/gfx/jpegdec/stm32u5/jpegdec.c
@@ -501,8 +501,7 @@ static void fast_copy_init(DMA_HandleTypeDef *hdma, size_t dst_stride) {
// `dst` is expected to be a pointer to destination bitmap buffer
static inline void fast_copy_block(DMA_HandleTypeDef *hdma, uint8_t *dst,
uint8_t *src) {
- while ((hdma->Instance->CSR & DMA_FLAG_IDLE) == 0)
- ;
+ while ((hdma->Instance->CSR & DMA_FLAG_IDLE) == 0);
hdma->Lock = 0;
hdma->State = HAL_DMA_STATE_READY;
@@ -512,8 +511,7 @@ static inline void fast_copy_block(DMA_HandleTypeDef *hdma, uint8_t *dst,
// Deinitialize the DMA base copy
static inline void fast_copy_deinit(DMA_HandleTypeDef *hdma) {
- while ((hdma->Instance->CSR & DMA_FLAG_IDLE) == 0)
- ;
+ while ((hdma->Instance->CSR & DMA_FLAG_IDLE) == 0);
hdma->Lock = 0;
hdma->State = HAL_DMA_STATE_READY;
diff --git a/core/embed/io/nfc/st25r3916b/rfal_platform.h b/core/embed/io/nfc/st25r3916b/rfal_platform.h
index c3ad8a79..71f4659f 100644
--- a/core/embed/io/nfc/st25r3916b/rfal_platform.h
+++ b/core/embed/io/nfc/st25r3916b/rfal_platform.h
@@ -85,7 +85,7 @@ extern "C" {
// Checks if the given timer is expired
#define platformTimerIsExpired(timer) ticks_expired(timer)
-#define platformTimerGetRemaining(timer) ((timer)-systick_ms())
+#define platformTimerGetRemaining(timer) ((timer) - systick_ms())
// Performs a delay for the given time (ms)
#define platformDelay(t) HAL_Delay(t)
diff --git a/core/embed/io/power_manager/npm1300/npm1300.c b/core/embed/io/power_manager/npm1300/npm1300.c
index c3a72fc7..267e6393 100644
--- a/core/embed/io/power_manager/npm1300/npm1300.c
+++ b/core/embed/io/power_manager/npm1300/npm1300.c
@@ -737,10 +737,11 @@ static void npm1300_calculate_report(npm1300_driver_t* drv,
}
// I2C operation for writing constant value to the npm1300 register
-#define NPM_WRITE_CONST(reg, value) \
- { \
- .flags = I2C_FLAG_TX | I2C_FLAG_EMBED | I2C_FLAG_START, .size = 3, \
- .data = {(reg) >> 8, (reg) & 0xFF, (value)}, \
+#define NPM_WRITE_CONST(reg, value) \
+ { \
+ .flags = I2C_FLAG_TX | I2C_FLAG_EMBED | I2C_FLAG_START, \
+ .size = 3, \
+ .data = {(reg) >> 8, (reg) & 0xFF, (value)}, \
}
// I2C operations for the value of specified uint8_t field
diff --git a/core/embed/io/power_manager/stwlc38/stwlc38.c b/core/embed/io/power_manager/stwlc38/stwlc38.c
index fb4d4ef0..0fbb8f40 100644
--- a/core/embed/io/power_manager/stwlc38/stwlc38.c
+++ b/core/embed/io/power_manager/stwlc38/stwlc38.c
@@ -37,10 +37,11 @@ stwlc38_driver_t g_stwlc38_driver = {
};
// I2C operation for writing 8-bit constant value to the STWLC38 register
-#define STWLC_WRITE_CONST8(reg, value) \
- { \
- .flags = I2C_FLAG_TX | I2C_FLAG_EMBED | I2C_FLAG_START, .size = 3, \
- .data = {(reg) >> 8, (reg) & 0xFF, (value)}, \
+#define STWLC_WRITE_CONST8(reg, value) \
+ { \
+ .flags = I2C_FLAG_TX | I2C_FLAG_EMBED | I2C_FLAG_START, \
+ .size = 3, \
+ .data = {(reg) >> 8, (reg) & 0xFF, (value)}, \
}
// I2C operations for reading 16-bit STWLC38 register into the
diff --git a/core/embed/io/touch/sitronix/sitronix.c b/core/embed/io/touch/sitronix/sitronix.c
index 93853287..ec0bedc4 100644
--- a/core/embed/io/touch/sitronix/sitronix.c
+++ b/core/embed/io/touch/sitronix/sitronix.c
@@ -537,8 +537,8 @@ int32_t SITRONIX_ClearIT(SITRONIX_Object_t *pObj) {
* @retval Number of active touches detected (can be between 0 and10) or
* SITRONIX_ERROR in case of error
*/
-__attribute__((optimize("-O0"))) int32_t SITRONIX_DetectTouch(
- SITRONIX_Object_t *pObj) {
+__attribute__((optimize("-O0"))) int32_t
+SITRONIX_DetectTouch(SITRONIX_Object_t *pObj) {
int32_t ret;
uint8_t nb_touch = 0;
static uint8_t first_event = 0;
diff --git a/core/embed/io/usb/stm32/usb.c b/core/embed/io/usb/stm32/usb.c
index de6648a3..45a82eea 100644
--- a/core/embed/io/usb/stm32/usb.c
+++ b/core/embed/io/usb/stm32/usb.c
@@ -485,7 +485,7 @@ static uint8_t *usb_get_interface_str_descriptor(USBD_SpeedTypeDef speed,
static uint8_t *usb_get_bos_descriptor(USBD_SpeedTypeDef speed,
uint16_t *length) {
usb_driver_t *drv = &g_usb_driver;
-
+ // clang-format off
if (sectrue == drv->usb21_enabled) {
static uint8_t bos[] = {
// usb_bos_descriptor {
@@ -506,6 +506,7 @@ static uint8_t *usb_get_bos_descriptor(USBD_SpeedTypeDef speed,
USB_WEBUSB_LANDING_PAGE, // uint8_t iLandingPage
// }
};
+ // clang-format on
bos[28] = (sectrue == drv->usb21_landing) ? USB_WEBUSB_LANDING_PAGE : 0;
*length = sizeof(bos);
return UNCONST(bos);
@@ -626,6 +627,7 @@ static uint8_t usb_class_setup(USBD_HandleTypeDef *dev,
req->bRequest == USB_WINUSB_VENDOR_CODE) {
if (req->wIndex ==
USB_WINUSB_REQ_GET_COMPATIBLE_ID_FEATURE_DESCRIPTOR) {
+ // clang-format off
static const uint8_t winusb_wcid[] = {
// header
0x28, 0x00, 0x00, 0x00, // dwLength
@@ -642,6 +644,7 @@ static uint8_t usb_class_setup(USBD_HandleTypeDef *dev,
0x00, // subCompatibleId
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // reserved
};
+ // clang-format on
wait_random();
USBD_CtlSendData(dev, UNCONST(winusb_wcid),
MIN_8bits(req->wLength, sizeof(winusb_wcid)));
@@ -660,6 +663,7 @@ static uint8_t usb_class_setup(USBD_HandleTypeDef *dev,
if (req->wIndex ==
USB_WINUSB_REQ_GET_EXTENDED_PROPERTIES_OS_FEATURE_DESCRIPTOR &&
(req->wValue & 0xFF) == 0) { // reply only if interface is 0
+ // clang-format off
static const uint8_t winusb_guid[] = {
// header
0x92, 0x00, 0x00, 0x00, // dwLength
@@ -683,6 +687,7 @@ static uint8_t usb_class_setup(USBD_HandleTypeDef *dev,
'c', 0x00, 'e', 0x00, 'a', 0x00, '5', 0x00, '0', 0x00, '3', 0x00,
'd', 0x00, '}', 0x00, 0x00, 0x00, 0x00, 0x00, // propertyData
};
+ // clang-format on
wait_random();
USBD_CtlSendData(dev, UNCONST(winusb_guid),
MIN_8bits(req->wLength, sizeof(winusb_guid)));
diff --git a/core/embed/projects/boardloader/sd_update.c b/core/embed/projects/boardloader/sd_update.c
index f881206e..61317f8a 100644
--- a/core/embed/projects/boardloader/sd_update.c
+++ b/core/embed/projects/boardloader/sd_update.c
@@ -26,8 +26,8 @@
#endif
// we use SRAM as SD card read buffer (because DMA can't access the CCMRAM)
-__attribute__((section(".buf")))
-uint32_t sdcard_buf[BOOTLOADER_MAXSIZE / sizeof(uint32_t)];
+__attribute__((section(
+ ".buf"))) uint32_t sdcard_buf[BOOTLOADER_MAXSIZE / sizeof(uint32_t)];
static uint32_t check_sdcard(void) {
if (sectrue != sdcard_power_on()) {
diff --git a/core/embed/projects/bootloader/protob/protob_common.h b/core/embed/projects/bootloader/protob/protob_common.h
index 884ccdab..5805e1df 100644
--- a/core/embed/projects/bootloader/protob/protob_common.h
+++ b/core/embed/projects/bootloader/protob/protob_common.h
@@ -21,7 +21,9 @@
#define MSG_SEND_INIT(TYPE) TYPE msg_send = TYPE##_init_default
#define MSG_SEND_ASSIGN_REQUIRED_VALUE(FIELD, VALUE) \
- { msg_send.FIELD = VALUE; }
+ { \
+ msg_send.FIELD = VALUE; \
+ }
#define MSG_SEND_ASSIGN_VALUE(FIELD, VALUE) \
{ \
msg_send.has_##FIELD = true; \
diff --git a/core/embed/projects/bootloader_ci/messages.c b/core/embed/projects/bootloader_ci/messages.c
index 006722be..4d81b8ac 100644
--- a/core/embed/projects/bootloader_ci/messages.c
+++ b/core/embed/projects/bootloader_ci/messages.c
@@ -155,7 +155,9 @@ static secbool _send_msg(uint8_t iface_num, uint16_t msg_id,
#define MSG_SEND_INIT(TYPE) TYPE msg_send = TYPE##_init_default
#define MSG_SEND_ASSIGN_REQUIRED_VALUE(FIELD, VALUE) \
- { msg_send.FIELD = VALUE; }
+ { \
+ msg_send.FIELD = VALUE; \
+ }
#define MSG_SEND_ASSIGN_VALUE(FIELD, VALUE) \
{ \
msg_send.has_##FIELD = true; \
diff --git a/core/embed/projects/prodtest/cmd/prodtest_optiga.c b/core/embed/projects/prodtest/cmd/prodtest_optiga.c
index b0b191e4..a37592d8 100644
--- a/core/embed/projects/prodtest/cmd/prodtest_optiga.c
+++ b/core/embed/projects/prodtest/cmd/prodtest_optiga.c
@@ -158,8 +158,10 @@ cleanup:
}
#if PRODUCTION
-#define METADATA_SET_LOCKED(metadata) \
- { metadata.lcso = OPTIGA_META_LCS_OPERATIONAL; }
+#define METADATA_SET_LOCKED(metadata) \
+ { \
+ metadata.lcso = OPTIGA_META_LCS_OPERATIONAL; \
+ }
#else
#define METADATA_SET_LOCKED(metadata)
#endif
diff --git a/core/embed/projects/secmon/main.c b/core/embed/projects/secmon/main.c
index cedc9c30..d7aa2f1f 100644
--- a/core/embed/projects/secmon/main.c
+++ b/core/embed/projects/secmon/main.c
@@ -126,7 +126,7 @@ static void secmon_panic(const systask_postmortem_t *pminfo) {
// defined in linker script
extern uint32_t _secmon_size;
-#define SECMON_SIZE ((uint32_t) & _secmon_size)
+#define SECMON_SIZE ((uint32_t)&_secmon_size)
#define KERNEL_START (FIRMWARE_START + SECMON_SIZE)
int main(void) {
diff --git a/core/embed/projects/unix/main.c b/core/embed/projects/unix/main.c
index 1cc87022..b2b60ad4 100644
--- a/core/embed/projects/unix/main.c
+++ b/core/embed/projects/unix/main.c
@@ -602,8 +602,7 @@ MP_NOINLINE int main_(int argc, char **argv) {
} else {
MP_STATE_VM(mp_optimise_value) = 0;
for (char *p = argv[a] + 1; *p && *p == 'O';
- p++, MP_STATE_VM(mp_optimise_value)++)
- ;
+ p++, MP_STATE_VM(mp_optimise_value)++);
}
} else {
return usage(argv);
diff --git a/core/embed/rtl/error_handling.c b/core/embed/rtl/error_handling.c
index 521e9edb..99df8e66 100644
--- a/core/embed/rtl/error_handling.c
+++ b/core/embed/rtl/error_handling.c
@@ -60,20 +60,19 @@ const char *ts_string(ts_t status) {
}
}
-void __attribute__((noreturn))
-error_shutdown_ex(const char *title, const char *message, const char *footer) {
+void __attribute__((noreturn)) error_shutdown_ex(const char *title,
+ const char *message,
+ const char *footer) {
system_exit_error(title, message, footer);
- while (1)
- ;
+ while (1);
}
void __attribute__((noreturn)) error_shutdown(const char *message) {
error_shutdown_ex(NULL, message, NULL);
}
-void __attribute__((noreturn))
-__fatal_error(const char *msg, const char *file, int line) {
+void __attribute__((noreturn)) __fatal_error(const char *msg, const char *file,
+ int line) {
system_exit_fatal(msg, file, line);
- while (1)
- ;
+ while (1);
}
diff --git a/core/embed/rtl/inc/assert.h b/core/embed/rtl/inc/assert.h
index 511000f9..43145ac5 100644
--- a/core/embed/rtl/inc/assert.h
+++ b/core/embed/rtl/inc/assert.h
@@ -36,8 +36,8 @@ extern "C" {
#ifndef NDEBUG
-void __attribute__((noreturn))
-__fatal_error(const char *msg, const char *file, int line);
+void __attribute__((noreturn)) __fatal_error(const char *msg, const char *file,
+ int line);
#define assert(expr) \
((expr) ? (void)0 : __fatal_error("Assert", __FILE_NAME__, __LINE__))
diff --git a/core/embed/rtl/inc/rtl/error_handling.h b/core/embed/rtl/inc/rtl/error_handling.h
index 558d96ae..ddad16cc 100644
--- a/core/embed/rtl/inc/rtl/error_handling.h
+++ b/core/embed/rtl/inc/rtl/error_handling.h
@@ -155,8 +155,9 @@ const char *ts_string(ts_t status);
* @param footer Footer of the error message (defaults to
* "PLEASE VISIT TREZOR.IO/RSOD" if NULL)
*/
-void __attribute__((noreturn))
-error_shutdown_ex(const char *title, const char *message, const char *footer);
+void __attribute__((noreturn)) error_shutdown_ex(const char *title,
+ const char *message,
+ const char *footer);
/**
* Shows an error message and shuts down the device.
@@ -176,8 +177,8 @@ void __attribute__((noreturn)) error_shutdown(const char *message);
* @param file Source file name where the error occurred
* @param line Line number in the source file where the error occurred
*/
-void __attribute__((noreturn))
-__fatal_error(const char *msg, const char *file, int line);
+void __attribute__((noreturn)) __fatal_error(const char *msg, const char *file,
+ int line);
/*
* TSH_DECLARE, TSH_RETURN and TSH_CHECK_xxx() macros define
diff --git a/core/embed/rtl/inc/rtl/sizedefs.h b/core/embed/rtl/inc/rtl/sizedefs.h
index ca29479b..15c0f032 100644
--- a/core/embed/rtl/inc/rtl/sizedefs.h
+++ b/core/embed/rtl/inc/rtl/sizedefs.h
@@ -45,7 +45,7 @@
#define SIZE_512M (512 * 1024 * 1024)
// Checks if a value 'x' is a power of two.
-#define IS_POWER_OF_TWO(x) (((x) != 0) && (((x) & ((x)-1)) == 0))
+#define IS_POWER_OF_TWO(x) (((x) != 0) && (((x) & ((x) - 1)) == 0))
// Ensures at compile-time that 'x' is a power of two.
#define ENSURE_POWER_OF_TWO(x) \
@@ -53,10 +53,10 @@
// Checks if 'addr' is properly aligned to 'align', which must be a
// power of two.
-#define IS_ALIGNED(addr, align) \
- ({ \
- ENSURE_POWER_OF_TWO(align); \
- (((addr) & ((align)-1)) == 0); \
+#define IS_ALIGNED(addr, align) \
+ ({ \
+ ENSURE_POWER_OF_TWO(align); \
+ (((addr) & ((align) - 1)) == 0); \
})
// Ensures that that 'addr' is properly aligned to 'align', which
@@ -66,10 +66,10 @@
// Aligns 'addr' upwards to the next boundary of 'align', which must
// be a power of two.
-#define ALIGN_UP(addr, align) \
- ({ \
- ENSURE_POWER_OF_TWO(align); \
- (((addr) + (align)-1) & ~((align)-1)); \
+#define ALIGN_UP(addr, align) \
+ ({ \
+ ENSURE_POWER_OF_TWO(align); \
+ (((addr) + (align) - 1) & ~((align) - 1)); \
})
// Aligns 'addr' upwards to the next boundary of 'align', which must
@@ -77,14 +77,14 @@
//
// This version is for use in constant expressions. Use only if `ALIGN_UP`
// doesn't work in your case.
-#define ALIGN_UP_CONST(addr, align) (((addr) + (align)-1) & ~((align)-1))
+#define ALIGN_UP_CONST(addr, align) (((addr) + (align) - 1) & ~((align) - 1))
// Aligns 'addr' downwards to the previous boundary of 'align', which
// must be a power of two.
#define ALIGN_DOWN(addr, align) \
({ \
ENSURE_POWER_OF_TWO(align); \
- ((addr) & ~((align)-1)); \
+ ((addr) & ~((align) - 1)); \
})
// Aligns 'addr' downwards to the previous boundary of 'align', which
@@ -92,6 +92,6 @@
//
// This version is for use in constant expressions. Use only if `ALIGN_DOWN`
// doesn't work in your case.
-#define ALIGN_DOWN_CONST(addr, align) ((addr) & ~((align)-1))
+#define ALIGN_DOWN_CONST(addr, align) ((addr) & ~((align) - 1))
#endif // LIB_SIZEDEFS_H
diff --git a/core/embed/sec/hash_processor/stm32u5/hash_processor.c b/core/embed/sec/hash_processor/stm32u5/hash_processor.c
index 881ec04a..c8c84bc0 100644
--- a/core/embed/sec/hash_processor/stm32u5/hash_processor.c
+++ b/core/embed/sec/hash_processor/stm32u5/hash_processor.c
@@ -81,8 +81,7 @@ static void hash_processor_sha256_calc_dma(const uint8_t *data, uint32_t len,
__HAL_HASH_SET_MDMAT();
HAL_HASHEx_SHA256_Start_DMA(&hhash, (uint8_t *)data, chunk);
- while (HAL_HASH_GetState(&hhash) != HAL_HASH_STATE_READY)
- ;
+ while (HAL_HASH_GetState(&hhash) != HAL_HASH_STATE_READY);
if (last) {
HASH->STR |= HASH_STR_DCAL;
diff --git a/core/embed/sec/optiga/inc/sec/optiga_commands.h b/core/embed/sec/optiga/inc/sec/optiga_commands.h
index 3ac52267..5eff5d80 100644
--- a/core/embed/sec/optiga/inc/sec/optiga_commands.h
+++ b/core/embed/sec/optiga/inc/sec/optiga_commands.h
@@ -181,14 +181,13 @@ typedef struct {
// The throttling delay when the security event counter is at its maximum.
#define OPTIGA_T_MAX_MS 5000
-#define OPTIGA_ACCESS_CONDITION(ac_id, oid) \
- (const optiga_metadata_item) { \
- (const uint8_t[]){ac_id, oid >> 8, oid & 0xff}, 3 \
- }
+#define OPTIGA_ACCESS_CONDITION(ac_id, oid) \
+ (const optiga_metadata_item){(const uint8_t[]){ac_id, oid >> 8, oid & 0xff}, \
+ 3}
// Single-byte value of optiga_metadata_item.
#define OPTIGA_META_VALUE(val) \
- (const optiga_metadata_item) { (const uint8_t[]){val}, 1 }
+ (const optiga_metadata_item){(const uint8_t[]){val}, 1}
// Commonly used data object access conditions.
extern const optiga_metadata_item OPTIGA_META_LCS_OPERATIONAL;
diff --git a/core/embed/sec/option_bytes/stm32f4/option_bytes.c b/core/embed/sec/option_bytes/stm32f4/option_bytes.c
index 961addfd..484faf73 100644
--- a/core/embed/sec/option_bytes/stm32f4/option_bytes.c
+++ b/core/embed/sec/option_bytes/stm32f4/option_bytes.c
@@ -65,8 +65,8 @@
FLASH_SR_WRPERR | FLASH_SR_SOP | FLASH_SR_EOP)
static uint32_t flash_wait_and_clear_status_flags(void) {
- while (FLASH->SR & FLASH_SR_BSY)
- ; // wait for all previous flash operations to complete
+ while (FLASH->SR & FLASH_SR_BSY); // wait for all previous flash
+ // operations to complete
const uint32_t result =
FLASH->SR & FLASH_STATUS_ALL_FLAGS; // get the current status flags
FLASH->SR |= FLASH_STATUS_ALL_FLAGS; // clear all status flags
@@ -119,8 +119,8 @@ static void flash_unlock_option_bytes(void) {
// write the special sequence to unlock
FLASH->OPTKEYR = FLASH_OPT_KEY1;
FLASH->OPTKEYR = FLASH_OPT_KEY2;
- while (FLASH->OPTCR & FLASH_OPTCR_OPTLOCK)
- ; // wait until the flash option control register is unlocked
+ while (FLASH->OPTCR & FLASH_OPTCR_OPTLOCK); // wait until the flash option
+ // control register is unlocked
}
static uint32_t flash_set_option_bytes(void) {
diff --git a/core/embed/sec/option_bytes/stm32u5/option_bytes.c b/core/embed/sec/option_bytes/stm32u5/option_bytes.c
index 4a0f6e19..c652a4bc 100644
--- a/core/embed/sec/option_bytes/stm32u5/option_bytes.c
+++ b/core/embed/sec/option_bytes/stm32u5/option_bytes.c
@@ -104,16 +104,16 @@ _Static_assert(SECRET_SECTOR_START == 0, "secret sector start must be 0");
(FLASH_NSSR_PGSERR | FLASH_NSSR_PGAERR | FLASH_NSSR_WRPERR | FLASH_NSSR_EOP)
static uint32_t flash_wait_and_clear_status_flags(void) {
- while (FLASH->NSSR & FLASH_NSSR_BSY)
- ; // wait for all previous flash operations to complete
+ while (FLASH->NSSR & FLASH_NSSR_BSY); // wait for all previous flash
+ // operations to complete
uint32_t result =
FLASH->NSSR & FLASH_STATUS_ALL_FLAGS; // get the current status flags
FLASH->NSSR |= FLASH_STATUS_ALL_FLAGS; // clear all status flags
#if defined(__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
- while (FLASH->SECSR & FLASH_SECSR_BSY)
- ; // wait for all previous flash operations to complete
+ while (FLASH->SECSR & FLASH_SECSR_BSY); // wait for all previous flash
+ // operations to complete
result |=
FLASH->SECSR & FLASH_STATUS_ALL_FLAGS; // get the current status flags
FLASH->SECSR |= FLASH_STATUS_ALL_FLAGS; // clear all status flags
@@ -181,8 +181,8 @@ static void flash_unlock_option_bytes(void) {
// write the special sequence to unlock
FLASH->OPTKEYR = FLASH_OPTKEY1;
FLASH->OPTKEYR = FLASH_OPTKEY2;
- while (FLASH->NSCR & FLASH_NSCR_OPTLOCK)
- ; // wait until the flash option control register is unlocked
+ while (FLASH->NSCR & FLASH_NSCR_OPTLOCK); // wait until the flash option
+ // control register is unlocked
}
static uint32_t flash_set_option_bytes(void) {
diff --git a/core/embed/sec/rsod/rsod_special.c b/core/embed/sec/rsod/rsod_special.c
index 5b49020b..19aafdb5 100644
--- a/core/embed/sec/rsod/rsod_special.c
+++ b/core/embed/sec/rsod/rsod_special.c
@@ -42,8 +42,7 @@ void __attribute__((noreturn)) show_wipe_code_screen(void) {
reboot_and_wipe(&info);
- while (1)
- ;
+ while (1);
}
void __attribute__((noreturn)) show_pin_too_many_screen(void) {
@@ -56,8 +55,7 @@ void __attribute__((noreturn)) show_pin_too_many_screen(void) {
strncpy(info.footer, RECONNECT_DEVICE_MESSAGE, sizeof(info.footer) - 1);
reboot_and_wipe(&info);
- while (1)
- ;
+ while (1);
}
void __attribute__((noreturn)) show_install_restricted_screen(void) {
diff --git a/core/embed/sys/flash/flash_utils.c b/core/embed/sys/flash/flash_utils.c
index 928bafd8..07d60586 100644
--- a/core/embed/sys/flash/flash_utils.c
+++ b/core/embed/sys/flash/flash_utils.c
@@ -87,15 +87,15 @@ secbool erase_device(flash_progress_callback_t progress_cb) {
"Unsupported number of storage areas");
static const flash_area_ref_t areas[] = {
- {.area = &STORAGE_AREAS[0], .mpu_mode = MPU_MODE_STORAGE},
- {.area = &STORAGE_AREAS[1], .mpu_mode = MPU_MODE_STORAGE},
- {.area = &ASSETS_AREA, .mpu_mode = MPU_MODE_ASSETS},
+ {.area = &STORAGE_AREAS[0], .mpu_mode = MPU_MODE_STORAGE},
+ {.area = &STORAGE_AREAS[1], .mpu_mode = MPU_MODE_STORAGE},
+ {.area = &ASSETS_AREA, .mpu_mode = MPU_MODE_ASSETS},
#if defined(BOARDLOADER) || defined(BOOTLOADER)
- {.area = &FIRMWARE_AREA, .mpu_mode = MPU_MODE_DEFAULT},
+ {.area = &FIRMWARE_AREA, .mpu_mode = MPU_MODE_DEFAULT},
#endif
#if defined(BOARDLOADER) && defined(USE_SD_CARD)
- {.area = &BOOTLOADER_AREA, .mpu_mode = MPU_MODE_DEFAULT},
- {.area = &UNUSED_AREA, .mpu_mode = MPU_MODE_UNUSED_FLASH},
+ {.area = &BOOTLOADER_AREA, .mpu_mode = MPU_MODE_DEFAULT},
+ {.area = &UNUSED_AREA, .mpu_mode = MPU_MODE_UNUSED_FLASH},
#endif
};
diff --git a/core/embed/sys/flash/layout_helpers.h b/core/embed/sys/flash/layout_helpers.h
index 7d27ffcf..a330924a 100644
--- a/core/embed/sys/flash/layout_helpers.h
+++ b/core/embed/sys/flash/layout_helpers.h
@@ -37,10 +37,10 @@
#define EVAL(x) x
// Defines flash_subarea_t structure
-#define SUBAREA(_first_sector, _end_sectors) \
- { \
- .first_sector = (_first_sector), \
- .num_sectors = (_end_sectors) - (_first_sector) + 1, \
+#define SUBAREA(_first_sector, _end_sectors) \
+ { \
+ .first_sector = (_first_sector), \
+ .num_sectors = (_end_sectors) - (_first_sector) + 1, \
}
// Defines flash area containing 1 subarea
diff --git a/core/embed/sys/flash/stm32u5/flash.c b/core/embed/sys/flash/stm32u5/flash.c
index 8549f4af..cb048588 100644
--- a/core/embed/sys/flash/stm32u5/flash.c
+++ b/core/embed/sys/flash/stm32u5/flash.c
@@ -41,7 +41,7 @@
#ifdef SECMON
extern uint32_t _codelen;
-#define SECMON_SIZE ((uint32_t) & _codelen)
+#define SECMON_SIZE ((uint32_t)&_codelen)
#define KERNEL_SECTOR_START \
((FIRMWARE_START_S + SECMON_SIZE - FLASH_BASE) / FLASH_PAGE_SIZE)
diff --git a/core/embed/sys/i2c_bus/stm32f4/i2c_bus.c b/core/embed/sys/i2c_bus/stm32f4/i2c_bus.c
index f89eeec9..ecb91fb6 100644
--- a/core/embed/sys/i2c_bus/stm32f4/i2c_bus.c
+++ b/core/embed/sys/i2c_bus/stm32f4/i2c_bus.c
@@ -657,8 +657,7 @@ static void i2c_bus_head_continue(i2c_bus_t* bus) {
// Add 5us as a safety margin since the stop_time was set before the
// STOP condition was issued
uint16_t guard_time = bus->def->guard_time + 5;
- while (systick_us() - bus->stop_time < guard_time)
- ;
+ while (systick_us() - bus->stop_time < guard_time);
}
}
diff --git a/core/embed/sys/i2c_bus/stm32u5/i2c_bus.c b/core/embed/sys/i2c_bus/stm32u5/i2c_bus.c
index 7b579d64..bb5ad1c9 100644
--- a/core/embed/sys/i2c_bus/stm32u5/i2c_bus.c
+++ b/core/embed/sys/i2c_bus/stm32u5/i2c_bus.c
@@ -720,8 +720,7 @@ static void i2c_bus_head_continue(i2c_bus_t* bus) {
// Guard time between operations STOP and START condition
if (bus->def->guard_time > 0) {
- while (systick_us() - bus->stop_time < bus->def->guard_time)
- ;
+ while (systick_us() - bus->stop_time < bus->def->guard_time);
}
regs->CR2 = cr2;
diff --git a/core/embed/sys/linker/inc/sys/linker_utils.h b/core/embed/sys/linker/inc/sys/linker_utils.h
index 389c2ece..528be071 100644
--- a/core/embed/sys/linker/inc/sys/linker_utils.h
+++ b/core/embed/sys/linker/inc/sys/linker_utils.h
@@ -52,7 +52,7 @@ typedef struct {
} memregion_t;
#define MEMBLOCK(start, size) \
- { (void*)(start), (void*)((uint8_t*)(start) + (size)) }
+ {(void*)(start), (void*)((uint8_t*)(start) + (size))}
// -------------------------------------------------------------------
// Standard memory regions used in boardloader / bootloader
diff --git a/core/embed/sys/mpu/stm32u5/mpu.c b/core/embed/sys/mpu/stm32u5/mpu.c
index ef7cfc9e..def4a911 100644
--- a/core/embed/sys/mpu/stm32u5/mpu.c
+++ b/core/embed/sys/mpu/stm32u5/mpu.c
@@ -109,7 +109,7 @@ static inline uint32_t mpu_permission_lookup(bool write, bool unpriv) {
uint32_t _ap = mpu_permission_lookup(_write, _unpriv); \
uint32_t _xn = mpu_region_lookup[_type].xn; \
MPU->RBAR = _start | _sh | _ap | _xn; \
- uint32_t _limit = (_start + (size)-1) & (~0x1F); \
+ uint32_t _limit = (_start + (size) - 1) & (~0x1F); \
uint32_t _attr = mpu_region_lookup[_type].attr << 1; \
uint32_t _enable = LL_MPU_REGION_ENABLE; \
MPU->RLAR = _limit | _attr | _enable; \
@@ -182,7 +182,7 @@ static inline bool is_flash_address(uint32_t addr) {
#ifdef SECMON
extern uint32_t _secmon_size;
#define SECMON_START FIRMWARE_START_S
-#define SECMON_SIZE (uint32_t) & _secmon_size
+#define SECMON_SIZE (uint32_t)&_secmon_size
#endif
#ifdef KERNEL
@@ -190,12 +190,12 @@ extern uint32_t _kernel_flash_start;
extern uint32_t _kernel_flash_end;
#ifdef USE_SECMON_LAYOUT
-#define KERNEL_START ((uint32_t) & _kernel_flash_start)
+#define KERNEL_START ((uint32_t)&_kernel_flash_start)
#else
#define KERNEL_START FIRMWARE_START
#endif
-#define KERNEL_END ALIGN_UP((uint32_t) & _kernel_flash_end, COREAPP_ALIGNMENT)
+#define KERNEL_END ALIGN_UP((uint32_t)&_kernel_flash_end, COREAPP_ALIGNMENT)
#define KERNEL_SIZE (KERNEL_END - KERNEL_START)
#endif // KERNEL
diff --git a/core/embed/sys/rng/stm32/rng.c b/core/embed/sys/rng/stm32/rng.c
index 9cb305da..606c357b 100644
--- a/core/embed/sys/rng/stm32/rng.c
+++ b/core/embed/sys/rng/stm32/rng.c
@@ -41,9 +41,9 @@ static uint32_t rng_read_u32(const uint32_t previous,
const uint32_t compare_previous) {
uint32_t temp = previous;
do {
- while ((RNG->SR & (RNG_SR_SECS | RNG_SR_CECS | RNG_SR_DRDY)) != RNG_SR_DRDY)
- ; // wait until TRNG is ready
- temp = RNG->DR; // read the data from the TRNG
+ while ((RNG->SR & (RNG_SR_SECS | RNG_SR_CECS | RNG_SR_DRDY)) !=
+ RNG_SR_DRDY); // wait until TRNG is ready
+ temp = RNG->DR; // read the data from the TRNG
} while (compare_previous &&
(temp == previous)); // RM0090 section 24.3.1 FIPS continuous random
// number generator test
diff --git a/core/embed/sys/smcall/stm32/smcall_invoke.h b/core/embed/sys/smcall/stm32/smcall_invoke.h
index 83d2e351..3590e3eb 100644
--- a/core/embed/sys/smcall/stm32/smcall_invoke.h
+++ b/core/embed/sys/smcall/stm32/smcall_invoke.h
@@ -28,22 +28,22 @@
void smcall_invoke(smcall_args_t* args, smcall_number_t smcall);
-static inline uint32_t __attribute__((no_stack_protector))
-smcall_invoke0(uint32_t smcall) {
+static inline uint32_t __attribute__((no_stack_protector)) smcall_invoke0(
+ uint32_t smcall) {
smcall_args_t args = {0};
smcall_invoke(&args, smcall);
return args.arg[0];
}
-static inline uint64_t __attribute__((no_stack_protector))
-smcall_invoke0_ret64(uint32_t smcall) {
+static inline uint64_t __attribute__((no_stack_protector)) smcall_invoke0_ret64(
+ uint32_t smcall) {
smcall_args_t args = {0};
smcall_invoke(&args, smcall);
return ((uint64_t)args.arg[1] << 32) | args.arg[0];
}
-static inline uint32_t __attribute__((no_stack_protector))
-smcall_invoke1(uint32_t arg1, uint32_t smcall) {
+static inline uint32_t __attribute__((no_stack_protector)) smcall_invoke1(
+ uint32_t arg1, uint32_t smcall) {
smcall_args_t args = {
.arg[0] = arg1,
};
@@ -51,8 +51,8 @@ smcall_invoke1(uint32_t arg1, uint32_t smcall) {
return args.arg[0];
}
-static inline uint32_t __attribute__((no_stack_protector))
-smcall_invoke2(uint32_t arg1, uint32_t arg2, uint32_t smcall) {
+static inline uint32_t __attribute__((no_stack_protector)) smcall_invoke2(
+ uint32_t arg1, uint32_t arg2, uint32_t smcall) {
smcall_args_t args = {
.arg[0] = arg1,
.arg[1] = arg2,
@@ -61,8 +61,8 @@ smcall_invoke2(uint32_t arg1, uint32_t arg2, uint32_t smcall) {
return args.arg[0];
}
-static inline uint64_t __attribute__((no_stack_protector))
-smcall_invoke2_ret64(uint32_t arg1, uint32_t arg2, uint32_t smcall) {
+static inline uint64_t __attribute__((no_stack_protector)) smcall_invoke2_ret64(
+ uint32_t arg1, uint32_t arg2, uint32_t smcall) {
smcall_args_t args = {
.arg[0] = arg1,
.arg[1] = arg2,
@@ -71,8 +71,8 @@ smcall_invoke2_ret64(uint32_t arg1, uint32_t arg2, uint32_t smcall) {
return ((uint64_t)args.arg[1] << 32) | args.arg[0];
}
-static inline uint32_t __attribute__((no_stack_protector))
-smcall_invoke3(uint32_t arg1, uint32_t arg2, uint32_t arg3, uint32_t smcall) {
+static inline uint32_t __attribute__((no_stack_protector)) smcall_invoke3(
+ uint32_t arg1, uint32_t arg2, uint32_t arg3, uint32_t smcall) {
smcall_args_t args = {
.arg[0] = arg1,
.arg[1] = arg2,
@@ -82,9 +82,9 @@ smcall_invoke3(uint32_t arg1, uint32_t arg2, uint32_t arg3, uint32_t smcall) {
return args.arg[0];
}
-static inline uint32_t __attribute__((no_stack_protector))
-smcall_invoke4(uint32_t arg1, uint32_t arg2, uint32_t arg3, uint32_t arg4,
- uint32_t smcall) {
+static inline uint32_t __attribute__((no_stack_protector)) smcall_invoke4(
+ uint32_t arg1, uint32_t arg2, uint32_t arg3, uint32_t arg4,
+ uint32_t smcall) {
smcall_args_t args = {
.arg[0] = arg1,
.arg[1] = arg2,
@@ -95,9 +95,9 @@ smcall_invoke4(uint32_t arg1, uint32_t arg2, uint32_t arg3, uint32_t arg4,
return args.arg[0];
}
-static inline uint32_t __attribute__((no_stack_protector))
-smcall_invoke5(uint32_t arg1, uint32_t arg2, uint32_t arg3, uint32_t arg4,
- uint32_t arg5, uint32_t smcall) {
+static inline uint32_t __attribute__((no_stack_protector)) smcall_invoke5(
+ uint32_t arg1, uint32_t arg2, uint32_t arg3, uint32_t arg4, uint32_t arg5,
+ uint32_t smcall) {
smcall_args_t args = {
.arg[0] = arg1,
.arg[1] = arg2,
@@ -109,9 +109,9 @@ smcall_invoke5(uint32_t arg1, uint32_t arg2, uint32_t arg3, uint32_t arg4,
return args.arg[0];
}
-static inline uint32_t __attribute__((no_stack_protector))
-smcall_invoke6(uint32_t arg1, uint32_t arg2, uint32_t arg3, uint32_t arg4,
- uint32_t arg5, uint32_t arg6, uint32_t smcall) {
+static inline uint32_t __attribute__((no_stack_protector)) smcall_invoke6(
+ uint32_t arg1, uint32_t arg2, uint32_t arg3, uint32_t arg4, uint32_t arg5,
+ uint32_t arg6, uint32_t smcall) {
smcall_args_t args = {
.arg[0] = arg1,
.arg[1] = arg2,
diff --git a/core/embed/sys/smcall/stm32/smcall_stubs.c b/core/embed/sys/smcall/stm32/smcall_stubs.c
index f411fae3..47f50421 100644
--- a/core/embed/sys/smcall/stm32/smcall_stubs.c
+++ b/core/embed/sys/smcall/stm32/smcall_stubs.c
@@ -71,38 +71,32 @@ void get_boardloader_version(boardloader_version_t *version) {
void reboot_to_bootloader(void) {
smcall_invoke0(SMCALL_REBOOT_TO_BOOTLOADER);
- while (1)
- ;
+ while (1);
}
void reboot_and_upgrade(const uint8_t hash[32]) {
smcall_invoke1((uint32_t)hash, SMCALL_REBOOT_AND_UPGRADE);
- while (1)
- ;
+ while (1);
}
void reboot_device(void) {
smcall_invoke0(SMCALL_REBOOT_DEVICE);
- while (1)
- ;
+ while (1);
}
void reboot_or_halt_after_rsod(void) {
smcall_invoke0(SMCALL_REBOOT_DEVICE);
- while (1)
- ;
+ while (1);
}
void reboot_to_off(void) {
smcall_invoke0(SMCALL_REBOOT_TO_OFF);
- while (1)
- ;
+ while (1);
}
void reboot_with_rsod(const systask_postmortem_t *pminfo) {
smcall_invoke1((uint32_t)pminfo, SMCALL_REBOOT_WITH_RSOD);
- while (1)
- ;
+ while (1);
}
// =============================================================================
diff --git a/core/embed/sys/smcall/stm32/smcall_verifiers.c b/core/embed/sys/smcall/stm32/smcall_verifiers.c
index 1316bb12..9fa39bdf 100644
--- a/core/embed/sys/smcall/stm32/smcall_verifiers.c
+++ b/core/embed/sys/smcall/stm32/smcall_verifiers.c
@@ -237,8 +237,8 @@ access_violation:
// ---------------------------------------------------------------------
-typedef __attribute__((cmse_nonsecure_call))
-PIN_UI_WAIT_CALLBACK ns_storage_callback_t;
+typedef __attribute__((
+ cmse_nonsecure_call)) PIN_UI_WAIT_CALLBACK ns_storage_callback_t;
static ns_storage_callback_t storage_callback = NULL;
diff --git a/core/embed/sys/startup/inc/sys/bootutils.h b/core/embed/sys/startup/inc/sys/bootutils.h
index 934d1744..70def5cf 100644
--- a/core/embed/sys/startup/inc/sys/bootutils.h
+++ b/core/embed/sys/startup/inc/sys/bootutils.h
@@ -58,14 +58,14 @@ void __attribute__((noreturn)) reboot_and_upgrade(const uint8_t hash[32]);
#ifdef USE_BOOTARGS_RSOD
// Resets the device with post-mortem information in bootargs
// so that the bootloader can display it.
-void __attribute__((noreturn))
-reboot_with_rsod(const systask_postmortem_t *pminfo);
+void __attribute__((noreturn)) reboot_with_rsod(
+ const systask_postmortem_t *pminfo);
#endif
// Resets the device and wipes all the user data.
// RSOD with wipe information is displayed.
-void __attribute__((noreturn))
-reboot_and_wipe(const bootutils_wipe_info_t *info);
+void __attribute__((noreturn)) reboot_and_wipe(
+ const bootutils_wipe_info_t *info);
// Allows the user to read the displayed error message and then
// reboots the device or waits for power-off.
diff --git a/core/embed/sys/startup/stm32/bootutils.c b/core/embed/sys/startup/stm32/bootutils.c
index c657ae5e..e69ab341 100644
--- a/core/embed/sys/startup/stm32/bootutils.c
+++ b/core/embed/sys/startup/stm32/bootutils.c
@@ -128,8 +128,7 @@ static void halt_device_phase_2(uint32_t arg1, uint32_t arg2) {
clear_otg_hs_memory();
#endif
- while (true)
- ; // Infinite loop
+ while (true); // Infinite loop
}
__attribute__((noreturn)) static void halt_device(void) {
diff --git a/core/embed/sys/startup/stm32/sysutils.c b/core/embed/sys/startup/stm32/sysutils.c
index 2326cfe5..ee729e81 100644
--- a/core/embed/sys/startup/stm32/sysutils.c
+++ b/core/embed/sys/startup/stm32/sysutils.c
@@ -269,8 +269,8 @@ __attribute((naked, noreturn, no_stack_protector)) void jump_to_vectbl(
}
#ifdef SECMON
-__attribute((naked, noreturn, no_stack_protector)) void jump_to_vectbl_ns(
- uint32_t vectbl_addr) {
+__attribute((naked, noreturn,
+ no_stack_protector)) void jump_to_vectbl_ns(uint32_t vectbl_addr) {
__asm__ volatile(
"MOV LR, R0 \n"
diff --git a/core/embed/sys/startup/stm32f4/startup_init.c b/core/embed/sys/startup/stm32f4/startup_init.c
index a2ee67af..0b6b960e 100644
--- a/core/embed/sys/startup/stm32f4/startup_init.c
+++ b/core/embed/sys/startup/stm32f4/startup_init.c
@@ -126,8 +126,7 @@ void SystemInit(void) {
FLASH->ACR = FLASH_ACR_LATENCY_5WS;
// wait until the new wait state config takes effect -- per section 3.5.1
// guidance
- while ((FLASH->ACR & FLASH_ACR_LATENCY) != FLASH_ACR_LATENCY_5WS)
- ;
+ while ((FLASH->ACR & FLASH_ACR_LATENCY) != FLASH_ACR_LATENCY_5WS);
// configure main PLL
// reference RM0090 section 6.3.2
RCC->PLLCFGR =
@@ -148,22 +147,19 @@ void SystemInit(void) {
RCC->CR |= RCC_CR_CSSON | RCC_CR_HSEON | RCC_CR_PLLON;
// wait until PLL and HSE ready
while ((RCC->CR & (RCC_CR_PLLRDY | RCC_CR_HSERDY)) !=
- (RCC_CR_PLLRDY | RCC_CR_HSERDY))
- ;
+ (RCC_CR_PLLRDY | RCC_CR_HSERDY));
// APB2=2, APB1=4, AHB=1, system clock = main PLL
const uint32_t cfgr = RCC_CFGR_PPRE2_DIV2 | RCC_CFGR_PPRE1_DIV4 |
RCC_CFGR_HPRE_DIV1 | RCC_CFGR_SW_PLL;
RCC->CFGR = cfgr;
// wait until PLL is system clock and also verify that the pre-scalers were
// set
- while (RCC->CFGR != (RCC_CFGR_SWS_PLL | cfgr))
- ;
+ while (RCC->CFGR != (RCC_CFGR_SWS_PLL | cfgr));
// turn off the HSI as it is now unused (it will be turned on again
// automatically if a clock security failure occurs)
RCC->CR &= ~RCC_CR_HSION;
// wait until ths HSI is off
- while ((RCC->CR & RCC_CR_HSION) == RCC_CR_HSION)
- ;
+ while ((RCC->CR & RCC_CR_HSION) == RCC_CR_HSION);
// init the TRNG peripheral
rng_init();
// set CP10 and CP11 to enable full access to the fpu coprocessor; ARMv7-M
@@ -195,8 +191,7 @@ void set_core_clock(clock_settings_t settings) {
RCC->CR |= RCC_CR_HSION;
// Wait till HSI is ready
- while (!(RCC->CR & RCC_CR_HSIRDY))
- ;
+ while (!(RCC->CR & RCC_CR_HSIRDY));
// Select HSI clock as main clock
RCC->CFGR = (RCC->CFGR & ~(RCC_CFGR_SW)) | RCC_CFGR_SW_HSI;
@@ -219,8 +214,7 @@ void set_core_clock(clock_settings_t settings) {
RCC->CR |= RCC_CR_PLLON;
// Wait till PLL is ready
- while (!(RCC->CR & RCC_CR_PLLRDY))
- ;
+ while (!(RCC->CR & RCC_CR_PLLRDY));
// Enable PLL as main clock
RCC->CFGR = (RCC->CFGR & ~(RCC_CFGR_SW)) | RCC_CFGR_SW_PLL;
@@ -231,8 +225,7 @@ void set_core_clock(clock_settings_t settings) {
// automatically if a clock security failure occurs)
RCC->CR &= ~RCC_CR_HSION;
// wait until ths HSI is off
- while ((RCC->CR & RCC_CR_HSION) == RCC_CR_HSION)
- ;
+ while ((RCC->CR & RCC_CR_HSION) == RCC_CR_HSION);
}
#endif
diff --git a/core/embed/sys/startup/stm32u5/startup_init.c b/core/embed/sys/startup/stm32u5/startup_init.c
index c4eb193b..6fdf5cc0 100644
--- a/core/embed/sys/startup/stm32u5/startup_init.c
+++ b/core/embed/sys/startup/stm32u5/startup_init.c
@@ -107,8 +107,7 @@ void lsi_init(void) {
SET_BIT(PWR->DBPR, PWR_DBPR_DBP);
// Wait for Backup domain Write protection disable
- while (HAL_IS_BIT_CLR(PWR->DBPR, PWR_DBPR_DBP))
- ;
+ while (HAL_IS_BIT_CLR(PWR->DBPR, PWR_DBPR_DBP));
}
uint32_t bdcr_temp = RCC->BDCR;
@@ -135,8 +134,7 @@ void lsi_init(void) {
__HAL_RCC_LSI_DISABLE();
// Wait till LSI is disabled
- while (READ_BIT(RCC->BDCR, RCC_BDCR_LSIRDY) != 0U)
- ;
+ while (READ_BIT(RCC->BDCR, RCC_BDCR_LSIRDY) != 0U);
}
// Set LSI division factor
@@ -147,8 +145,7 @@ void lsi_init(void) {
__HAL_RCC_LSI_ENABLE();
// Wait till LSI is ready
- while (READ_BIT(RCC->BDCR, RCC_BDCR_LSIRDY) == 0U)
- ;
+ while (READ_BIT(RCC->BDCR, RCC_BDCR_LSIRDY) == 0U);
}
// This function replaces calls to universal, but flash-wasting
@@ -166,23 +163,20 @@ void lse_init(void) {
// Enable write access to Backup domain
SET_BIT(PWR->DBPR, PWR_DBPR_DBP);
- while (HAL_IS_BIT_CLR(PWR->DBPR, PWR_DBPR_DBP))
- ;
+ while (HAL_IS_BIT_CLR(PWR->DBPR, PWR_DBPR_DBP));
}
// LSE oscillator enable
SET_BIT(RCC->BDCR, RCC_BDCR_LSEON);
// Wait till LSE is ready
- while (READ_BIT(RCC->BDCR, RCC_BDCR_LSERDY) == 0U)
- ;
+ while (READ_BIT(RCC->BDCR, RCC_BDCR_LSERDY) == 0U);
// Make sure LSESYSEN/LSESYSRDY are reset
CLEAR_BIT(RCC->BDCR, RCC_BDCR_LSESYSEN);
// Wait till LSESYSRDY is cleared
- while (READ_BIT(RCC->BDCR, RCC_BDCR_LSESYSRDY) != 0U)
- ;
+ while (READ_BIT(RCC->BDCR, RCC_BDCR_LSESYSRDY) != 0U);
}
void SystemInit(void) {
@@ -191,8 +185,7 @@ void SystemInit(void) {
FLASH->ACR = FLASH_ACR_LATENCY_5WS;
// wait until the new wait state config takes effect -- per section 3.5.1
// guidance
- while ((FLASH->ACR & FLASH_ACR_LATENCY) != FLASH_ACR_LATENCY_5WS)
- ;
+ while ((FLASH->ACR & FLASH_ACR_LATENCY) != FLASH_ACR_LATENCY_5WS);
// Reset the RCC clock configuration to the default reset state
// Set MSION bit
@@ -220,20 +213,16 @@ void SystemInit(void) {
MODIFY_REG(PWR->VOSR, (PWR_VOSR_VOS | PWR_VOSR_BOOSTEN),
PWR_REGULATOR_VOLTAGE_SCALE1);
- while (HAL_IS_BIT_CLR(PWR->VOSR, PWR_VOSR_VOSRDY))
- ;
- while (HAL_IS_BIT_CLR(PWR->SVMSR, PWR_SVMSR_ACTVOSRDY))
- ;
+ while (HAL_IS_BIT_CLR(PWR->VOSR, PWR_VOSR_VOSRDY));
+ while (HAL_IS_BIT_CLR(PWR->SVMSR, PWR_SVMSR_ACTVOSRDY));
RCC->CR |= RCC_CR_HSION;
// wait until the HSI is on
- while ((RCC->CR & RCC_CR_HSIRDY) != RCC_CR_HSIRDY)
- ;
+ while ((RCC->CR & RCC_CR_HSIRDY) != RCC_CR_HSIRDY);
#ifndef HSI_ONLY
__HAL_RCC_HSE_CONFIG(RCC_HSE_ON);
- while (READ_BIT(RCC->CR, RCC_CR_HSERDY) == 0U)
- ;
+ while (READ_BIT(RCC->CR, RCC_CR_HSERDY) == 0U);
__HAL_RCC_PLL_CONFIG(RCC_PLLSOURCE_HSE, RCC_PLLMBOOST_DIV1, DEFAULT_PLLM,
DEFAULT_PLLN, DEFAULT_PLLP, DEFAULT_PLLQ, DEFAULT_PLLR);
#else
@@ -249,19 +238,16 @@ void SystemInit(void) {
__HAL_RCC_PLLCLKOUT_ENABLE(RCC_PLL1_DIVR);
__HAL_RCC_PLL_ENABLE();
- while (READ_BIT(RCC->CR, RCC_CR_PLL1RDY) == 0U)
- ;
+ while (READ_BIT(RCC->CR, RCC_CR_PLL1RDY) == 0U);
__HAL_RCC_HSI48_ENABLE();
- while (READ_BIT(RCC->CR, RCC_CR_HSI48RDY) == 0U)
- ;
+ while (READ_BIT(RCC->CR, RCC_CR_HSI48RDY) == 0U);
// Initializes the CPU, AHB and APB buses clocks
FLASH->ACR = FLASH_ACR_LATENCY_4WS;
// wait until the new wait state config takes effect -- per section 3.5.1
// guidance
- while ((FLASH->ACR & FLASH_ACR_LATENCY) != FLASH_ACR_LATENCY_4WS)
- ;
+ while ((FLASH->ACR & FLASH_ACR_LATENCY) != FLASH_ACR_LATENCY_4WS);
MODIFY_REG(RCC->CFGR3, RCC_CFGR3_PPRE3, RCC_HCLK_DIV1);
MODIFY_REG(RCC->CFGR2, RCC_CFGR2_PPRE2, ((RCC_HCLK_DIV1) << 4));
MODIFY_REG(RCC->CFGR2, RCC_CFGR2_PPRE1, RCC_HCLK_DIV1);
@@ -283,8 +269,7 @@ void SystemInit(void) {
// Switch to SMPS regulator instead of LDO
SET_BIT(PWR->CR3, PWR_CR3_REGSEL);
// Wait until system switch on new regulator
- while (HAL_IS_BIT_CLR(PWR->SVMSR, PWR_SVMSR_REGS))
- ;
+ while (HAL_IS_BIT_CLR(PWR->SVMSR, PWR_SVMSR_REGS));
#endif
// enable power supply for GPIOG 2 to 15
diff --git a/core/embed/sys/syscall/stm32/syscall_internal.h b/core/embed/sys/syscall/stm32/syscall_internal.h
index b127b3b8..a37f632f 100644
--- a/core/embed/sys/syscall/stm32/syscall_internal.h
+++ b/core/embed/sys/syscall/stm32/syscall_internal.h
@@ -27,8 +27,8 @@
#ifndef KERNEL_MODE
-static inline uint32_t __attribute__((no_stack_protector))
-syscall_invoke0(uint32_t syscall) {
+static inline uint32_t __attribute__((no_stack_protector)) syscall_invoke0(
+ uint32_t syscall) {
register uint32_t ret __asm__("r0");
register uint32_t r6 __asm__("r6") = syscall;
@@ -54,8 +54,8 @@ syscall_invoke0_ret64(uint32_t syscall) {
return ((uint64_t)ret_hi << 32) | ret_lo;
}
-static inline uint32_t __attribute__((no_stack_protector))
-syscall_invoke1(uint32_t arg1, uint32_t syscall) {
+static inline uint32_t __attribute__((no_stack_protector)) syscall_invoke1(
+ uint32_t arg1, uint32_t syscall) {
register uint32_t ret __asm__("r0") = arg1;
register uint32_t r6 __asm__("r6") = syscall;
@@ -66,8 +66,8 @@ syscall_invoke1(uint32_t arg1, uint32_t syscall) {
return ret;
}
-static inline uint32_t __attribute__((no_stack_protector))
-syscall_invoke2(uint32_t arg1, uint32_t arg2, uint32_t syscall) {
+static inline uint32_t __attribute__((no_stack_protector)) syscall_invoke2(
+ uint32_t arg1, uint32_t arg2, uint32_t syscall) {
register uint32_t ret __asm__("r0") = arg1;
register uint32_t r1 __asm__("r1") = arg2;
register uint32_t r6 __asm__("r6") = syscall;
@@ -94,8 +94,8 @@ syscall_invoke2_ret64(uint32_t arg1, uint32_t arg2, uint32_t syscall) {
return ((uint64_t)ret_hi << 32) | ret_lo;
}
-static inline uint32_t __attribute__((no_stack_protector))
-syscall_invoke3(uint32_t arg1, uint32_t arg2, uint32_t arg3, uint32_t syscall) {
+static inline uint32_t __attribute__((no_stack_protector)) syscall_invoke3(
+ uint32_t arg1, uint32_t arg2, uint32_t arg3, uint32_t syscall) {
register uint32_t ret __asm__("r0") = arg1;
register uint32_t r1 __asm__("r1") = arg2;
register uint32_t r2 __asm__("r2") = arg3;
@@ -110,9 +110,9 @@ syscall_invoke3(uint32_t arg1, uint32_t arg2, uint32_t arg3, uint32_t syscall) {
return ret;
}
-static inline uint32_t __attribute__((no_stack_protector))
-syscall_invoke4(uint32_t arg1, uint32_t arg2, uint32_t arg3, uint32_t arg4,
- uint32_t syscall) {
+static inline uint32_t __attribute__((no_stack_protector)) syscall_invoke4(
+ uint32_t arg1, uint32_t arg2, uint32_t arg3, uint32_t arg4,
+ uint32_t syscall) {
register uint32_t ret __asm__("r0") = arg1;
register uint32_t r1 __asm__("r1") = arg2;
register uint32_t r2 __asm__("r2") = arg3;
@@ -128,9 +128,9 @@ syscall_invoke4(uint32_t arg1, uint32_t arg2, uint32_t arg3, uint32_t arg4,
return ret;
}
-static inline uint32_t __attribute__((no_stack_protector))
-syscall_invoke5(uint32_t arg1, uint32_t arg2, uint32_t arg3, uint32_t arg4,
- uint32_t arg5, uint32_t syscall) {
+static inline uint32_t __attribute__((no_stack_protector)) syscall_invoke5(
+ uint32_t arg1, uint32_t arg2, uint32_t arg3, uint32_t arg4, uint32_t arg5,
+ uint32_t syscall) {
register uint32_t ret __asm__("r0") = arg1;
register uint32_t r1 __asm__("r1") = arg2;
register uint32_t r2 __asm__("r2") = arg3;
@@ -147,9 +147,9 @@ syscall_invoke5(uint32_t arg1, uint32_t arg2, uint32_t arg3, uint32_t arg4,
return ret;
}
-static inline uint32_t __attribute__((no_stack_protector))
-syscall_invoke6(uint32_t arg1, uint32_t arg2, uint32_t arg3, uint32_t arg4,
- uint32_t arg5, uint32_t arg6, uint32_t syscall) {
+static inline uint32_t __attribute__((no_stack_protector)) syscall_invoke6(
+ uint32_t arg1, uint32_t arg2, uint32_t arg3, uint32_t arg4, uint32_t arg5,
+ uint32_t arg6, uint32_t syscall) {
register uint32_t ret __asm__("r0") = arg1;
register uint32_t r1 __asm__("r1") = arg2;
register uint32_t r2 __asm__("r2") = arg3;
diff --git a/core/embed/sys/syscall/stm32/syscall_stubs.c b/core/embed/sys/syscall/stm32/syscall_stubs.c
index 42917f88..d6561f71 100644
--- a/core/embed/sys/syscall/stm32/syscall_stubs.c
+++ b/core/embed/sys/syscall/stm32/syscall_stubs.c
@@ -33,8 +33,7 @@
void system_exit(int exit_code) {
syscall_invoke1(exit_code, SYSCALL_SYSTEM_EXIT);
- while (1)
- ;
+ while (1);
}
void system_exit_error_ex(const char *title, size_t title_len,
@@ -42,16 +41,14 @@ void system_exit_error_ex(const char *title, size_t title_len,
const char *footer, size_t footer_len) {
syscall_invoke6((uint32_t)title, title_len, (uint32_t)message, message_len,
(uint32_t)footer, footer_len, SYSCALL_SYSTEM_EXIT_ERROR);
- while (1)
- ;
+ while (1);
}
void system_exit_fatal_ex(const char *message, size_t message_len,
const char *file, size_t file_len, int line) {
syscall_invoke5((uint32_t)message, message_len, (uint32_t)file, file_len,
line, SYSCALL_SYSTEM_EXIT_FATAL);
- while (1)
- ;
+ while (1);
}
// =============================================================================
@@ -196,20 +193,17 @@ void boot_image_replace(const boot_image_t *image) {
void reboot_to_bootloader(void) {
syscall_invoke0(SYSCALL_REBOOT_TO_BOOTLOADER);
- while (1)
- ;
+ while (1);
}
void reboot_and_upgrade(const uint8_t hash[32]) {
syscall_invoke1((uint32_t)hash, SYSCALL_REBOOT_AND_UPGRADE);
- while (1)
- ;
+ while (1);
}
void reboot_device(void) {
syscall_invoke0(SYSCALL_REBOOT_DEVICE);
- while (1)
- ;
+ while (1);
}
// =============================================================================
diff --git a/core/embed/sys/task/stm32/coreapp.c b/core/embed/sys/task/stm32/coreapp.c
index bd0daff0..653b9b51 100644
--- a/core/embed/sys/task/stm32/coreapp.c
+++ b/core/embed/sys/task/stm32/coreapp.c
@@ -40,7 +40,7 @@ static void* coreapp_api_getter = NULL;
// defined in linker script
extern uint32_t _kernel_flash_end;
-#define KERNEL_END ALIGN_UP((uint32_t) & _kernel_flash_end, COREAPP_ALIGNMENT)
+#define KERNEL_END ALIGN_UP((uint32_t)&_kernel_flash_end, COREAPP_ALIGNMENT)
static void coreapp_clear_memory(applet_t* applet) {
if (applet->layout.data1.size > 0) {
diff --git a/core/embed/sys/time/unix/systick.c b/core/embed/sys/time/unix/systick.c
index 678f005a..66934da8 100644
--- a/core/embed/sys/time/unix/systick.c
+++ b/core/embed/sys/time/unix/systick.c
@@ -73,7 +73,7 @@ void systick_deinit(void) {
drv->initialized = false;
}
-void systick_update_freq(void){};
+void systick_update_freq(void) {};
uint32_t systick_ms() {
systick_driver_t* drv = &g_systick_driver;
diff --git a/core/embed/sys/trustzone/stm32u5/trustzone.c b/core/embed/sys/trustzone/stm32u5/trustzone.c
index 42de43a8..804c4b96 100644
--- a/core/embed/sys/trustzone/stm32u5/trustzone.c
+++ b/core/embed/sys/trustzone/stm32u5/trustzone.c
@@ -31,10 +31,10 @@
#define SAU_INIT_CTRL_ENABLE 1
#define SAU_INIT_CTRL_ALLNS 0
-#define SET_REGION(n, start, size, sec) \
- SAU->RNR = ((n) & SAU_RNR_REGION_Msk); \
- SAU->RBAR = ((start) & SAU_RBAR_BADDR_Msk); \
- SAU->RLAR = (((start) + (size)-1) & SAU_RLAR_LADDR_Msk) | \
+#define SET_REGION(n, start, size, sec) \
+ SAU->RNR = ((n) & SAU_RNR_REGION_Msk); \
+ SAU->RBAR = ((start) & SAU_RBAR_BADDR_Msk); \
+ SAU->RLAR = (((start) + (size) - 1) & SAU_RLAR_LADDR_Msk) | \
(((sec) << SAU_RLAR_NSC_Pos) & SAU_RLAR_NSC_Msk) | 1U
#define DIS_REGION(n) \
@@ -57,14 +57,14 @@ static void tz_configure_sau(void) {
extern uint8_t _sgstubs_section_start;
extern uint8_t _sgstubs_section_end;
-#define SGSTUBS_START ((uint32_t) & _sgstubs_section_start)
-#define SGSTUBS_END ((uint32_t) & _sgstubs_section_end)
+#define SGSTUBS_START ((uint32_t)&_sgstubs_section_start)
+#define SGSTUBS_END ((uint32_t)&_sgstubs_section_end)
#define SGSTUBS_SIZE (SGSTUBS_END - SGSTUBS_START)
// defined in linker script
extern uint32_t _secmon_size;
-#define SECMON_SIZE ((uint32_t) & _secmon_size)
+#define SECMON_SIZE ((uint32_t)&_secmon_size)
#define NONSECURE_CODE_START (FIRMWARE_START + SECMON_SIZE)
#define NONSECURE_CODE_SIZE (FIRMWARE_MAXSIZE - SECMON_SIZE)
diff --git a/core/embed/upymod/modtrezorutils/modtrezorutils-meminfo.h b/core/embed/upymod/modtrezorutils/modtrezorutils-meminfo.h
index 8fc8af75..a5556908 100644
--- a/core/embed/upymod/modtrezorutils/modtrezorutils-meminfo.h
+++ b/core/embed/upymod/modtrezorutils/modtrezorutils-meminfo.h
@@ -103,7 +103,7 @@
} while (0)
#define BLOCK_FROM_PTR(ptr) \
- (((byte *)(ptr)-MP_STATE_MEM(gc_pool_start)) / BYTES_PER_BLOCK)
+ (((byte *)(ptr) - MP_STATE_MEM(gc_pool_start)) / BYTES_PER_BLOCK)
#define PTR_FROM_BLOCK(block) \
(((block) * BYTES_PER_BLOCK + (uintptr_t)MP_STATE_MEM(gc_pool_start)))
#define ATB_FROM_BLOCK(bl) ((bl) / BLOCKS_PER_ATB)
diff --git a/core/embed/upymod/mpycross_include/mpconfigport.h b/core/embed/upymod/mpycross_include/mpconfigport.h
index 54255a45..899f602a 100644
--- a/core/embed/upymod/mpycross_include/mpconfigport.h
+++ b/core/embed/upymod/mpycross_include/mpconfigport.h
@@ -143,8 +143,7 @@ typedef long mp_off_t;
#define MP_NOINLINE __declspec(noinline)
#define MP_LIKELY(x) (x)
#define MP_UNLIKELY(x) (x)
-#define MICROPY_PORT_CONSTANTS \
- { MP_ROM_QSTR(MP_QSTR_dummy), MP_ROM_PTR(NULL) }
+#define MICROPY_PORT_CONSTANTS {MP_ROM_QSTR(MP_QSTR_dummy), MP_ROM_PTR(NULL)}
#ifdef _WIN64
#define MP_SSIZE_MAX _I64_MAX
#else
diff --git a/crypto/base58.c b/crypto/base58.c
index ef687f02..407feade 100644
--- a/crypto/base58.c
+++ b/crypto/base58.c
@@ -169,8 +169,7 @@ bool b58enc(char *b58, size_t *b58sz, const void *data, size_t binsz) {
}
}
- for (j = 0; j < size && !buf[j]; ++j)
- ;
+ for (j = 0; j < size && !buf[j]; ++j);
if (*b58sz <= zcount + size - j) {
*b58sz = zcount + size - j + 1;
diff --git a/crypto/ecdsa.c b/crypto/ecdsa.c
index 42e6b909..57f87329 100644
--- a/crypto/ecdsa.c
+++ b/crypto/ecdsa.c
@@ -1208,7 +1208,7 @@ int ecdsa_sig_to_der(const uint8_t *sig, uint8_t *der) {
i = 0;
while (i < 31 && sig[i] == 0) {
i++;
- } // skip leading zeroes
+ } // skip leading zeroes
if (sig[i] >= 0x80) { // put zero in output if MSB set
*p = 0x00;
p++;
@@ -1231,7 +1231,7 @@ int ecdsa_sig_to_der(const uint8_t *sig, uint8_t *der) {
i = 32;
while (i < 63 && sig[i] == 0) {
i++;
- } // skip leading zeroes
+ } // skip leading zeroes
if (sig[i] >= 0x80) { // put zero in output if MSB set
*p = 0x00;
p++;
diff --git a/crypto/nem.h b/crypto/nem.h
index fe68316f..42beb7a2 100644
--- a/crypto/nem.h
+++ b/crypto/nem.h
@@ -57,12 +57,13 @@
#define NEM_ENCRYPTED_PAYLOAD_SIZE(size) \
(AES_BLOCK_SIZE + NEM_SALT_SIZE + NEM_ENCRYPTED_SIZE(size))
-#define _NEM_PADDING_SIZE(buffer, size) ((buffer)[(size)-1])
+#define _NEM_PADDING_SIZE(buffer, size) ((buffer)[(size) - 1])
#define NEM_PADDING_SIZE(buffer, size) \
(_NEM_PADDING_SIZE(buffer, size) > (size) ? (size) \
: _NEM_PADDING_SIZE(buffer, size))
-#define NEM_DECRYPTED_SIZE(buffer, size) ((size)-NEM_PADDING_SIZE(buffer, size))
+#define NEM_DECRYPTED_SIZE(buffer, size) \
+ ((size) - NEM_PADDING_SIZE(buffer, size))
typedef struct {
ed25519_public_key public_key;
diff --git a/crypto/rand.c b/crypto/rand.c
index 65d3ae42..612e5c0a 100644
--- a/crypto/rand.c
+++ b/crypto/rand.c
@@ -25,8 +25,7 @@
uint32_t random_uniform(uint32_t n) {
uint32_t x = 0, max = 0xFFFFFFFF - (0xFFFFFFFF % n);
- while ((x = random32()) >= max)
- ;
+ while ((x = random32()) >= max);
return x / (max / n);
}
diff --git a/legacy/common.c b/legacy/common.c
index 5114c89b..8ff7843e 100644
--- a/legacy/common.c
+++ b/legacy/common.c
@@ -33,8 +33,8 @@ uint8_t HW_ENTROPY_DATA[HW_ENTROPY_LEN];
static HMAC_DRBG_CTX drbg_ctx;
-void __attribute__((noreturn))
-__fatal_error(const char *msg, const char *file, int line_num) {
+void __attribute__((noreturn)) __fatal_error(const char *msg, const char *file,
+ int line_num) {
const BITMAP *icon = &bmp_icon_error;
char line[128] = {0};
int y = icon->height + 3;
@@ -69,9 +69,10 @@ __fatal_error(const char *msg, const char *file, int line_num) {
shutdown();
}
-void __attribute__((noreturn))
-error_shutdown(const char *line1, const char *line2, const char *line3,
- const char *line4) {
+void __attribute__((noreturn)) error_shutdown(const char *line1,
+ const char *line2,
+ const char *line3,
+ const char *line4) {
layoutDialog(&bmp_icon_error, NULL, NULL, NULL, line1, line2, line3, line4,
"Please unplug", "the device.");
shutdown();
diff --git a/legacy/common.h b/legacy/common.h
index c504b611..1b7e1ce7 100644
--- a/legacy/common.h
+++ b/legacy/common.h
@@ -27,11 +27,12 @@
#define HW_ENTROPY_LEN (12 + 32)
extern uint8_t HW_ENTROPY_DATA[HW_ENTROPY_LEN];
-void __attribute__((noreturn))
-__fatal_error(const char *msg, const char *file, int line);
-void __attribute__((noreturn))
-error_shutdown(const char *line1, const char *line2, const char *line3,
- const char *line4);
+void __attribute__((noreturn)) __fatal_error(const char *msg, const char *file,
+ int line);
+void __attribute__((noreturn)) error_shutdown(const char *line1,
+ const char *line2,
+ const char *line3,
+ const char *line4);
void show_wipe_code_screen(void);
void show_pin_too_many_screen(void);
diff --git a/legacy/demo/demo.c b/legacy/demo/demo.c
index 00d8da5e..c78c49d1 100644
--- a/legacy/demo/demo.c
+++ b/legacy/demo/demo.c
@@ -143,19 +143,19 @@ static const struct {
uint8_t bReportDescriptorType;
uint16_t wDescriptorLength;
} __attribute__((packed)) hid_report;
-} __attribute__((packed))
-hid_function = {.hid_descriptor =
- {
- .bLength = sizeof(hid_function),
- .bDescriptorType = USB_DT_HID,
- .bcdHID = 0x0111,
- .bCountryCode = 0,
- .bNumDescriptors = 1,
- },
- .hid_report = {
- .bReportDescriptorType = USB_DT_REPORT,
- .wDescriptorLength = sizeof(hid_report_descriptor),
- }};
+} __attribute__((packed)) hid_function = {
+ .hid_descriptor =
+ {
+ .bLength = sizeof(hid_function),
+ .bDescriptorType = USB_DT_HID,
+ .bcdHID = 0x0111,
+ .bCountryCode = 0,
+ .bNumDescriptors = 1,
+ },
+ .hid_report = {
+ .bReportDescriptorType = USB_DT_REPORT,
+ .wDescriptorLength = sizeof(hid_report_descriptor),
+ }};
static const struct usb_endpoint_descriptor hid_endpoints[2] = {
{
diff --git a/legacy/firmware/usb.c b/legacy/firmware/usb.c
index 352e9bb4..f2a0ebe2 100644
--- a/legacy/firmware/usb.c
+++ b/legacy/firmware/usb.c
@@ -129,19 +129,19 @@ static const struct {
uint8_t bReportDescriptorType;
uint16_t wDescriptorLength;
} __attribute__((packed)) hid_report_u2f;
-} __attribute__((packed))
-hid_function_u2f = {.hid_descriptor_u2f =
- {
- .bLength = sizeof(hid_function_u2f),
- .bDescriptorType = USB_DT_HID,
- .bcdHID = 0x0111,
- .bCountryCode = 0,
- .bNumDescriptors = 1,
- },
- .hid_report_u2f = {
- .bReportDescriptorType = USB_DT_REPORT,
- .wDescriptorLength = sizeof(hid_report_descriptor_u2f),
- }};
+} __attribute__((packed)) hid_function_u2f = {
+ .hid_descriptor_u2f =
+ {
+ .bLength = sizeof(hid_function_u2f),
+ .bDescriptorType = USB_DT_HID,
+ .bcdHID = 0x0111,
+ .bCountryCode = 0,
+ .bNumDescriptors = 1,
+ },
+ .hid_report_u2f = {
+ .bReportDescriptorType = USB_DT_REPORT,
+ .wDescriptorLength = sizeof(hid_report_descriptor_u2f),
+ }};
static const struct usb_endpoint_descriptor hid_endpoints_u2f[2] = {
{
diff --git a/legacy/intermediate_fw/trezor.c b/legacy/intermediate_fw/trezor.c
index 8f0d9866..1b774ac5 100644
--- a/legacy/intermediate_fw/trezor.c
+++ b/legacy/intermediate_fw/trezor.c
@@ -46,11 +46,10 @@ static const uint8_t norcow_sectors[NORCOW_SECTOR_COUNT] = NORCOW_SECTORS;
/** Flash program word operation extracted from libopencm3,
* so it can run from RAM
*/
-static void __attribute__((noinline, section(".data#")))
-_flash_program_word(uint32_t address, uint32_t data) {
+static void __attribute__((noinline, section(".data#"))) _flash_program_word(
+ uint32_t address, uint32_t data) {
// Wait for flash controller to be ready
- while ((FLASH_SR & FLASH_SR_BSY) == FLASH_SR_BSY)
- ;
+ while ((FLASH_SR & FLASH_SR_BSY) == FLASH_SR_BSY);
// Set program word width
FLASH_CR &= ~(FLASH_CR_PROGRAM_MASK << FLASH_CR_PROGRAM_SHIFT);
@@ -63,15 +62,14 @@ _flash_program_word(uint32_t address, uint32_t data) {
MMIO32(address) = data;
// Wait for flash controller to be ready
- while ((FLASH_SR & FLASH_SR_BSY) == FLASH_SR_BSY)
- ;
+ while ((FLASH_SR & FLASH_SR_BSY) == FLASH_SR_BSY);
// Disable writes to flash
FLASH_CR &= ~FLASH_CR_PG;
}
-static void __attribute__((noinline, section(".data#")))
-invalidate_firmware(void) {
+static void __attribute__((noinline, section(".data#"))) invalidate_firmware(
+ void) {
// Flash unlock
FLASH_KEYR = FLASH_KEYR_KEY1;
FLASH_KEYR = FLASH_KEYR_KEY2;
@@ -84,13 +82,12 @@ invalidate_firmware(void) {
FLASH_CR |= FLASH_CR_LOCK;
}
-void __attribute__((noinline, noreturn, section(".data#")))
-reboot_device(void) {
+void __attribute__((noinline, noreturn, section(".data#"))) reboot_device(
+ void) {
__disable_irq();
*STAY_IN_BOOTLOADER_FLAG_ADDR = STAY_IN_BOOTLOADER_FLAG;
SCB_AIRCR = SCB_AIRCR_VECTKEY | SCB_AIRCR_SYSRESETREQ;
- while (1)
- ;
+ while (1);
}
/** Entry point of RAM shim that deletes old FW, storage and reboot */
@@ -99,8 +96,7 @@ invalidate_firmware_and_reboot(void) {
invalidate_firmware();
reboot_device();
- for (;;)
- ; // never reached, but compiler would generate error
+ for (;;); // never reached, but compiler would generate error
}
int main(void) {
diff --git a/legacy/norcow_config.h b/legacy/norcow_config.h
index 62142aa9..95d872e2 100644
--- a/legacy/norcow_config.h
+++ b/legacy/norcow_config.h
@@ -24,8 +24,7 @@
#define NORCOW_SECTOR_COUNT 2
#define NORCOW_SECTOR_SIZE (16 * 1024)
-#define NORCOW_SECTORS \
- { 2, 3 }
+#define NORCOW_SECTORS {2, 3}
/*
* The length of the sector header in bytes. The header is preserved between
diff --git a/legacy/oled.c b/legacy/oled.c
index 7fe94d90..5989bf53 100644
--- a/legacy/oled.c
+++ b/legacy/oled.c
@@ -118,10 +118,8 @@ static inline void SPISend(uint32_t base, const uint8_t *data, int len) {
for (int i = 0; i < len; i++) {
spi_send(base, data[i]);
}
- while (!(SPI_SR(base) & SPI_SR_TXE))
- ;
- while ((SPI_SR(base) & SPI_SR_BSY))
- ;
+ while (!(SPI_SR(base) & SPI_SR_TXE));
+ while ((SPI_SR(base) & SPI_SR_BSY));
}
/*
diff --git a/legacy/util.h b/legacy/util.h
index d0b31c7e..2c1666b8 100644
--- a/legacy/util.h
+++ b/legacy/util.h
@@ -71,8 +71,9 @@ extern void memset_reg(void *start, void *stop, uint32_t val);
#define FW_SIGNED 0x5A3CA5C3
#define FW_UNTRUSTED 0x00000000
-static inline void __attribute__((noreturn))
-jump_to_firmware(const vector_table_t *ivt, int trust) {
+static inline void
+ __attribute__((noreturn)) jump_to_firmware(const vector_table_t *ivt,
+ int trust) {
if (FW_SIGNED == trust) { // trusted signed firmware
SCB_VTOR = (uint32_t)ivt; // * relocate vector table
// Set stack pointer
@@ -92,8 +93,7 @@ jump_to_firmware(const vector_table_t *ivt, int trust) {
// Prevent compiler from generating stack protector code (which causes CPU
// fault because the stack is moved)
- for (;;)
- ;
+ for (;;);
}
static inline void set_mode_unprivileged(void) {
diff --git a/legacy/webusb_defs.h b/legacy/webusb_defs.h
index b8566f12..458fafdd 100644
--- a/legacy/webusb_defs.h
+++ b/legacy/webusb_defs.h
@@ -48,11 +48,9 @@ struct webusb_platform_descriptor {
// from https://wicg.github.io/webusb/#webusb-platform-capability-descriptor
// see also this (for endianness explanation)
// https://github.com/WICG/webusb/issues/115#issuecomment-352206549
-#define WEBUSB_UUID \
- { \
- 0x38, 0xB6, 0x08, 0x34, 0xA9, 0x09, 0xA0, 0x47, 0x8B, 0xFD, 0xA0, 0x76, \
- 0x88, 0x15, 0xB6, 0x65 \
- }
+#define WEBUSB_UUID \
+ {0x38, 0xB6, 0x08, 0x34, 0xA9, 0x09, 0xA0, 0x47, \
+ 0x8B, 0xFD, 0xA0, 0x76, 0x88, 0x15, 0xB6, 0x65}
struct webusb_url_descriptor {
uint8_t bLength;
diff --git a/legacy/winusb.h b/legacy/winusb.h
index 071f262f..2c63a966 100644
--- a/legacy/winusb.h
+++ b/legacy/winusb.h
@@ -25,7 +25,7 @@
// Arbitrary, but must be equivalent to the last character in extra string
#define WINUSB_MS_VENDOR_CODE '!'
#define WINUSB_EXTRA_STRING \
- { 'M', 'S', 'F', 'T', '1', '0', '0', WINUSB_MS_VENDOR_CODE }
+ {'M', 'S', 'F', 'T', '1', '0', '0', WINUSB_MS_VENDOR_CODE}
extern void winusb_setup(usbd_device* usbd_dev, uint8_t interface);
diff --git a/storage/tests/c0/norcow_config.h b/storage/tests/c0/norcow_config.h
index 1478be68..f351caa3 100644
--- a/storage/tests/c0/norcow_config.h
+++ b/storage/tests/c0/norcow_config.h
@@ -24,7 +24,6 @@
#define NORCOW_SECTOR_COUNT 2
#define NORCOW_SECTOR_SIZE (64 * 1024)
-#define NORCOW_SECTORS \
- { 4, 16 }
+#define NORCOW_SECTORS {4, 16}
#endif
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.