From 18f7820d4706454d0c0ab5aa0af8d5011394d6f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Vejpustek?= Date: Fri, 10 May 2024 15:36:21 +0200 Subject: [PATCH] style: fix style according to new clang [no changelog] --- .../modtrezorutils/modtrezorutils-meminfo.h | 10 +++++----- core/embed/lib/display.c | 4 +++- core/embed/lib/fonts/fonts.c | 2 +- core/embed/trezorhal/boards/stm32u5a9j-dk.h | 4 ++-- .../embed/trezorhal/stm32f4/displays/st7789v.c | 2 +- .../embed/trezorhal/stm32f4/displays/st7789v.h | 2 +- core/embed/trezorhal/stm32u5/touch/sitronix.c | 4 ++-- core/embed/trezorhal/stm32u5/trustzone.c | 8 ++++---- crypto/chacha_drbg.h | 2 +- crypto/monero/int-util.h | 18 +++++++++--------- crypto/monero/serialize.c | 2 +- legacy/firmware/ethereum.c | 2 +- legacy/firmware/recovery.c | 2 +- storage/flash_ll.h | 4 ++-- 14 files changed, 34 insertions(+), 32 deletions(-) diff --git a/core/embed/extmod/modtrezorutils/modtrezorutils-meminfo.h b/core/embed/extmod/modtrezorutils/modtrezorutils-meminfo.h index 6c825343fd..422c83caac 100644 --- a/core/embed/extmod/modtrezorutils/modtrezorutils-meminfo.h +++ b/core/embed/extmod/modtrezorutils/modtrezorutils-meminfo.h @@ -59,10 +59,10 @@ #define ATB_MASK_2 (0x30) #define ATB_MASK_3 (0xc0) -#define ATB_0_IS_FREE(a) (((a)&ATB_MASK_0) == 0) -#define ATB_1_IS_FREE(a) (((a)&ATB_MASK_1) == 0) -#define ATB_2_IS_FREE(a) (((a)&ATB_MASK_2) == 0) -#define ATB_3_IS_FREE(a) (((a)&ATB_MASK_3) == 0) +#define ATB_0_IS_FREE(a) (((a) & ATB_MASK_0) == 0) +#define ATB_1_IS_FREE(a) (((a) & ATB_MASK_1) == 0) +#define ATB_2_IS_FREE(a) (((a) & ATB_MASK_2) == 0) +#define ATB_3_IS_FREE(a) (((a) & ATB_MASK_3) == 0) #define BLOCK_SHIFT(block) (2 * ((block) & (BLOCKS_PER_ATB - 1))) #define ATB_GET_KIND(block) \ @@ -98,7 +98,7 @@ #define BLOCK_FROM_PTR(ptr) \ (((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))) + (((block) * BYTES_PER_BLOCK + (uintptr_t)MP_STATE_MEM(gc_pool_start))) #define ATB_FROM_BLOCK(bl) ((bl) / BLOCKS_PER_ATB) // ptr should be of type void* diff --git a/core/embed/lib/display.c b/core/embed/lib/display.c index 5c99bfaffc..c50886799e 100644 --- a/core/embed/lib/display.c +++ b/core/embed/lib/display.c @@ -36,7 +36,9 @@ #include "display_interface.h" -static struct { int x, y; } DISPLAY_OFFSET; +static struct { + int x, y; +} DISPLAY_OFFSET; // common display functions diff --git a/core/embed/lib/fonts/fonts.c b/core/embed/lib/fonts/fonts.c index b40be71e19..7bb2350a38 100644 --- a/core/embed/lib/fonts/fonts.c +++ b/core/embed/lib/fonts/fonts.c @@ -139,7 +139,7 @@ font_glyph_iter_t font_glyph_iter_init(const int font, const uint8_t *text, }; } -#define IS_UTF8_CONTINUE(c) (((c)&0b11000000) == 0b10000000) +#define IS_UTF8_CONTINUE(c) (((c) & 0b11000000) == 0b10000000) static uint16_t next_utf8_codepoint(font_glyph_iter_t *iter) { uint16_t out; diff --git a/core/embed/trezorhal/boards/stm32u5a9j-dk.h b/core/embed/trezorhal/boards/stm32u5a9j-dk.h index 3ff3673ee6..bb21f24766 100644 --- a/core/embed/trezorhal/boards/stm32u5a9j-dk.h +++ b/core/embed/trezorhal/boards/stm32u5a9j-dk.h @@ -7,8 +7,8 @@ #define USE_I2C 1 #define USE_RGB_COLORS 1 #define USE_TOUCH 1 -//#define USE_SBU 1 -//#define USE_DISP_I8080_8BIT_DW 1 +// #define USE_SBU 1 +// #define USE_DISP_I8080_8BIT_DW 1 #define USE_HASH_PROCESSOR 1 #include "displays/dsi.h" diff --git a/core/embed/trezorhal/stm32f4/displays/st7789v.c b/core/embed/trezorhal/stm32f4/displays/st7789v.c index 7e9f1392c7..f4e047dc44 100644 --- a/core/embed/trezorhal/stm32f4/displays/st7789v.c +++ b/core/embed/trezorhal/stm32f4/displays/st7789v.c @@ -70,7 +70,7 @@ __IO DISP_MEM_TYPE *const DISPLAY_DATA_ADDRESS = #endif #define DATA_TRANSFER(X) \ - DATA((X)&0xFF); \ + DATA((X) & 0xFF); \ DATA((X) >> 8) __attribute__((section(".fb1"))) diff --git a/core/embed/trezorhal/stm32f4/displays/st7789v.h b/core/embed/trezorhal/stm32f4/displays/st7789v.h index f3f1958714..4f8a816ffd 100644 --- a/core/embed/trezorhal/stm32f4/displays/st7789v.h +++ b/core/embed/trezorhal/stm32f4/displays/st7789v.h @@ -55,7 +55,7 @@ void display_efficient_clear(void); #define PIXELDATA(X) DATA(X) #elif USE_DISP_I8080_8BIT_DW #define PIXELDATA(X) \ - DATA((X)&0xFF); \ + DATA((X) & 0xFF); \ DATA((X) >> 8) #endif diff --git a/core/embed/trezorhal/stm32u5/touch/sitronix.c b/core/embed/trezorhal/stm32u5/touch/sitronix.c index d097cc9ca7..b705ceba77 100644 --- a/core/embed/trezorhal/stm32u5/touch/sitronix.c +++ b/core/embed/trezorhal/stm32u5/touch/sitronix.c @@ -681,8 +681,8 @@ typedef struct { #define TS_INT_EXTI_IRQn EXTI8_IRQn /* Includes ------------------------------------------------------------------*/ -//#include "stm32u5x9j_discovery_ts.h" -//#include "stm32u5x9j_discovery.h" +// #include "stm32u5x9j_discovery_ts.h" +// #include "stm32u5x9j_discovery.h" /** @addtogroup BSP * @{ diff --git a/core/embed/trezorhal/stm32u5/trustzone.c b/core/embed/trezorhal/stm32u5/trustzone.c index e760217cc2..f77fbb4a15 100644 --- a/core/embed/trezorhal/stm32u5/trustzone.c +++ b/core/embed/trezorhal/stm32u5/trustzone.c @@ -25,10 +25,10 @@ #define SAU_INIT_CTRL_ENABLE 1 #define SAU_INIT_CTRL_ALLNS 0 -#define SAU_INIT_REGION(n, start, end, sec) \ - SAU->RNR = ((n)&SAU_RNR_REGION_Msk); \ - SAU->RBAR = ((start)&SAU_RBAR_BADDR_Msk); \ - SAU->RLAR = ((end)&SAU_RLAR_LADDR_Msk) | \ +#define SAU_INIT_REGION(n, start, end, sec) \ + SAU->RNR = ((n) & SAU_RNR_REGION_Msk); \ + SAU->RBAR = ((start) & SAU_RBAR_BADDR_Msk); \ + SAU->RLAR = ((end) & SAU_RLAR_LADDR_Msk) | \ (((sec) << SAU_RLAR_NSC_Pos) & SAU_RLAR_NSC_Msk) | 1U static void trustzone_configure_sau(void) { diff --git a/crypto/chacha_drbg.h b/crypto/chacha_drbg.h index 83e2d0b421..15c3d73161 100644 --- a/crypto/chacha_drbg.h +++ b/crypto/chacha_drbg.h @@ -33,7 +33,7 @@ // block_count blocks of hash function in derivation_function. There is no need // the input to have this length, it's just an optimalization. #define CHACHA_DRBG_OPTIMAL_RESEED_LENGTH(block_count) \ - ((block_count)*SHA256_BLOCK_LENGTH - 1 - 4 - 9) + ((block_count) * SHA256_BLOCK_LENGTH - 1 - 4 - 9) // 1 = sizeof(counter), 4 = sizeof(output_length) in // derivation_function, 9 is length of SHA256 padding of message // aligned to bytes diff --git a/crypto/monero/int-util.h b/crypto/monero/int-util.h index 4942a1a0a0..c1c8553807 100644 --- a/crypto/monero/int-util.h +++ b/crypto/monero/int-util.h @@ -67,12 +67,12 @@ static inline uint64_t mul128(uint64_t multiplier, uint64_t multiplicand, return product_lo; } -#define SWAP64(x) \ - ((((uint64_t)(x)&0x00000000000000ff) << 56) | \ - (((uint64_t)(x)&0x000000000000ff00) << 40) | \ - (((uint64_t)(x)&0x0000000000ff0000) << 24) | \ - (((uint64_t)(x)&0x00000000ff000000) << 8) | \ - (((uint64_t)(x)&0x000000ff00000000) >> 8) | \ - (((uint64_t)(x)&0x0000ff0000000000) >> 24) | \ - (((uint64_t)(x)&0x00ff000000000000) >> 40) | \ - (((uint64_t)(x)&0xff00000000000000) >> 56)) +#define SWAP64(x) \ + ((((uint64_t)(x) & 0x00000000000000ff) << 56) | \ + (((uint64_t)(x) & 0x000000000000ff00) << 40) | \ + (((uint64_t)(x) & 0x0000000000ff0000) << 24) | \ + (((uint64_t)(x) & 0x00000000ff000000) << 8) | \ + (((uint64_t)(x) & 0x000000ff00000000) >> 8) | \ + (((uint64_t)(x) & 0x0000ff0000000000) >> 24) | \ + (((uint64_t)(x) & 0x00ff000000000000) >> 40) | \ + (((uint64_t)(x) & 0xff00000000000000) >> 56)) diff --git a/crypto/monero/serialize.c b/crypto/monero/serialize.c index 4d4cbd8bbe..1580718cb9 100644 --- a/crypto/monero/serialize.c +++ b/crypto/monero/serialize.c @@ -16,7 +16,7 @@ int xmr_size_varint(uint64_t num) { int xmr_write_varint(uint8_t *buff, size_t buff_size, uint64_t num) { unsigned ctr = 0; while (num >= 0x80 && ctr < buff_size) { - *buff = (uint8_t)(((num)&0x7f) | 0x80); + *buff = (uint8_t)(((num) & 0x7f) | 0x80); ++buff; ++ctr; num >>= 7; diff --git a/legacy/firmware/ethereum.c b/legacy/firmware/ethereum.c index e5682a08e8..c047ceb9b7 100644 --- a/legacy/firmware/ethereum.c +++ b/legacy/firmware/ethereum.c @@ -159,7 +159,7 @@ static void hash_rlp_number(uint64_t number) { data[4] = (number >> 24) & 0xff; data[5] = (number >> 16) & 0xff; data[6] = (number >> 8) & 0xff; - data[7] = (number)&0xff; + data[7] = (number) & 0xff; int offset = 0; while (!data[offset]) { offset++; diff --git a/legacy/firmware/recovery.c b/legacy/firmware/recovery.c index 6aae892efc..9ed3b7b435 100644 --- a/legacy/firmware/recovery.c +++ b/legacy/firmware/recovery.c @@ -112,7 +112,7 @@ static uint8_t word_matrix[9]; * prefix length or table for the very first level, as the prefix length * is always one and there are always nine choices on the second level. */ -#define MASK_IDX(x) ((x)&0xfff) +#define MASK_IDX(x) ((x) & 0xfff) #define TABLE1(x) MASK_IDX(word_table1[x]) #define TABLE2(x) MASK_IDX(word_table2[x]) diff --git a/storage/flash_ll.h b/storage/flash_ll.h index c7704cf0d2..e6faaee09a 100644 --- a/storage/flash_ll.h +++ b/storage/flash_ll.h @@ -36,10 +36,10 @@ typedef uint32_t flash_block_t[FLASH_BLOCK_WORDS]; #if FLASH_BLOCK_WORDS == 1 #define FLASH_ALIGN(X) (((X) + 3) & ~3) -#define FLASH_IS_ALIGNED(X) (((X)&3) == 0) +#define FLASH_IS_ALIGNED(X) (((X) & 3) == 0) #elif FLASH_BLOCK_WORDS == 4 #define FLASH_ALIGN(X) (((X) + 0xF) & ~0xF) -#define FLASH_IS_ALIGNED(X) (((X)&0xF) == 0) +#define FLASH_IS_ALIGNED(X) (((X) & 0xF) == 0) #else #error Unsupported number of FLASH_BLOCK_WORDS. #endif