misra: add Rule 5.5 deviations for macro clashes
v2 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.
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 | 24 +++++++++++++++++++ docs/misra/rules.rst | 12 ++++++++++ 3 files changed, 48 insertions(+)
Signature · 1 line
2.43.0
PATCH v2 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
@@ -132,6 +132,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 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
@@ -222,6 +222,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 names 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
Re: [PATCH v2 1/3] misra: deviate MISRA C Rule 5.5 for 'hypfs_alloc_dyndata()'
docs/misra/rules.rst maintainers if you want to suggest a change. · line 227
Quoted 3 lines · On Sun, Jul 12, 2026 at 02:04:44PM +0000, Dmytro Prokopchuk1 wrote:
docs/misra/rules.rst +3
-0+ Clash between hypfs_alloc_dyndata() function and macro names is allowed + because the macro is a typed convenience wrapper around the size-based + allocation function.
Is this really the whole reason for this? The macro is a wrapper to the function, so it must be named the same?
If there is a deeper meaning, this should be documented here. Looking at the current code, there is no documention at least in the code directly. And the function is used once?!?
Bastian
Signature · 3 lines
... The prejudices people feel about each other disappear when they get to know each other. -- Kirk, "Elaan of Troyius", stardate 4372.5
Re: [PATCH v2 1/3] misra: deviate MISRA C Rule 5.5 for 'hypfs_alloc_dyndata()'
Quoted 7 lines · Bastian Blank
docs/misra/rules.rst maintainers if you want to suggest a change. · line 227
Quoted 3 lines · On Sun, Jul 12, 2026 at 02:04:44PM +0000, Dmytro Prokopchuk1 wrote:
docs/misra/rules.rst +3
-0+ Clash between hypfs_alloc_dyndata() function and macro names is allowed + because the macro is a typed convenience wrapper around the size-based + allocation function.Is this really the whole reason for this? The macro is a wrapper to the function, so it must be named the same?
Why "must"? It's still a choice we have. Imo a good one, to make accidental use of the non-wrapper less likely. But opinions may vary there, and iirc there were discussions around this when we settled on what rules to accept and what exceptions to plan for right away.
Quoted 3 lines
If there is a deeper meaning, this should be documented here. Looking at the current code, there is no documention at least in the code directly. And the function is used once?!?
More uses may appear at any time - it's a library-like function for hypfs, after all. It's just that hypfs, after its introduction, hasn't seen much interest (as in: further uses) anymore.
Jan
Re: [PATCH v2 1/3] misra: deviate MISRA C Rule 5.5 for 'hypfs_alloc_dyndata()'
In reply to Dmytro Prokopchuk1Quoted 9 lines · On 12.07.2026 16:04, Dmytro Prokopchuk1 wrote:
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).
Quoted 3 lines
Update
deviations.rstandrules.rstaccordingly.Signed-off-by Dmytro Prokopchuk <[email protected]>
PATCH v2 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 | 4 ++++ 3 files changed, 15 insertions(+)
automation/eclair_analysis/ECLAIR/deviations.ecl +4 -0
@@ -136,6 +136,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: 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 is deliberate. + The function uses the Xen 'request_irq()' 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 +4 -0
@@ -226,6 +226,10 @@ maintainers if you want to suggest a change. because the macro is a typed convenience wrapper around the size-based allocation function. + Clash between request_irq() function and macro names is allowed because + the macro is a local compatibility wrapper that adapts ARM SMMU driver + call to Xen'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
Re: [PATCH v2 2/3] misra: deviate MISRA C Rule 5.5 for 'request_irq()'
automation/eclair_analysis/ECLAIR/deviations.ecl These macros address differences in argument count during compile-time, effectiv · line 141
Quoted 9 lines · On 12.07.2026 16:04, Dmytro Prokopchuk1 wrote:
automation/eclair_analysis/ECLAIR/deviations.ecl +3
-0@@ -136,6 +136,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
This suitably constrains things to a single file.
docs/misra/deviations.rst Deviations related to MISRA C:2012 Rules: · line 189
Quoted 8 lines
docs/misra/deviations.rst +2
-0@@ -185,6 +185,13 @@ Deviations related to MISRA C:2012 Rules: 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 is deliberate.
This doesn't, and ...
docs/misra/deviations.rst Deviations related to MISRA C:2012 Rules: · line 193
Quoted 4 lines
docs/misra/deviations.rst +4
-0+ The function uses the Xen 'request_irq()' 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.
... there's then not even a mention of the file name later (ftaod: even if there was, to me at least this would come too late).
docs/misra/rules.rst maintainers if you want to suggest a change. · line 231
Quoted 9 lines
docs/misra/rules.rst +3
-0@@ -226,6 +226,10 @@ maintainers if you want to suggest a change. because the macro is a typed convenience wrapper around the size-based allocation function. + Clash between request_irq() function and macro names is allowed because + the macro is a local compatibility wrapper that adapts ARM SMMU driver + call to Xen's request_irq() argument order.
Similarly here.
Jan
Re: [PATCH v2 2/3] misra: deviate MISRA C Rule 5.5 for 'request_irq()'
Hello Jan,
Quoted 38 lines · Jan Beulich
automation/eclair_analysis/ECLAIR/deviations.ecl These macros address differences in argument count during compile-time, effectiv · line 141
Quoted 9 lines · On 12.07.2026 16:04, Dmytro Prokopchuk1 wrote:
automation/eclair_analysis/ECLAIR/deviations.ecl +3
-0@@ -136,6 +136,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_endThis suitably constrains things to a single file.
docs/misra/deviations.rst Deviations related to MISRA C:2012 Rules: · line 189
Quoted 8 lines
docs/misra/deviations.rst +2
-0@@ -185,6 +185,13 @@ Deviations related to MISRA C:2012 Rules: 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 is deliberate.This doesn't, and ...
docs/misra/deviations.rst Deviations related to MISRA C:2012 Rules: · line 193
Quoted 4 lines
docs/misra/deviations.rst +4
-0+ The function uses the Xen 'request_irq()' 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.... there's then not even a mention of the file name later (ftaod: even if there was, to me at least this would come too late).
Quoted 6 lines
docs/misra/rules.rst +0
-0@@ -226,6 +226,10 @@ maintainers if you want to suggest a change. because the macro is a typed convenience wrapper around the size-based allocation function.
Quoted 7 lines
docs/misra/rules.rst maintainers if you want to suggest a change. · line 231
Quoted 3 lines
docs/misra/rules.rst +3
-0+ Clash between request_irq() function and macro names is allowed because + the macro is a local compatibility wrapper that adapts ARM SMMU driver + call to Xen's request_irq() argument order.Similarly here.
Jan
Sounds reasonable. I'll update wording with specifying file name.
BR, Dmytro.
PATCH v2 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 Xen 'request_irq()'.
Update deviations.rst and rules.rst accordingly.
--- automation/eclair_analysis/ECLAIR/deviations.ecl | 4 ++++ docs/misra/deviations.rst | 8 ++++++++ docs/misra/rules.rst | 4 ++++ 3 files changed, 16 insertions(+)
automation/eclair_analysis/ECLAIR/deviations.ecl +4 -0
@@ -140,6 +140,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 +8 -0
@@ -192,6 +192,14 @@ Deviations related to MISRA C:2012 Rules: 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 are deliberate. + The original ARM SMMU handler returns irqreturn_t, while the macro + redirects later uses to a Xen wrapper with the void interrupt-handler + signature expected by Xen '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 +4 -0
@@ -230,6 +230,10 @@ maintainers if you want to suggest a change. the macro is a local compatibility wrapper that adapts ARM SMMU driver call to Xen's request_irq() argument order. + Clashes between ARM SMMU fault handler functions and macro names are + allowed because the macros redirect ARM SMMU driver uses to a Xen 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