diff mbox series

[v2,1/1] xen/arm: asm/atomic.h: Fix MISRA C 2012 Rule 20.7 violation

Message ID 20220727171841.1163075-2-burzalodowa@gmail.com (mailing list archive)
State New, archived
Headers show
Series xen/arm: asm/atomic.h: Fix MISRA C 2012 Rule violations | expand

Commit Message

Xenia Ragiadakou July 27, 2022, 5:18 p.m. UTC
The macro parameter 'p' is used as an expression and needs to be enclosed in
parentheses.

Signed-off-by: Xenia Ragiadakou <burzalodowa@gmail.com>
---

Changes in v2:
- remove parentheses in the cases that p is not used as an expression that is
  when it is used as a function argument

 xen/arch/arm/include/asm/atomic.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Stefano Stabellini July 28, 2022, 1:26 a.m. UTC | #1
On Wed, 27 Jul 2022, Xenia Ragiadakou wrote:
> The macro parameter 'p' is used as an expression and needs to be enclosed in
> parentheses.
> 
> Signed-off-by: Xenia Ragiadakou <burzalodowa@gmail.com>

Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>


> ---
> 
> Changes in v2:
> - remove parentheses in the cases that p is not used as an expression that is
>   when it is used as a function argument
> 
>  xen/arch/arm/include/asm/atomic.h | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/xen/arch/arm/include/asm/atomic.h b/xen/arch/arm/include/asm/atomic.h
> index ac2798d095..1f60c28b1b 100644
> --- a/xen/arch/arm/include/asm/atomic.h
> +++ b/xen/arch/arm/include/asm/atomic.h
> @@ -123,15 +123,15 @@ static always_inline void write_atomic_size(volatile void *p,
>  }
>  
>  #define read_atomic(p) ({                                               \
> -    union { typeof(*p) val; char c[0]; } x_;                            \
> -    read_atomic_size(p, x_.c, sizeof(*p));                              \
> +    union { typeof(*(p)) val; char c[0]; } x_;                          \
> +    read_atomic_size(p, x_.c, sizeof(*(p)));                            \
>      x_.val;                                                             \
>  })
>  
>  #define write_atomic(p, x)                                              \
>      do {                                                                \
> -        typeof(*p) x_ = (x);                                            \
> -        write_atomic_size(p, &x_, sizeof(*p));                          \
> +        typeof(*(p)) x_ = (x);                                          \
> +        write_atomic_size(p, &x_, sizeof(*(p)));                        \
>      } while ( false )
>  
>  #define add_sized(p, x) ({                                              \
> -- 
> 2.34.1
>
diff mbox series

Patch

diff --git a/xen/arch/arm/include/asm/atomic.h b/xen/arch/arm/include/asm/atomic.h
index ac2798d095..1f60c28b1b 100644
--- a/xen/arch/arm/include/asm/atomic.h
+++ b/xen/arch/arm/include/asm/atomic.h
@@ -123,15 +123,15 @@  static always_inline void write_atomic_size(volatile void *p,
 }
 
 #define read_atomic(p) ({                                               \
-    union { typeof(*p) val; char c[0]; } x_;                            \
-    read_atomic_size(p, x_.c, sizeof(*p));                              \
+    union { typeof(*(p)) val; char c[0]; } x_;                          \
+    read_atomic_size(p, x_.c, sizeof(*(p)));                            \
     x_.val;                                                             \
 })
 
 #define write_atomic(p, x)                                              \
     do {                                                                \
-        typeof(*p) x_ = (x);                                            \
-        write_atomic_size(p, &x_, sizeof(*p));                          \
+        typeof(*(p)) x_ = (x);                                          \
+        write_atomic_size(p, &x_, sizeof(*(p)));                        \
     } while ( false )
 
 #define add_sized(p, x) ({                                              \