From 68083e7ad5ded7adbeca147546bbda6c14cab049 Mon Sep 17 00:00:00 2001 From: Yann Gautier Date: Mon, 28 Nov 2022 14:55:14 +0100 Subject: [PATCH] fix(st-regulator): explicitly check operators precedence This corrects the MISRA violation C2012-12.1: The precedence of operators within expressions should be made explicit. This is done either by adding parentheses, or by creating dedicated variables. Signed-off-by: Yann Gautier Change-Id: If8312442222ba848ac1f5e38df1bed0a367646a7 --- drivers/st/regulator/regulator_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/st/regulator/regulator_core.c b/drivers/st/regulator/regulator_core.c index 5cc832915..a7482e03a 100644 --- a/drivers/st/regulator/regulator_core.c +++ b/drivers/st/regulator/regulator_core.c @@ -86,7 +86,7 @@ static int32_t get_supply_phandle(const void *fdt, int node, const char *name) char prop_name[MAX_PROPERTY_LEN]; len = snprintf(prop_name, MAX_PROPERTY_LEN - 1, "%s-supply", name); - assert((len >= 0) && (len < MAX_PROPERTY_LEN - 1)); + assert((len >= 0) && (len < (MAX_PROPERTY_LEN - 1))); cuint = fdt_getprop(fdt, node, prop_name, NULL); if (cuint != NULL) { @@ -525,7 +525,7 @@ int regulator_register(const struct regul_description *desc, int node) } } - if (rdev == rdev_array + PLAT_NB_RDEVS) { + if (rdev == (rdev_array + PLAT_NB_RDEVS)) { WARN("Not enough place for regulators, PLAT_NB_RDEVS should be increased.\n"); return -ENOMEM; } -- 2.39.5