From 5f5377f22512d65ccc6906e1c66e74488c5c20b5 Mon Sep 17 00:00:00 2001 From: Flavio Ceolin Date: Thu, 14 Mar 2019 14:40:28 -0700 Subject: [PATCH] include: Add missing U for unsigned constants MISRA-C rule 10.1 Signed-off-by: Flavio Ceolin --- include/logging/log_core.h | 12 ++++++++---- include/misc/util.h | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/include/logging/log_core.h b/include/logging/log_core.h index eb4a86317b6..ef13a64b4ac 100644 --- a/include/logging/log_core.h +++ b/include/logging/log_core.h @@ -10,6 +10,7 @@ #include #include #include +#include #ifdef __cplusplus extern "C" { @@ -26,10 +27,13 @@ extern "C" { #endif #define LOG_FUNCTION_PREFIX_MASK \ - ((IS_ENABLED(CONFIG_LOG_FUNC_NAME_PREFIX_ERR) << LOG_LEVEL_ERR) | \ - (IS_ENABLED(CONFIG_LOG_FUNC_NAME_PREFIX_WRN) << LOG_LEVEL_WRN) | \ - (IS_ENABLED(CONFIG_LOG_FUNC_NAME_PREFIX_INF) << LOG_LEVEL_INF) | \ - (IS_ENABLED(CONFIG_LOG_FUNC_NAME_PREFIX_DBG) << LOG_LEVEL_DBG)) + (((u32_t)IS_ENABLED(CONFIG_LOG_FUNC_NAME_PREFIX_ERR) << \ + LOG_LEVEL_ERR) | \ + ((u32_t)IS_ENABLED(CONFIG_LOG_FUNC_NAME_PREFIX_WRN) << \ + LOG_LEVEL_WRN) | \ + ((u32_t)IS_ENABLED(CONFIG_LOG_FUNC_NAME_PREFIX_INF) << \ + LOG_LEVEL_INF) | \ + ((u32_t)IS_ENABLED(CONFIG_LOG_FUNC_NAME_PREFIX_DBG) << LOG_LEVEL_DBG)) /** @brief Macro for returning local level value if defined or default. * diff --git a/include/misc/util.h b/include/misc/util.h index 9110bac5b61..959785ba5c0 100644 --- a/include/misc/util.h +++ b/include/misc/util.h @@ -96,14 +96,14 @@ constexpr size_t ARRAY_SIZE(T(&)[N]) { return N; } static inline bool is_power_of_two(unsigned int x) { - return (x != 0) && !(x & (x - 1)); + return (x != 0U) && ((x & (x - 1)) == 0U); } static inline s64_t arithmetic_shift_right(s64_t value, u8_t shift) { s64_t sign_ext; - if (shift == 0) { + if (shift == 0U) { return value; }