[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen staging] xen/list: address violations of MISRA C Rule 20.7
commit 12a3b90c2ae4998c389e53d1f68cbdba5914adce Author: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx> AuthorDate: Wed Mar 27 09:09:50 2024 +0100 Commit: Jan Beulich <jbeulich@xxxxxxxx> CommitDate: Wed Mar 27 09:09:50 2024 +0100 xen/list: 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@xxxxxxxxxxx> Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx> --- xen/include/xen/list.h | 143 ++++++++++++++++++++++++------------------------- 1 file changed, 71 insertions(+), 72 deletions(-) diff --git a/xen/include/xen/list.h b/xen/include/xen/list.h index b5eab3a1eb..6506ac4089 100644 --- a/xen/include/xen/list.h +++ b/xen/include/xen/list.h @@ -452,7 +452,7 @@ static inline void list_splice_init(struct list_head *list, * @head: the head for your list. */ #define list_for_each(pos, head) \ - for (pos = (head)->next; pos != (head); pos = pos->next) + for ((pos) = (head)->next; (pos) != (head); (pos) = (pos)->next) /** * list_for_each_prev - iterate over a list backwards @@ -460,7 +460,7 @@ static inline void list_splice_init(struct list_head *list, * @head: the head for your list. */ #define list_for_each_prev(pos, head) \ - for (pos = (head)->prev; pos != (head); pos = pos->prev) + for ((pos) = (head)->prev; (pos) != (head); (pos) = (pos)->prev) /** * list_for_each_safe - iterate over a list safe against removal of list entry @@ -468,9 +468,9 @@ static inline void list_splice_init(struct list_head *list, * @n: another &struct list_head to use as temporary storage * @head: the head for your list. */ -#define list_for_each_safe(pos, n, head) \ - for (pos = (head)->next, n = pos->next; pos != (head); \ - pos = n, n = pos->next) +#define list_for_each_safe(pos, n, head) \ + for ((pos) = (head)->next, (n) = (pos)->next; (pos) != (head); \ + (pos) = (n), (n) = (pos)->next) /** * list_for_each_backwards_safe - iterate backwards over a list safe @@ -479,9 +479,9 @@ static inline void list_splice_init(struct list_head *list, * @n: another &struct list_head to use as temporary storage * @head: the head for your list. */ -#define list_for_each_backwards_safe(pos, n, head) \ - for ( pos = (head)->prev, n = pos->prev; pos != (head); \ - pos = n, n = pos->prev ) +#define list_for_each_backwards_safe(pos, n, head) \ + for ( (pos) = (head)->prev, (n) = (pos)->prev; (pos) != (head); \ + (pos) = (n), (n) = (pos)->prev ) /** * list_for_each_entry - iterate over list of given type @@ -490,9 +490,9 @@ static inline void list_splice_init(struct list_head *list, * @member: the name of the list_struct within the struct. */ #define list_for_each_entry(pos, head, member) \ - for (pos = list_entry((head)->next, typeof(*pos), member); \ - &pos->member != (head); \ - pos = list_entry(pos->member.next, typeof(*pos), member)) + for ((pos) = list_entry((head)->next, typeof(*(pos)), member); \ + &(pos)->member != (head); \ + (pos) = list_entry((pos)->member.next, typeof(*(pos)), member)) /** * list_for_each_entry_reverse - iterate backwards over list of given type. @@ -501,9 +501,9 @@ static inline void list_splice_init(struct list_head *list, * @member: the name of the list_struct within the struct. */ #define list_for_each_entry_reverse(pos, head, member) \ - for (pos = list_entry((head)->prev, typeof(*pos), member); \ - &pos->member != (head); \ - pos = list_entry(pos->member.prev, typeof(*pos), member)) + for ((pos) = list_entry((head)->prev, typeof(*(pos)), member); \ + &(pos)->member != (head); \ + (pos) = list_entry((pos)->member.prev, typeof(*(pos)), member)) /** * list_prepare_entry - prepare a pos entry for use in @@ -516,7 +516,7 @@ static inline void list_splice_init(struct list_head *list, * list_for_each_entry_continue. */ #define list_prepare_entry(pos, head, member) \ - ((pos) ? : list_entry(head, typeof(*pos), member)) + ((pos) ? : list_entry(head, typeof(*(pos)), member)) /** * list_for_each_entry_continue - continue iteration over list of given type @@ -527,10 +527,10 @@ static inline void list_splice_init(struct list_head *list, * Continue to iterate over list of given type, continuing after * the current position. */ -#define list_for_each_entry_continue(pos, head, member) \ - for (pos = list_entry(pos->member.next, typeof(*pos), member); \ - &pos->member != (head); \ - pos = list_entry(pos->member.next, typeof(*pos), member)) +#define list_for_each_entry_continue(pos, head, member) \ + for ((pos) = list_entry((pos)->member.next, typeof(*(pos)), member); \ + &(pos)->member != (head); \ + (pos) = list_entry((pos)->member.next, typeof(*(pos)), member)) /** * list_for_each_entry_from - iterate over list of given type from the @@ -542,8 +542,8 @@ static inline void list_splice_init(struct list_head *list, * Iterate over list of given type, continuing from current position. */ #define list_for_each_entry_from(pos, head, member) \ - for (; &pos->member != (head); \ - pos = list_entry(pos->member.next, typeof(*pos), member)) + for (; &(pos)->member != (head); \ + (pos) = list_entry((pos)->member.next, typeof(*(pos)), member)) /** * list_for_each_entry_safe - iterate over list of given type safe @@ -554,10 +554,10 @@ static inline void list_splice_init(struct list_head *list, * @member: the name of the list_struct within the struct. */ #define list_for_each_entry_safe(pos, n, head, member) \ - for (pos = list_entry((head)->next, typeof(*pos), member), \ - n = list_entry(pos->member.next, typeof(*pos), member); \ - &pos->member != (head); \ - pos = n, n = list_entry(n->member.next, typeof(*n), member)) + for ((pos) = list_entry((head)->next, typeof(*(pos)), member), \ + (n) = list_entry((pos)->member.next, typeof(*(pos)), member); \ + &(pos)->member != (head); \ + (pos) = (n), (n) = list_entry((n)->member.next, typeof(*(n)), member)) /** * list_for_each_entry_safe_continue @@ -569,11 +569,11 @@ static inline void list_splice_init(struct list_head *list, * Iterate over list of given type, continuing after current point, * safe against removal of list entry. */ -#define list_for_each_entry_safe_continue(pos, n, head, member) \ - for (pos = list_entry(pos->member.next, typeof(*pos), member), \ - n = list_entry(pos->member.next, typeof(*pos), member); \ - &pos->member != (head); \ - pos = n, n = list_entry(n->member.next, typeof(*n), member)) +#define list_for_each_entry_safe_continue(pos, n, head, member) \ + for ((pos) = list_entry((pos)->member.next, typeof(*(pos)), member), \ + (n) = list_entry((pos)->member.next, typeof(*(pos)), member); \ + &(pos)->member != (head); \ + (pos) = (n), (n) = list_entry((n)->member.next, typeof(*(n)), member)) /** * list_for_each_entry_safe_from @@ -586,9 +586,9 @@ static inline void list_splice_init(struct list_head *list, * removal of list entry. */ #define list_for_each_entry_safe_from(pos, n, head, member) \ - for (n = list_entry(pos->member.next, typeof(*pos), member); \ - &pos->member != (head); \ - pos = n, n = list_entry(n->member.next, typeof(*n), member)) + for ((n) = list_entry((pos)->member.next, typeof(*(pos)), member); \ + &(pos)->member != (head); \ + (pos) = (n), (n) = list_entry((n)->member.next, typeof(*(n)), member)) /** * list_for_each_entry_safe_reverse @@ -601,10 +601,10 @@ static inline void list_splice_init(struct list_head *list, * of list entry. */ #define list_for_each_entry_safe_reverse(pos, n, head, member) \ - for (pos = list_entry((head)->prev, typeof(*pos), member), \ - n = list_entry(pos->member.prev, typeof(*pos), member); \ - &pos->member != (head); \ - pos = n, n = list_entry(n->member.prev, typeof(*n), member)) + for ((pos) = list_entry((head)->prev, typeof(*(pos)), member), \ + (n) = list_entry((pos)->member.prev, typeof(*(pos)), member); \ + &(pos)->member != (head); \ + (pos) = (n), (n) = list_entry((n)->member.prev, typeof(*(n)), member)) /** * list_for_each_rcu - iterate over an rcu-protected list @@ -616,14 +616,14 @@ static inline void list_splice_init(struct list_head *list, * as long as the traversal is guarded by rcu_read_lock(). */ #define list_for_each_rcu(pos, head) \ - for (pos = (head)->next; \ + for ((pos) = (head)->next; \ rcu_dereference(pos) != (head); \ - pos = pos->next) + (pos) = (pos)->next) #define __list_for_each_rcu(pos, head) \ - for (pos = (head)->next; \ + for ((pos) = (head)->next; \ rcu_dereference(pos) != (head); \ - pos = pos->next) + (pos) = (pos)->next) /** * list_for_each_safe_rcu @@ -638,9 +638,9 @@ static inline void list_splice_init(struct list_head *list, * as long as the traversal is guarded by rcu_read_lock(). */ #define list_for_each_safe_rcu(pos, n, head) \ - for (pos = (head)->next; \ - n = rcu_dereference(pos)->next, pos != (head); \ - pos = n) + for ((pos) = (head)->next; \ + (n) = rcu_dereference(pos)->next, (pos) != (head); \ + (pos) = (n)) /** * list_for_each_entry_rcu - iterate over rcu list of given type @@ -653,9 +653,9 @@ static inline void list_splice_init(struct list_head *list, * as long as the traversal is guarded by rcu_read_lock(). */ #define list_for_each_entry_rcu(pos, head, member) \ - for (pos = list_entry((head)->next, typeof(*pos), member); \ + for ((pos) = list_entry((head)->next, typeof(*(pos)), member); \ &rcu_dereference(pos)->member != (head); \ - pos = list_entry(pos->member.next, typeof(*pos), member)) + (pos) = list_entry((pos)->member.next, typeof(*(pos)), member)) /** * list_for_each_continue_rcu @@ -899,11 +899,11 @@ static inline void hlist_add_after_rcu(struct hlist_node *prev, #define hlist_entry(ptr, type, member) container_of(ptr,type,member) #define hlist_for_each(pos, head) \ - for (pos = (head)->first; pos; pos = pos->next) + for ((pos) = (head)->first; (pos); (pos) = (pos)->next) -#define hlist_for_each_safe(pos, n, head) \ - for (pos = (head)->first; pos && ({ n = pos->next; 1; }); \ - pos = n) +#define hlist_for_each_safe(pos, n, head) \ + for ((pos) = (head)->first; (pos) && ({ (n) = (pos)->next; 1; }); \ + (pos) = (n)) /** * hlist_for_each_entry - iterate over list of given type @@ -913,10 +913,10 @@ static inline void hlist_add_after_rcu(struct hlist_node *prev, * @member: the name of the hlist_node within the struct. */ #define hlist_for_each_entry(tpos, pos, head, member) \ - for (pos = (head)->first; \ - pos && \ - ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \ - pos = pos->next) + for ((pos) = (head)->first; \ + (pos) && \ + ({ tpos = hlist_entry(pos, typeof(*(tpos)), member); 1;}); \ + (pos) = (pos)->next) /** * hlist_for_each_entry_continue - iterate over a hlist continuing @@ -925,11 +925,11 @@ static inline void hlist_add_after_rcu(struct hlist_node *prev, * @pos: the &struct hlist_node to use as a loop cursor. * @member: the name of the hlist_node within the struct. */ -#define hlist_for_each_entry_continue(tpos, pos, member) \ - for (pos = (pos)->next; \ - pos && \ - ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \ - pos = pos->next) +#define hlist_for_each_entry_continue(tpos, pos, member) \ + for ((pos) = (pos)->next; \ + (pos) && \ + ({ tpos = hlist_entry(pos, typeof(*(tpos)), member); 1;}); \ + (pos) = (pos)->next) /** * hlist_for_each_entry_from - iterate over a hlist continuing from @@ -938,10 +938,10 @@ static inline void hlist_add_after_rcu(struct hlist_node *prev, * @pos: the &struct hlist_node to use as a loop cursor. * @member: the name of the hlist_node within the struct. */ -#define hlist_for_each_entry_from(tpos, pos, member) \ - for (; pos && \ - ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \ - pos = pos->next) +#define hlist_for_each_entry_from(tpos, pos, member) \ + for (; (pos) && \ + ({ tpos = hlist_entry(pos, typeof(*(tpos)), member); 1;}); \ + (pos) = (pos)->next) /** * hlist_for_each_entry_safe - iterate over list of given type safe @@ -952,11 +952,11 @@ static inline void hlist_add_after_rcu(struct hlist_node *prev, * @head: the head for your list. * @member: the name of the hlist_node within the struct. */ -#define hlist_for_each_entry_safe(tpos, pos, n, head, member) \ - for (pos = (head)->first; \ - pos && ({ n = pos->next; 1; }) && \ - ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \ - pos = n) +#define hlist_for_each_entry_safe(tpos, pos, n, head, member) \ + for ((pos) = (head)->first; \ + (pos) && ({ n = (pos)->next; 1; }) && \ + ({ tpos = hlist_entry(pos, typeof(*(tpos)), member); 1;}); \ + (pos) = (n)) /** @@ -971,10 +971,9 @@ static inline void hlist_add_after_rcu(struct hlist_node *prev, * as long as the traversal is guarded by rcu_read_lock(). */ #define hlist_for_each_entry_rcu(tpos, pos, head, member) \ - for (pos = (head)->first; \ + for ((pos) = (head)->first; \ rcu_dereference(pos) && \ - ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \ - pos = pos->next) + ({ tpos = hlist_entry(pos, typeof(*(tpos)), member); 1;}); \ + (pos) = (pos)->next) #endif /* __XEN_LIST_H__ */ - -- generated by git-patchbot for /home/xen/git/xen.git#staging
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |