diff mbox series

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

Message ID 2cd78bd0d39b36fe73e87cd1011658a54c2c729d.1691158092.git.federico.serafini@bugseng.com (mailing list archive)
State New, archived
Headers show
Series [XEN] x86: Address violations of MISRA C:2012 and drop bool_t | expand

Commit Message

Federico Serafini Aug. 4, 2023, 2:11 p.m. UTC
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(-)

Comments

Stefano Stabellini Aug. 4, 2023, 8:53 p.m. UTC | #1
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>
Jan Beulich Aug. 7, 2023, 8:44 a.m. UTC | #2
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
Federico Serafini Aug. 7, 2023, 9:03 a.m. UTC | #3
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.
Andrew Cooper Aug. 7, 2023, 12:31 p.m. UTC | #4
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
Federico Serafini Aug. 7, 2023, 12:44 p.m. UTC | #5
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.
diff mbox series

Patch

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);