]> xenbits.xensource.com Git - people/royger/xen.git/commitdiff
xen/arm64: address violations of MISRA C:2012 Rule 11.8
authorMaria Celeste Cesario <maria.celeste.cesario@bugseng.com>
Mon, 18 Dec 2023 14:20:47 +0000 (15:20 +0100)
committerJan Beulich <jbeulich@suse.com>
Mon, 18 Dec 2023 14:20:47 +0000 (15:20 +0100)
The xen sources contain violations of MISRA C:2012 Rule 11.8 whose
headline states:
"A conversion shall not remove any const, volatile or _Atomic qualification
from the type pointed to by a pointer".

Add volatile qualifiers missing in casts.
Arguments p and ptr are originally volatile-qualified.
There's no reason to drop the qualifiers.
No functional change.

Signed-off-by: Maria Celeste Cesario <maria.celeste.cesario@bugseng.com>
Signed-off-by: Simone Ballarin <simone.ballarin@bugseng.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
xen/arch/arm/arm64/lib/bitops.c
xen/arch/arm/include/asm/arm64/cmpxchg.h

index 20e3f3d6ceafc0f66310d6dccab1c78e3afd8702..275a780329a02114e006f7f3c76fdd461a72158a 100644 (file)
@@ -32,7 +32,8 @@
 static always_inline bool int_##name(int nr, volatile void *p, bool timeout,\
                                      unsigned int max_try)                  \
 {                                                                           \
-    volatile uint32_t *ptr = (uint32_t *)p + BITOP_WORD((unsigned int)nr);  \
+    volatile uint32_t *ptr = (volatile uint32_t *)p +                       \
+                             BITOP_WORD((unsigned int)nr);                  \
     const uint32_t mask = BITOP_MASK((unsigned int)nr);                     \
     unsigned long res, tmp;                                                 \
                                                                             \
@@ -67,7 +68,8 @@ bool name##_timeout(int nr, volatile void *p, unsigned int max_try)         \
 static always_inline bool int_##name(int nr, volatile void *p, int *oldbit, \
                                      bool timeout, unsigned int max_try)    \
 {                                                                           \
-    volatile uint32_t *ptr = (uint32_t *)p + BITOP_WORD((unsigned int)nr);  \
+    volatile uint32_t *ptr = (volatile uint32_t *)p +                       \
+                             BITOP_WORD((unsigned int)nr);                  \
     unsigned int bit = (unsigned int)nr % BITOP_BITS_PER_WORD;              \
     const uint32_t mask = BITOP_MASK(bit);                                  \
     unsigned long res, tmp;                                                 \
index dbfaf915676c67ec51eaa050582d936bbee0e79a..031fa6d92a0b37ec4c8a9c2be7ee1a0c312a7ea2 100644 (file)
@@ -13,7 +13,7 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
                "1:     ldxrb   %w0, %2\n"
                "       stlxrb  %w1, %w3, %2\n"
                "       cbnz    %w1, 1b\n"
-                       : "=&r" (ret), "=&r" (tmp), "+Q" (*(u8 *)ptr)
+                       : "=&r" (ret), "=&r" (tmp), "+Q" (*(volatile u8 *)ptr)
                        : "r" (x)
                        : "memory");
                break;
@@ -22,7 +22,7 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
                "1:     ldxrh   %w0, %2\n"
                "       stlxrh  %w1, %w3, %2\n"
                "       cbnz    %w1, 1b\n"
-                       : "=&r" (ret), "=&r" (tmp), "+Q" (*(u16 *)ptr)
+                       : "=&r" (ret), "=&r" (tmp), "+Q" (*(volatile u16 *)ptr)
                        : "r" (x)
                        : "memory");
                break;
@@ -31,7 +31,7 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
                "1:     ldxr    %w0, %2\n"
                "       stlxr   %w1, %w3, %2\n"
                "       cbnz    %w1, 1b\n"
-                       : "=&r" (ret), "=&r" (tmp), "+Q" (*(u32 *)ptr)
+                       : "=&r" (ret), "=&r" (tmp), "+Q" (*(volatile u32 *)ptr)
                        : "r" (x)
                        : "memory");
                break;
@@ -40,7 +40,7 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
                "1:     ldxr    %0, %2\n"
                "       stlxr   %w1, %3, %2\n"
                "       cbnz    %w1, 1b\n"
-                       : "=&r" (ret), "=&r" (tmp), "+Q" (*(u64 *)ptr)
+                       : "=&r" (ret), "=&r" (tmp), "+Q" (*(volatile u64 *)ptr)
                        : "r" (x)
                        : "memory");
                break;
@@ -82,7 +82,7 @@ static inline bool __cmpxchg_case_##name(volatile void *ptr,          \
                "       stxr" #sz "     %w0, %" #w "4, %2\n"            \
                "1:\n"                                                  \
                : "=&r" (res), "=&r" (oldval),                          \
-                 "+Q" (*(unsigned long *)ptr)                          \
+                 "+Q" (*(volatile unsigned long *)ptr) \
                : "Ir" (*old), "r" (new)                                \
                : "cc");                                                \
                                                                        \