With CONFIG_HVM=n, private.h defines X86EMUL_NO_FPU, X86EMUL_NO_MMX
and X86EMUL_NO_SIMD, and x86_emulate.c is left with 91 unused labels,
which ECLAIR reports under MISRA C:2012 Rule 2.6 (advisory). The
ECLAIR jobs in automation/gitlab-ci/analyze.yaml all build with
CONFIG_HVM=y, so upstream's scans don't show them today; they surfaced
while analysing an HVM-less x86 configuration.
The 91 labels split in two groups:
- 9 hand-written simd_* labels whose gotos are all preprocessed out.
Patch 1 marks them __maybe_unused, which the existing R2.6
deviation already covers. No functional change: the code and data
sections of x86_emulate.o are unchanged.
- 82 labels produced by the CASE_SIMD_* macros, which deliberately
expand to plain labels instead of case labels in this configuration.
ECLAIR reports them at the macro use site, so they cannot be
annotated in the source. Patch 2 extends the R2.6 deviation to
them.
Reproduced on current master with clang -Wunused-label on a
CONFIG_HVM=n build: 91 unused labels without the series, 82 (all
CASE_SIMD_*) with patch 1. ECLAIR on an HVM-less x86 configuration:
before: https://gitlab.com/xen-project/people/amd/xen/-/jobs/17763605066
after: https://gitlab.com/xen-project/people/amd/xen/-/jobs/17764580898
Sent as RFC for patch 2, a new deviation for reports upstream doesn't
currently see:
- Is extending the R2.6 deviation acceptable here?
- Alternatives considered: folding the ':' into the macros still
leaves the labels in place; expanding the macros to nothing makes
the code behind them unreachable (Rule 2.1, required).
- Would an ECLAIR job for a CONFIG_HVM=n configuration be welcome?
Shuaidong Chen (2):
x86emul: mark the trimmed emulator's section-internal labels
maybe-unused
misra: deviate R2.6 for the labels generated by CASE_SIMD_*
.../eclair_analysis/ECLAIR/deviations.ecl | 4 +++-
docs/misra/deviations.rst | 9 +++++++++
xen/arch/x86/x86_emulate/x86_emulate.c | 18 +++++++++---------
3 files changed, 21 insertions(+), 10 deletions(-)
--
2.34.1