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

Andrew Cooper posted 1 patch 6 months, 2 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/20240510192631.2296870-1-andrew.cooper3@citrix.com
xen/arch/x86/include/asm/io.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
[PATCH] x86/io: Don't cast away constness in read{b..q}()
Posted by Andrew Cooper 6 months, 2 weeks ago
Addresses various MISRA R11.8 violations.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Nicola Vetrini <nicola.vetrini@bugseng.com>
CC: consulting@bugseng.com <consulting@bugseng.com>
---
 xen/arch/x86/include/asm/io.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/xen/arch/x86/include/asm/io.h b/xen/arch/x86/include/asm/io.h
index 9b19d2d389ee..1cb4217cff39 100644
--- a/xen/arch/x86/include/asm/io.h
+++ b/xen/arch/x86/include/asm/io.h
@@ -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
-- 
2.30.2


Re: [PATCH] x86/io: Don't cast away constness in read{b..q}()
Posted by Stefano Stabellini 6 months, 2 weeks ago
On Fri, 10 May 2024, Andrew Cooper wrote:
> Addresses various MISRA R11.8 violations.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

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


> ---
> CC: Jan Beulich <JBeulich@suse.com>
> CC: Roger Pau Monné <roger.pau@citrix.com>
> CC: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
> CC: Stefano Stabellini <sstabellini@kernel.org>
> CC: Nicola Vetrini <nicola.vetrini@bugseng.com>
> CC: consulting@bugseng.com <consulting@bugseng.com>
> ---
>  xen/arch/x86/include/asm/io.h | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/xen/arch/x86/include/asm/io.h b/xen/arch/x86/include/asm/io.h
> index 9b19d2d389ee..1cb4217cff39 100644
> --- a/xen/arch/x86/include/asm/io.h
> +++ b/xen/arch/x86/include/asm/io.h
> @@ -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
> -- 
> 2.30.2
>