[XEN PATCH v2 04/13] x86/vpmu: address violations of MISRA C Rule 16.3

Federico Serafini posted 13 patches 5 months ago
There is a newer version of this series
[XEN PATCH v2 04/13] x86/vpmu: address violations of MISRA C Rule 16.3
Posted by Federico Serafini 5 months ago
Add missing break statements to address violations of MISRA C Rule
16.3: "An unconditional `break' statement shall terminate every
switch-clause".

No functional change.

Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
---
 xen/arch/x86/cpu/vpmu.c       | 3 +++
 xen/arch/x86/cpu/vpmu_intel.c | 1 +
 2 files changed, 4 insertions(+)

diff --git a/xen/arch/x86/cpu/vpmu.c b/xen/arch/x86/cpu/vpmu.c
index a7bc0cd1fc..b2ba999412 100644
--- a/xen/arch/x86/cpu/vpmu.c
+++ b/xen/arch/x86/cpu/vpmu.c
@@ -663,6 +663,8 @@ long do_xenpmu_op(
 
         if ( pmu_params.version.maj != XENPMU_VER_MAJ )
             return -EINVAL;
+
+        break;
     }
 
     switch ( op )
@@ -776,6 +778,7 @@ long do_xenpmu_op(
 
     default:
         ret = -EINVAL;
+        break;
     }
 
     return ret;
diff --git a/xen/arch/x86/cpu/vpmu_intel.c b/xen/arch/x86/cpu/vpmu_intel.c
index cd414165df..46f3ff86e7 100644
--- a/xen/arch/x86/cpu/vpmu_intel.c
+++ b/xen/arch/x86/cpu/vpmu_intel.c
@@ -713,6 +713,7 @@ static int cf_check core2_vpmu_do_rdmsr(unsigned int msr, uint64_t *msr_content)
             break;
         default:
             rdmsrl(msr, *msr_content);
+            break;
         }
     }
     else if ( msr == MSR_IA32_MISC_ENABLE )
-- 
2.34.1
Re: [XEN PATCH v2 04/13] x86/vpmu: address violations of MISRA C Rule 16.3
Posted by Stefano Stabellini 5 months ago
On Mon, 24 Jun 2024, Federico Serafini wrote:
> Add missing break statements to address violations of MISRA C Rule
> 16.3: "An unconditional `break' statement shall terminate every
> switch-clause".
> 
> No functional change.
> 
> Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>

Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Re: [XEN PATCH v2 04/13] x86/vpmu: address violations of MISRA C Rule 16.3
Posted by Jan Beulich 5 months ago
On 24.06.2024 11:04, Federico Serafini wrote:
> --- a/xen/arch/x86/cpu/vpmu_intel.c
> +++ b/xen/arch/x86/cpu/vpmu_intel.c
> @@ -713,6 +713,7 @@ static int cf_check core2_vpmu_do_rdmsr(unsigned int msr, uint64_t *msr_content)
>              break;
>          default:
>              rdmsrl(msr, *msr_content);
> +            break;
>          }
>      }
>      else if ( msr == MSR_IA32_MISC_ENABLE )

Up from here, in core2_vpmu_do_wrmsr() there's a pretty long default
block with no terminating break. Is there a reason that you don't put
one there?

Jan
Re: [XEN PATCH v2 04/13] x86/vpmu: address violations of MISRA C Rule 16.3
Posted by Federico Serafini 4 months, 4 weeks ago
On 24/06/24 17:16, Jan Beulich wrote:
> On 24.06.2024 11:04, Federico Serafini wrote:
>> --- a/xen/arch/x86/cpu/vpmu_intel.c
>> +++ b/xen/arch/x86/cpu/vpmu_intel.c
>> @@ -713,6 +713,7 @@ static int cf_check core2_vpmu_do_rdmsr(unsigned int msr, uint64_t *msr_content)
>>               break;
>>           default:
>>               rdmsrl(msr, *msr_content);
>> +            break;
>>           }
>>       }
>>       else if ( msr == MSR_IA32_MISC_ENABLE )
> 
> Up from here, in core2_vpmu_do_wrmsr() there's a pretty long default
> block with no terminating break. Is there a reason that you don't put
> one there?

I noticed that vpmu_intel.c is a file out-of-scope.
The violation I addressed was shown because it involves
the macro rdmsrl coming from file xen/arch/x86/include/asm/msr.h
(in scope).
I will address also the violation you pointed out in a v3.

-- 
Federico Serafini, M.Sc.

Software Engineer, BUGSENG (http://bugseng.com)