|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [RFC PATCH 2/2] misra: deviate R2.6 for the labels generated by CASE_SIMD_*
MISRA C:2012 Rule 2.6 (advisory) states that "a function should not
contain unused label declarations".
When SIMD emulation is compiled out of the x86 emulator (CONFIG_HVM=n),
private.h defines X86EMUL_NO_SIMD and the CASE_SIMD_* macros
deliberately expand to plain identifiers instead of case labels, so
that the opcode switch builds without conditionals around every case.
The labels they produce (e.g. Cs0x0f_0x2b) are never the target of a
goto, and the build already passes -Wno-unused-label for this object.
These cannot be annotated in the source: ECLAIR reports them at the
macro's use site, while __maybe_unused could only live in the macro's
replacement list, out of reach of the existing text-based R2.6
deviation. Extend that deviation to labels coming from the expansion
of a CASE_SIMD_* macro, and document it.
Signed-off-by: Shuaidong Chen <shuaidong.chen@xxxxxxx>
---
automation/eclair_analysis/ECLAIR/deviations.ecl | 4 +++-
docs/misra/deviations.rst | 9 +++++++++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/automation/eclair_analysis/ECLAIR/deviations.ecl
b/automation/eclair_analysis/ECLAIR/deviations.ecl
index 296340bb4c..6055279674 100644
--- a/automation/eclair_analysis/ECLAIR/deviations.ecl
+++ b/automation/eclair_analysis/ECLAIR/deviations.ecl
@@ -51,8 +51,10 @@ removed by the compiler, the resulting slowdown is
negligible."
-config=MC3A2.R2.2,reports+={disapplied,"any()"}
-doc_end
--doc_begin="Some labels are unused in certain build configurations, or are
deliberately marked as unused, so that the compiler is entitled to remove them."
+-doc_begin="Some labels are unused in certain build configurations, or are
deliberately marked as unused, so that the compiler is entitled to remove them.
+With SIMD emulation compiled out, the CASE_SIMD_* macros of the x86 emulator
expand to plain labels in place of case labels."
-config=MC3A2.R2.6,reports+={deliberate,
"any_area(text(^.*__maybe_unused.*$))"}
+-config=MC3A2.R2.6,reports+={deliberate,
"any_area(any_loc(any_exp(macro(^CASE_SIMD_.*$))))"}
-doc_end
#
diff --git a/docs/misra/deviations.rst b/docs/misra/deviations.rst
index bee4686675..658e438980 100644
--- a/docs/misra/deviations.rst
+++ b/docs/misra/deviations.rst
@@ -116,6 +116,15 @@ Deviations related to MISRA C:2012 Rules:
such labels poses no risks.
- Tagged as `deliberate` for ECLAIR.
+ * - R2.6
+ - When SIMD emulation is compiled out of the x86 instruction emulator
+ (X86EMUL_NO_SIMD), the CASE_SIMD_* macros deliberately expand to plain
+ labels instead of case labels, so that the opcode switch builds
+ without conditionals around every case. Nothing jumps to these
+ labels, and the code behind them stays reachable through the
+ remaining case labels.
+ - Tagged as `deliberate` for ECLAIR.
+
* - R3.1
- Comments starting with '/\*' and containing URLs are safe as they are
not instances of commented-out code.
--
2.34.1
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |