xen/arm: asm/atomic.h: Fix MISRA C 2012 Rule violations
v2 cover xen/arm: asm/atomic.h: Fix MISRA C 2012 Rule violations
This patch series fixes violations of rule 20.7 found in xen/arch/arm/include/asm/atomic.h.
Changes in v2:
- removed redundant parentheses in patch 1/2
- dropped patch 2/2 that removes unused atomic_xchg() because changes Xen's atomic API, and such a change cannot be justified since compliance to MISRA C Rule 2.5 is advisory. If at some point it is decided to remove the relevant macro, this will be done for both arm and x86 with a separate patch.
Xenia Ragiadakou (1):
xen/arm: asm/atomic.h: Fix MISRA C 2012 Rule 20.7 violation
xen/arch/arm/include/asm/atomic.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
Signature · 1 line
2.34.1
PATCH v2 1/1 xen/arm: asm/atomic.h: Fix MISRA C 2012 Rule 20.7 violation
The macro parameter 'p' is used as an expression and needs to be enclosed in parentheses.
---
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(-)
xen/arch/arm/include/asm/atomic.h +4 -4
@@ -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) ({ \
Signature · 1 line
2.34.1
Re: [PATCH v2 1/1] xen/arm: asm/atomic.h: Fix MISRA C 2012 Rule 20.7 violation
Quoted 4 lines · Xenia Ragiadakou
The macro parameter 'p' is used as an expression and needs to be enclosed in parentheses.
Signed-off-by Xenia Ragiadakou <[email protected]>
Quoted 36 lines
---
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 argumentxen/arch/arm/include/asm/atomic.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)xen/arch/arm/include/asm/atomic.h +4
-4@@ -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) ({ \Signature · 1 line
2.34.1