[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [XEN PATCH 00/11] xen: address MISRA C:2012 Rule 2.1
The headline for Rule 2.1 states: "A project shall not contain unreachable code". Violations of this rule addressed by this patch are caused by two constructs: 1. Declarations inside switch statements, before any clause. This construct is allowed by the language, but is considered unreachable code, since the program execution doesn't ever reach these statements, even though the variables are introduced in the switch block. 2. Code following functions that are not intended to return to the caller or additional statements required by defensive programming practices or other MISRA rules (such as a break to end each switch clause, even if that break is effectively unreachable). (1) is resolved by moving the declarations in an appropriate scope, while (2) is addressed by adding ASSERT_UNREACHABLE() calls to signal that the code below is intentionally unreachable, thus motivating the violation of the rule. --- The approach taken in this series to address the violations is the outcome of a MISRA C group meeting held 25/07/2023. Nicola Vetrini (11): x86/efi: move variable declaration to address MISRA C:2012 Rule 2.1 x86: move declarations to address MISRA C:2012 Rule 2.1 x86/uaccess: move declarations to address MISRA C:2012 Rule 2.1 x86emul: move variable definitions to address MISRA C:2012 Rule 2.1 drivers/pci: move variable definitions to address MISRA C:2012 Rule 2.1 xen/ioreq: move variable declaration to address MISRA C:2012 Rule 2.1 xen: address MISRA C:2012 Rule 2.1 xen: move declarations to address MISRA C:2012 Rule 2.1 x86/xstate: moved BUILD_BUG_ON to address MISRA C:2012 Rule 2.1 xen/sched: add ASSERT_UNREACHABLE() to address MISRA C:2012 Rule 2.1 x86/mm: Add assertion to address MISRA C:2012 Rule 2.1 xen/arch/x86/cpuid.c | 3 +-- xen/arch/x86/domain.c | 23 +++++++++++------------ xen/arch/x86/efi/efi-boot.h | 5 ++--- xen/arch/x86/hvm/emulate.c | 9 ++++----- xen/arch/x86/hvm/hvm.c | 10 ++++------ xen/arch/x86/include/asm/uaccess.h | 6 ++++-- xen/arch/x86/irq.c | 3 +-- xen/arch/x86/mm.c | 1 + xen/arch/x86/mm/p2m-pod.c | 1 + xen/arch/x86/msr.c | 3 +-- xen/arch/x86/x86_emulate/0f01.c | 7 +++---- xen/arch/x86/x86_emulate/blk.c | 17 ++++++++--------- xen/arch/x86/x86_emulate/decode.c | 3 ++- xen/arch/x86/x86_emulate/fpu.c | 3 +-- xen/arch/x86/x86_emulate/util-xen.c | 4 ++-- xen/arch/x86/x86_emulate/x86_emulate.c | 14 +++++++------- xen/arch/x86/xstate.c | 3 ++- xen/common/compat/memory.c | 3 +-- xen/common/domain.c | 15 +++++++-------- xen/common/ioreq.c | 3 +-- xen/common/sched/core.c | 1 + xen/common/shutdown.c | 18 ++++++++++++------ xen/drivers/passthrough/pci.c | 10 ++++------ 23 files changed, 81 insertions(+), 84 deletions(-) -- 2.34.1
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |