lib: utils: Simplify SET_ISA_EXT_MAP()
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Thu, 28 Sep 2023 12:17:20 +0000 (14:17 +0200)
committerAnup Patel <anup@brainfault.org>
Fri, 6 Oct 2023 11:58:52 +0000 (17:28 +0530)
The define is hard to read. The continue statement does not do what was
intended.

* Remove do {} while (false);
* Change the name to set_multi_letter_ext
  - Other local macros are lower case too.
  - Refer to the fact that this is only used for multi-letter extensions.

Addresses-Coverity-ID: 1568359 Unexpected control flow
Fixes: d72f5f17478d ("lib: utils: Add detection of Smepmp from ISA string in FDT")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Xiang W <wxjstz@126.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
lib/utils/fdt/fdt_helper.c

index 13e79b96f7e90a01be526834546fab8d1045fa58..9ae7f09fb3b6a225d434410b6ed4335d3683eb2d 100644 (file)
@@ -369,16 +369,14 @@ static int fdt_parse_isa_one_hart(const char *isa, unsigned long *extensions)
                if (!j)
                        continue;
 
-#define SET_ISA_EXT_MAP(name, bit)                             \
-               do {                                            \
+#define set_multi_letter_ext(name, bit)                                \
                        if (!strcmp(mstr, name)) {              \
                                __set_bit(bit, extensions);     \
                                continue;                       \
-                       }                                       \
-               } while (false)                                 \
+                       }
 
-               SET_ISA_EXT_MAP("smepmp", SBI_HART_EXT_SMEPMP);
-#undef SET_ISA_EXT_MAP
+               set_multi_letter_ext("smepmp", SBI_HART_EXT_SMEPMP);
+#undef set_multi_letter_ext
        }
 
        return 0;