Mailing List Archive

[XEN PATCH v3 6/7] xen/mm: address violations of MISRA C Rule 20.7
MISRA C Rule 20.7 states: "Expressions resulting from the expansion
of macro parameters shall be enclosed in parentheses". Therefore, some
macro definitions should gain additional parentheses to ensure that all
current and future users will be safe with respect to expansions that
can possibly alter the semantics of the passed-in macro parameter.

No functional change.

Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
---
xen/include/xen/mm.h | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h
index 3e84960a365f..7561297a7553 100644
--- a/xen/include/xen/mm.h
+++ b/xen/include/xen/mm.h
@@ -415,15 +415,15 @@ page_list_splice(struct page_list_head *list, struct page_list_head *head)
}

#define page_list_for_each(pos, head) \
- for ( pos = (head)->next; pos; pos = page_list_next(pos, head) )
+ for ( (pos) = (head)->next; (pos); (pos) = page_list_next(pos, head) )
#define page_list_for_each_safe(pos, tmp, head) \
- for ( pos = (head)->next; \
- pos ? (tmp = page_list_next(pos, head), 1) : 0; \
- pos = tmp )
+ for ( (pos) = (head)->next; \
+ (pos) ? ((tmp) = page_list_next(pos, head), 1) : 0; \
+ (pos) = (tmp) )
#define page_list_for_each_safe_reverse(pos, tmp, head) \
- for ( pos = (head)->tail; \
- pos ? (tmp = page_list_prev(pos, head), 1) : 0; \
- pos = tmp )
+ for ( (pos) = (head)->tail; \
+ (pos) ? ((tmp) = page_list_prev(pos, head), 1) : 0; \
+ (pos) = (tmp) )
#else
# define page_list_head list_head
# define PAGE_LIST_HEAD_INIT LIST_HEAD_INIT
--
2.34.1
Re: [XEN PATCH v3 6/7] xen/mm: address violations of MISRA C Rule 20.7 [ In reply to ]
On 29.03.2024 10:11, Nicola Vetrini wrote:
> MISRA C Rule 20.7 states: "Expressions resulting from the expansion
> of macro parameters shall be enclosed in parentheses". Therefore, some
> macro definitions should gain additional parentheses to ensure that all
> current and future users will be safe with respect to expansions that
> can possibly alter the semantics of the passed-in macro parameter.
>
> No functional change.
>
> Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>

Acked-by: Jan Beulich <jbeulich@suse.com>