diff --git a/include/arch/bits_portable.h b/include/arch/bits_portable.h index 2890a74cb43..d4496665e86 100644 --- a/include/arch/bits_portable.h +++ b/include/arch/bits_portable.h @@ -29,7 +29,7 @@ static ALWAYS_INLINE unsigned int find_msb_set(u32_t op) { - if (!op) { + if (op == 0) { return 0; } diff --git a/include/arch/x86/arch.h b/include/arch/x86/arch.h index 21bbf470f72..e5d6e7711f1 100644 --- a/include/arch/x86/arch.h +++ b/include/arch/x86/arch.h @@ -444,7 +444,7 @@ static ALWAYS_INLINE unsigned int z_arch_irq_lock(void) static ALWAYS_INLINE void z_arch_irq_unlock(unsigned int key) { - if (!(key & 0x200)) { + if ((key & 0x200) == 0) { return; } diff --git a/include/atomic.h b/include/atomic.h index 510ffdfffde..1596d60e91c 100644 --- a/include/atomic.h +++ b/include/atomic.h @@ -12,6 +12,8 @@ #include #include +#include + #ifdef __cplusplus extern "C" { #endif @@ -312,7 +314,7 @@ extern atomic_val_t atomic_nand(atomic_t *target, atomic_val_t value); */ #define ATOMIC_BITS (sizeof(atomic_val_t) * 8) -#define ATOMIC_MASK(bit) (1 << ((bit) & (ATOMIC_BITS - 1))) +#define ATOMIC_MASK(bit) (1 << ((u32_t)(bit) & (ATOMIC_BITS - 1))) #define ATOMIC_ELEM(addr, bit) ((addr) + ((bit) / ATOMIC_BITS)) /** diff --git a/include/gpio.h b/include/gpio.h index 4507f2e994a..0d7dabe07a7 100644 --- a/include/gpio.h +++ b/include/gpio.h @@ -165,7 +165,7 @@ static inline int z_impl_gpio_enable_callback(struct device *port, const struct gpio_driver_api *api = (const struct gpio_driver_api *)port->driver_api; - if (!api->enable_callback) { + if (api->enable_callback == NULL) { return -ENOTSUP; } @@ -181,7 +181,7 @@ static inline int z_impl_gpio_disable_callback(struct device *port, const struct gpio_driver_api *api = (const struct gpio_driver_api *)port->driver_api; - if (!api->disable_callback) { + if (api->disable_callback == NULL) { return -ENOTSUP; } @@ -268,7 +268,7 @@ static inline int gpio_add_callback(struct device *port, const struct gpio_driver_api *api = (const struct gpio_driver_api *)port->driver_api; - if (!api->manage_callback) { + if (api->manage_callback == NULL) { return -ENOTSUP; } @@ -297,7 +297,7 @@ static inline int gpio_remove_callback(struct device *port, const struct gpio_driver_api *api = (const struct gpio_driver_api *)port->driver_api; - if (!api->manage_callback) { + if (api->manage_callback == NULL) { return -ENOTSUP; } @@ -428,7 +428,7 @@ static inline int z_impl_gpio_get_pending_int(struct device *dev) const struct gpio_driver_api *api = (const struct gpio_driver_api *)dev->driver_api; - if (!api->get_pending_int) { + if (api->get_pending_int == NULL) { return -ENOTSUP; } diff --git a/include/i2c.h b/include/i2c.h index 2120b1c9580..1c1fa8004a1 100644 --- a/include/i2c.h +++ b/include/i2c.h @@ -284,7 +284,7 @@ static inline int z_impl_i2c_slave_register(struct device *dev, const struct i2c_driver_api *api = (const struct i2c_driver_api *)dev->driver_api; - if (!api->slave_register) { + if (api->slave_register == NULL) { return -ENOTSUP; } @@ -315,7 +315,7 @@ static inline int z_impl_i2c_slave_unregister(struct device *dev, const struct i2c_driver_api *api = (const struct i2c_driver_api *)dev->driver_api; - if (!api->slave_unregister) { + if (api->slave_unregister == NULL) { return -ENOTSUP; } diff --git a/include/logging/log_core.h b/include/logging/log_core.h index 6a41c06668b..727181b3d89 100644 --- a/include/logging/log_core.h +++ b/include/logging/log_core.h @@ -219,13 +219,13 @@ extern "C" { .source_id = _id \ }; \ \ - if (BIT(_level) & LOG_FUNCTION_PREFIX_MASK) { \ + if ((BIT(_level) & LOG_FUNCTION_PREFIX_MASK) != 0) {\ __LOG_INTERNAL(src_level, \ Z_LOG_STR(__VA_ARGS__)); \ } else { \ __LOG_INTERNAL(src_level, __VA_ARGS__); \ } \ - } else if (0) { \ + } else if (false) { \ /* Arguments checker present but never evaluated.*/ \ /* Placed here to ensure that __VA_ARGS__ are*/ \ /* evaluated once when log is enabled.*/ \ diff --git a/include/misc/list_gen.h b/include/misc/list_gen.h index 9cba9d4b0a9..e9cb41598a3 100644 --- a/include/misc/list_gen.h +++ b/include/misc/list_gen.h @@ -58,7 +58,7 @@ static inline bool \ sys_ ## __lname ## _is_empty(sys_ ## __lname ## _t *list) \ { \ - return (!sys_ ## __lname ## _peek_head(list)); \ + return (sys_ ## __lname ## _peek_head(list) == NULL); \ } #define Z_GENLIST_PEEK_NEXT_NO_CHECK(__lname, __nname) \ @@ -145,7 +145,7 @@ sys_ ## __nname ## _t *prev, \ sys_ ## __nname ## _t *node) \ { \ - if (!prev) { \ + if (prev == NULL) { \ sys_ ## __lname ## _prepend(list, node); \ } else if (!z_ ## __nname ## _next_peek(prev)) { \ sys_ ## __lname ## _append(list, node); \ @@ -187,7 +187,7 @@ sys_ ## __nname ## _t *prev_node, \ sys_ ## __nname ## _t *node) \ { \ - if (!prev_node) { \ + if (prev_node == NULL) { \ z_ ## __lname ## _head_set(list, \ z_ ## __nname ## _next_peek(node)); \ \ diff --git a/include/misc/util.h b/include/misc/util.h index 73f50bd8a80..9110bac5b61 100644 --- a/include/misc/util.h +++ b/include/misc/util.h @@ -94,7 +94,7 @@ constexpr size_t ARRAY_SIZE(T(&)[N]) { return N; } #define MIN(a, b) (((a) < (b)) ? (a) : (b)) #endif -static inline int is_power_of_two(unsigned int x) +static inline bool is_power_of_two(unsigned int x) { return (x != 0) && !(x & (x - 1)); } diff --git a/include/rtc.h b/include/rtc.h index 11aac3a5549..7d7196d485d 100644 --- a/include/rtc.h +++ b/include/rtc.h @@ -101,7 +101,7 @@ __deprecated static inline int rtc_set_config(struct device *dev, err = counter_set_top_value(dev, cfg->alarm_val, rtc_counter_top_callback, cfg->cb_fn); - if (!err && cfg->alarm_enable) { + if (err == 0 && cfg->alarm_enable != 0) { err = counter_start(dev); } diff --git a/include/sensor.h b/include/sensor.h index d65a3df4396..972f84b5561 100644 --- a/include/sensor.h +++ b/include/sensor.h @@ -288,7 +288,7 @@ static inline int z_impl_sensor_attr_set(struct device *dev, { const struct sensor_driver_api *api = dev->driver_api; - if (!api->attr_set) { + if (api->attr_set == NULL) { return -ENOTSUP; } @@ -318,7 +318,7 @@ static inline int sensor_trigger_set(struct device *dev, { const struct sensor_driver_api *api = dev->driver_api; - if (!api->trigger_set) { + if (api->trigger_set == NULL) { return -ENOTSUP; } diff --git a/include/uart.h b/include/uart.h index ac06a9cb827..c11517ccbf3 100644 --- a/include/uart.h +++ b/include/uart.h @@ -582,7 +582,7 @@ static inline int z_impl_uart_err_check(struct device *dev) const struct uart_driver_api *api = (const struct uart_driver_api *)dev->driver_api; - if (api->err_check) { + if (api->err_check != NULL) { return api->err_check(dev); } return 0; @@ -657,7 +657,7 @@ static inline int z_impl_uart_configure(struct device *dev, const struct uart_driver_api *api = (const struct uart_driver_api *)dev->driver_api; - if (api->configure) { + if (api->configure != NULL) { return api->configure(dev, cfg); } @@ -684,7 +684,7 @@ static inline int z_impl_uart_config_get(struct device *dev, const struct uart_driver_api *api = (const struct uart_driver_api *)dev->driver_api; - if (api->config_get) { + if (api->config_get != NULL) { return api->config_get(dev, cfg); }