scsi: mpi3mr: Replace 1-element arrays with flexible arrays
Subsystems (2)
cover scsi: mpi3mr: Replace 1-element arrays with flexible arrays
Hi,
Replace all the uses of deprecated 1-element "fake" flexible arrays with modern C99 flexible arrays.
Thanks!
-Kees
Kees Cook (4):
scsi: mpi3mr: struct mpi3_event_data_sas_topology_change_list: Replace
1-element array with flexible array
scsi: mpi3mr: struct mpi3_event_data_pcie_topology_change_list:
Replace 1-element array with flexible array
scsi: mpi3mr: struct mpi3_sas_io_unit_page0: Replace 1-element array
with flexible array
scsi: mpi3mr: struct mpi3_sas_io_unit_page1: Replace 1-element array
with flexible array
drivers/scsi/mpi3mr/mpi/mpi30_cnfg.h | 10 ++-------- drivers/scsi/mpi3mr/mpi/mpi30_ioc.h | 10 ++-------- 2 files changed, 4 insertions(+), 16 deletions(-)
Signature · 1 line
2.34.1
PATCH 1/4 scsi: mpi3mr: struct mpi3_event_data_sas_topology_change_list: Replace 1-element array with flexible array
Replace the deprecated[1] use of a 1-element array in struct mpi3_event_data_sas_topology_change_list with a modern flexible array.
Additionally add __counted_by annotation since phy_entry is only ever accessed in loops controlled by num_entries. For example:
for (i = 0; i < event_data->num_entries; i++) {
...
handle = le16_to_cpu(event_data->phy_entry[i].attached_dev_handle);No binary differences are present after this conversion.
---
Cc: Sathya Prakash Veerichetty <[email protected]>
Cc: Kashyap Desai <[email protected]>
Cc: Sumit Saxena <[email protected]>
Cc: Sreekanth Reddy <[email protected]>
Cc: "James E.J. Bottomley" <[email protected]>
Cc: "Martin K. Petersen" <[email protected]>
Cc: "Gustavo A. R. Silva" <[email protected]>
Cc: Ranjan Kumar <[email protected]>
Cc: Stephen Rothwell <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
--- drivers/scsi/mpi3mr/mpi/mpi30_ioc.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/scsi/mpi3mr/mpi/mpi30_ioc.h +1 -4
@@ -453,9 +453,6 @@ struct mpi3_event_data_sas_notify_primitive {#define MPI3_EVENT_NOTIFY_PRIMITIVE_POWER_LOSS_EXPECTED (0x02)#define MPI3_EVENT_NOTIFY_PRIMITIVE_RESERVED1 (0x03)#define MPI3_EVENT_NOTIFY_PRIMITIVE_RESERVED2 (0x04) -#ifndef MPI3_EVENT_SAS_TOPO_PHY_COUNT -#define MPI3_EVENT_SAS_TOPO_PHY_COUNT (1) -#endif struct mpi3_event_sas_topo_phy_entry {__le16 attached_dev_handle;u8 link_rate;
@@ -496,7 +493,7 @@ struct mpi3_event_data_sas_topology_change_list {u8 start_phy_num;u8 exp_status;u8 io_unit_port; -struct mpi3_event_sas_topo_phy_entry phy_entry[MPI3_EVENT_SAS_TOPO_PHY_COUNT ]; + struct mpi3_event_sas_topo_phy_entry phy_entry[] __counted_by(num_entries); };#define MPI3_EVENT_SAS_TOPO_ES_NO_EXPANDER (0x00)
Signature · 1 line
2.34.1
PATCH 2/4 scsi: mpi3mr: struct mpi3_event_data_pcie_topology_change_list: Replace 1-element array with flexible array
In reply to Kees CookReplace the deprecated[1] use of a 1-element array in struct mpi3_event_data_pcie_topology_change_list with a modern flexible array.
Additionally add __counted_by annotation since port_entry is only ever accessed in loops controlled by num_entries. For example:
for (i = 0; i < event_data->num_entries; i++) {
handle =
le16_to_cpu(event_data->port_entry[i].attached_dev_handle);No binary differences are present after this conversion.
---
Cc: Sathya Prakash Veerichetty <[email protected]>
Cc: Kashyap Desai <[email protected]>
Cc: Sumit Saxena <[email protected]>
Cc: Sreekanth Reddy <[email protected]>
Cc: "James E.J. Bottomley" <[email protected]>
Cc: "Martin K. Petersen" <[email protected]>
Cc: "Gustavo A. R. Silva" <[email protected]>
Cc: Ranjan Kumar <[email protected]>
Cc: Stephen Rothwell <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
--- drivers/scsi/mpi3mr/mpi/mpi30_ioc.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/scsi/mpi3mr/mpi/mpi30_ioc.h +1 -4
@@ -542,9 +542,6 @@ struct mpi3_event_data_pcie_enumeration {#define MPI3_EVENT_PCIE_ENUM_ES_MAX_SWITCHES_EXCEED (0x40000000)#define MPI3_EVENT_PCIE_ENUM_ES_MAX_DEVICES_EXCEED (0x20000000)#define MPI3_EVENT_PCIE_ENUM_ES_RESOURCES_EXHAUSTED (0x10000000) -#ifndef MPI3_EVENT_PCIE_TOPO_PORT_COUNT -#define MPI3_EVENT_PCIE_TOPO_PORT_COUNT (1) -#endif struct mpi3_event_pcie_topo_port_entry {__le16 attached_dev_handle;u8 port_status;
@@ -585,7 +582,7 @@ struct mpi3_event_data_pcie_topology_change_list {u8 switch_status;u8 io_unit_port;__le32 reserved0c; -struct mpi3_event_pcie_topo_port_entry port_entry[MPI3_EVENT_PCIE_TOPO_PORT_COUNT ]; + struct mpi3_event_pcie_topo_port_entry port_entry[] __counted_by(num_entries); };#define MPI3_EVENT_PCIE_TOPO_SS_NO_PCIE_SWITCH (0x00)
Signature · 1 line
2.34.1
PATCH 3/4 scsi: mpi3mr: struct mpi3_sas_io_unit_page0: Replace 1-element array with flexible array
In reply to Kees CookReplace the deprecated[1] use of a 1-element array in struct mpi3_sas_io_unit_page0 with a modern flexible array.
No binary differences are present after this conversion.
---
Cc: Sathya Prakash Veerichetty <[email protected]>
Cc: Kashyap Desai <[email protected]>
Cc: Sumit Saxena <[email protected]>
Cc: Sreekanth Reddy <[email protected]>
Cc: "James E.J. Bottomley" <[email protected]>
Cc: "Martin K. Petersen" <[email protected]>
Cc: Ranjan Kumar <[email protected]>
Cc: [email protected]
Cc: [email protected]
--- drivers/scsi/mpi3mr/mpi/mpi30_cnfg.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/scsi/mpi3mr/mpi/mpi30_cnfg.h +1 -4
@@ -1565,16 +1565,13 @@ struct mpi3_sas_io_unit0_phy_data {__le32 reserved10; }; -#ifndef MPI3_SAS_IO_UNIT0_PHY_MAX -#define MPI3_SAS_IO_UNIT0_PHY_MAX (1) -#endif struct mpi3_sas_io_unit_page0 {struct mpi3_config_page_header header;__le32 reserved08;u8 num_phys;u8 init_status;__le16 reserved0e; -struct mpi3_sas_io_unit0_phy_data phy_data[MPI3_SAS_IO_UNIT0_PHY_MAX ]; +struct mpi3_sas_io_unit0_phy_data phy_data[]; };#define MPI3_SASIOUNIT0_PAGEVERSION (0x00)
Signature · 1 line
2.34.1
PATCH 4/4 scsi: mpi3mr: struct mpi3_sas_io_unit_page1: Replace 1-element array with flexible array
In reply to Kees CookReplace the deprecated[1] use of a 1-element array in struct mpi3_sas_io_unit_page1 with a modern flexible array.
No binary differences are present after this conversion.
---
Cc: Sathya Prakash Veerichetty <[email protected]>
Cc: Kashyap Desai <[email protected]>
Cc: Sumit Saxena <[email protected]>
Cc: Sreekanth Reddy <[email protected]>
Cc: "James E.J. Bottomley" <[email protected]>
Cc: "Martin K. Petersen" <[email protected]>
Cc: Ranjan Kumar <[email protected]>
Cc: [email protected]
Cc: [email protected]
--- drivers/scsi/mpi3mr/mpi/mpi30_cnfg.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/scsi/mpi3mr/mpi/mpi30_cnfg.h +1 -4
@@ -1603,9 +1603,6 @@ struct mpi3_sas_io_unit1_phy_data {__le32 reserved08; }; -#ifndef MPI3_SAS_IO_UNIT1_PHY_MAX -#define MPI3_SAS_IO_UNIT1_PHY_MAX (1) -#endif struct mpi3_sas_io_unit_page1 {struct mpi3_config_page_header header;__le16 control_flags;
@@ -1615,7 +1612,7 @@ struct mpi3_sas_io_unit_page1 {u8 num_phys;u8 sata_max_q_depth;__le16 reserved12; -struct mpi3_sas_io_unit1_phy_data phy_data[MPI3_SAS_IO_UNIT1_PHY_MAX ]; +struct mpi3_sas_io_unit1_phy_data phy_data[]; };#define MPI3_SASIOUNIT1_PAGEVERSION (0x00)
Signature · 1 line
2.34.1
Re: [PATCH 1/4] scsi: mpi3mr: struct mpi3_event_data_sas_topology_change_list: Replace 1-element array with flexible array
In reply to Kees CookQuoted 7 lines · Kees Cook
Replace the deprecated[1] use of a 1-element array in struct
mpi3_event_data_sas_topology_change_listwith a modern flexible array.Additionally add
__counted_byannotation sincephy_entryis only ever accessed in loops controlled bynum_entries. For example:
Quoted 8 lines
for (i = 0; i < event_data->num_entries; i++) { ... handle = le16_to_cpu(event_data->phy_entry[i].attached_dev_handle);No binary differences are present after this conversion.
Signed-off-by Kees Cook <[email protected]>
Thanks
Signature · 1 line
Gustavo
Quoted 40 lines
---
Cc: Sathya Prakash Veerichetty <[email protected]>
Cc: Kashyap Desai <[email protected]>
Cc: Sumit Saxena <[email protected]>
Cc: Sreekanth Reddy <[email protected]>
Cc: "James E.J. Bottomley" <[email protected]>
Cc: "Martin K. Petersen" <[email protected]>
Cc: "Gustavo A. R. Silva" <[email protected]>
Cc: Ranjan Kumar <[email protected]>
Cc: Stephen Rothwell <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]--- drivers/scsi/mpi3mr/mpi/mpi30_ioc.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)drivers/scsi/mpi3mr/mpi/mpi30_ioc.h +1
-4@@ -453,9 +453,6 @@ struct mpi3_event_data_sas_notify_primitive {#define MPI3_EVENT_NOTIFY_PRIMITIVE_POWER_LOSS_EXPECTED (0x02)#define MPI3_EVENT_NOTIFY_PRIMITIVE_RESERVED1 (0x03)#define MPI3_EVENT_NOTIFY_PRIMITIVE_RESERVED2 (0x04) -#ifndef MPI3_EVENT_SAS_TOPO_PHY_COUNT -#define MPI3_EVENT_SAS_TOPO_PHY_COUNT (1) -#endif struct mpi3_event_sas_topo_phy_entry {__le16 attached_dev_handle;u8 link_rate;@@ -496,7 +493,7 @@ struct mpi3_event_data_sas_topology_change_list {u8 start_phy_num;u8 exp_status;u8 io_unit_port; -struct mpi3_event_sas_topo_phy_entry phy_entry[MPI3_EVENT_SAS_TOPO_PHY_COUNT ]; + struct mpi3_event_sas_topo_phy_entry phy_entry[] __counted_by(num_entries); };#define MPI3_EVENT_SAS_TOPO_ES_NO_EXPANDER (0x00)
Re: [PATCH 2/4] scsi: mpi3mr: struct mpi3_event_data_pcie_topology_change_list: Replace 1-element array with flexible array
In reply to Kees CookQuoted 7 lines · Kees Cook
Replace the deprecated[1] use of a 1-element array in struct
mpi3_event_data_pcie_topology_change_listwith a modern flexible array.Additionally add
__counted_byannotation sinceport_entryis only ever accessed in loops controlled bynum_entries. For example:
Quoted 8 lines
for (i = 0; i < event_data->num_entries; i++) { handle = le16_to_cpu(event_data->port_entry[i].attached_dev_handle);No binary differences are present after this conversion.
Signed-off-by Kees Cook <[email protected]>
Thanks
Signature · 1 line
Gustavo
Quoted 40 lines
---
Cc: Sathya Prakash Veerichetty <[email protected]>
Cc: Kashyap Desai <[email protected]>
Cc: Sumit Saxena <[email protected]>
Cc: Sreekanth Reddy <[email protected]>
Cc: "James E.J. Bottomley" <[email protected]>
Cc: "Martin K. Petersen" <[email protected]>
Cc: "Gustavo A. R. Silva" <[email protected]>
Cc: Ranjan Kumar <[email protected]>
Cc: Stephen Rothwell <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]--- drivers/scsi/mpi3mr/mpi/mpi30_ioc.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)drivers/scsi/mpi3mr/mpi/mpi30_ioc.h +1
-4@@ -542,9 +542,6 @@ struct mpi3_event_data_pcie_enumeration {#define MPI3_EVENT_PCIE_ENUM_ES_MAX_SWITCHES_EXCEED (0x40000000)#define MPI3_EVENT_PCIE_ENUM_ES_MAX_DEVICES_EXCEED (0x20000000)#define MPI3_EVENT_PCIE_ENUM_ES_RESOURCES_EXHAUSTED (0x10000000) -#ifndef MPI3_EVENT_PCIE_TOPO_PORT_COUNT -#define MPI3_EVENT_PCIE_TOPO_PORT_COUNT (1) -#endif struct mpi3_event_pcie_topo_port_entry {__le16 attached_dev_handle;u8 port_status;@@ -585,7 +582,7 @@ struct mpi3_event_data_pcie_topology_change_list {u8 switch_status;u8 io_unit_port;__le32 reserved0c; -struct mpi3_event_pcie_topo_port_entry port_entry[MPI3_EVENT_PCIE_TOPO_PORT_COUNT ]; + struct mpi3_event_pcie_topo_port_entry port_entry[] __counted_by(num_entries); };#define MPI3_EVENT_PCIE_TOPO_SS_NO_PCIE_SWITCH (0x00)
Re: [PATCH 3/4] scsi: mpi3mr: struct mpi3_sas_io_unit_page0: Replace 1-element array with flexible array
In reply to Kees CookQuoted 7 lines · Kees Cook
Replace the deprecated[1] use of a 1-element array in struct
mpi3_sas_io_unit_page0with a modern flexible array.No binary differences are present after this conversion.
Signed-off-by Kees Cook <[email protected]>
Thanks
Signature · 1 line
Gustavo
Quoted 36 lines
---
Cc: Sathya Prakash Veerichetty <[email protected]>
Cc: Kashyap Desai <[email protected]>
Cc: Sumit Saxena <[email protected]>
Cc: Sreekanth Reddy <[email protected]>
Cc: "James E.J. Bottomley" <[email protected]>
Cc: "Martin K. Petersen" <[email protected]>
Cc: Ranjan Kumar <[email protected]>
Cc: [email protected]
Cc: [email protected]--- drivers/scsi/mpi3mr/mpi/mpi30_cnfg.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)drivers/scsi/mpi3mr/mpi/mpi30_cnfg.h +1
-4@@ -1565,16 +1565,13 @@ struct mpi3_sas_io_unit0_phy_data {__le32 reserved10; }; -#ifndef MPI3_SAS_IO_UNIT0_PHY_MAX -#define MPI3_SAS_IO_UNIT0_PHY_MAX (1) -#endif struct mpi3_sas_io_unit_page0 {struct mpi3_config_page_header header;__le32 reserved08;u8 num_phys;u8 init_status;__le16 reserved0e; -struct mpi3_sas_io_unit0_phy_data phy_data[MPI3_SAS_IO_UNIT0_PHY_MAX ]; +struct mpi3_sas_io_unit0_phy_data phy_data[]; };#define MPI3_SASIOUNIT0_PAGEVERSION (0x00)
Re: [PATCH 4/4] scsi: mpi3mr: struct mpi3_sas_io_unit_page1: Replace 1-element array with flexible array
In reply to Kees CookQuoted 7 lines · Kees Cook
Replace the deprecated[1] use of a 1-element array in struct
mpi3_sas_io_unit_page1with a modern flexible array.No binary differences are present after this conversion.
Signed-off-by Kees Cook <[email protected]>
Thanks
Signature · 1 line
Gustavo
Quoted 37 lines
---
Cc: Sathya Prakash Veerichetty <[email protected]>
Cc: Kashyap Desai <[email protected]>
Cc: Sumit Saxena <[email protected]>
Cc: Sreekanth Reddy <[email protected]>
Cc: "James E.J. Bottomley" <[email protected]>
Cc: "Martin K. Petersen" <[email protected]>
Cc: Ranjan Kumar <[email protected]>
Cc: [email protected]
Cc: [email protected]--- drivers/scsi/mpi3mr/mpi/mpi30_cnfg.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)drivers/scsi/mpi3mr/mpi/mpi30_cnfg.h +1
-4@@ -1603,9 +1603,6 @@ struct mpi3_sas_io_unit1_phy_data {__le32 reserved08; }; -#ifndef MPI3_SAS_IO_UNIT1_PHY_MAX -#define MPI3_SAS_IO_UNIT1_PHY_MAX (1) -#endif struct mpi3_sas_io_unit_page1 {struct mpi3_config_page_header header;__le16 control_flags;@@ -1615,7 +1612,7 @@ struct mpi3_sas_io_unit_page1 {u8 num_phys;u8 sata_max_q_depth;__le16 reserved12; -struct mpi3_sas_io_unit1_phy_data phy_data[MPI3_SAS_IO_UNIT1_PHY_MAX ]; +struct mpi3_sas_io_unit1_phy_data phy_data[]; };#define MPI3_SASIOUNIT1_PAGEVERSION (0x00)
Martin K. Petersen
AppliedKees,
Quoted 2 lines
Replace all the uses of deprecated 1-element "fake" flexible arrays with modern C99 flexible arrays.
Applied to 6.12/scsi-staging, thanks!
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Martin K. Petersen
AppliedQuoted 8 lines · Kees Cook
Replace all the uses of deprecated 1-element "fake" flexible arrays with modern C99 flexible arrays.
Thanks!
-Kees
[...]
Applied to 6.12/scsi-queue, thanks!
[1/4] scsi: mpi3mr: struct mpi3_event_data_sas_topology_change_list: Replace 1-element array with flexible array
https://git.kernel.org/mkp/scsi/c/ac5b7505de70 [2/4] scsi: mpi3mr: struct mpi3_event_data_pcie_topology_change_list: Replace 1-element array with flexible array https://git.kernel.org/mkp/scsi/c/0e11f97bfddc [3/4] scsi: mpi3mr: struct mpi3_sas_io_unit_page0: Replace 1-element array with flexible array https://git.kernel.org/mkp/scsi/c/41bb96296f9d [4/4] scsi: mpi3mr: struct mpi3_sas_io_unit_page1: Replace 1-element array with flexible array https://git.kernel.org/mkp/scsi/c/a62193abae75
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering