]> git.baikalelectronics.ru Git - arm-tf.git/commitdiff
fix(st-regulator): explicitly check operators precedence
authorYann Gautier <yann.gautier@st.com>
Mon, 28 Nov 2022 13:55:14 +0000 (14:55 +0100)
committerYann Gautier <yann.gautier@st.com>
Wed, 7 Dec 2022 13:18:30 +0000 (14:18 +0100)
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 <yann.gautier@st.com>
Change-Id: If8312442222ba848ac1f5e38df1bed0a367646a7

drivers/st/regulator/regulator_core.c

index 5cc832915f73e40c680bfb438d816b58c8eacbfc..a7482e03accca4e5fe01365f814799014c2ad2a2 100644 (file)
@@ -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;
        }