All of lore.kernel.org
 help / color / mirror / Atom feed
* [XEN PATCH 00/11] xen: address MISRA C:2012 Rule 2.1
@ 2023-08-02 14:38 Nicola Vetrini
  2023-08-02 14:38 ` [XEN PATCH 01/11] x86/efi: move variable declaration to " Nicola Vetrini
                   ` (10 more replies)
  0 siblings, 11 replies; 56+ messages in thread
From: Nicola Vetrini @ 2023-08-02 14:38 UTC (permalink / raw)
  To: xen-devel
  Cc: sstabellini, michal.orzel, xenia.ragiadakou, ayan.kumar.halder,
	consulting, Nicola Vetrini, Jan Beulich, Andrew Cooper,
	Roger Pau Monné, Wei Liu, Paul Durrant, George Dunlap,
	Julien Grall, Dario Faggioli

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


^ permalink raw reply	[flat|nested] 56+ messages in thread

end of thread, other threads:[~2023-08-18 12:57 UTC | newest]

Thread overview: 56+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-02 14:38 [XEN PATCH 00/11] xen: address MISRA C:2012 Rule 2.1 Nicola Vetrini
2023-08-02 14:38 ` [XEN PATCH 01/11] x86/efi: move variable declaration to " Nicola Vetrini
2023-08-03  2:08   ` Stefano Stabellini
2023-08-03  8:57     ` Jan Beulich
2023-08-04  7:12       ` Nicola Vetrini
2023-08-02 14:38 ` [XEN PATCH 02/11] x86: move declarations " Nicola Vetrini
2023-08-02 14:44   ` Andrew Cooper
2023-08-03  2:13   ` Stefano Stabellini
2023-08-03  9:01     ` Jan Beulich
2023-08-03 14:22       ` Nicola Vetrini
2023-08-03 19:23         ` Stefano Stabellini
2023-08-04  1:14           ` Stefano Stabellini
2023-08-04  7:06         ` Jan Beulich
2023-08-04  9:50           ` Nicola Vetrini
2023-08-04 20:26           ` Stefano Stabellini
2023-08-07  7:18             ` Jan Beulich
2023-08-03  9:05   ` Jan Beulich
2023-08-02 14:38 ` [XEN PATCH 03/11] x86/uaccess: " Nicola Vetrini
2023-08-03  2:14   ` Stefano Stabellini
2023-08-02 14:38 ` [XEN PATCH 04/11] x86emul: move variable definitions " Nicola Vetrini
2023-08-03  2:33   ` Stefano Stabellini
2023-08-03  9:09     ` Jan Beulich
2023-08-02 14:38 ` [XEN PATCH 05/11] drivers/pci: " Nicola Vetrini
2023-08-03  2:36   ` Stefano Stabellini
2023-08-02 14:38 ` [XEN PATCH 06/11] xen/ioreq: move variable declaration " Nicola Vetrini
2023-08-02 14:38 ` [XEN PATCH 07/11] xen: " Nicola Vetrini
2023-08-03  9:16   ` Jan Beulich
2023-08-03 23:50     ` Stefano Stabellini
2023-08-04  6:42       ` Jan Beulich
2023-08-08  9:03         ` Nicola Vetrini
2023-08-16 10:01           ` Nicola Vetrini
2023-08-16 10:31             ` Jan Beulich
2023-08-16 10:47               ` Nicola Vetrini
2023-08-16 11:23                 ` Jan Beulich
2023-08-16 13:43                   ` Nicola Vetrini
2023-08-16 15:00                     ` Jan Beulich
2023-08-16 19:28                   ` Stefano Stabellini
2023-08-18 12:57                     ` Nicola Vetrini
2023-08-02 14:38 ` [XEN PATCH 08/11] xen: move declarations to " Nicola Vetrini
2023-08-02 14:38 ` [XEN PATCH 09/11] x86/xstate: moved BUILD_BUG_ON " Nicola Vetrini
2023-08-02 14:38 ` [XEN PATCH 10/11] xen/sched: add ASSERT_UNREACHABLE() " Nicola Vetrini
2023-08-03  9:17   ` Jan Beulich
2023-08-07  8:13     ` Nicola Vetrini
2023-08-07  8:50       ` Jan Beulich
2023-08-08 15:25   ` Julien Grall
2023-08-08 15:36     ` Jan Beulich
2023-08-08 15:44       ` Julien Grall
2023-08-08 15:53         ` Nicola Vetrini
2023-08-08 15:57           ` Julien Grall
2023-08-08 21:14             ` Stefano Stabellini
2023-08-09  6:01               ` Jan Beulich
2023-08-11 18:41               ` Julien Grall
2023-08-02 14:38 ` [XEN PATCH 11/11] x86/mm: Add assertion " Nicola Vetrini
2023-08-03  9:20   ` Jan Beulich
2023-08-03  9:30     ` Nicola Vetrini
2023-08-03 15:41       ` Jan Beulich

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.