diff --git a/embed/bootloader/messages.c b/embed/bootloader/messages.c index 6c981dd94..4cd1fa0f7 100644 --- a/embed/bootloader/messages.c +++ b/embed/bootloader/messages.c @@ -140,8 +140,6 @@ static secbool _send_msg(uint8_t iface_num, uint16_t msg_id, const pb_field_t fi return sectrue; } -#define MIN(a, b) (((a) < (b)) ? (a) : (b)) - #define MSG_SEND_INIT(TYPE) TYPE msg_send = TYPE##_init_default #define MSG_SEND_ASSIGN_VALUE(FIELD, VALUE) { msg_send.has_##FIELD = true; msg_send.FIELD = VALUE; } #define MSG_SEND_ASSIGN_STRING(FIELD, VALUE) { msg_send.has_##FIELD = true; memset(msg_send.FIELD, 0, sizeof(msg_send.FIELD)); strncpy(msg_send.FIELD, VALUE, sizeof(msg_send.FIELD) - 1); } diff --git a/embed/extmod/modtrezorui/display.c b/embed/extmod/modtrezorui/display.c index 46c407df6..518567131 100644 --- a/embed/extmod/modtrezorui/display.c +++ b/embed/extmod/modtrezorui/display.c @@ -40,9 +40,6 @@ static struct { #error Unsupported TREZOR port. Only STM32 and UNIX ports are supported. #endif -#define MIN(a,b) (((a)<(b))?(a):(b)) -#define MAX(a,b) (((a)>(b))?(a):(b)) - // common display functions static inline uint16_t interpolate_color(uint16_t color0, uint16_t color1, uint8_t step) diff --git a/embed/trezorhal/common.h b/embed/trezorhal/common.h index 7e1c32e09..bc904a221 100644 --- a/embed/trezorhal/common.h +++ b/embed/trezorhal/common.h @@ -4,6 +4,13 @@ #include #include "secbool.h" +#ifndef MIN +#define MIN(a, b) (((a) < (b)) ? (a) : (b)) +#endif +#ifndef MAX +#define MAX(a, b) (((a) > (b)) ? (a) : (b)) +#endif + void __attribute__((noreturn)) __fatal_error(const char *expr, const char *msg, const char *file, int line, const char *func); #define ensure(expr, msg) (((expr) == sectrue) ? (void)0 : __fatal_error(#expr, msg, __FILE__, __LINE__, __func__)) diff --git a/embed/trezorhal/image.c b/embed/trezorhal/image.c index bbc9f4ce8..14c4083f9 100644 --- a/embed/trezorhal/image.c +++ b/embed/trezorhal/image.c @@ -153,8 +153,6 @@ secbool check_single_hash(const uint8_t * const hash, const uint8_t * const data return sectrue * (0 == memcmp(h, hash, BLAKE2S_DIGEST_LENGTH)); } -#define MIN(a,b) ((a) < (b) ? (a) : (b)) - secbool check_image_contents(const image_header * const hdr, uint32_t firstskip, const uint8_t *sectors, int blocks) { if (0 == sectors || blocks < 1) { diff --git a/embed/unix/common.h b/embed/unix/common.h index 41c12946f..30718ee6d 100644 --- a/embed/unix/common.h +++ b/embed/unix/common.h @@ -4,6 +4,13 @@ #include #include "secbool.h" +#ifndef MIN +#define MIN(a, b) (((a) < (b)) ? (a) : (b)) +#endif +#ifndef MAX +#define MAX(a, b) (((a) > (b)) ? (a) : (b)) +#endif + void __attribute__((noreturn)) __fatal_error(const char *expr, const char *msg, const char *file, int line, const char *func); #define ensure(expr, msg) (((expr) == sectrue) ? (void)0 : __fatal_error(#expr, msg, __FILE__, __LINE__, __func__))