Skip to contentSkip to conversation

x86/io: Don't cast away constness in read{b..q}()

PATCH In review Andrew Cooper 2 participants 2 messages May 10, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/io: Don't cast away constness in read{b..q}()

Addresses various MISRA R11.8 violations.

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Marek Marczykowski-Górecki <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Nicola Vetrini <[email protected]>
CC: [email protected] <[email protected]>

---
 xen/arch/x86/include/asm/io.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
xen/arch/x86/include/asm/io.h +4 -4
index 9b19d2d389ee..1cb4217cff39 100644
@@ -4,10 +4,10 @@
 #include <xen/vmap.h>
 #include <xen/types.h>
 
-#define readb(x) (*(volatile uint8_t  *)(x))
-#define readw(x) (*(volatile uint16_t *)(x))
-#define readl(x) (*(volatile uint32_t *)(x))
-#define readq(x) (*(volatile uint64_t *)(x))
+#define readb(x) (*(const volatile uint8_t  *)(x))
+#define readw(x) (*(const volatile uint16_t *)(x))
+#define readl(x) (*(const volatile uint32_t *)(x))
+#define readq(x) (*(const volatile uint64_t *)(x))
 #define writeb(d,x) (*(volatile uint8_t  *)(x) = (d))
 #define writew(d,x) (*(volatile uint16_t *)(x) = (d))
 #define writel(d,x) (*(volatile uint32_t *)(x) = (d))

base-commit: b0082b908391b29b7c4dd5e6c389ebd6481926f8

Signature · 1 line
2.30.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 3 lines · Andrew Cooper

Addresses various MISRA R11.8 violations.

Quoted 35 lines

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Marek Marczykowski-Górecki <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Nicola Vetrini <[email protected]>
CC: [email protected] <[email protected]>

---
 xen/arch/x86/include/asm/io.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
xen/arch/x86/include/asm/io.h +4 -4
index 9b19d2d389ee..1cb4217cff39 100644
@@ -4,10 +4,10 @@
 #include <xen/vmap.h>
 #include <xen/types.h>
 
-#define readb(x) (*(volatile uint8_t  *)(x))
-#define readw(x) (*(volatile uint16_t *)(x))
-#define readl(x) (*(volatile uint32_t *)(x))
-#define readq(x) (*(volatile uint64_t *)(x))
+#define readb(x) (*(const volatile uint8_t  *)(x))
+#define readw(x) (*(const volatile uint16_t *)(x))
+#define readl(x) (*(const volatile uint32_t *)(x))
+#define readq(x) (*(const volatile uint64_t *)(x))
 #define writeb(d,x) (*(volatile uint8_t  *)(x) = (d))
 #define writew(d,x) (*(volatile uint16_t *)(x) = (d))
 #define writel(d,x) (*(volatile uint32_t *)(x) = (d))

base-commit: b0082b908391b29b7c4dd5e6c389ebd6481926f8

Signature · 1 line
2.30.2