address remaining violations of Rule 20.12
v2 cover address remaining violations of Rule 20.12
This series addresses the remaining violations of Rule 20.12, and consequently sets the rule (and others) as clean to enable the gating.
Patches 1 and 2 are retained from the previous version, while patch 3 was sent standalone and now merged in this series, as it depends on the previous two patches.
Nicola Vetrini (3):
x86/domain: deviate violation of MISRA C Rule 20.12 automation/eclair_analysis: address remaining violations of MISRA C
Rule 20.12
automation/eclair_analysis: add more clean MISRA guidelines
automation/eclair_analysis/ECLAIR/deviations.ecl | 6 ++++++ automation/eclair_analysis/ECLAIR/tagging.ecl | 4 +++- docs/misra/safe.json | 8 ++++++++ xen/arch/x86/domain.c | 1 + xen/arch/x86/domctl.c | 1 + 5 files changed, 19 insertions(+), 1 deletion(-)
--
2.34.1
PATCH v2 1/3 x86/domain: deviate violation of MISRA C Rule 20.12
MISRA C Rule 20.12 states: "A macro parameter used as an operand to the # or ## operators, which is itself subject to further macro replacement, shall only be used as an operand to these operators".
In this case, builds where CONFIG_COMPAT=y the fpu_ctxt macro is used both as a regular macro argument and as an operand for stringification in the expansion of CHECK_FIELD_.
This is deviated using a SAF-x-safe comment.
No functional change.
--- docs/misra/safe.json | 8 ++++++++ xen/arch/x86/domain.c | 1 + xen/arch/x86/domctl.c | 1 + 3 files changed, 10 insertions(+)
docs/misra/safe.json +8 -0
@@ -52,6 +52,14 @@ }, { "id": "SAF-6-safe", + "analyser": { + "eclair": "MC3R1.R20.12" + }, + "name": "MC3R1.R20.12: use of a macro argument that deliberately violates the Rule", + "text": "A macro parameter that is itself a macro is intentionally used within the macro both as a regular parameter and for text replacement." + }, + { + "id": "SAF-7-safe", "analyser": {}, "name": "Sentinel", "text": "Next ID to be used"
xen/arch/x86/domain.c +1 -0
@@ -1084,6 +1084,7 @@ void arch_domain_creation_finished(struct domain *d)#ifdef CONFIG_COMPAT #define xen_vcpu_guest_context vcpu_guest_context#define fpu_ctxt fpu_ctxt.x +/* SAF-6-safe Rule 20.12 expansion of macro fpu_ctxt with CONFIG_COMPAT */ CHECK_FIELD_ (struct, vcpu_guest_context, fpu_ctxt);#undef fpu_ctxt#undef xen_vcpu_guest_context
xen/arch/x86/domctl.c +1 -0
@@ -1326,6 +1326,7 @@ long arch_do_domctl(#ifdef CONFIG_COMPAT #define xen_vcpu_guest_context vcpu_guest_context#define fpu_ctxt fpu_ctxt.x +/* SAF-6-safe Rule 20.12 expansion of macro fpu_ctxt with CONFIG_COMPAT */ CHECK_FIELD_ (struct, vcpu_guest_context, fpu_ctxt);#undef fpu_ctxt#undef xen_vcpu_guest_context
--
2.34.1
PATCH v2 2/3 automation/eclair_analysis: address remaining violations of MISRA C Rule 20.12
In reply to Nicola VetriniThe DEFINE macro in asm-offsets.c (for all architectures) still generates violations despite the file(s) being excluded from compliance, due to the fact that in its expansion it sometimes refers entities in non-excluded files. These corner cases are deviated by the configuration.
No functional change.
--- automation/eclair_analysis/ECLAIR/deviations.ecl | 6 ++++++ 1 file changed, 6 insertions(+)
automation/eclair_analysis/ECLAIR/deviations.ecl +6 -0
@@ -483,6 +483,12 @@ leads to a violation of the Rule are deviated." -config=MC3R1.R20.12,macros+={deliberate, "name(GENERATE_CASE)&&loc(file(deliberate_generate_case))"} -doc_end +-doc_begin="The macro DEFINE is defined and used in excluded files asm-offsets.c. +This may still cause violations if entities outside these files are referred to +in the expansion." +-config=MC3R1.R20.12,macros+={deliberate, "name(DEFINE)&&loc(file(asm_offsets))"} +-doc_end + # # Series 21. #
--
2.34.1
Re: [XEN PATCH for-4.19 v2 2/3] automation/eclair_analysis: address remaining violations of MISRA C Rule 20.12
Quoted 8 lines · Nicola Vetrini
The DEFINE macro in
asm-offsets.c(for all architectures) still generates violations despite the file(s) being excluded from compliance, due to the fact that in its expansion it sometimes refers entities in non-excluded files. These corner cases are deviated by the configuration.No functional change.
Signed-off-by Nicola Vetrini <[email protected]>
Quoted 24 lines
--- automation/eclair_analysis/ECLAIR/deviations.ecl | 6 ++++++ 1 file changed, 6 insertions(+)automation/eclair_analysis/ECLAIR/deviations.ecl +6
-1@@ -483,6 +483,12 @@ leads to a violation of the Rule are deviated." -config=MC3R1.R20.12,macros+={deliberate, "name(GENERATE_CASE)&&loc(file(deliberate_generate_case))"} -doc_end +-doc_begin="The macro DEFINE is defined and used in excluded files asm-offsets.c. +This may still cause violations if entities outside these files are referred to +in the expansion." +-config=MC3R1.R20.12,macros+={deliberate, "name(DEFINE)&&loc(file(asm_offsets))"} +-doc_end + # # Series 21. # --2.34.1
PATCH v2 3/3 automation/eclair_analysis: add more clean MISRA guidelines
In reply to Nicola VetriniRules 20.9, 20.12 and 14.4 are now clean on ARM and x86, so they are added to the list of clean guidelines.
Some guidelines listed in the additional clean section for ARM are also clean on x86, so they can be removed from there.
No functional change.
--- automation/eclair_analysis/ECLAIR/tagging.ecl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
automation/eclair_analysis/ECLAIR/tagging.ecl +3 -1
@@ -60,6 +60,7 @@ MC3R1.R11.7|| MC3R1.R11.9|| MC3R1.R12.5|| MC3R1.R14.1|| +MC3R1.R14.4|| MC3R1.R16.7|| MC3R1.R17.1|| MC3R1.R17.3||
@@ -73,6 +74,7 @@ MC3R1.R20.4|| MC3R1.R20.6|| MC3R1.R20.9|| MC3R1.R20.11|| +MC3R1.R20.12|| MC3R1.R20.13|| MC3R1.R20.14|| MC3R1.R21.3||
@@ -105,7 +107,7 @@ if(string_equal(target,"x86_64"), ) if(string_equal(target,"arm64"), - service_selector({"additional_clean_guidelines","MC3R1.R14.4||MC3R1.R16.6||MC3R1.R20.12||MC3R1.R2.1||MC3R1.R5.3||MC3R1.R7.2||MC3R1.R7.3||MC3R1.R8.6||MC3R1.R9.3"}) + service_selector({"additional_clean_guidelines","MC3R1.R16.6||MC3R1.R2.1||MC3R1.R5.3||MC3R1.R7.3"}) ) -reports+={clean:added,"service(clean_guidelines_common||additional_clean_guidelines)"}
--
2.34.1
Re: [XEN PATCH for-4.19 v2 3/3] automation/eclair_analysis: add more clean MISRA guidelines
Quoted 2 lines · Nicola Vetrini
Rules 20.9, 20.12 and 14.4 are now clean on ARM and x86, so they are added to the list of clean guidelines.
Why is 20.9 being mentioned here when ...
Quoted 11 lines
automation/eclair_analysis/ECLAIR/tagging.ecl +1
-0@@ -60,6 +60,7 @@ MC3R1.R11.7|| MC3R1.R11.9|| MC3R1.R12.5|| MC3R1.R14.1|| +MC3R1.R14.4|| MC3R1.R16.7|| MC3R1.R17.1|| MC3R1.R17.3||
automation/eclair_analysis/ECLAIR/tagging.ecl MC3R1.R20.4|| · line 80
Quoted 7 lines
automation/eclair_analysis/ECLAIR/tagging.ecl +1
-0@@ -73,6 +74,7 @@ MC3R1.R20.4|| MC3R1.R20.6|| MC3R1.R20.9|| MC3R1.R20.11|| +MC3R1.R20.12|| MC3R1.R20.13|| MC3R1.R20.14|| MC3R1.R21.3||
... nothing changes in its regard?
Jan
Re: [XEN PATCH for-4.19 v2 3/3] automation/eclair_analysis: add more clean MISRA guidelines
Quoted 18 lines · Jan Beulich
Quoted 2 lines · Nicola Vetrini
Rules 20.9, 20.12 and 14.4 are now clean on ARM and x86, so they are added to the list of clean guidelines.
Why is 20.9 being mentioned here when ...
Quoted 12 lines
automation/eclair_analysis/ECLAIR/tagging.ecl +1
-0@@ -60,6 +60,7 @@ MC3R1.R11.7|| MC3R1.R11.9|| MC3R1.R12.5|| MC3R1.R14.1|| +MC3R1.R14.4|| MC3R1.R16.7|| MC3R1.R17.1|| MC3R1.R17.3||@@ -73,6 +74,7 @@ MC3R1.R20.4|| MC3R1.R20.6||
Quoted 9 lines
automation/eclair_analysis/ECLAIR/tagging.ecl MC3R1.R20.4|| · line 80
Quoted 6 lines
automation/eclair_analysis/ECLAIR/tagging.ecl +1
-0MC3R1.R20.9|| MC3R1.R20.11|| +MC3R1.R20.12|| MC3R1.R20.13|| MC3R1.R20.14|| MC3R1.R21.3||... nothing changes in its regard?
Right, it should be removed from the message.
Quoted 1 line
Jan
Signature · 2 lines
Nicola Vetrini, BSc Software Engineer, BUGSENG srl (https://bugseng.com)
Re: [XEN PATCH for-4.19 v2 3/3] automation/eclair_analysis: add more clean MISRA guidelines
Quoted 29 lines · Nicola Vetrini
Quoted 18 lines · Jan Beulich
Quoted 2 lines · Nicola Vetrini
Rules 20.9, 20.12 and 14.4 are now clean on ARM and x86, so they are added to the list of clean guidelines.
Why is 20.9 being mentioned here when ...
Quoted 12 lines
automation/eclair_analysis/ECLAIR/tagging.ecl +1
-0@@ -60,6 +60,7 @@ MC3R1.R11.7|| MC3R1.R11.9|| MC3R1.R12.5|| MC3R1.R14.1|| +MC3R1.R14.4|| MC3R1.R16.7|| MC3R1.R17.1|| MC3R1.R17.3||@@ -73,6 +74,7 @@ MC3R1.R20.4|| MC3R1.R20.6||Quoted 9 lines
automation/eclair_analysis/ECLAIR/tagging.ecl MC3R1.R20.4|| · line 80
Quoted 6 lines
automation/eclair_analysis/ECLAIR/tagging.ecl +1
-0MC3R1.R20.9|| MC3R1.R20.11|| +MC3R1.R20.12|| MC3R1.R20.13|| MC3R1.R20.14|| MC3R1.R21.3||... nothing changes in its regard?
Quoted 1 line
Right, it should be removed from the message.
I fixed the commit message, acked the patch and committed it