udf: Get rid of 0-length arrays

Declare variable length arrays using [] instead of the old-style
declarations using arrays with 0 members. Also comment out entries in
structures beyond the first variable length array (we still do keep them
in comments as a reminder there are further entries in the structure
behind the variable length array). Accessing such entries needs a
careful offset math anyway so it is safer to not have them declared.

Signed-off-by: Jan Kara <jack@suse.cz>
This commit is contained in:
Jan Kara 2021-05-03 11:50:38 +02:00
parent 04e8ee504a
commit b3c8c9801e
2 changed files with 25 additions and 26 deletions

View File

@ -307,14 +307,14 @@ struct logicalVolDesc {
struct regid impIdent; struct regid impIdent;
uint8_t impUse[128]; uint8_t impUse[128];
struct extent_ad integritySeqExt; struct extent_ad integritySeqExt;
uint8_t partitionMaps[0]; uint8_t partitionMaps[];
} __packed; } __packed;
/* Generic Partition Map (ECMA 167r3 3/10.7.1) */ /* Generic Partition Map (ECMA 167r3 3/10.7.1) */
struct genericPartitionMap { struct genericPartitionMap {
uint8_t partitionMapType; uint8_t partitionMapType;
uint8_t partitionMapLength; uint8_t partitionMapLength;
uint8_t partitionMapping[0]; uint8_t partitionMapping[];
} __packed; } __packed;
/* Partition Map Type (ECMA 167r3 3/10.7.1.1) */ /* Partition Map Type (ECMA 167r3 3/10.7.1.1) */
@ -342,7 +342,7 @@ struct unallocSpaceDesc {
struct tag descTag; struct tag descTag;
__le32 volDescSeqNum; __le32 volDescSeqNum;
__le32 numAllocDescs; __le32 numAllocDescs;
struct extent_ad allocDescs[0]; struct extent_ad allocDescs[];
} __packed; } __packed;
/* Terminating Descriptor (ECMA 167r3 3/10.9) */ /* Terminating Descriptor (ECMA 167r3 3/10.9) */
@ -360,9 +360,9 @@ struct logicalVolIntegrityDesc {
uint8_t logicalVolContentsUse[32]; uint8_t logicalVolContentsUse[32];
__le32 numOfPartitions; __le32 numOfPartitions;
__le32 lengthOfImpUse; __le32 lengthOfImpUse;
__le32 freeSpaceTable[0]; __le32 freeSpaceTable[];
__le32 sizeTable[0]; /* __le32 sizeTable[]; */
uint8_t impUse[0]; /* uint8_t impUse[]; */
} __packed; } __packed;
/* Integrity Type (ECMA 167r3 3/10.10.3) */ /* Integrity Type (ECMA 167r3 3/10.10.3) */
@ -578,8 +578,8 @@ struct fileEntry {
__le64 uniqueID; __le64 uniqueID;
__le32 lengthExtendedAttr; __le32 lengthExtendedAttr;
__le32 lengthAllocDescs; __le32 lengthAllocDescs;
uint8_t extendedAttr[0]; uint8_t extendedAttr[];
uint8_t allocDescs[0]; /* uint8_t allocDescs[]; */
} __packed; } __packed;
/* Permissions (ECMA 167r3 4/14.9.5) */ /* Permissions (ECMA 167r3 4/14.9.5) */
@ -632,7 +632,7 @@ struct genericFormat {
uint8_t attrSubtype; uint8_t attrSubtype;
uint8_t reserved[3]; uint8_t reserved[3];
__le32 attrLength; __le32 attrLength;
uint8_t attrData[0]; uint8_t attrData[];
} __packed; } __packed;
/* Character Set Information (ECMA 167r3 4/14.10.3) */ /* Character Set Information (ECMA 167r3 4/14.10.3) */
@ -643,7 +643,7 @@ struct charSetInfo {
__le32 attrLength; __le32 attrLength;
__le32 escapeSeqLength; __le32 escapeSeqLength;
uint8_t charSetType; uint8_t charSetType;
uint8_t escapeSeq[0]; uint8_t escapeSeq[];
} __packed; } __packed;
/* Alternate Permissions (ECMA 167r3 4/14.10.4) */ /* Alternate Permissions (ECMA 167r3 4/14.10.4) */
@ -682,7 +682,7 @@ struct infoTimesExtAttr {
__le32 attrLength; __le32 attrLength;
__le32 dataLength; __le32 dataLength;
__le32 infoTimeExistence; __le32 infoTimeExistence;
uint8_t infoTimes[0]; uint8_t infoTimes[];
} __packed; } __packed;
/* Device Specification (ECMA 167r3 4/14.10.7) */ /* Device Specification (ECMA 167r3 4/14.10.7) */
@ -694,7 +694,7 @@ struct deviceSpec {
__le32 impUseLength; __le32 impUseLength;
__le32 majorDeviceIdent; __le32 majorDeviceIdent;
__le32 minorDeviceIdent; __le32 minorDeviceIdent;
uint8_t impUse[0]; uint8_t impUse[];
} __packed; } __packed;
/* Implementation Use Extended Attr (ECMA 167r3 4/14.10.8) */ /* Implementation Use Extended Attr (ECMA 167r3 4/14.10.8) */
@ -705,7 +705,7 @@ struct impUseExtAttr {
__le32 attrLength; __le32 attrLength;
__le32 impUseLength; __le32 impUseLength;
struct regid impIdent; struct regid impIdent;
uint8_t impUse[0]; uint8_t impUse[];
} __packed; } __packed;
/* Application Use Extended Attribute (ECMA 167r3 4/14.10.9) */ /* Application Use Extended Attribute (ECMA 167r3 4/14.10.9) */
@ -716,7 +716,7 @@ struct appUseExtAttr {
__le32 attrLength; __le32 attrLength;
__le32 appUseLength; __le32 appUseLength;
struct regid appIdent; struct regid appIdent;
uint8_t appUse[0]; uint8_t appUse[];
} __packed; } __packed;
#define EXTATTR_CHAR_SET 1 #define EXTATTR_CHAR_SET 1
@ -733,7 +733,7 @@ struct unallocSpaceEntry {
struct tag descTag; struct tag descTag;
struct icbtag icbTag; struct icbtag icbTag;
__le32 lengthAllocDescs; __le32 lengthAllocDescs;
uint8_t allocDescs[0]; uint8_t allocDescs[];
} __packed; } __packed;
/* Space Bitmap Descriptor (ECMA 167r3 4/14.12) */ /* Space Bitmap Descriptor (ECMA 167r3 4/14.12) */
@ -741,7 +741,7 @@ struct spaceBitmapDesc {
struct tag descTag; struct tag descTag;
__le32 numOfBits; __le32 numOfBits;
__le32 numOfBytes; __le32 numOfBytes;
uint8_t bitmap[0]; uint8_t bitmap[];
} __packed; } __packed;
/* Partition Integrity Entry (ECMA 167r3 4/14.13) */ /* Partition Integrity Entry (ECMA 167r3 4/14.13) */
@ -780,7 +780,7 @@ struct pathComponent {
uint8_t componentType; uint8_t componentType;
uint8_t lengthComponentIdent; uint8_t lengthComponentIdent;
__le16 componentFileVersionNum; __le16 componentFileVersionNum;
dchars componentIdent[0]; dchars componentIdent[];
} __packed; } __packed;
/* File Entry (ECMA 167r3 4/14.17) */ /* File Entry (ECMA 167r3 4/14.17) */
@ -809,8 +809,8 @@ struct extendedFileEntry {
__le64 uniqueID; __le64 uniqueID;
__le32 lengthExtendedAttr; __le32 lengthExtendedAttr;
__le32 lengthAllocDescs; __le32 lengthAllocDescs;
uint8_t extendedAttr[0]; uint8_t extendedAttr[];
uint8_t allocDescs[0]; /* uint8_t allocDescs[]; */
} __packed; } __packed;
#endif /* _ECMA_167_H */ #endif /* _ECMA_167_H */

View File

@ -111,7 +111,7 @@ struct logicalVolIntegrityDescImpUse {
__le16 minUDFReadRev; __le16 minUDFReadRev;
__le16 minUDFWriteRev; __le16 minUDFWriteRev;
__le16 maxUDFWriteRev; __le16 maxUDFWriteRev;
uint8_t impUse[0]; uint8_t impUse[];
} __packed; } __packed;
/* Implementation Use Volume Descriptor (UDF 2.60 2.2.7) */ /* Implementation Use Volume Descriptor (UDF 2.60 2.2.7) */
@ -190,8 +190,8 @@ struct virtualAllocationTable20 {
__le16 minUDFWriteRev; __le16 minUDFWriteRev;
__le16 maxUDFWriteRev; __le16 maxUDFWriteRev;
__le16 reserved; __le16 reserved;
uint8_t impUse[0]; uint8_t impUse[];
__le32 vatEntry[0]; /* __le32 vatEntry[]; */
} __packed; } __packed;
#define ICBTAG_FILE_TYPE_VAT20 0xF8U #define ICBTAG_FILE_TYPE_VAT20 0xF8U
@ -208,8 +208,7 @@ struct sparingTable {
__le16 reallocationTableLen; __le16 reallocationTableLen;
__le16 reserved; __le16 reserved;
__le32 sequenceNum; __le32 sequenceNum;
struct sparingEntry struct sparingEntry mapEntry[];
mapEntry[0];
} __packed; } __packed;
/* Metadata File (and Metadata Mirror File) (UDF 2.60 2.2.13.1) */ /* Metadata File (and Metadata Mirror File) (UDF 2.60 2.2.13.1) */
@ -232,7 +231,7 @@ struct allocDescImpUse {
/* FreeEASpace (UDF 2.60 3.3.4.5.1.1) */ /* FreeEASpace (UDF 2.60 3.3.4.5.1.1) */
struct freeEaSpace { struct freeEaSpace {
__le16 headerChecksum; __le16 headerChecksum;
uint8_t freeEASpace[0]; uint8_t freeEASpace[];
} __packed; } __packed;
/* DVD Copyright Management Information (UDF 2.60 3.3.4.5.1.2) */ /* DVD Copyright Management Information (UDF 2.60 3.3.4.5.1.2) */
@ -256,7 +255,7 @@ struct LVExtensionEA {
/* FreeAppEASpace (UDF 2.60 3.3.4.6.1) */ /* FreeAppEASpace (UDF 2.60 3.3.4.6.1) */
struct freeAppEASpace { struct freeAppEASpace {
__le16 headerChecksum; __le16 headerChecksum;
uint8_t freeEASpace[0]; uint8_t freeEASpace[];
} __packed; } __packed;
/* UDF Defined System Stream (UDF 2.60 3.3.7) */ /* UDF Defined System Stream (UDF 2.60 3.3.7) */