Skip to content

RFC address MISRA C:2012 Rule 15.2

Nicola Vetrini xen-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest4 patches 11 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4xen/vsprintf: replace backwards jump with loopxen/common/vsprintf.c+12 -82 replies
2/4x86/dom0: make goto jump forwardxen/arch/x86/dom0_build.c+7 -71 reply
3/4xen/arm: GICv3: address MISRA C:2012 Rule 15.2xen/arch/arm/gic-v3-its.c+42 -391 reply
4/4automation/eclair: add deviation for certain backwards gotoautomation/eclair_analysis/ECLAIR/deviations.ecl docs/misra/deviations.rst+20 -04 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC PATCH 0/4] address MISRA C:2012 Rule 15.2

This series is aimed at presenting some strategies that can be used to deal with violations of Rule 15.2:
"The goto statement shall jump to a label declared later in the same function".

The rule's rationale is about possible developer confusion, therefore it could be argued that there is no substantial gain in complying with it, given the torough review process in place.

Nonetheless, the proposed resolution strategies are the following:
- use a loop instead of a goto (see patch 1 and 3)
- make the jump due to the goto forward, rather than backward (see patch 2)
- unconditionally allow certain constructs, such as "goto retry", whose presence in the codebase typically signifies that all other reasonable approaches (e.g, loops, forward jumps) have been considered and deemed inferior in terms of code readability.

The latter strategy may be postponed until all goto-s with a certain label have been examined. An alternative strategy could be to allow certain files (most notably those under x86/x86_emulate) to have backward jumps, and resolve the remaining violations.

Any feedback on this matter is welcome.

Nicola Vetrini (4):
xen/vsprintf: replace backwards jump with loop x86/dom0: make goto jump forward
xen/arm: GICv3: address MISRA C:2012 Rule 15.2 automation/eclair: add deviation for certain backwards goto

 .../eclair_analysis/ECLAIR/deviations.ecl     | 10 +++
 docs/misra/deviations.rst                     | 10 +++
 xen/arch/arm/gic-v3-its.c                     | 81 ++++++++++---------
 xen/arch/x86/dom0_build.c                     | 14 ++--
 xen/common/vsprintf.c                         | 20 +++--
 5 files changed, 81 insertions(+), 54 deletions(-)
Signature · 1 line
2.34.1