compile: use flexible arrays to use compiler checks

We use zero-size arrays throughout the code in place of flexible
arrays. There are only two cases where flexible arrays cannot be
used: inside unions and where such an array is the only member of the
structure. In all other cases we can switch to flexible arrays to let
the compiler warn us of any improper use.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
This commit is contained in:
Guennadi Liakhovetski 2023-03-13 16:17:34 +01:00 committed by Liam Girdwood
parent b541e415e0
commit afb1a0d6a3
11 changed files with 13 additions and 13 deletions

View File

@ -40,7 +40,7 @@ struct sof_ipc_channel_map {
uint32_t ext_id;
uint32_t ch_mask;
uint32_t reserved;
int32_t ch_coeffs[0];
int32_t ch_coeffs[];
} __attribute__((packed, aligned(4)));
/**
@ -56,7 +56,7 @@ struct sof_ipc_stream_map {
struct sof_ipc_cmd_hdr hdr;
uint32_t num_ch_map;
uint32_t reserved[3];
struct sof_ipc_channel_map ch_map[0];
struct sof_ipc_channel_map ch_map[];
} __attribute__((packed, aligned(4)));
#endif /* __IPC_CHANNEL_MAP_H__ */

View File

@ -235,7 +235,7 @@ struct sof_ipc_comp_process {
/* reserved for future use */
uint32_t reserved[7];
unsigned char data[0];
unsigned char data[];
} __attribute__((packed, aligned(4)));
/* IPC file component used by testbench only */

View File

@ -401,7 +401,7 @@ enum ipc4_hw_config_params {
struct ipc4_tuple {
uint32_t type;
uint32_t length;
char data[0];
char data[];
} __attribute__((packed, aligned(4)));
enum ipc4_memory_type {

View File

@ -152,7 +152,7 @@ struct ipc4_gateway_config_data {
union ipc4_gateway_attributes gtw_attributes;
/**< Configuration BLOB */
uint32_t config_blob[0];
uint32_t config_blob[];
} __attribute__((packed, aligned(4)));
/**< Configuration for the IPC Gateway */

View File

@ -48,7 +48,7 @@ struct ipc4_ipc_gateway_cmd_data {
/* node_id of the target gateway */
union ipc4_connector_node_id node_id;
/* Payload (actual size is in the header extension.r.data_size) */
uint8_t payload[0];
uint8_t payload[];
};
/* Reply to IPC gateway message */
@ -60,7 +60,7 @@ struct ipc4_ipc_gateway_cmd_data_reply {
/* Total reply size is returned in reply header extension.r.data_size.
* This payload size if 4 bytes smaller (size of the union above).
*/
uint8_t payload[0];
uint8_t payload[];
};
int ipcgtw_process_cmd(const struct ipc4_ipcgtw_cmd *cmd,

View File

@ -69,7 +69,7 @@ struct ipc4_module_init_ext_data {
struct ipc4_module_init_ext_init extended_init;
/**< Data (actual size set to param_block_size) */
uint32_t param_data[0];
uint32_t param_data[];
} __attribute__((packed, aligned(4)));
struct ipc4_module_init_gna_config {

View File

@ -72,6 +72,6 @@ struct ipc4_peak_volume_config {
struct ipc4_peak_volume_module_cfg {
struct ipc4_base_module_cfg base_cfg;
struct ipc4_peak_volume_config config[0];
struct ipc4_peak_volume_config config[];
} __packed __aligned(8);
#endif

View File

@ -179,7 +179,7 @@ struct ipc4_pipeline_set_state_data {
/**< Number of items in ppl_id[] */
uint32_t pipelines_count;
/**< Pipeline ids */
uint32_t ppl_id[0];
uint32_t ppl_id[];
} __attribute__((packed, aligned(4)));
struct ipc4_pipeline_set_state {

View File

@ -112,7 +112,7 @@ struct ipc4_ssp_configuration_blob {
struct ipc4_ssp_driver_config i2s_driver_config;
/* optional configuration parameters */
union ipc4_ssp_dma_control i2s_dma_control[0];
union ipc4_ssp_dma_control i2s_dma_control[];
} __attribute__((packed, aligned(4)));
#endif

View File

@ -42,7 +42,7 @@ struct sof_abi_hdr {
/**< The version is valid in scope of the 'magic', */
/**< IPC3 and IPC4 ABI version numbers have no relationship. */
uint32_t reserved[4]; /**< reserved for future use */
uint32_t data[0]; /**< Component data - opaque to core */
uint32_t data[]; /**< Component data - opaque to core */
} __attribute__((packed));
#endif /* __KERNEL_HEADER_H__ */

View File

@ -47,7 +47,7 @@ typedef struct _ModuleEventNotification {
uint32_t event_data_size; /*!< Size of event_data array in bytes. May be set to 0
* in case there is no data.
*/
uint32_t event_data[0]; /*< Optional event data (size set to 0 as it is optional
uint32_t event_data[]; /*!< Optional event data (size set to 0 as it is optional
* data)
*/
} ModuleEventNotification;