]> xenbits.xensource.com Git - xen.git/commitdiff
xen/device_tree: add parentheses around macro parameters
authorXenia Ragiadakou <burzalodowa@gmail.com>
Fri, 3 Feb 2023 19:09:07 +0000 (21:09 +0200)
committerJulien Grall <jgrall@amazon.com>
Wed, 8 Feb 2023 08:32:49 +0000 (08:32 +0000)
Add parentheses around macro parameters when the precedence and
associativity of the performed operators can lead to unintended order of evaluation.

This is fixing some ECLAIR finding for Misra Rule 20.7.

Link: https://lore.kernel.org/xen-devel/20230203190908.211541-2-burzalodowa@gmail.com/
Signed-off-by: Xenia Ragiadakou <burzalodowa@gmail.com>
Reviewed-by: Luca Fancellu <luca.fancellu@arm.com>
[jgrall: Reworded the commit message]
Acked-by: Julien Grall <jgrall@amazon.com>
xen/include/xen/device_tree.h

index a28937d12ae8580e4752e772a783df48b383c3ab..7839a199e311e6f4de1cd23c0b166b6395f7b358 100644 (file)
@@ -37,11 +37,11 @@ struct dt_device_match {
     const void *data;
 };
 
-#define __DT_MATCH_PATH(p)              .path = p
-#define __DT_MATCH_TYPE(typ)            .type = typ
-#define __DT_MATCH_COMPATIBLE(compat)   .compatible = compat
+#define __DT_MATCH_PATH(p)              .path = (p)
+#define __DT_MATCH_TYPE(typ)            .type = (typ)
+#define __DT_MATCH_COMPATIBLE(compat)   .compatible = (compat)
 #define __DT_MATCH_NOT_AVAILABLE()      .not_available = 1
-#define __DT_MATCH_PROP(p)              .prop = p
+#define __DT_MATCH_PROP(p)              .prop = (p)
 
 #define DT_MATCH_PATH(p)                { __DT_MATCH_PATH(p) }
 #define DT_MATCH_TYPE(typ)              { __DT_MATCH_TYPE(typ) }
@@ -226,13 +226,13 @@ dt_find_interrupt_controller(const struct dt_device_match *matches);
 #define DT_ROOT_NODE_SIZE_CELLS_DEFAULT 1
 
 #define dt_for_each_property_node(dn, pp)                   \
-    for ( pp = dn->properties; pp != NULL; pp = pp->next )
+    for ( pp = (dn)->properties; (pp) != NULL; pp = (pp)->next )
 
 #define dt_for_each_device_node(dt, dn)                     \
-    for ( dn = dt; dn != NULL; dn = dn->allnext )
+    for ( dn = dt; (dn) != NULL; dn = (dn)->allnext )
 
 #define dt_for_each_child_node(dt, dn)                      \
-    for ( dn = dt->child; dn != NULL; dn = dn->sibling )
+    for ( dn = (dt)->child; (dn) != NULL; dn = (dn)->sibling )
 
 /* Helper to read a big number; size is in cells (not bytes) */
 static inline u64 dt_read_number(const __be32 *cell, int size)