Skip to content

RFC address violations of MISRA C Rule 9.3

Nicola Vetrini xen-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest4 patches 13 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4x86/ioemul: address MISRA C:2012 Rule 9.3xen/arch/x86/ioport_emulate.c+16 -1610 replies
2/4x86/shutdown: address MISRA C:2012 Rule 9.3xen/arch/x86/shutdown.c+76 -762 replies
3/4x86/hvm: quirks: address MISRA C:2012 Rule 9.3xen/arch/x86/hvm/quirks.c+10 -100 replies
4/4amd/iommu: fully initialize array in 'flush_command_buffer'xen/drivers/passthrough/amd/iommu_cmd.c+2 -11 reply

Reviews trailers per patch

1 of 4 patches has a Reviewed-by or Acked-by.

PatchJan Beulich
1/4
2/4
3/4
4/4A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

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

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