From: Michal Krawczyk Date: Thu, 17 Sep 2020 05:30:16 +0000 (+0200) Subject: net/ena/base: use min/max macros with type conversion X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=8478f502f844ca0055a313609a58d80d30a0bdfd;p=dpdk.git net/ena/base: use min/max macros with type conversion Usage of RTE_MIN(MAX) in ENA_MIN32, ENA_MIN16, ENA_MIN8 (and same for the MAX), was not enough, as the HAL code is assuming that those macros will convert both arguments to the specified uintX_t type. As RTE_MIN(MAX) is using 'typeof' operator, the behavior won't be the same, especially if arguments has different types (and it could cause compilation warnings). To satisfy that, the ENA_MIN_T and ENA_MAX_T macros were added, which are converting both arguments to the type which is being passed as an argument. Fixes: 9ba7981ec992 ("ena: add communication layer for DPDK") Cc: stable@dpdk.org Signed-off-by: Michal Krawczyk Reviewed-by: Igor Chauskin Reviewed-by: Guy Tzalik Reviewed-by: Stephen Hemminger --- diff --git a/drivers/net/ena/base/ena_plat_dpdk.h b/drivers/net/ena/base/ena_plat_dpdk.h index 595967e6e3..ba7a098f59 100644 --- a/drivers/net/ena/base/ena_plat_dpdk.h +++ b/drivers/net/ena/base/ena_plat_dpdk.h @@ -86,12 +86,14 @@ extern int ena_logtype_com; #define ENA_ASSERT(cond, format, arg...) do {} while (0) #endif -#define ENA_MAX32(x, y) RTE_MAX((x), (y)) -#define ENA_MAX16(x, y) RTE_MAX((x), (y)) -#define ENA_MAX8(x, y) RTE_MAX((x), (y)) -#define ENA_MIN32(x, y) RTE_MIN((x), (y)) -#define ENA_MIN16(x, y) RTE_MIN((x), (y)) -#define ENA_MIN8(x, y) RTE_MIN((x), (y)) +#define ENA_MAX_T(type, x, y) RTE_MAX((type)(x), (type)(y)) +#define ENA_MAX32(x, y) ENA_MAX_T(uint32_t, (x), (y)) +#define ENA_MAX16(x, y) ENA_MAX_T(uint16_t, (x), (y)) +#define ENA_MAX8(x, y) ENA_MAX_T(uint8_t, (x), (y)) +#define ENA_MIN_T(type, x, y) RTE_MIN((type)(x), (type)(y)) +#define ENA_MIN32(x, y) ENA_MIN_T(uint32_t, (x), (y)) +#define ENA_MIN16(x, y) ENA_MIN_T(uint16_t, (x), (y)) +#define ENA_MIN8(x, y) ENA_MIN_T(uint8_t, (x), (y)) #define BITS_PER_LONG_LONG (__SIZEOF_LONG_LONG__ * 8) #define U64_C(x) x ## ULL