diff mbox series

[XEN,10/13] xen/x86: fixed violations of MISRA C:2012 Rule 7.2

Message ID c22614e2febfe9078fcefeff4aae897fbaf92e39.1687250177.git.gianluca.luparini@bugseng.com (mailing list archive)
State New, archived
Headers show
Series xen: fixed violations of MISRA C:2012 Rule 7.2 | expand

Commit Message

Simone Ballarin June 20, 2023, 10:35 a.m. UTC
From: Gianluca Luparini <gianluca.luparini@bugseng.com>

The xen sources contains violations of MISRA C:2012 Rule 7.2 whose headline states:
"A "u" or "U" suffix shall be applied to all integer constants that are represented in an unsigned type".

I propose to use "U" as a suffix to explicitly state when an integer constant is represented in an unsigned type.
For homogeneity, I also added the "U" suffix in some cases that the tool didn't report as violations.

Signed-off-by: Simone Ballarin <simone.ballarin@bugseng.com>
---
 xen/arch/x86/monitor.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Stefano Stabellini June 20, 2023, 9:13 p.m. UTC | #1
On Tue, 20 Jun 2023, Simone Ballarin wrote:
> From: Gianluca Luparini <gianluca.luparini@bugseng.com>
> 
> The xen sources contains violations of MISRA C:2012 Rule 7.2 whose headline states:
> "A "u" or "U" suffix shall be applied to all integer constants that are represented in an unsigned type".
> 
> I propose to use "U" as a suffix to explicitly state when an integer constant is represented in an unsigned type.
> For homogeneity, I also added the "U" suffix in some cases that the tool didn't report as violations.
> 
> Signed-off-by: Simone Ballarin <simone.ballarin@bugseng.com>

Commit message aside:

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

You might want also to change the commit title to:

  xen/x86/monitor: fixed violations of MISRA C:2012 Rule 7.2

to make it unique


> ---
>  xen/arch/x86/monitor.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/xen/arch/x86/monitor.c b/xen/arch/x86/monitor.c
> index d4857faf8a..dc336c239a 100644
> --- a/xen/arch/x86/monitor.c
> +++ b/xen/arch/x86/monitor.c
> @@ -48,17 +48,17 @@ static unsigned long *monitor_bitmap_for_msr(const struct domain *d, u32 *msr)
>  
>      switch ( *msr )
>      {
> -    case 0 ... 0x1fff:
> +    case 0 ... 0x1fffU:
>          BUILD_BUG_ON(sizeof(d->arch.monitor.msr_bitmap->low) * 8 <= 0x1fff);
>          return d->arch.monitor.msr_bitmap->low;
>  
> -    case 0x40000000 ... 0x40001fff:
> +    case 0x40000000U ... 0x40001fffU:
>          BUILD_BUG_ON(
>              sizeof(d->arch.monitor.msr_bitmap->hypervisor) * 8 <= 0x1fff);
>          *msr &= 0x1fff;
>          return d->arch.monitor.msr_bitmap->hypervisor;
>  
> -    case 0xc0000000 ... 0xc0001fff:
> +    case 0xc0000000U ... 0xc0001fffU:
>          BUILD_BUG_ON(sizeof(d->arch.monitor.msr_bitmap->high) * 8 <= 0x1fff);
>          *msr &= 0x1fff;
>          return d->arch.monitor.msr_bitmap->high;
> -- 
> 2.41.0
>
diff mbox series

Patch

diff --git a/xen/arch/x86/monitor.c b/xen/arch/x86/monitor.c
index d4857faf8a..dc336c239a 100644
--- a/xen/arch/x86/monitor.c
+++ b/xen/arch/x86/monitor.c
@@ -48,17 +48,17 @@  static unsigned long *monitor_bitmap_for_msr(const struct domain *d, u32 *msr)
 
     switch ( *msr )
     {
-    case 0 ... 0x1fff:
+    case 0 ... 0x1fffU:
         BUILD_BUG_ON(sizeof(d->arch.monitor.msr_bitmap->low) * 8 <= 0x1fff);
         return d->arch.monitor.msr_bitmap->low;
 
-    case 0x40000000 ... 0x40001fff:
+    case 0x40000000U ... 0x40001fffU:
         BUILD_BUG_ON(
             sizeof(d->arch.monitor.msr_bitmap->hypervisor) * 8 <= 0x1fff);
         *msr &= 0x1fff;
         return d->arch.monitor.msr_bitmap->hypervisor;
 
-    case 0xc0000000 ... 0xc0001fff:
+    case 0xc0000000U ... 0xc0001fffU:
         BUILD_BUG_ON(sizeof(d->arch.monitor.msr_bitmap->high) * 8 <= 0x1fff);
         *msr &= 0x1fff;
         return d->arch.monitor.msr_bitmap->high;