diff mbox series

[5/9] xen/x86: address violations of MISRA C:2012 Rule 11.8

Message ID 68e28c7631f1233df1527674cfc27cf3f44797a7.1702555387.git.maria.celeste.cesario@bugseng.com (mailing list archive)
State Superseded
Headers show
Series xen: address violations of MISRA C:2012 Rule 11.8 | expand

Commit Message

Simone Ballarin Dec. 14, 2023, 12:07 p.m. UTC
From: Maria Celeste Cesario <maria.celeste.cesario@bugseng.com>

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 missing const qualifiers in casts.

Macro get_mb2_data returns values that are const-qualified.
The results are stored in const struct pointers, hence
there's no need to cast away the const qualifiers.

Signed-off-by: Maria Celeste Cesario  <maria.celeste.cesario@bugseng.com>
Signed-off-by: Simone Ballarin  <simone.ballarin@bugseng.com>
---
 xen/arch/x86/boot/reloc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Jan Beulich Dec. 14, 2023, 4:41 p.m. UTC | #1
On 14.12.2023 13:07, Simone Ballarin wrote:
> --- a/xen/arch/x86/boot/reloc.c
> +++ b/xen/arch/x86/boot/reloc.c
> @@ -300,8 +300,8 @@ static multiboot_info_t *mbi2_reloc(uint32_t mbi_in, uint32_t video_out)
>                  const struct vesa_mode_info *mi;
>  
>                  video = _p(video_out);
> -                ci = (void *)get_mb2_data(tag, vbe, vbe_control_info);
> -                mi = (void *)get_mb2_data(tag, vbe, vbe_mode_info);
> +                ci = (const void *)get_mb2_data(tag, vbe, vbe_control_info);
> +                mi = (const void *)get_mb2_data(tag, vbe, vbe_mode_info);

This wasn't and isn't very nice, but I also can't think of a way to
improve it, so
Acked-by: Jan Beulich <jbeulich@suse.com>

Jan
Stefano Stabellini Dec. 14, 2023, 9:50 p.m. UTC | #2
On Thu, 14 Dec 2023, Simone Ballarin wrote:
> From: Maria Celeste Cesario <maria.celeste.cesario@bugseng.com>
> 
> 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 missing const qualifiers in casts.
> 
> Macro get_mb2_data returns values that are const-qualified.
> The results are stored in const struct pointers, hence
> there's no need to cast away the const qualifiers.
> 
> 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>
diff mbox series

Patch

diff --git a/xen/arch/x86/boot/reloc.c b/xen/arch/x86/boot/reloc.c
index df0bc710a7..77fdb2be05 100644
--- a/xen/arch/x86/boot/reloc.c
+++ b/xen/arch/x86/boot/reloc.c
@@ -300,8 +300,8 @@  static multiboot_info_t *mbi2_reloc(uint32_t mbi_in, uint32_t video_out)
                 const struct vesa_mode_info *mi;
 
                 video = _p(video_out);
-                ci = (void *)get_mb2_data(tag, vbe, vbe_control_info);
-                mi = (void *)get_mb2_data(tag, vbe, vbe_mode_info);
+                ci = (const void *)get_mb2_data(tag, vbe, vbe_control_info);
+                mi = (const void *)get_mb2_data(tag, vbe, vbe_mode_info);
 
                 if ( ci->version >= 0x0200 && (mi->attrib & 0x9b) == 0x9b )
                 {