mbox series

[RFC,0/4] address violations of MISRA C Rule 9.3

Message ID cover.1698155925.git.nicola.vetrini@bugseng.com (mailing list archive)
Headers show
Series address violations of MISRA C Rule 9.3 | expand

Message

Nicola Vetrini Oct. 24, 2023, 2:31 p.m. UTC
This series addresses some of the violations of Rule 9.3, which is about
partially initialized arrays. The resolution strategy proposed in these patches
uses designated initializers, except in patch 4, allowed by MISRA for
sparse initialization. The reason why I chose this method is that, given that
most of the violations are about the 'matches' field of struct
'struct dmi_system_id', which is a sized array of structs:

struct dmi_strmatch matches[4];

Since the initialization is already partially implicit, using designated
initalizers is convenient because, if the lenght of the matches array changes,
no adjustment is needed

Another, stricter, resolution strategy is the following:

             .matches  = {
                 DMI_MATCH(DMI_BOARD_VENDOR, "Quanta"),
-                DMI_MATCH(DMI_BOARD_NAME,   "30B7"),
+                DMI_MATCH(DMI_BOARD_NAME,   "30B7"),
+                {}, {}
             }

Note that Rule 9.3 is not about array elements that may be uninitialized, but
the fact of having some explicitly initialized elements and some implicitly
initialized elements.

Nicola Vetrini (4):
  x86/ioemul: address MISRA C:2012 Rule 9.3
  x86/shutdown: address MISRA C:2012 Rule 9.3
  x86/hvm: quirks: address MISRA C:2012 Rule 9.3
  amd/iommu: fully initialize array in 'flush_command_buffer'

 xen/arch/x86/hvm/quirks.c               |  20 ++--
 xen/arch/x86/ioport_emulate.c           |  32 ++---
 xen/arch/x86/shutdown.c                 | 152 ++++++++++++------------
 xen/drivers/passthrough/amd/iommu_cmd.c |   3 +-
 4 files changed, 104 insertions(+), 103 deletions(-)

--
2.34.1