diff mbox series

[XEN,RFC] xen/automation: add deviations for MISRA C:2012 Rule 8.3

Message ID 565552f9e7cfff56fb1d1037cfa9662a1818c5d3.1698153310.git.federico.serafini@bugseng.com (mailing list archive)
State New, archived
Headers show
Series [XEN,RFC] xen/automation: add deviations for MISRA C:2012 Rule 8.3 | expand

Commit Message

Federico Serafini Oct. 24, 2023, 1:22 p.m. UTC
Update ECLAIR configuration to deviate Rule 8.3 ("All declarations of
an object or function shall use the same names and type qualifiers")
for the following functions:
- set_px_pminfo();
- guest_walk_tables_[0-9]+_levels().

Update file docs/misra/deviations.rst accordingly.
No functional change.

Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
---
I had a discussion with Jan about the reasons behind the choice of parameter
name 'walk' for the definitions of functions guest_walk_tables_[0-9]+_levels()
and the parameter name 'pfec' for the corresponding declarations.
Also for the function set_px_pminfo(), it seems that the parameter names are
different on purpose.
Can I submit a patch with these deviations? Do you have any comments?
---
 automation/eclair_analysis/ECLAIR/deviations.ecl | 4 ++++
 docs/misra/deviations.rst                        | 7 +++++++
 2 files changed, 11 insertions(+)

Comments

Jan Beulich Oct. 24, 2023, 2:32 p.m. UTC | #1
On 24.10.2023 15:22, Federico Serafini wrote:
> Update ECLAIR configuration to deviate Rule 8.3 ("All declarations of
> an object or function shall use the same names and type qualifiers")
> for the following functions:
> - set_px_pminfo();
> - guest_walk_tables_[0-9]+_levels().
> 
> Update file docs/misra/deviations.rst accordingly.
> No functional change.
> 
> Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
> ---
> I had a discussion with Jan about the reasons behind the choice of parameter
> name 'walk' for the definitions of functions guest_walk_tables_[0-9]+_levels()
> and the parameter name 'pfec' for the corresponding declarations.
> Also for the function set_px_pminfo(), it seems that the parameter names are
> different on purpose.

In this latter case I wonder why you think so. Did I end up making a
misleading comment anywhere? It looks to me as if naming the parameter
in question "perf" uniformly would be quite okay.

Jan
Federico Serafini Oct. 24, 2023, 3:22 p.m. UTC | #2
On 24/10/23 16:32, Jan Beulich wrote:
> On 24.10.2023 15:22, Federico Serafini wrote:
>> Update ECLAIR configuration to deviate Rule 8.3 ("All declarations of
>> an object or function shall use the same names and type qualifiers")
>> for the following functions:
>> - set_px_pminfo();
>> - guest_walk_tables_[0-9]+_levels().
>>
>> Update file docs/misra/deviations.rst accordingly.
>> No functional change.
>>
>> Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
>> ---
>> I had a discussion with Jan about the reasons behind the choice of parameter
>> name 'walk' for the definitions of functions guest_walk_tables_[0-9]+_levels()
>> and the parameter name 'pfec' for the corresponding declarations.
>> Also for the function set_px_pminfo(), it seems that the parameter names are
>> different on purpose.
> 
> In this latter case I wonder why you think so. Did I end up making a
> misleading comment anywhere? It looks to me as if naming the parameter
> in question "perf" uniformly would be quite okay.
> 
> Jan

No, it was just my impression.
What about the mismatch on the first parameter "acpi_id" vs "cpu"?
Jan Beulich Oct. 24, 2023, 4:05 p.m. UTC | #3
On 24.10.2023 17:22, Federico Serafini wrote:
> On 24/10/23 16:32, Jan Beulich wrote:
>> On 24.10.2023 15:22, Federico Serafini wrote:
>>> Update ECLAIR configuration to deviate Rule 8.3 ("All declarations of
>>> an object or function shall use the same names and type qualifiers")
>>> for the following functions:
>>> - set_px_pminfo();
>>> - guest_walk_tables_[0-9]+_levels().
>>>
>>> Update file docs/misra/deviations.rst accordingly.
>>> No functional change.
>>>
>>> Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
>>> ---
>>> I had a discussion with Jan about the reasons behind the choice of parameter
>>> name 'walk' for the definitions of functions guest_walk_tables_[0-9]+_levels()
>>> and the parameter name 'pfec' for the corresponding declarations.
>>> Also for the function set_px_pminfo(), it seems that the parameter names are
>>> different on purpose.
>>
>> In this latter case I wonder why you think so. Did I end up making a
>> misleading comment anywhere? It looks to me as if naming the parameter
>> in question "perf" uniformly would be quite okay.
> 
> No, it was just my impression.
> What about the mismatch on the first parameter "acpi_id" vs "cpu"?

The two can't possibly be used interchangeably, so whichever entity it
is that is being passed should determine the uniformly used name.

Jan
diff mbox series

Patch

diff --git a/automation/eclair_analysis/ECLAIR/deviations.ecl b/automation/eclair_analysis/ECLAIR/deviations.ecl
index d8170106b4..9485d66928 100644
--- a/automation/eclair_analysis/ECLAIR/deviations.ecl
+++ b/automation/eclair_analysis/ECLAIR/deviations.ecl
@@ -204,6 +204,10 @@  const-qualified."
 -config=MC3R1.R8.3,reports+={deliberate,"any_area(any_loc(file(adopted_mpparse_r8_3)))&&any_area(any_loc(file(^xen/arch/x86/include/asm/mpspec\\.h$)))"}
 -doc_end
 
+-doc_begin="For functions set_px_pminfo() and guest_walk_tables_[0-9]+_levels(), parameter names of definitions deliberately differ from the ones used in the corresponding declarations."
+-config=MC3R1.R8.3,declarations={deliberate,"^set_px_pminfo\\(uint32_t, struct xen_processor_performance\\*\\)|guest_walk_tables_[0-9]+_levels\\(const struct vcpu\\*, struct p2m_domain\\*, unsigned long, walk_t\\*, uint32_t, gfn_t, mfn_t, void\\*\\)$"}
+-doc_end
+
 -doc_begin="The following variables are compiled in multiple translation units
 belonging to different executables and therefore are safe."
 -config=MC3R1.R8.6,declarations+={safe, "name(current_stack_pointer||bsearch||sort)"}
diff --git a/docs/misra/deviations.rst b/docs/misra/deviations.rst
index 8511a18925..b5016412f6 100644
--- a/docs/misra/deviations.rst
+++ b/docs/misra/deviations.rst
@@ -121,6 +121,13 @@  Deviations related to MISRA C:2012 Rules:
          - xen/common/unxz.c
          - xen/common/unzstd.c
 
+   * - R8.3
+     - In some cases, parameter names used in the function definition
+       deliberately differ from the ones used in the corresponding declaration.
+     - Tagged as `deliberate` for ECLAIR. Such functions are:
+         - set_px_pminfo()
+         - guest_walk_tables_[0-9]+_levels()
+
    * - R8.4
      - The definitions present in the files 'asm-offsets.c' for any architecture
        are used to generate definitions for asm modules, and are not called by