[XEN PATCH] x86: Address violations of MISRA C:2012 and drop bool_t

Federico Serafini posted 1 patch 8 months, 4 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/2cd78bd0d39b36fe73e87cd1011658a54c2c729d.1691158092.git.federico.serafini@bugseng.com
xen/arch/x86/cpu/common.c            |  6 +++---
xen/arch/x86/include/asm/processor.h | 16 ++++++++--------
2 files changed, 11 insertions(+), 11 deletions(-)
[XEN PATCH] x86: Address violations of MISRA C:2012 and drop bool_t
Posted by Federico Serafini 8 months, 4 weeks ago
Give a name to unnamed parameters to address violations of
MISRA C:2012 Rule 8.2 ("Function types shall be in prototype form with
named parameters").
Keep consistency between object and function declarations thus
addressing violations of MISRA C:2012 Rule 8.3 ("All declarations of an
object or function shall use the same names and type qualifiers").
Replace the occurrences of bool_t with bool.

No functional change.

Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
---
 xen/arch/x86/cpu/common.c            |  6 +++---
 xen/arch/x86/include/asm/processor.h | 16 ++++++++--------
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/xen/arch/x86/cpu/common.c b/xen/arch/x86/cpu/common.c
index cfcdaace12..5f29148416 100644
--- a/xen/arch/x86/cpu/common.c
+++ b/xen/arch/x86/cpu/common.c
@@ -26,11 +26,11 @@
 
 bool __read_mostly opt_dom0_cpuid_faulting = true;
 
-bool_t opt_arat = 1;
+bool opt_arat = 1;
 boolean_param("arat", opt_arat);
 
 /* pku: Flag to enable Memory Protection Keys (default on). */
-static bool_t opt_pku = 1;
+static bool opt_pku = 1;
 boolean_param("pku", opt_pku);
 
 unsigned int opt_cpuid_mask_ecx = ~0u;
@@ -208,7 +208,7 @@ void ctxt_switch_levelling(const struct vcpu *next)
 		alternative_vcall(ctxt_switch_masking, next);
 }
 
-bool_t opt_cpu_info;
+bool opt_cpu_info;
 boolean_param("cpuinfo", opt_cpu_info);
 
 int get_model_name(struct cpuinfo_x86 *c)
diff --git a/xen/arch/x86/include/asm/processor.h b/xen/arch/x86/include/asm/processor.h
index 0989748be6..8d1909f73d 100644
--- a/xen/arch/x86/include/asm/processor.h
+++ b/xen/arch/x86/include/asm/processor.h
@@ -96,7 +96,7 @@ extern bool probe_cpuid_faulting(void);
 extern void ctxt_switch_levelling(const struct vcpu *next);
 extern void (*ctxt_switch_masking)(const struct vcpu *next);
 
-extern bool_t opt_cpu_info;
+extern bool opt_cpu_info;
 extern u32 trampoline_efer;
 extern u64 trampoline_misc_enable_off;
 
@@ -109,17 +109,17 @@ extern unsigned int vaddr_bits;
 
 extern const struct x86_cpu_id *x86_match_cpu(const struct x86_cpu_id table[]);
 
-extern void identify_cpu(struct cpuinfo_x86 *);
-extern void setup_clear_cpu_cap(unsigned int);
-extern void setup_force_cpu_cap(unsigned int);
-extern bool is_forced_cpu_cap(unsigned int);
+extern void identify_cpu(struct cpuinfo_x86 *c);
+extern void setup_clear_cpu_cap(unsigned int cap);
+extern void setup_force_cpu_cap(unsigned int cap);
+extern bool is_forced_cpu_cap(unsigned int cap);
 extern void print_cpu_info(unsigned int cpu);
 extern void init_intel_cacheinfo(struct cpuinfo_x86 *c);
 
 #define cpu_to_core(_cpu)   (cpu_data[_cpu].cpu_core_id)
 #define cpu_to_socket(_cpu) (cpu_data[_cpu].phys_proc_id)
 
-unsigned int apicid_to_socket(unsigned int);
+unsigned int apicid_to_socket(unsigned int apicid);
 
 static inline int cpu_nr_siblings(unsigned int cpu)
 {
@@ -410,12 +410,12 @@ void show_registers(const struct cpu_user_regs *regs);
 #define dump_execution_state() \
     run_in_exception_handler(show_execution_state_nonconst)
 void show_page_walk(unsigned long addr);
-void noreturn fatal_trap(const struct cpu_user_regs *regs, bool_t show_remote);
+void noreturn fatal_trap(const struct cpu_user_regs *regs, bool show_remote);
 
 extern void mtrr_ap_init(void);
 extern void mtrr_bp_init(void);
 
-void mcheck_init(struct cpuinfo_x86 *c, bool_t bsp);
+void mcheck_init(struct cpuinfo_x86 *c, bool bsp);
 
 void do_nmi(const struct cpu_user_regs *regs);
 void do_machine_check(const struct cpu_user_regs *regs);
-- 
2.34.1
[BUGGY] Re: [XEN PATCH] x86: Address violations of MISRA C:2012 and drop bool_t
Posted by Andrew Cooper 8 months, 3 weeks ago
On 04/08/2023 3:11 pm, Federico Serafini wrote:
> Give a name to unnamed parameters to address violations of
> MISRA C:2012 Rule 8.2 ("Function types shall be in prototype form with
> named parameters").
> Keep consistency between object and function declarations thus
> addressing violations of MISRA C:2012 Rule 8.3 ("All declarations of an
> object or function shall use the same names and type qualifiers").
> Replace the occurrences of bool_t with bool.
>
> No functional change.
>
> Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
> ---
>  xen/arch/x86/cpu/common.c            |  6 +++---
>  xen/arch/x86/include/asm/processor.h | 16 ++++++++--------
>  2 files changed, 11 insertions(+), 11 deletions(-)
>
> diff --git a/xen/arch/x86/cpu/common.c b/xen/arch/x86/cpu/common.c
> index cfcdaace12..5f29148416 100644
> --- a/xen/arch/x86/cpu/common.c
> +++ b/xen/arch/x86/cpu/common.c
> @@ -26,11 +26,11 @@
>  
>  bool __read_mostly opt_dom0_cpuid_faulting = true;
>  
> -bool_t opt_arat = 1;
> +bool opt_arat = 1;
>  boolean_param("arat", opt_arat);

I see this has been committed, but you do realise you've created a new
violation of 8.3 by failing to change the declaration of opt_arat to be
bool ?

Please everyone be more careful.  There is an enormous amount of MISRA
churn, and it's hard enough to deal with this when the patches are correct.

~Andrew

Re: [BUGGY] Re: [XEN PATCH] x86: Address violations of MISRA C:2012 and drop bool_t
Posted by Federico Serafini 8 months, 3 weeks ago
On 07/08/23 14:31, Andrew Cooper wrote:
> On 04/08/2023 3:11 pm, Federico Serafini wrote:
>> Give a name to unnamed parameters to address violations of
>> MISRA C:2012 Rule 8.2 ("Function types shall be in prototype form with
>> named parameters").
>> Keep consistency between object and function declarations thus
>> addressing violations of MISRA C:2012 Rule 8.3 ("All declarations of an
>> object or function shall use the same names and type qualifiers").
>> Replace the occurrences of bool_t with bool.
>>
>> No functional change.
>>
>> Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
>> ---
>>   xen/arch/x86/cpu/common.c            |  6 +++---
>>   xen/arch/x86/include/asm/processor.h | 16 ++++++++--------
>>   2 files changed, 11 insertions(+), 11 deletions(-)
>>
>> diff --git a/xen/arch/x86/cpu/common.c b/xen/arch/x86/cpu/common.c
>> index cfcdaace12..5f29148416 100644
>> --- a/xen/arch/x86/cpu/common.c
>> +++ b/xen/arch/x86/cpu/common.c
>> @@ -26,11 +26,11 @@
>>   
>>   bool __read_mostly opt_dom0_cpuid_faulting = true;
>>   
>> -bool_t opt_arat = 1;
>> +bool opt_arat = 1;
>>   boolean_param("arat", opt_arat);
> 
> I see this has been committed, but you do realise you've created a new
> violation of 8.3 by failing to change the declaration of opt_arat to be
> bool ?
> 
> Please everyone be more careful.  There is an enormous amount of MISRA
> churn, and it's hard enough to deal with this when the patches are correct.
> 
> ~Andrew

I'm sorry, I noticed too late.
I will submit a patch to address the new violations.

-- 
Federico Serafini, M.Sc.

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

Re: [XEN PATCH] x86: Address violations of MISRA C:2012 and drop bool_t
Posted by Jan Beulich 8 months, 3 weeks ago
On 04.08.2023 16:11, Federico Serafini wrote:
> Give a name to unnamed parameters to address violations of
> MISRA C:2012 Rule 8.2 ("Function types shall be in prototype form with
> named parameters").
> Keep consistency between object and function declarations thus
> addressing violations of MISRA C:2012 Rule 8.3 ("All declarations of an
> object or function shall use the same names and type qualifiers").
> Replace the occurrences of bool_t with bool.

Hmm, I read the title as a promise that bool_t would be gone from the
code base (which I couldn't really believe). Perhaps "... by replacing
bool_t uses"?

> --- a/xen/arch/x86/cpu/common.c
> +++ b/xen/arch/x86/cpu/common.c
> @@ -26,11 +26,11 @@
>  
>  bool __read_mostly opt_dom0_cpuid_faulting = true;
>  
> -bool_t opt_arat = 1;
> +bool opt_arat = 1;
>  boolean_param("arat", opt_arat);
>  
>  /* pku: Flag to enable Memory Protection Keys (default on). */
> -static bool_t opt_pku = 1;
> +static bool opt_pku = 1;
>  boolean_param("pku", opt_pku);

In both cases this also wants switching to "true". Happy to make that
adjustment while committing (together with whatever adjustment to the
title you'd prefer), at which point:
Acked-by: Jan Beulich <jbeulich@suse.com>

Jan
Re: [XEN PATCH] x86: Address violations of MISRA C:2012 and drop bool_t
Posted by Federico Serafini 8 months, 3 weeks ago
On 07/08/23 10:44, Jan Beulich wrote:
> On 04.08.2023 16:11, Federico Serafini wrote:
>> Give a name to unnamed parameters to address violations of
>> MISRA C:2012 Rule 8.2 ("Function types shall be in prototype form with
>> named parameters").
>> Keep consistency between object and function declarations thus
>> addressing violations of MISRA C:2012 Rule 8.3 ("All declarations of an
>> object or function shall use the same names and type qualifiers").
>> Replace the occurrences of bool_t with bool.
> 
> Hmm, I read the title as a promise that bool_t would be gone from the
> code base (which I couldn't really believe). Perhaps "... by replacing
> bool_t uses"?

Sounds good to me.

-- 
Federico Serafini, M.Sc.

Software Engineer, BUGSENG (http://bugseng.com)
Re: [XEN PATCH] x86: Address violations of MISRA C:2012 and drop bool_t
Posted by Stefano Stabellini 8 months, 4 weeks ago
On Fri, 4 Aug 2023, Federico Serafini wrote:
> Give a name to unnamed parameters to address violations of
> MISRA C:2012 Rule 8.2 ("Function types shall be in prototype form with
> named parameters").
> Keep consistency between object and function declarations thus
> addressing violations of MISRA C:2012 Rule 8.3 ("All declarations of an
> object or function shall use the same names and type qualifiers").
> Replace the occurrences of bool_t with bool.
> 
> No functional change.
> 
> Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>

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