misra: add Rule 5.5 deviations for macro clashes
v3 cover misra: add Rule 5.5 deviations for macro clashes
This series adds deviations for function/macro name clashes where the macro is used as a wrapper around an existing function name.
With these three patches all ARM Rules 5.5 became clean.
Changes in v3:
- update wording with specifying file (constrains)
- add Jan's ack for the first patch in the list
- remove single quotes around names
Changes in v2:
- remove much details from deviations.ecl file
- use word "deliberate" in descriptions
- append "()" to function to avoid mixing style
Dmytro Prokopchuk (3):
misra: deviate MISRA C Rule 5.5 for hypfs_alloc_dyndata()
misra: deviate MISRA C Rule 5.5 for request_irq()
misra: deviate MISRA C Rule 5.5 for ARM SMMU fault handlers
.../eclair_analysis/ECLAIR/deviations.ecl | 12 +++++++++ docs/misra/deviations.rst | 25 +++++++++++++++++++ docs/misra/rules.rst | 14 +++++++++++ 3 files changed, 51 insertions(+)
Signature · 1 line
2.43.0
PATCH v3 1/3 misra: deviate MISRA C Rule 5.5 for hypfs_alloc_dyndata()
MISRA C Rule 5.5 states: "Identifiers shall be distinct from macro names".
Update ECLAIR configuration to deviate identifier and macro name clashes by specifying the macros that should be ignored. This includes hypfs_alloc_dyndata(), where the real function takes an allocation size and the same-named macro is a typed convenience wrapper that expands calls using sizeof(type).
Update deviations.rst and rules.rst accordingly.
--- automation/eclair_analysis/ECLAIR/deviations.ecl | 4 ++++ docs/misra/deviations.rst | 9 +++++++++ docs/misra/rules.rst | 4 ++++ 3 files changed, 17 insertions(+)
automation/eclair_analysis/ECLAIR/deviations.ecl +4 -0
@@ -133,6 +133,10 @@ These macros address differences in argument count during compile-time, effectiv -config=MC3A2.R5.5,ignored_macros+="name(update_gnttab_par||parse_gnttab_limit)&&loc(file(^xen/common/grant_table\\.c$))" -doc_end +-doc_begin="Clash between hypfs_alloc_dyndata() function and macro name in xen/include/xen/hypfs.h is deliberate." +-config=MC3A2.R5.5,ignored_macros+="name(hypfs_alloc_dyndata)&&loc(file(^xen/include/xen/hypfs\\.h$))" +-doc_end + -doc_begin="The type \"ret_t\" is deliberately defined multiple times, depending on the guest." -config=MC3A2.R5.6,reports+={deliberate,"any_area(any_loc(text(^.*ret_t.*$)))"}
docs/misra/deviations.rst +9 -0
@@ -176,6 +176,15 @@ Deviations related to MISRA C:2012 Rules: unused 2nd and 3rd parameters to avoid warnings or errors related to them. - ECLAIR has been configured to ignore these macros. + * - R5.5 + - Clash between the hypfs_alloc_dyndata() function and macro name in the + file xen/include/xen/hypfs.h is deliberate. The function is the allocator + taking a size in bytes, while the macro is a typed convenience wrapper used + by dynamic hypfs nodes to allocate per-request traversal data with the + correct size and return type. The implementation explicitly undefines the + macro before defining the real function, so the name clash is controlled. + - ECLAIR has been configured to ignore this macro. + * - R5.6 - The type ret_t is deliberately defined multiple times depending on the type of guest to service.
docs/misra/rules.rst +4 -0
@@ -223,6 +223,10 @@ maintainers if you want to suggest a change. Clashes between grant table functions and macro names are allowed because they are used for discarding unused parameters. + Clash between hypfs_alloc_dyndata() function and macro name in the + file xen/include/xen/hypfs.h is allowed because the macro is a typed + convenience wrapper around the size-based allocation function. + * - `Rule 5.6 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_05_06.c>`_ - Required - A typedef name shall be a unique identifier
Signature · 1 line
2.43.0
PATCH v3 2/3 misra: deviate MISRA C Rule 5.5 for request_irq()
In reply to Dmytro Prokopchuk1MISRA C Rule 5.5 states: "Identifiers shall be distinct from macro names".
Update ECLAIR configuration to deviate identifier and macro name clashes by specifying the macros that should be ignored. This includes request_irq(), where the Xen function takes the IRQ flags before the handler argument, while the macro adapts ARM SMMU driver calls by reordering the arguments.
Update deviations.rst and rules.rst accordingly.
--- automation/eclair_analysis/ECLAIR/deviations.ecl | 4 ++++ docs/misra/deviations.rst | 7 +++++++ docs/misra/rules.rst | 5 +++++ 3 files changed, 16 insertions(+)
automation/eclair_analysis/ECLAIR/deviations.ecl +4 -0
@@ -137,6 +137,10 @@ These macros address differences in argument count during compile-time, effectiv -config=MC3A2.R5.5,ignored_macros+="name(hypfs_alloc_dyndata)&&loc(file(^xen/include/xen/hypfs\\.h$))" -doc_end +-doc_begin="Clash between request_irq() function and macro name in xen/drivers/passthrough/arm/smmu.c is deliberate." +-config=MC3A2.R5.5,ignored_macros+="name(request_irq)&&loc(file(^xen/drivers/passthrough/arm/smmu\\.c$))" +-doc_end + -doc_begin="The type \"ret_t\" is deliberately defined multiple times, depending on the guest." -config=MC3A2.R5.6,reports+={deliberate,"any_area(any_loc(text(^.*ret_t.*$)))"}
docs/misra/deviations.rst +7 -0
@@ -185,6 +185,13 @@ Deviations related to MISRA C:2012 Rules: macro before defining the real function, so the name clash is controlled. - ECLAIR has been configured to ignore this macro. + * - R5.5 + - Clash between the request_irq() function and macro name in the file + xen/drivers/passthrough/arm/smmu.c is deliberate. The function uses the + argument order, while the macro is a compatibility wrapper for the ARM + SMMU driver that adapts calls by reordering the handler and flags arguments. + - ECLAIR has been configured to ignore this macro. + * - R5.6 - The type ret_t is deliberately defined multiple times depending on the type of guest to service.
docs/misra/rules.rst +5 -0
@@ -227,6 +227,11 @@ maintainers if you want to suggest a change. file xen/include/xen/hypfs.h is allowed because the macro is a typed convenience wrapper around the size-based allocation function. + Clash between request_irq() function and macro names in the file + xen/drivers/passthrough/arm/smmu.c is allowed because the macro is a + local compatibility wrapper that adapts ARM SMMU driver's request_irq() + argument order. + * - `Rule 5.6 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_05_06.c>`_ - Required - A typedef name shall be a unique identifier
Signature · 1 line
2.43.0
PATCH v3 3/3 misra: deviate MISRA C Rule 5.5 for ARM SMMU fault handlers
In reply to Dmytro Prokopchuk1MISRA C Rule 5.5 states: "Identifiers shall be distinct from macro names".
Update ECLAIR configuration to deviate identifier and macro name clashes by specifying the macros that should be ignored. This includes arm_smmu_global_fault() and arm_smmu_context_fault(), where the original ARM SMMU handler returns irqreturn_t, while the same-named macro redirects later uses to a Xen wrapper with the void interrupt-handler signature expected by request_irq().
Update deviations.rst and rules.rst accordingly.
--- automation/eclair_analysis/ECLAIR/deviations.ecl | 4 ++++ docs/misra/deviations.rst | 9 +++++++++ docs/misra/rules.rst | 5 +++++ 3 files changed, 18 insertions(+)
automation/eclair_analysis/ECLAIR/deviations.ecl +4 -0
@@ -141,6 +141,10 @@ These macros address differences in argument count during compile-time, effectiv -config=MC3A2.R5.5,ignored_macros+="name(request_irq)&&loc(file(^xen/drivers/passthrough/arm/smmu\\.c$))" -doc_end +-doc_begin="Clashes between ARM SMMU fault handler functions and macro names in xen/drivers/passthrough/arm/smmu.c are deliberate." +-config=MC3A2.R5.5,ignored_macros+="name(arm_smmu_global_fault||arm_smmu_context_fault)&&loc(file(^xen/drivers/passthrough/arm/smmu\\.c$))" +-doc_end + -doc_begin="The type \"ret_t\" is deliberately defined multiple times, depending on the guest." -config=MC3A2.R5.6,reports+={deliberate,"any_area(any_loc(text(^.*ret_t.*$)))"}
docs/misra/deviations.rst +9 -0
@@ -192,6 +192,15 @@ Deviations related to MISRA C:2012 Rules: SMMU driver that adapts calls by reordering the handler and flags arguments. - ECLAIR has been configured to ignore this macro. + * - R5.5 + - Clashes between the ARM SMMU fault handler arm_smmu_global_fault(), + arm_smmu_context_fault() functions and macro names in the file + xen/drivers/passthrough/arm/smmu.c are deliberate. + The original ARM SMMU handler returns irqreturn_t, while the macro + redirects later uses to a wrapper with the void interrupt-handler + signature expected by request_irq(). + - ECLAIR has been configured to ignore these macros. + * - R5.6 - The type ret_t is deliberately defined multiple times depending on the type of guest to service.
docs/misra/rules.rst +5 -0
@@ -232,6 +232,11 @@ maintainers if you want to suggest a change. local compatibility wrapper that adapts ARM SMMU driver's request_irq() argument order. + Clashes between arm_smmu_global_fault(), arm_smmu_context_fault() functions + and macro names in the file xen/drivers/passthrough/arm/smmu.c are allowed + because the macros redirect ARM SMMU driver uses to a interrupt wrapper + with the handler signature expected by request_irq(). + * - `Rule 5.6 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_05_06.c>`_ - Required - A typedef name shall be a unique identifier
Signature · 1 line
2.43.0
Quoted 8 lines · On 29.09.2026 08:21, Dmytro Prokopchuk1 wrote:
This series adds deviations for function/macro name clashes where the macro is used as a wrapper around an existing function name.
With these three patches all ARM Rules 5.5 became clean.
Changes in v3:
- update wording with specifying file (constrains)
- add Jan's ack for the first patch in the list
I.e. you took my reply to Bastian's comment as sufficient to address his concern?
Jan
Hi Jan,
Quoted 6 lines · Jan Beulich
Quoted 5 lines · On 29.09.2026 08:21, Dmytro Prokopchuk1 wrote:
This series adds deviations for function/macro name clashes where the macro is used as a wrapper around an existing function name.
With these three patches all ARM Rules 5.5 became clean.
Quoted 8 lines
Quoted 3 lines
Changes in v3:
- update wording with specifying file (constrains)
- add Jan's ack for the first patch in the listI.e. you took my reply to Bastian's comment as sufficient to address his concern?
Jan
Not entirely. I took your explanation as the rationale, but v3 doesn't record it in the deviation text.
The patch is already committed, so v3 didn't record the rationale you gave for sharing the name. I can send a follow-up patch that adds it to the deviation text and rules.rst: the macro deliberately shares the function's name so that accidental use of the size-based function is less likely.
BR, Dmytro.