Skip to content

Commit e0c39a5

Browse files
Merge patch series "scsi: message: fusion: Replace 1-element arrays with flexible arrays"
Kees Cook <kees@kernel.org> says: Replace all remaining uses of deprecated 1-element "fake" flexible arrays with modern C99 flexible arrays. Add __counted_by annotations at the same time. Link: https://lore.kernel.org/r/20240711172432.work.523-kees@kernel.org Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 parents c72e13c + f296cc1 commit e0c39a5

1 file changed

Lines changed: 6 additions & 54 deletions

File tree

drivers/message/fusion/lsi/mpi_cnfg.h

Lines changed: 6 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,14 +1018,6 @@ typedef struct _CONFIG_PAGE_IOC_2_RAID_VOL
10181018

10191019
#define MPI_IOCPAGE2_FLAG_VOLUME_INACTIVE (0x08)
10201020

1021-
/*
1022-
* Host code (drivers, BIOS, utilities, etc.) should leave this define set to
1023-
* one and check Header.PageLength at runtime.
1024-
*/
1025-
#ifndef MPI_IOC_PAGE_2_RAID_VOLUME_MAX
1026-
#define MPI_IOC_PAGE_2_RAID_VOLUME_MAX (1)
1027-
#endif
1028-
10291021
typedef struct _CONFIG_PAGE_IOC_2
10301022
{
10311023
CONFIG_PAGE_HEADER Header; /* 00h */
@@ -1034,7 +1026,7 @@ typedef struct _CONFIG_PAGE_IOC_2
10341026
U8 MaxVolumes; /* 09h */
10351027
U8 NumActivePhysDisks; /* 0Ah */
10361028
U8 MaxPhysDisks; /* 0Bh */
1037-
CONFIG_PAGE_IOC_2_RAID_VOL RaidVolume[MPI_IOC_PAGE_2_RAID_VOLUME_MAX];/* 0Ch */
1029+
CONFIG_PAGE_IOC_2_RAID_VOL RaidVolume[] __counted_by(NumActiveVolumes); /* 0Ch */
10381030
} CONFIG_PAGE_IOC_2, MPI_POINTER PTR_CONFIG_PAGE_IOC_2,
10391031
IOCPage2_t, MPI_POINTER pIOCPage2_t;
10401032

@@ -1064,21 +1056,13 @@ typedef struct _IOC_3_PHYS_DISK
10641056
} IOC_3_PHYS_DISK, MPI_POINTER PTR_IOC_3_PHYS_DISK,
10651057
Ioc3PhysDisk_t, MPI_POINTER pIoc3PhysDisk_t;
10661058

1067-
/*
1068-
* Host code (drivers, BIOS, utilities, etc.) should leave this define set to
1069-
* one and check Header.PageLength at runtime.
1070-
*/
1071-
#ifndef MPI_IOC_PAGE_3_PHYSDISK_MAX
1072-
#define MPI_IOC_PAGE_3_PHYSDISK_MAX (1)
1073-
#endif
1074-
10751059
typedef struct _CONFIG_PAGE_IOC_3
10761060
{
10771061
CONFIG_PAGE_HEADER Header; /* 00h */
10781062
U8 NumPhysDisks; /* 04h */
10791063
U8 Reserved1; /* 05h */
10801064
U16 Reserved2; /* 06h */
1081-
IOC_3_PHYS_DISK PhysDisk[MPI_IOC_PAGE_3_PHYSDISK_MAX]; /* 08h */
1065+
IOC_3_PHYS_DISK PhysDisk[] __counted_by(NumPhysDisks); /* 08h */
10821066
} CONFIG_PAGE_IOC_3, MPI_POINTER PTR_CONFIG_PAGE_IOC_3,
10831067
IOCPage3_t, MPI_POINTER pIOCPage3_t;
10841068

@@ -1093,21 +1077,13 @@ typedef struct _IOC_4_SEP
10931077
} IOC_4_SEP, MPI_POINTER PTR_IOC_4_SEP,
10941078
Ioc4Sep_t, MPI_POINTER pIoc4Sep_t;
10951079

1096-
/*
1097-
* Host code (drivers, BIOS, utilities, etc.) should leave this define set to
1098-
* one and check Header.PageLength at runtime.
1099-
*/
1100-
#ifndef MPI_IOC_PAGE_4_SEP_MAX
1101-
#define MPI_IOC_PAGE_4_SEP_MAX (1)
1102-
#endif
1103-
11041080
typedef struct _CONFIG_PAGE_IOC_4
11051081
{
11061082
CONFIG_PAGE_HEADER Header; /* 00h */
11071083
U8 ActiveSEP; /* 04h */
11081084
U8 MaxSEP; /* 05h */
11091085
U16 Reserved1; /* 06h */
1110-
IOC_4_SEP SEP[MPI_IOC_PAGE_4_SEP_MAX]; /* 08h */
1086+
IOC_4_SEP SEP[] __counted_by(ActiveSEP); /* 08h */
11111087
} CONFIG_PAGE_IOC_4, MPI_POINTER PTR_CONFIG_PAGE_IOC_4,
11121088
IOCPage4_t, MPI_POINTER pIOCPage4_t;
11131089

@@ -2295,14 +2271,6 @@ typedef struct _RAID_VOL0_SETTINGS
22952271
#define MPI_RAID_HOT_SPARE_POOL_6 (0x40)
22962272
#define MPI_RAID_HOT_SPARE_POOL_7 (0x80)
22972273

2298-
/*
2299-
* Host code (drivers, BIOS, utilities, etc.) should leave this define set to
2300-
* one and check Header.PageLength at runtime.
2301-
*/
2302-
#ifndef MPI_RAID_VOL_PAGE_0_PHYSDISK_MAX
2303-
#define MPI_RAID_VOL_PAGE_0_PHYSDISK_MAX (1)
2304-
#endif
2305-
23062274
typedef struct _CONFIG_PAGE_RAID_VOL_0
23072275
{
23082276
CONFIG_PAGE_HEADER Header; /* 00h */
@@ -2321,7 +2289,7 @@ typedef struct _CONFIG_PAGE_RAID_VOL_0
23212289
U8 DataScrubRate; /* 25h */
23222290
U8 ResyncRate; /* 26h */
23232291
U8 InactiveStatus; /* 27h */
2324-
RAID_VOL0_PHYS_DISK PhysDisk[MPI_RAID_VOL_PAGE_0_PHYSDISK_MAX];/* 28h */
2292+
RAID_VOL0_PHYS_DISK PhysDisk[] __counted_by(NumPhysDisks); /* 28h */
23252293
} CONFIG_PAGE_RAID_VOL_0, MPI_POINTER PTR_CONFIG_PAGE_RAID_VOL_0,
23262294
RaidVolumePage0_t, MPI_POINTER pRaidVolumePage0_t;
23272295

@@ -2455,22 +2423,14 @@ typedef struct _RAID_PHYS_DISK1_PATH
24552423
#define MPI_RAID_PHYSDISK1_FLAG_INVALID (0x0001)
24562424

24572425

2458-
/*
2459-
* Host code (drivers, BIOS, utilities, etc.) should leave this define set to
2460-
* one and check Header.PageLength or NumPhysDiskPaths at runtime.
2461-
*/
2462-
#ifndef MPI_RAID_PHYS_DISK1_PATH_MAX
2463-
#define MPI_RAID_PHYS_DISK1_PATH_MAX (1)
2464-
#endif
2465-
24662426
typedef struct _CONFIG_PAGE_RAID_PHYS_DISK_1
24672427
{
24682428
CONFIG_PAGE_HEADER Header; /* 00h */
24692429
U8 NumPhysDiskPaths; /* 04h */
24702430
U8 PhysDiskNum; /* 05h */
24712431
U16 Reserved2; /* 06h */
24722432
U32 Reserved1; /* 08h */
2473-
RAID_PHYS_DISK1_PATH Path[MPI_RAID_PHYS_DISK1_PATH_MAX];/* 0Ch */
2433+
RAID_PHYS_DISK1_PATH Path[] __counted_by(NumPhysDiskPaths);/* 0Ch */
24742434
} CONFIG_PAGE_RAID_PHYS_DISK_1, MPI_POINTER PTR_CONFIG_PAGE_RAID_PHYS_DISK_1,
24752435
RaidPhysDiskPage1_t, MPI_POINTER pRaidPhysDiskPage1_t;
24762436

@@ -2555,14 +2515,6 @@ typedef struct _MPI_SAS_IO_UNIT0_PHY_DATA
25552515
} MPI_SAS_IO_UNIT0_PHY_DATA, MPI_POINTER PTR_MPI_SAS_IO_UNIT0_PHY_DATA,
25562516
SasIOUnit0PhyData, MPI_POINTER pSasIOUnit0PhyData;
25572517

2558-
/*
2559-
* Host code (drivers, BIOS, utilities, etc.) should leave this define set to
2560-
* one and check Header.PageLength at runtime.
2561-
*/
2562-
#ifndef MPI_SAS_IOUNIT0_PHY_MAX
2563-
#define MPI_SAS_IOUNIT0_PHY_MAX (1)
2564-
#endif
2565-
25662518
typedef struct _CONFIG_PAGE_SAS_IO_UNIT_0
25672519
{
25682520
CONFIG_EXTENDED_PAGE_HEADER Header; /* 00h */
@@ -2571,7 +2523,7 @@ typedef struct _CONFIG_PAGE_SAS_IO_UNIT_0
25712523
U8 NumPhys; /* 0Ch */
25722524
U8 Reserved2; /* 0Dh */
25732525
U16 Reserved3; /* 0Eh */
2574-
MPI_SAS_IO_UNIT0_PHY_DATA PhyData[MPI_SAS_IOUNIT0_PHY_MAX]; /* 10h */
2526+
MPI_SAS_IO_UNIT0_PHY_DATA PhyData[] __counted_by(NumPhys); /* 10h */
25752527
} CONFIG_PAGE_SAS_IO_UNIT_0, MPI_POINTER PTR_CONFIG_PAGE_SAS_IO_UNIT_0,
25762528
SasIOUnitPage0_t, MPI_POINTER pSasIOUnitPage0_t;
25772529

0 commit comments

Comments
 (0)