address violations of MISRA C Rule 9.3
RFC 1/4 x86/ioemul: address MISRA C:2012 Rule 9.3
In reply to Nicola VetriniPartially explicitly initalized .matches arrays result in violations of Rule 9.3; this is resolved by using designated initializers, which is permitted by the Rule.
Mechanical changes.
--- xen/arch/x86/ioport_emulate.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-)
xen/arch/x86/ioport_emulate.c +16 -16
@@ -44,57 +44,57 @@ static const struct dmi_system_id __initconstrel ioport_quirks_tbl[] = { { .ident = "HP ProLiant DL3xx", .matches = { - DMI_MATCH(DMI_BIOS_VENDOR, "HP"), - DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL3"), + [0] = DMI_MATCH(DMI_BIOS_VENDOR, "HP"), + [1] = DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL3"), }, }, { .ident = "HP ProLiant DL5xx", .matches = { - DMI_MATCH(DMI_BIOS_VENDOR, "HP"), - DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL5"), + [0] = DMI_MATCH(DMI_BIOS_VENDOR, "HP"), + [1] = DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL5"), }, }, { .ident = "HP ProLiant DL7xx", .matches = { - DMI_MATCH(DMI_BIOS_VENDOR, "HP"), - DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL7"), + [0] = DMI_MATCH(DMI_BIOS_VENDOR, "HP"), + [1] = DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL7"), }, }, { .ident = "HP ProLiant ML3xx", .matches = { - DMI_MATCH(DMI_BIOS_VENDOR, "HP"), - DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant ML3"), + [0] = DMI_MATCH(DMI_BIOS_VENDOR, "HP"), + [1] = DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant ML3"), }, }, { .ident = "HP ProLiant ML5xx", .matches = { - DMI_MATCH(DMI_BIOS_VENDOR, "HP"), - DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant ML5"), + [0] = DMI_MATCH(DMI_BIOS_VENDOR, "HP"), + [1] = DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant ML5"), }, }, { .ident = "HP ProLiant BL2xx", .matches = { - DMI_MATCH(DMI_BIOS_VENDOR, "HP"), - DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL2"), + [0] = DMI_MATCH(DMI_BIOS_VENDOR, "HP"), + [1] = DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL2"), }, }, { .ident = "HP ProLiant BL4xx", .matches = { - DMI_MATCH(DMI_BIOS_VENDOR, "HP"), - DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL4"), + [0] = DMI_MATCH(DMI_BIOS_VENDOR, "HP"), + [1] = DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL4"), }, }, { .ident = "HP ProLiant BL6xx", .matches = { - DMI_MATCH(DMI_BIOS_VENDOR, "HP"), - DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL6"), + [0] = DMI_MATCH(DMI_BIOS_VENDOR, "HP"), + [1] = DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL6"), }, }, { }
--
2.34.1
RFC 3/4 x86/hvm: quirks: address MISRA C:2012 Rule 9.3
In reply to Nicola VetriniPartially explicitly initalized .matches arrays result in violations of Rule 9.3; this is resolved by using designated initializers, which is permitted by the Rule.
Mechanical changes.
--- xen/arch/x86/hvm/quirks.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
xen/arch/x86/hvm/quirks.c +10 -10
@@ -37,40 +37,40 @@ static int __init cf_check check_port80(void) .callback = dmi_hvm_deny_port80, .ident = "Compaq Presario V6000", .matches = { -DMI_MATCH (DMI_BOARD_VENDOR ,"Quanta" ), - DMI_MATCH(DMI_BOARD_NAME, "30B7") + [0] = DMI_MATCH(DMI_BOARD_VENDOR, "Quanta"), + [1] = DMI_MATCH(DMI_BOARD_NAME, "30B7") } }, { .callback = dmi_hvm_deny_port80, .ident = "HP Pavilion dv9000z", .matches = { -DMI_MATCH (DMI_BOARD_VENDOR ,"Quanta" ), - DMI_MATCH(DMI_BOARD_NAME, "30B9") + [0] = DMI_MATCH(DMI_BOARD_VENDOR, "Quanta"), + [1] = DMI_MATCH(DMI_BOARD_NAME, "30B9") } }, { .callback = dmi_hvm_deny_port80, .ident = "HP Pavilion dv6000", .matches = { -DMI_MATCH (DMI_BOARD_VENDOR ,"Quanta" ), - DMI_MATCH(DMI_BOARD_NAME, "30B8") + [0] = DMI_MATCH(DMI_BOARD_VENDOR, "Quanta"), + [1] = DMI_MATCH(DMI_BOARD_NAME, "30B8") } }, { .callback = dmi_hvm_deny_port80, .ident = "HP Pavilion tx1000", .matches = { -DMI_MATCH (DMI_BOARD_VENDOR ,"Quanta" ), - DMI_MATCH(DMI_BOARD_NAME, "30BF") + [0] = DMI_MATCH(DMI_BOARD_VENDOR, "Quanta"), + [1] = DMI_MATCH(DMI_BOARD_NAME, "30BF") } }, { .callback = dmi_hvm_deny_port80, .ident = "Presario F700", .matches = { -DMI_MATCH (DMI_BOARD_VENDOR ,"Quanta" ), - DMI_MATCH(DMI_BOARD_NAME, "30D3") + [0] = DMI_MATCH(DMI_BOARD_VENDOR, "Quanta"), + [1] = DMI_MATCH(DMI_BOARD_NAME, "30D3") } }, { }
Signature · 1 line
2.34.1
cover 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
RFC 2/4 x86/shutdown: address MISRA C:2012 Rule 9.3
Partially explicitly initalized .matches arrays result in violations of Rule 9.3; this is resolved by using designated initializers, which is permitted by the Rule.
Mechanical changes.
--- xen/arch/x86/shutdown.c | 152 ++++++++++++++++++++-------------------- 1 file changed, 76 insertions(+), 76 deletions(-)
xen/arch/x86/shutdown.c +76 -76
@@ -188,8 +188,8 @@ static const struct dmi_system_id __initconstrel reboot_dmi_table[] = { .driver_data = (void *)(long)BOOT_KBD, .ident = "Dell E520", .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"Dell Inc." ), - DMI_MATCH(DMI_PRODUCT_NAME, "Dell DM061"), + [0] = DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + [1 ] =DMI_MATCH (DMI_PRODUCT_NAME ,"Dell DM061" ) }, }, { /* Handle problems with rebooting on Dell 1300's */
@@ -197,8 +197,8 @@ static const struct dmi_system_id __initconstrel reboot_dmi_table[] = { .driver_data = (void *)(long)BOOT_KBD, .ident = "Dell PowerEdge 1300", .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"Dell Computer Corporation" ), - DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 1300/"), + [0] = DMI_MATCH(DMI_SYS_VENDOR, "Dell Computer Corporation"), + [1 ] =DMI_MATCH (DMI_PRODUCT_NAME ,"PowerEdge 1300/" ) }, }, { /* Handle problems with rebooting on Dell 300's */
@@ -206,8 +206,8 @@ static const struct dmi_system_id __initconstrel reboot_dmi_table[] = { .driver_data = (void *)(long)BOOT_KBD, .ident = "Dell PowerEdge 300", .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"Dell Computer Corporation" ), - DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 300/"), + [0] = DMI_MATCH(DMI_SYS_VENDOR, "Dell Computer Corporation"), + [1 ] =DMI_MATCH (DMI_PRODUCT_NAME ,"PowerEdge 300/" ) }, }, { /* Handle problems with rebooting on Dell Optiplex 745's SFF */
@@ -215,8 +215,8 @@ static const struct dmi_system_id __initconstrel reboot_dmi_table[] = { .driver_data = (void *)(long)BOOT_KBD, .ident = "Dell OptiPlex 745", .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"Dell Inc." ), - DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 745"), + [0] = DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + [1 ] =DMI_MATCH (DMI_PRODUCT_NAME ,"OptiPlex 745" ) }, }, { /* Handle problems with rebooting on Dell Optiplex 745's DFF */
@@ -225,8 +225,8 @@ static const struct dmi_system_id __initconstrel reboot_dmi_table[] = { .ident = "Dell OptiPlex 745", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), -DMI_MATCH (DMI_PRODUCT_NAME ,"OptiPlex 745" ), - DMI_MATCH(DMI_BOARD_NAME, "0MM599"), + [0] = DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 745"), + [1 ] =DMI_MATCH (DMI_BOARD_NAME ,"0MM599" ) }, }, { /* Handle problems with rebooting on Dell Optiplex 745 with 0KW626 */
@@ -235,8 +235,8 @@ static const struct dmi_system_id __initconstrel reboot_dmi_table[] = { .ident = "Dell OptiPlex 745", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), -DMI_MATCH (DMI_PRODUCT_NAME ,"OptiPlex 745" ), - DMI_MATCH(DMI_BOARD_NAME, "0KW626"), + [0] = DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 745"), + [1 ] =DMI_MATCH (DMI_BOARD_NAME ,"0KW626" ) }, }, { /* Handle problems with rebooting on Dell Optiplex 330 with 0KP561 */
@@ -245,8 +245,8 @@ static const struct dmi_system_id __initconstrel reboot_dmi_table[] = { .ident = "Dell OptiPlex 330", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), -DMI_MATCH (DMI_PRODUCT_NAME ,"OptiPlex 330" ), - DMI_MATCH(DMI_BOARD_NAME, "0KP561"), + [0] = DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 330"), + [1 ] =DMI_MATCH (DMI_BOARD_NAME ,"0KP561" ) }, }, { /* Handle problems with rebooting on Dell Optiplex 360 with 0T656F */
@@ -255,8 +255,8 @@ static const struct dmi_system_id __initconstrel reboot_dmi_table[] = { .ident = "Dell OptiPlex 360", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), -DMI_MATCH (DMI_PRODUCT_NAME ,"OptiPlex 360" ), - DMI_MATCH(DMI_BOARD_NAME, "0T656F"), + [0] = DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 360"), + [1 ] =DMI_MATCH (DMI_BOARD_NAME ,"0T656F" ) }, }, { /* Handle problems with rebooting on Dell OptiPlex 760 with 0G919G */
@@ -265,8 +265,8 @@ static const struct dmi_system_id __initconstrel reboot_dmi_table[] = { .ident = "Dell OptiPlex 760", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), -DMI_MATCH (DMI_PRODUCT_NAME ,"OptiPlex 760" ), - DMI_MATCH(DMI_BOARD_NAME, "0G919G"), + [0] = DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 760"), + [1 ] =DMI_MATCH (DMI_BOARD_NAME ,"0G919G" ) }, }, { /* Handle problems with rebooting on Dell 2400's */
@@ -274,8 +274,8 @@ static const struct dmi_system_id __initconstrel reboot_dmi_table[] = { .driver_data = (void *)(long)BOOT_KBD, .ident = "Dell PowerEdge 2400", .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"Dell Computer Corporation" ), - DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 2400"), + [0] = DMI_MATCH(DMI_SYS_VENDOR, "Dell Computer Corporation"), + [1 ] =DMI_MATCH (DMI_PRODUCT_NAME ,"PowerEdge 2400" ) }, }, { /* Handle problems with rebooting on Dell T5400's */
@@ -283,8 +283,8 @@ static const struct dmi_system_id __initconstrel reboot_dmi_table[] = { .driver_data = (void *)(long)BOOT_KBD, .ident = "Dell Precision T5400", .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"Dell Inc." ), - DMI_MATCH(DMI_PRODUCT_NAME, "Precision WorkStation T5400"), + [0] = DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + [1 ] =DMI_MATCH (DMI_PRODUCT_NAME ,"Precision WorkStation T5400" ) }, }, { /* Handle problems with rebooting on Dell T7400's */
@@ -292,8 +292,8 @@ static const struct dmi_system_id __initconstrel reboot_dmi_table[] = { .driver_data = (void *)(long)BOOT_KBD, .ident = "Dell Precision T7400", .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"Dell Inc." ), - DMI_MATCH(DMI_PRODUCT_NAME, "Precision WorkStation T7400"), + [0] = DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + [1 ] =DMI_MATCH (DMI_PRODUCT_NAME ,"Precision WorkStation T7400" ) }, }, { /* Handle problems with rebooting on HP laptops */
@@ -301,8 +301,8 @@ static const struct dmi_system_id __initconstrel reboot_dmi_table[] = { .driver_data = (void *)(long)BOOT_KBD, .ident = "HP Compaq Laptop", .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"Hewlett-Packard" ), - DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq"), + [0] = DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), + [1 ] =DMI_MATCH (DMI_PRODUCT_NAME ,"HP Compaq" ) }, }, { /* Handle problems with rebooting on Dell XPS710 */
@@ -310,8 +310,8 @@ static const struct dmi_system_id __initconstrel reboot_dmi_table[] = { .driver_data = (void *)(long)BOOT_KBD, .ident = "Dell XPS710", .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"Dell Inc." ), - DMI_MATCH(DMI_PRODUCT_NAME, "Dell XPS710"), + [0] = DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + [1 ] =DMI_MATCH (DMI_PRODUCT_NAME ,"Dell XPS710" ) }, }, { /* Handle problems with rebooting on Dell DXP061 */
@@ -319,8 +319,8 @@ static const struct dmi_system_id __initconstrel reboot_dmi_table[] = { .driver_data = (void *)(long)BOOT_KBD, .ident = "Dell DXP061", .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"Dell Inc." ), - DMI_MATCH(DMI_PRODUCT_NAME, "Dell DXP061"), + [0] = DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + [1 ] =DMI_MATCH (DMI_PRODUCT_NAME ,"Dell DXP061" ) }, }, { /* Handle problems with rebooting on Sony VGN-Z540N */
@@ -328,8 +328,8 @@ static const struct dmi_system_id __initconstrel reboot_dmi_table[] = { .driver_data = (void *)(long)BOOT_KBD, .ident = "Sony VGN-Z540N", .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"Sony Corporation" ), - DMI_MATCH(DMI_PRODUCT_NAME, "VGN-Z540N"), + [0] = DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"), + [1 ] =DMI_MATCH (DMI_PRODUCT_NAME ,"VGN-Z540N" ) }, }, { /* Handle problems with rebooting on ASUS P4S800 */
@@ -337,8 +337,8 @@ static const struct dmi_system_id __initconstrel reboot_dmi_table[] = { .driver_data = (void *)(long)BOOT_KBD, .ident = "ASUS P4S800", .matches = { -DMI_MATCH (DMI_BOARD_VENDOR ,"ASUSTeK Computer INC." ), - DMI_MATCH(DMI_BOARD_NAME, "P4S800"), + [0] = DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."), + [1 ] =DMI_MATCH (DMI_BOARD_NAME ,"P4S800" ) }, }, { /* Handle reboot issue on Acer Aspire one */
@@ -346,8 +346,8 @@ static const struct dmi_system_id __initconstrel reboot_dmi_table[] = { .driver_data = (void *)(long)BOOT_KBD, .ident = "Acer Aspire One A110", .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"Acer" ), - DMI_MATCH(DMI_PRODUCT_NAME, "AOA110"), + [0] = DMI_MATCH(DMI_SYS_VENDOR, "Acer"), + [1 ] =DMI_MATCH (DMI_PRODUCT_NAME ,"AOA110" ) }, }, { /* Handle problems with rebooting on Apple MacBook5 */
@@ -355,8 +355,8 @@ static const struct dmi_system_id __initconstrel reboot_dmi_table[] = { .driver_data = (void *)(long)BOOT_CF9, .ident = "Apple MacBook5", .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"Apple Inc." ), - DMI_MATCH(DMI_PRODUCT_NAME, "MacBook5"), + [0] = DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."), + [1 ] =DMI_MATCH (DMI_PRODUCT_NAME ,"MacBook5" ) }, }, { /* Handle problems with rebooting on Apple MacBookPro5 */
@@ -364,8 +364,8 @@ static const struct dmi_system_id __initconstrel reboot_dmi_table[] = { .driver_data = (void *)(long)BOOT_CF9, .ident = "Apple MacBookPro5", .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"Apple Inc." ), - DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro5"), + [0] = DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."), + [1 ] =DMI_MATCH (DMI_PRODUCT_NAME ,"MacBookPro5" ) }, }, { /* Handle problems with rebooting on Apple Macmini3,1 */
@@ -373,8 +373,8 @@ static const struct dmi_system_id __initconstrel reboot_dmi_table[] = { .driver_data = (void *)(long)BOOT_CF9, .ident = "Apple Macmini3,1", .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"Apple Inc." ), - DMI_MATCH(DMI_PRODUCT_NAME, "Macmini3,1"), + [0] = DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."), + [1 ] =DMI_MATCH (DMI_PRODUCT_NAME ,"Macmini3,1" ) }, }, { /* Handle problems with rebooting on the iMac9,1. */
@@ -382,8 +382,8 @@ static const struct dmi_system_id __initconstrel reboot_dmi_table[] = { .driver_data = (void *)(long)BOOT_CF9, .ident = "Apple iMac9,1", .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"Apple Inc." ), - DMI_MATCH(DMI_PRODUCT_NAME, "iMac9,1"), + [0] = DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."), + [1 ] =DMI_MATCH (DMI_PRODUCT_NAME ,"iMac9,1" ) }, }, { /* Handle problems with rebooting on the Latitude E6320. */
@@ -391,8 +391,8 @@ static const struct dmi_system_id __initconstrel reboot_dmi_table[] = { .driver_data = (void *)(long)BOOT_CF9, .ident = "Dell Latitude E6320", .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"Dell Inc." ), - DMI_MATCH(DMI_PRODUCT_NAME, "Latitude E6320"), + [0] = DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + [1 ] =DMI_MATCH (DMI_PRODUCT_NAME ,"Latitude E6320" ) }, }, { /* Handle problems with rebooting on the Latitude E5420. */
@@ -400,8 +400,8 @@ static const struct dmi_system_id __initconstrel reboot_dmi_table[] = { .driver_data = (void *)(long)BOOT_CF9, .ident = "Dell Latitude E5420", .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"Dell Inc." ), - DMI_MATCH(DMI_PRODUCT_NAME, "Latitude E5420"), + [0] = DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + [1 ] =DMI_MATCH (DMI_PRODUCT_NAME ,"Latitude E5420" ) }, }, { /* Handle problems with rebooting on the Latitude E6220. */
@@ -409,8 +409,8 @@ static const struct dmi_system_id __initconstrel reboot_dmi_table[] = { .driver_data = (void *)(long)BOOT_CF9, .ident = "Dell Latitude E6220", .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"Dell Inc." ), - DMI_MATCH(DMI_PRODUCT_NAME, "Latitude E6220"), + [0] = DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + [1 ] =DMI_MATCH (DMI_PRODUCT_NAME ,"Latitude E6220" ) }, }, { /* Handle problems with rebooting on the Latitude E6420. */
@@ -418,8 +418,8 @@ static const struct dmi_system_id __initconstrel reboot_dmi_table[] = { .driver_data = (void *)(long)BOOT_CF9, .ident = "Dell Latitude E6420", .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"Dell Inc." ), - DMI_MATCH(DMI_PRODUCT_NAME, "Latitude E6420"), + [0] = DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + [1 ] =DMI_MATCH (DMI_PRODUCT_NAME ,"Latitude E6420" ) }, }, { /* Handle problems with rebooting on the OptiPlex 990. */
@@ -427,8 +427,8 @@ static const struct dmi_system_id __initconstrel reboot_dmi_table[] = { .driver_data = (void *)(long)BOOT_CF9, .ident = "Dell OptiPlex 990", .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"Dell Inc." ), - DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 990"), + [0] = DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + [1 ] =DMI_MATCH (DMI_PRODUCT_NAME ,"OptiPlex 990" ) }, }, { /* Handle problems with rebooting on the Precision M6600. */
@@ -436,8 +436,8 @@ static const struct dmi_system_id __initconstrel reboot_dmi_table[] = { .driver_data = (void *)(long)BOOT_CF9, .ident = "Dell OptiPlex 990", .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"Dell Inc." ), - DMI_MATCH(DMI_PRODUCT_NAME, "Precision M6600"), + [0] = DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + [1 ] =DMI_MATCH (DMI_PRODUCT_NAME ,"Precision M6600" ) }, }, { /* Handle problems with rebooting on the Latitude E6520. */
@@ -445,8 +445,8 @@ static const struct dmi_system_id __initconstrel reboot_dmi_table[] = { .driver_data = (void *)(long)BOOT_CF9, .ident = "Dell Latitude E6520", .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"Dell Inc." ), - DMI_MATCH(DMI_PRODUCT_NAME, "Latitude E6520"), + [0] = DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + [1 ] =DMI_MATCH (DMI_PRODUCT_NAME ,"Latitude E6520" ) }, }, { /* Handle problems with rebooting on the OptiPlex 790. */
@@ -454,8 +454,8 @@ static const struct dmi_system_id __initconstrel reboot_dmi_table[] = { .driver_data = (void *)(long)BOOT_CF9, .ident = "Dell OptiPlex 790", .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"Dell Inc." ), - DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 790"), + [0] = DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + [1 ] =DMI_MATCH (DMI_PRODUCT_NAME ,"OptiPlex 790" ) }, }, { /* Handle problems with rebooting on the OptiPlex 990. */
@@ -463,8 +463,8 @@ static const struct dmi_system_id __initconstrel reboot_dmi_table[] = { .driver_data = (void *)(long)BOOT_CF9, .ident = "Dell OptiPlex 990", .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"Dell Inc." ), - DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 990"), + [0] = DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + [1 ] =DMI_MATCH (DMI_PRODUCT_NAME ,"OptiPlex 990" ) }, }, { /* Handle problems with rebooting on the OptiPlex 390. */
@@ -472,8 +472,8 @@ static const struct dmi_system_id __initconstrel reboot_dmi_table[] = { .driver_data = (void *)(long)BOOT_CF9, .ident = "Dell OptiPlex 390", .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"Dell Inc." ), - DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 390"), + [0] = DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + [1 ] =DMI_MATCH (DMI_PRODUCT_NAME ,"OptiPlex 390" ) }, }, { /* Handle problems with rebooting on Dell OptiPlex 9020. */
@@ -481,8 +481,8 @@ static const struct dmi_system_id __initconstrel reboot_dmi_table[] = { .driver_data = (void *)(long)BOOT_ACPI, .ident = "Dell OptiPlex 9020", .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"Dell Inc." ), - DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 9020"), + [0] = DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + [1 ] =DMI_MATCH (DMI_PRODUCT_NAME ,"OptiPlex 9020" ) }, }, { /* Handle problems with rebooting on the Latitude E6320. */
@@ -490,8 +490,8 @@ static const struct dmi_system_id __initconstrel reboot_dmi_table[] = { .driver_data = (void *)(long)BOOT_CF9, .ident = "Dell Latitude E6320", .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"Dell Inc." ), - DMI_MATCH(DMI_PRODUCT_NAME, "Latitude E6320"), + [0] = DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + [1 ] =DMI_MATCH (DMI_PRODUCT_NAME ,"Latitude E6320" ) }, }, { /* Handle problems with rebooting on the Latitude E6420. */
@@ -499,8 +499,8 @@ static const struct dmi_system_id __initconstrel reboot_dmi_table[] = { .driver_data = (void *)(long)BOOT_CF9, .ident = "Dell Latitude E6420", .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"Dell Inc." ), - DMI_MATCH(DMI_PRODUCT_NAME, "Latitude E6420"), + [0] = DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + [1 ] =DMI_MATCH (DMI_PRODUCT_NAME ,"Latitude E6420" ) }, }, { /* Handle problems with rebooting on the Latitude E6520. */
@@ -508,8 +508,8 @@ static const struct dmi_system_id __initconstrel reboot_dmi_table[] = { .driver_data = (void *)(long)BOOT_CF9, .ident = "Dell Latitude E6520", .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"Dell Inc." ), - DMI_MATCH(DMI_PRODUCT_NAME, "Latitude E6520"), + [0] = DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + [1 ] =DMI_MATCH (DMI_PRODUCT_NAME ,"Latitude E6520" ) }, }, { /* Handle problems with rebooting on Dell PowerEdge R540. */
@@ -517,8 +517,8 @@ static const struct dmi_system_id __initconstrel reboot_dmi_table[] = { .driver_data = (void *)(long)BOOT_ACPI, .ident = "Dell PowerEdge R540", .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"Dell Inc." ), - DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge R540"), + [0] = DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + [1 ] =DMI_MATCH (DMI_PRODUCT_NAME ,"PowerEdge R540" ) }, }, { /* Handle problems with rebooting on Dell PowerEdge R740. */
@@ -526,8 +526,8 @@ static const struct dmi_system_id __initconstrel reboot_dmi_table[] = { .driver_data = (void *)(long)BOOT_ACPI, .ident = "Dell PowerEdge R740", .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"Dell Inc." ), - DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge R740"), + [0] = DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + [1] = DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge R740") }, }, { }
--
2.34.1
RFC 4/4 amd/iommu: fully initialize array in 'flush_command_buffer'
In reply to Nicola VetriniFully explicit initialization of the cmd array resolves a violation of MISRA C:2012 Rule 9.3.
--- xen/drivers/passthrough/amd/iommu_cmd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
xen/drivers/passthrough/amd/iommu_cmd.c +2 -1
@@ -66,7 +66,8 @@ static void flush_command_buffer(struct amd_iommu *iommu, IOMMU_COMP_WAIT_S_FLAG_MASK), (addr >>32 ) |MASK_INSR (IOMMU_CMD_COMPLETION_WAIT ,IOMMU_CMD_OPCODE_MASK ), - CMD_COMPLETION_DONE +CMD_COMPLETION_DONE , + 0 };s_time_t start, timeout;static unsigned int __read_mostly threshold =1 ;
--
2.34.1
Re: [RFC 1/4] x86/ioemul: address MISRA C:2012 Rule 9.3
In reply to Nicola VetriniQuoted 7 lines · Nicola Vetrini
Partially explicitly initalized .matches arrays result in violations of Rule 9.3; this is resolved by using designated initializers, which is permitted by the Rule.
Mechanical changes.
Signed-off-by Nicola Vetrini <[email protected]>
While not overly bad, I'm still not really seeing the improvement. Yet aiui changes induced by Misra are supposed to improve things in some direction?
Jan
Quoted 78 lines
xen/arch/x86/ioport_emulate.c +16
-17@@ -44,57 +44,57 @@ static const struct dmi_system_id __initconstrel ioport_quirks_tbl[] = { { .ident = "HP ProLiant DL3xx", .matches = { - DMI_MATCH(DMI_BIOS_VENDOR, "HP"), - DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL3"), + [0] = DMI_MATCH(DMI_BIOS_VENDOR, "HP"), + [1] = DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL3"), }, }, { .ident = "HP ProLiant DL5xx", .matches = { - DMI_MATCH(DMI_BIOS_VENDOR, "HP"), - DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL5"), + [0] = DMI_MATCH(DMI_BIOS_VENDOR, "HP"), + [1] = DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL5"), }, }, { .ident = "HP ProLiant DL7xx", .matches = { - DMI_MATCH(DMI_BIOS_VENDOR, "HP"), - DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL7"), + [0] = DMI_MATCH(DMI_BIOS_VENDOR, "HP"), + [1] = DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL7"), }, }, { .ident = "HP ProLiant ML3xx", .matches = { - DMI_MATCH(DMI_BIOS_VENDOR, "HP"), - DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant ML3"), + [0] = DMI_MATCH(DMI_BIOS_VENDOR, "HP"), + [1] = DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant ML3"), }, }, { .ident = "HP ProLiant ML5xx", .matches = { - DMI_MATCH(DMI_BIOS_VENDOR, "HP"), - DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant ML5"), + [0] = DMI_MATCH(DMI_BIOS_VENDOR, "HP"), + [1] = DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant ML5"), }, }, { .ident = "HP ProLiant BL2xx", .matches = { - DMI_MATCH(DMI_BIOS_VENDOR, "HP"), - DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL2"), + [0] = DMI_MATCH(DMI_BIOS_VENDOR, "HP"), + [1] = DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL2"), }, }, { .ident = "HP ProLiant BL4xx", .matches = { - DMI_MATCH(DMI_BIOS_VENDOR, "HP"), - DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL4"), + [0] = DMI_MATCH(DMI_BIOS_VENDOR, "HP"), + [1] = DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL4"), }, }, { .ident = "HP ProLiant BL6xx", .matches = { - DMI_MATCH(DMI_BIOS_VENDOR, "HP"), - DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL6"), + [0] = DMI_MATCH(DMI_BIOS_VENDOR, "HP"), + [1] = DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL6"), }, }, { } --2.34.1
Re: [RFC 4/4] amd/iommu: fully initialize array in 'flush_command_buffer'
In reply to Nicola VetriniQuoted 4 lines · Nicola Vetrini
Fully explicit initialization of the cmd array resolves a violation of MISRA C:2012 Rule 9.3.
Signed-off-by Nicola Vetrini <[email protected]>
While I'm not overly happy, we accepted the rule, so
Re: [RFC 2/4] x86/shutdown: address MISRA C:2012 Rule 9.3
In reply to Nicola VetriniQuoted 45 lines · Nicola Vetrini
xen/arch/x86/shutdown.c +8
-8@@ -225,8 +225,8 @@ static const struct dmi_system_id __initconstrel reboot_dmi_table[] = { .ident = "Dell OptiPlex 745", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), -DMI_MATCH (DMI_PRODUCT_NAME ,"OptiPlex 745" ), - DMI_MATCH(DMI_BOARD_NAME, "0MM599"), + [0] = DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 745"), + [1 ] =DMI_MATCH (DMI_BOARD_NAME ,"0MM599" ) }, }, { /* Handle problems with rebooting on Dell Optiplex 745 with 0KW626 */@@ -235,8 +235,8 @@ static const struct dmi_system_id __initconstrel reboot_dmi_table[] = { .ident = "Dell OptiPlex 745", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), -DMI_MATCH (DMI_PRODUCT_NAME ,"OptiPlex 745" ), - DMI_MATCH(DMI_BOARD_NAME, "0KW626"), + [0] = DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 745"), + [1 ] =DMI_MATCH (DMI_BOARD_NAME ,"0KW626" ) }, }, { /* Handle problems with rebooting on Dell Optiplex 330 with 0KP561 */@@ -245,8 +245,8 @@ static const struct dmi_system_id __initconstrel reboot_dmi_table[] = { .ident = "Dell OptiPlex 330", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), -DMI_MATCH (DMI_PRODUCT_NAME ,"OptiPlex 330" ), - DMI_MATCH(DMI_BOARD_NAME, "0KP561"), + [0] = DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 330"), + [1 ] =DMI_MATCH (DMI_BOARD_NAME ,"0KP561" ) }, }, { /* Handle problems with rebooting on Dell Optiplex 360 with 0T656F */@@ -255,8 +255,8 @@ static const struct dmi_system_id __initconstrel reboot_dmi_table[] = { .ident = "Dell OptiPlex 360", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), -DMI_MATCH (DMI_PRODUCT_NAME ,"OptiPlex 360" ), - DMI_MATCH(DMI_BOARD_NAME, "0T656F"), + [0] = DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 360"), + [1 ] =DMI_MATCH (DMI_BOARD_NAME ,"0T656F" ) }, }, { /* Handle problems with rebooting on Dell OptiPlex 760 with 0G919G */
xen/arch/x86/shutdown.c static const struct dmi_system_id __initconstrel reboot_dmi_table[] = { · line 272
Quoted 10 lines
xen/arch/x86/shutdown.c +2
-2@@ -265,8 +265,8 @@ static const struct dmi_system_id __initconstrel reboot_dmi_table[] = { .ident = "Dell OptiPlex 760", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), -DMI_MATCH (DMI_PRODUCT_NAME ,"OptiPlex 760" ), - DMI_MATCH(DMI_BOARD_NAME, "0G919G"), + [0] = DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 760"), + [1 ] =DMI_MATCH (DMI_BOARD_NAME ,"0G919G" ) }, }, { /* Handle problems with rebooting on Dell 2400's */
Well, no, this is what absolutely should not happen: You're breaking the code here, but initializing slot 0 twice in multiple instances. From looking just at the patch I probably wouldn't have noticed, but the "always elements 0 and 1 only" pattern made me "grep -lr", where the issue became apparent. Otherwise I was about to suggest we shrink array size to just 2 elements.
Jan
Re: [RFC 2/4] x86/shutdown: address MISRA C:2012 Rule 9.3
Quoted 73 lines · Jan Beulich
Quoted 63 lines · Nicola Vetrini
xen/arch/x86/shutdown.c +2
-2@@ -225,8 +225,8 @@ static const struct dmi_system_id __initconstrel reboot_dmi_table[] = { .ident = "Dell OptiPlex 745", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), - DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 745"), - DMI_MATCH(DMI_BOARD_NAME, "0MM599"), + [0] = DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 745"), + [1 ] =DMI_MATCH (DMI_BOARD_NAME ,"0MM599" ) }, },{ /* Handle problems with rebooting on Dell Optiplex 745 with
0KW626 */xen/arch/x86/shutdown.c +2
-2@@ -235,8 +235,8 @@ static const struct dmi_system_id __initconstrel reboot_dmi_table[] = { .ident = "Dell OptiPlex 745", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), - DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 745"), - DMI_MATCH(DMI_BOARD_NAME, "0KW626"), + [0] = DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 745"), + [1 ] =DMI_MATCH (DMI_BOARD_NAME ,"0KW626" ) }, },{ /* Handle problems with rebooting on Dell Optiplex 330 with
0KP561 */xen/arch/x86/shutdown.c +2
-2@@ -245,8 +245,8 @@ static const struct dmi_system_id __initconstrel reboot_dmi_table[] = { .ident = "Dell OptiPlex 330", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), - DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 330"), - DMI_MATCH(DMI_BOARD_NAME, "0KP561"), + [0] = DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 330"), + [1 ] =DMI_MATCH (DMI_BOARD_NAME ,"0KP561" ) }, },{ /* Handle problems with rebooting on Dell Optiplex 360 with
0T656F */xen/arch/x86/shutdown.c +2
-2@@ -255,8 +255,8 @@ static const struct dmi_system_id __initconstrel reboot_dmi_table[] = { .ident = "Dell OptiPlex 360", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), - DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 360"), - DMI_MATCH(DMI_BOARD_NAME, "0T656F"), + [0] = DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 360"), + [1 ] =DMI_MATCH (DMI_BOARD_NAME ,"0T656F" ) }, },{ /* Handle problems with rebooting on Dell OptiPlex 760 with
0G919G */xen/arch/x86/shutdown.c +2
-2@@ -265,8 +265,8 @@ static const struct dmi_system_id __initconstrel reboot_dmi_table[] = { .ident = "Dell OptiPlex 760", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), - DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 760"), - DMI_MATCH(DMI_BOARD_NAME, "0G919G"), + [0] = DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 760"), + [1 ] =DMI_MATCH (DMI_BOARD_NAME ,"0G919G" ) }, },Quoted 1 line
{ /* Handle problems with rebooting on Dell 2400's */
Well, no, this is what absolutely should not happen: You're breaking the code here, but initializing slot 0 twice in multiple instances. From looking just at the patch I probably wouldn't have noticed, but the "always elements 0 and 1 only" pattern made me "grep -lr", where the issue became apparent. Otherwise I was about to suggest we shrink array size to just 2 elements.
Quoted 1 line
Jan
Right, that was a shortcoming of my regex.
Signature · 2 lines
Nicola Vetrini, BSc Software Engineer, BUGSENG srl (https://bugseng.com)
Re: [RFC 1/4] x86/ioemul: address MISRA C:2012 Rule 9.3
In reply to Jan BeulichQuoted 5 lines · Jan Beulich
Quoted 4 lines · Nicola Vetrini
Partially explicitly initalized .matches arrays result in violations of Rule 9.3; this is resolved by using designated initializers, which is permitted by the Rule.
Quoted 7 lines
Quoted 3 lines
Mechanical changes.
Signed-off-by Nicola Vetrini <[email protected]>While not overly bad, I'm still not really seeing the improvement. Yet aiui changes induced by Misra are supposed to improve things in some direction?
I think the improvement is clarity, in the sense that the designated initializers make it clearer that the array may be sparsely initialized and that the remaining elements should be initialized to zero automatically.
Quoted 79 lines
Quoted 78 lines
xen/arch/x86/ioport_emulate.c +16
-17@@ -44,57 +44,57 @@ static const struct dmi_system_id __initconstrel ioport_quirks_tbl[] = { { .ident = "HP ProLiant DL3xx", .matches = { - DMI_MATCH(DMI_BIOS_VENDOR, "HP"), - DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL3"), + [0] = DMI_MATCH(DMI_BIOS_VENDOR, "HP"), + [1] = DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL3"), }, }, { .ident = "HP ProLiant DL5xx", .matches = { - DMI_MATCH(DMI_BIOS_VENDOR, "HP"), - DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL5"), + [0] = DMI_MATCH(DMI_BIOS_VENDOR, "HP"), + [1] = DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL5"), }, }, { .ident = "HP ProLiant DL7xx", .matches = { - DMI_MATCH(DMI_BIOS_VENDOR, "HP"), - DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL7"), + [0] = DMI_MATCH(DMI_BIOS_VENDOR, "HP"), + [1] = DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL7"), }, }, { .ident = "HP ProLiant ML3xx", .matches = { - DMI_MATCH(DMI_BIOS_VENDOR, "HP"), - DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant ML3"), + [0] = DMI_MATCH(DMI_BIOS_VENDOR, "HP"), + [1] = DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant ML3"), }, }, { .ident = "HP ProLiant ML5xx", .matches = { - DMI_MATCH(DMI_BIOS_VENDOR, "HP"), - DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant ML5"), + [0] = DMI_MATCH(DMI_BIOS_VENDOR, "HP"), + [1] = DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant ML5"), }, }, { .ident = "HP ProLiant BL2xx", .matches = { - DMI_MATCH(DMI_BIOS_VENDOR, "HP"), - DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL2"), + [0] = DMI_MATCH(DMI_BIOS_VENDOR, "HP"), + [1] = DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL2"), }, }, { .ident = "HP ProLiant BL4xx", .matches = { - DMI_MATCH(DMI_BIOS_VENDOR, "HP"), - DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL4"), + [0] = DMI_MATCH(DMI_BIOS_VENDOR, "HP"), + [1] = DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL4"), }, }, { .ident = "HP ProLiant BL6xx", .matches = { - DMI_MATCH(DMI_BIOS_VENDOR, "HP"), - DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL6"), + [0] = DMI_MATCH(DMI_BIOS_VENDOR, "HP"), + [1] = DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL6"), }, }, { } --2.34.1
Re: [RFC 1/4] x86/ioemul: address MISRA C:2012 Rule 9.3
Quoted 10 lines · Stefano Stabellini
Quoted 9 lines · Jan Beulich
Quoted 7 lines · Nicola Vetrini
Partially explicitly initalized .matches arrays result in violations of Rule 9.3; this is resolved by using designated initializers, which is permitted by the Rule.
Mechanical changes.
Signed-off-by Nicola Vetrini <[email protected]>
Quoted 8 lines
Quoted 3 lines
While not overly bad, I'm still not really seeing the improvement. Yet aiui changes induced by Misra are supposed to improve things in some direction?
I think the improvement is clarity, in the sense that the designated initializers make it clearer that the array may be sparsely initialized and that the remaining elements should be initialized to zero automatically.
That's as clear from the original code, imo.
Jan
Re: [RFC 1/4] x86/ioemul: address MISRA C:2012 Rule 9.3
Quoted 15 lines · Jan Beulich
Quoted 14 lines · Stefano Stabellini
Quoted 12 lines · Jan Beulich
Quoted 7 lines · Nicola Vetrini
Partially explicitly initalized .matches arrays result in violations of Rule 9.3; this is resolved by using designated initializers, which is permitted by the Rule.
Mechanical changes.
Signed-off-by Nicola Vetrini <[email protected]>While not overly bad, I'm still not really seeing the improvement. Yet aiui changes induced by Misra are supposed to improve things in some direction?
Quoted 8 lines
Quoted 4 lines
I think the improvement is clarity, in the sense that the designated initializers make it clearer that the array may be sparsely initialized and that the remaining elements should be initialized to zero automatically.
That's as clear from the original code, imo.
Jan
There's also this functionally equivalent alternative, with or without the zeros, which doesn't incur in the risk of mistakenly attempting to initialize the same element twice, while also giving an explicit cue to the reader that all elements are truly zero-initialized.
.matches = {
DMI_MATCH(DMI_BIOS_VENDOR, "HP"),
DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL5"),
+ {0}, {0}
},Signature · 2 lines
Nicola Vetrini, BSc Software Engineer, BUGSENG srl (https://bugseng.com)
Re: [RFC 1/4] x86/ioemul: address MISRA C:2012 Rule 9.3
Quoted 31 lines · Nicola Vetrini
Quoted 15 lines · Jan Beulich
Quoted 14 lines · Stefano Stabellini
Quoted 12 lines · Jan Beulich
Quoted 7 lines · Nicola Vetrini
Partially explicitly initalized .matches arrays result in violations of Rule 9.3; this is resolved by using designated initializers, which is permitted by the Rule.
Mechanical changes.
Signed-off-by Nicola Vetrini <[email protected]>While not overly bad, I'm still not really seeing the improvement. Yet aiui changes induced by Misra are supposed to improve things in some direction?
Quoted 7 lines
Quoted 5 lines
I think the improvement is clarity, in the sense that the designated initializers make it clearer that the array may be sparsely initialized
and that the remaining elements should be initialized to zero automatically.That's as clear from the original code, imo.
There's also this functionally equivalent alternative, with or without the zeros, which
doesn't incur in the risk of mistakenly attempting to initialize the same element twice,
while also giving an explicit cue to the reader that all elements are truly zero-initialized.
Quoted 5 lines
.matches = {
DMI_MATCH(DMI_BIOS_VENDOR, "HP"),
DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL5"),
+ {0}, {0}
},Adding a dependency on the array actually having 4 elements (while iirc we have seen already that we could in principle go down to 3). A change of this number would then require touching all these sites, which is what we'd like to avoid.
Jan
Re: [RFC 1/4] x86/ioemul: address MISRA C:2012 Rule 9.3
Quoted 17 lines · Jan Beulich
Quoted 16 lines · Nicola Vetrini
Quoted 15 lines · Jan Beulich
Quoted 14 lines · Stefano Stabellini
Quoted 12 lines · Jan Beulich
Quoted 7 lines · Nicola Vetrini
Partially explicitly initalized .matches arrays result in violations of Rule 9.3; this is resolved by using designated initializers, which is permitted by the Rule.
Mechanical changes.
Signed-off-by Nicola Vetrini <[email protected]>While not overly bad, I'm still not really seeing the improvement. Yet aiui changes induced by Misra are supposed to improve things in some direction?
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines
I think the improvement is clarity, in the sense that the designated initializers make it clearer that the array may be sparsely initialized
and that the remaining elements should be initialized to zero automatically.That's as clear from the original code, imo.
This specific instance is simple and might be clear either way, but in general especially in more complex scenarios and potentially nested structures and arrays, it could be harder to figure out and that leads to errors. The MISRA checker is a powerful tool to help us make sure the code is correct in all cases, but to take advantage of it properly we need to get to the point where we don't have violations in the current code.
Looking at the results, we have zero violations for Rule 9.3 on ARM already and only 55 on x86. It should be possible to fix them all mechanically in short order. Of course for that to happen, we need to make some compromises. For instance, adding {0} like in the example below, or adding [0]=init,[2]=init like in the first version of the patch. Taking individually, they might not be all great improvements, but all together having the Xen codebase Rule 9.3-free and easy to scan for future violations should be.
Quoted 13 lines
Quoted 7 lines
There's also this functionally equivalent alternative, with or without the zeros, which
doesn't incur in the risk of mistakenly attempting to initialize the same element twice,
while also giving an explicit cue to the reader that all elements are truly zero-initialized.Quoted 5 lines
.matches = { DMI_MATCH(DMI_BIOS_VENDOR, "HP"), DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL5"), + {0}, {0} },
Quoted 4 lines
Adding a dependency on the array actually having 4 elements (while iirc we have seen already that we could in principle go down to 3). A change of this number would then require touching all these sites, which is what we'd like to avoid.
How often the array needs to change though? Looking at the git history it doesn't seem the number of elements ever changed. So I think it is a good tradeoff, and I would go with this type of fix (maybe also at the other locations mechanically too although I haven't looked at them in details).
Re: [RFC 1/4] x86/ioemul: address MISRA C:2012 Rule 9.3
Quoted 63 lines · Stefano Stabellini
Quoted 17 lines · Jan Beulich
Quoted 16 lines · Nicola Vetrini
Quoted 15 lines · Jan Beulich
Quoted 14 lines · Stefano Stabellini
Quoted 12 lines · Jan Beulich
Quoted 7 lines · Nicola Vetrini
Partially explicitly initalized .matches arrays result in violations of Rule 9.3; this is resolved by using designated initializers, which is permitted by the Rule.
Mechanical changes.
Signed-off-by Nicola Vetrini <[email protected]>While not overly bad, I'm still not really seeing the improvement. Yet aiui changes induced by Misra are supposed to improve things in some direction?
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines
I think the improvement is clarity, in the sense that the designated initializers make it clearer that the array may be sparsely initialized
and that the remaining elements should be initialized to zero automatically.That's as clear from the original code, imo.
This specific instance is simple and might be clear either way, but in general especially in more complex scenarios and potentially nested structures and arrays, it could be harder to figure out and that leads to errors. The MISRA checker is a powerful tool to help us make sure the code is correct in all cases, but to take advantage of it properly we need to get to the point where we don't have violations in the current code.
Looking at the results, we have zero violations for Rule 9.3 on ARM already and only 55 on x86. It should be possible to fix them all mechanically in short order. Of course for that to happen, we need to make some compromises. For instance, adding {0} like in the example below, or adding [0]=init,[2]=init like in the first version of the patch. Taking individually, they might not be all great improvements, but all together having the Xen codebase Rule 9.3-free and easy to scan for future violations should be.
Quoted 13 lines
Quoted 7 lines
There's also this functionally equivalent alternative, with or without the zeros, which
doesn't incur in the risk of mistakenly attempting to initialize the same element twice,
while also giving an explicit cue to the reader that all elements are truly zero-initialized.Quoted 5 lines
.matches = { DMI_MATCH(DMI_BIOS_VENDOR, "HP"), DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL5"), + {0}, {0} },Quoted 4 lines
Adding a dependency on the array actually having 4 elements (while iirc we have seen already that we could in principle go down to 3). A change of this number would then require touching all these sites, which is what we'd like to avoid.
Quoted 5 lines
How often the array needs to change though? Looking at the git history it doesn't seem the number of elements ever changed. So I think it is a good tradeoff, and I would go with this type of fix (maybe also at the other locations mechanically too although I haven't looked at them in details).
Hi, any updates on this? Considering the opinions expressed above, what would be the path preferred by the community?
Signature · 2 lines
Nicola Vetrini, BSc Software Engineer, BUGSENG srl (https://bugseng.com)
Re: [RFC 1/4] x86/ioemul: address MISRA C:2012 Rule 9.3
Quoted 18 lines · Nicola Vetrini
Quoted 18 lines
Quoted 17 lines
Quoted 7 lines
There's also this functionally equivalent alternative, with or without the zeros, which
doesn't incur in the risk of mistakenly attempting to initialize the same element twice,
while also giving an explicit cue to the reader that all elements are truly zero-initialized.Quoted 5 lines
.matches = { DMI_MATCH(DMI_BIOS_VENDOR, "HP"), DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL5"), + {0}, {0} },Adding a dependency on the array actually having 4 elements (while iirc we have seen already that we could in principle go down to 3). A change of this number would then require touching all these sites, which is what we'd like to avoid.
Quoted 8 lines
Quoted 5 lines
How often the array needs to change though? Looking at the git history it doesn't seem the number of elements ever changed. So I think it is a good tradeoff, and I would go with this type of fix (maybe also at the other locations mechanically too although I haven't looked at them in details).
Hi, any updates on this? Considering the opinions expressed above, what would be the path preferred by the community?
Hi Jan, to bring this discussion to a conclusion, I think we have these options:
1) fix these violations by adding {}, {}
2) fix these violations by adding [0]=xxx,[1]=xxx
3) deviate these violations by adding /* SAF-safe-xxx */
4) remove the MISRA rule 9.3 from docs/misra/rules.rst
Let's make a decision. My preference is 1) as we only have ~50 violations.
Re: [RFC 1/4] x86/ioemul: address MISRA C:2012 Rule 9.3
Quoted 31 lines · Stefano Stabellini
Quoted 18 lines · Nicola Vetrini
Quoted 18 lines
Quoted 17 lines
Quoted 7 lines
There's also this functionally equivalent alternative, with or without the zeros, which
doesn't incur in the risk of mistakenly attempting to initialize the same element twice,
while also giving an explicit cue to the reader that all elements are truly zero-initialized.Quoted 5 lines
.matches = { DMI_MATCH(DMI_BIOS_VENDOR, "HP"), DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL5"), + {0}, {0} },Adding a dependency on the array actually having 4 elements (while iirc we have seen already that we could in principle go down to 3). A change of this number would then require touching all these sites, which is what we'd like to avoid.
Quoted 8 lines
Quoted 5 lines
How often the array needs to change though? Looking at the git history it doesn't seem the number of elements ever changed. So I think it is a good tradeoff, and I would go with this type of fix (maybe also at the other locations mechanically too although I haven't looked at them in details).
Hi, any updates on this? Considering the opinions expressed above, what would be the path preferred by the community?
Hi Jan, to bring this discussion to a conclusion, I think we have these options:
Quoted 7 lines
1) fix these violations by adding {}, {}
2) fix these violations by adding [0]=xxx,[1]=xxx
3) deviate these violations by adding /* SAF-safe-xxx */
4) remove the MISRA rule 9.3 fromdocs/misra/rules.rstLet's make a decision. My preference is 1) as we only have ~50 violations.
Of these, to be honest, my preference would be 4. Just that that's undesirable for other reasons. But have we thought of alternatives, say a variadic macro that would supply the "missing" initializers? Imo such decisions shouldn't be rushed; there are enough other issues to take care of in the meantime. A sound solution is, I think, generally preferable to a quick one. (Whether my new suggestion is "sound" I of course can't tell, until it was tried out and the overall result / effects can be inspected.)
Jan
Re: [RFC 1/4] x86/ioemul: address MISRA C:2012 Rule 9.3
Quoted 40 lines · Jan Beulich
Quoted 31 lines · Stefano Stabellini
Quoted 18 lines · Nicola Vetrini
Quoted 18 lines
Quoted 17 lines
Quoted 7 lines
There's also this functionally equivalent alternative, with or without the zeros, which
doesn't incur in the risk of mistakenly attempting to initialize the same element twice,
while also giving an explicit cue to the reader that all elements are truly zero-initialized.Quoted 5 lines
.matches = { DMI_MATCH(DMI_BIOS_VENDOR, "HP"), DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL5"), + {0}, {0} },Adding a dependency on the array actually having 4 elements (while iirc we have seen already that we could in principle go down to 3). A change of this number would then require touching all these sites, which is what we'd like to avoid.
Quoted 8 lines
Quoted 5 lines
How often the array needs to change though? Looking at the git history it doesn't seem the number of elements ever changed. So I think it is a good tradeoff, and I would go with this type of fix (maybe also at the other locations mechanically too although I haven't looked at them in details).
Hi, any updates on this? Considering the opinions expressed above, what would be the path preferred by the community?
Hi Jan, to bring this discussion to a conclusion, I think we have these options:
Quoted 7 lines
1) fix these violations by adding {}, {}
2) fix these violations by adding [0]=xxx,[1]=xxx
3) deviate these violations by adding /* SAF-safe-xxx */
4) remove the MISRA rule 9.3 fromdocs/misra/rules.rstLet's make a decision. My preference is 1) as we only have ~50 violations.
Quoted 8 lines
Of these, to be honest, my preference would be 4. Just that that's undesirable for other reasons. But have we thought of alternatives, say a variadic macro that would supply the "missing" initializers? Imo such decisions shouldn't be rushed; there are enough other issues to take care of in the meantime. A sound solution is, I think, generally preferable to a quick one. (Whether my new suggestion is "sound" I of course can't tell, until it was tried out and the overall result / effects can be inspected.)
I don't like the idea of the variadic macro as we should attempt to make things more obviously correct, rather than more obscure.
Thinking out of the box, what if we added a single {} E.g.:
.ident = "HP ProLiant DL3xx",
.matches = {
DMI_MATCH(DMI_BIOS_VENDOR, "HP"),
DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL3"),
{}
},It would accomplish the goal of highlighting that there are more members of the array that gets initialized to zero. At the same time it wouldn't require the introductino of [0] and [1] that as we have seen are error prone and it wouldn't depend on the exact number of elements like adding one {} per missing initialization. To be clear, I am suggesting adding a single {} only.
Nicola, what do you think? Would it be OK for MISRA / ECLAIR?