ath: Replace zero-length array with flexible-array member
Subsystems (10)
PATCH 1/1 ath: Replace zero-length array with flexible-array member
The current codebase makes use of the zero-length array language extension to the C90 standard, but the preferred mechanism to declare variable-length types such as these ones is a flexible array member[1][2], introduced in C99:
struct foo {
int stuff;
struct boo array[];
};By making use of the mechanism above, we will get a compiler warning in case the flexible array does not occur last in the structure, which will help us prevent some kind of undefined behavior bugs from being inadvertently introduced[3] to the codebase from now on.
Also, notice that, dynamic memory allocations won't be affected by this change:
"Flexible array members have incomplete type, and so the sizeof operator may not be applied. As a quirk of the original implementation of zero-length arrays, sizeof evaluates to zero."[1]
This issue was detected with the help of Coccinelle.
[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[2] https://github.com/KSPP/linux/issues/21
[3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour")
--- drivers/net/wireless/ath/ath10k/ce.h | 2 +- drivers/net/wireless/ath/ath10k/core.h | 2 +- drivers/net/wireless/ath/ath10k/coredump.h | 4 +- drivers/net/wireless/ath/ath10k/debug.h | 2 +- drivers/net/wireless/ath/ath10k/hw.h | 2 +- drivers/net/wireless/ath/ath10k/pci.h | 2 +- drivers/net/wireless/ath/ath10k/swap.h | 2 +- drivers/net/wireless/ath/ath10k/wmi-tlv.h | 6 +- drivers/net/wireless/ath/ath10k/wmi.h | 42 +++++++------- drivers/net/wireless/ath/ath11k/ce.h | 2 +- drivers/net/wireless/ath/ath11k/debug.h | 2 +- .../net/wireless/ath/ath11k/debug_htt_stats.h | 8 +-- drivers/net/wireless/ath/ath11k/dp.h | 10 ++-- drivers/net/wireless/ath/ath11k/hal_desc.h | 4 +- drivers/net/wireless/ath/ath11k/hal_rx.h | 2 +- drivers/net/wireless/ath/ath11k/hw.h | 2 +- drivers/net/wireless/ath/ath11k/rx_desc.h | 2 +- drivers/net/wireless/ath/ath11k/wmi.h | 2 +- drivers/net/wireless/ath/ath6kl/core.h | 4 +- drivers/net/wireless/ath/ath6kl/debug.c | 2 +- drivers/net/wireless/ath/ath6kl/hif.h | 2 +- drivers/net/wireless/ath/ath6kl/wmi.h | 26 ++++----- drivers/net/wireless/ath/carl9170/fwcmd.h | 2 +- drivers/net/wireless/ath/carl9170/fwdesc.h | 2 +- drivers/net/wireless/ath/carl9170/hw.h | 2 +- drivers/net/wireless/ath/carl9170/wlan.h | 2 +- drivers/net/wireless/ath/spectral_common.h | 2 +- drivers/net/wireless/ath/wcn36xx/hal.h | 4 +- drivers/net/wireless/ath/wcn36xx/testmode.h | 2 +- drivers/net/wireless/ath/wil6210/fw.h | 16 ++--- drivers/net/wireless/ath/wil6210/wmi.c | 2 +- drivers/net/wireless/ath/wil6210/wmi.h | 58 +++++++++---------- 32 files changed, 112 insertions(+), 112 deletions(-)
drivers/net/wireless/ath/ath10k/ce.h +1 -1
@@ -110,7 +110,7 @@ struct ath10k_ce_ring {struct ce_desc_64 *shadow_base;/* keep last */ -void *per_transfer_context[0 ]; +void *per_transfer_context[]; };struct ath10k_ce_pipe {
drivers/net/wireless/ath/ath10k/core.h +1 -1
@@ -1223,7 +1223,7 @@ struct ath10k {struct completion peer_delete_done;/* must be last */ -u8 drv_priv[0 ]__aligned(sizeof(void *)) ; +u8 drv_priv[]__aligned(sizeof(void *)) ; };static inline bool ath10k_peer_stats_enabled (struct ath10k *ar)
drivers/net/wireless/ath/ath10k/coredump.h +2 -2
@@ -88,7 +88,7 @@ struct ath10k_dump_file_data {u8 unused[128 ];/* struct ath10k_tlv_dump_data + more */ -u8 data[0 ]; +u8 data[]; } __packed;struct ath10k_dump_ram_data_hdr {
@@ -100,7 +100,7 @@ struct ath10k_dump_ram_data_hdr {/* length of payload data, not including this header */ __le32 length; -u8 data[0 ]; +u8 data[]; };/* magic number to fill the holes not copied due to sections in regions */
drivers/net/wireless/ath/ath10k/debug.h +1 -1
@@ -65,7 +65,7 @@ struct ath10k_pktlog_hdr {__le16 log_type;/* Type of log information foll this header */ __le16 size;/* Size of variable length log information in bytes */ __le32 timestamp; -u8 payload[0 ]; +u8 payload[]; } __packed;/* FIXME: How to calculate the buffer size sanely? */
drivers/net/wireless/ath/ath10k/hw.h +1 -1
@@ -165,7 +165,7 @@ enum qca9377_chip_id_rev {struct ath10k_fw_ie {__le32 id;__le32 len; -u8 data[0 ]; +u8 data[]; };enum ath10k_fw_ie_type {
drivers/net/wireless/ath/ath10k/pci.h +1 -1
@@ -182,7 +182,7 @@ struct ath10k_pci {* allocated (ahb support enabled case) in the continuation of * this struct. */ -struct ath10k_ahb ahb[0 ]; +struct ath10k_ahb ahb[]; };static inline struct ath10k_pci *ath10k_pci_priv (struct ath10k *ar)
drivers/net/wireless/ath/ath10k/swap.h +1 -1
@@ -17,7 +17,7 @@ struct ath10k_fw_file;struct ath10k_swap_code_seg_tlv {__le32 address;__le32 length; -u8 data[0 ]; +u8 data[]; } __packed;struct ath10k_swap_code_seg_tail {
drivers/net/wireless/ath/ath10k/wmi-tlv.h +3 -3
@@ -1623,7 +1623,7 @@ wmi_tlv_svc_map_ext(const __le32 *in, unsigned long *out, size_t len)struct wmi_tlv {__le16 len;__le16 tag; -u8 value[0 ]; +u8 value[]; } __packed;struct ath10k_mgmt_tx_pkt_addr {
@@ -2023,7 +2023,7 @@ struct wmi_tlv_bcn_tx_status_ev {struct wmi_tlv_bcn_prb_info {__le32 caps;__le32 erp; -u8 ies[0 ]; +u8 ies[]; } __packed;struct wmi_tlv_bcn_tmpl_cmd {
@@ -2054,7 +2054,7 @@ struct wmi_tlv_diag_item {__le16 len;__le32 timestamp;__le32 code; -u8 payload[0 ]; +u8 payload[]; } __packed;struct wmi_tlv_diag_data_ev {
drivers/net/wireless/ath/ath10k/wmi.h +21 -21
164 lines not on this page · raw message
drivers/net/wireless/ath/ath11k/ce.h +1 -1
@@ -144,7 +144,7 @@ struct ath11k_ce_ring {u32 hal_ring_id;/* keep last */ -struct sk_buff *skb[0 ]; +struct sk_buff *skb[]; };struct ath11k_ce_pipe {
drivers/net/wireless/ath/ath11k/debug.h +1 -1
@@ -65,7 +65,7 @@ struct debug_htt_stats_req {u8 peer_addr[ETH_ALEN ];struct completion cmpln;u32 buf_len; -u8 buf[0 ]; +u8 buf[]; };#define ATH11K_HTT_STATS_BUF_SIZE (1024 * 512)
drivers/net/wireless/ath/ath11k/debug_htt_stats.h +4 -4
@@ -237,7 +237,7 @@ struct htt_tx_pdev_stats_tx_ppdu_stats_tlv_v {*/ struct htt_tx_pdev_stats_tried_mpdu_cnt_hist_tlv_v {u32 hist_bin_size; -u32 tried_mpdu_cnt_hist[0 ];/* HTT_TX_PDEV_TRIED_MPDU_CNT_HIST */ +u32 tried_mpdu_cnt_hist[];/* HTT_TX_PDEV_TRIED_MPDU_CNT_HIST */ };/* == SOC ERROR STATS == */
@@ -548,7 +548,7 @@ struct htt_tx_hwq_stats_cmn_tlv {struct htt_tx_hwq_difs_latency_stats_tlv_v {u32 hist_intvl;/* histogram of ppdu post to hwsch - > cmd status received */ -u32 difs_latency_hist[0 ];/* HTT_TX_HWQ_MAX_DIFS_LATENCY_BINS */ +u32 difs_latency_hist[];/* HTT_TX_HWQ_MAX_DIFS_LATENCY_BINS */ };/* NOTE: Variable length TLV, use length spec to infer array size */
@@ -584,7 +584,7 @@ struct htt_tx_hwq_fes_result_stats_tlv_v {struct htt_tx_hwq_tried_mpdu_cnt_hist_tlv_v {u32 hist_bin_size;/* Histogram of number of mpdus on tried mpdu */ -u32 tried_mpdu_cnt_hist[0 ];/* HTT_TX_HWQ_TRIED_MPDU_CNT_HIST */ +u32 tried_mpdu_cnt_hist[];/* HTT_TX_HWQ_TRIED_MPDU_CNT_HIST */ };/* NOTE: Variable length TLV, use length spec to infer array size
@@ -1582,7 +1582,7 @@ struct htt_pdev_stats_twt_session_tlv {struct htt_pdev_stats_twt_sessions_tlv {u32 pdev_id;u32 num_sessions; -struct htt_pdev_stats_twt_session_tlv twt_session[0 ]; +struct htt_pdev_stats_twt_session_tlv twt_session[]; };enum htt_rx_reo_resource_sample_id_enum {
drivers/net/wireless/ath/ath11k/dp.h +5 -5
@@ -1022,12 +1022,12 @@ struct ath11k_htt_ppdu_stats_msg {u32 ppdu_id;u32 timestamp;u32 rsvd; -u8 data[0 ]; +u8 data[]; } __packed;struct htt_tlv {u32 header; -u8 value[0 ]; +u8 value[]; } __packed;#define HTT_TLV_TAG GENMASK(11, 0)
@@ -1205,7 +1205,7 @@ struct htt_ppdu_stats_usr_cmn_array {* tx_ppdu_stats_info is variable length, with length = * number_of_ppdu_stats * sizeof (struct htt_tx_ppdu_stats_info) */ -struct htt_tx_ppdu_stats_info tx_ppdu_info[0 ]; +struct htt_tx_ppdu_stats_info tx_ppdu_info[]; } __packed;struct htt_ppdu_user_stats {
@@ -1267,7 +1267,7 @@ struct htt_ppdu_stats_info {*/ struct htt_pktlog_msg {u32 hdr; -u8 payload[0 ]; +u8 payload[]; };/**
@@ -1487,7 +1487,7 @@ struct ath11k_htt_extd_stats_msg {u32 info0;u64 cookie;u32 info1; -u8 data[0 ]; +u8 data[]; } __packed;struct htt_mac_addr {
drivers/net/wireless/ath/ath11k/hal_desc.h +2 -2
@@ -477,7 +477,7 @@ enum hal_tlv_tag {struct hal_tlv_hdr {u32 tl; -u8 value[0 ]; +u8 value[]; } __packed;#define RX_MPDU_DESC_INFO0_MSDU_COUNT GENMASK(7, 0)
@@ -1972,7 +1972,7 @@ struct hal_rx_reo_queue {u32 processed_total_bytes;u32 info5;u32 rsvd[3 ]; -struct hal_rx_reo_queue_ext ext_desc[0 ]; +struct hal_rx_reo_queue_ext ext_desc[]; } __packed;/* hal_rx_reo_queue
drivers/net/wireless/ath/ath11k/hal_rx.h +1 -1
@@ -23,7 +23,7 @@ struct hal_rx_wbm_rel_info {struct hal_rx_mon_status_tlv_hdr {u32 hdr; -u8 value[0 ]; +u8 value[]; };enum hal_rx_su_mu_coding {
drivers/net/wireless/ath/ath11k/hw.h +1 -1
@@ -110,7 +110,7 @@ struct ath11k_hw_params {struct ath11k_fw_ie {__le32 id;__le32 len; -u8 data[0 ]; +u8 data[]; };enum ath11k_bd_ie_board_type {
drivers/net/wireless/ath/ath11k/rx_desc.h +1 -1
@@ -1206,7 +1206,7 @@ struct hal_rx_desc {__le32 hdr_status_tag;__le32 phy_ppdu_id;u8 hdr_status[HAL_RX_DESC_HDR_STATUS_LEN ]; - u8 msdu_payload[0]; + u8 msdu_payload[]; } __packed;#endif /* ATH11K_RX_DESC_H */
drivers/net/wireless/ath/ath11k/wmi.h +1 -1
@@ -39,7 +39,7 @@ struct wmi_cmd_hdr {struct wmi_tlv {u32 header; -u8 value[0 ]; +u8 value[]; } __packed;#define WMI_TLV_LEN GENMASK(15, 0)
drivers/net/wireless/ath/ath6kl/core.h +2 -2
@@ -160,7 +160,7 @@ enum ath6kl_fw_capability {struct ath6kl_fw_ie {__le32 id;__le32 len; -u8 data[0 ]; +u8 data[]; };enum ath6kl_hw_flags {
@@ -406,7 +406,7 @@ struct ath6kl_mgmt_buff {u32 id;bool no_cck;size_t len; -u8 buf[0 ]; +u8 buf[]; };struct ath6kl_sta {
drivers/net/wireless/ath/ath6kl/debug.c +1 -1
@@ -30,7 +30,7 @@ struct ath6kl_fwlog_slot {__le32 length;/* max ATH6KL_FWLOG_PAYLOAD_SIZE bytes */ -u8 payload[0 ]; +u8 payload[]; };#define ATH6KL_FWLOG_MAX_ENTRIES 20
drivers/net/wireless/ath/ath6kl/hif.h +1 -1
@@ -199,7 +199,7 @@ struct hif_scatter_req {u32 scat_q_depth; -struct hif_scatter_item scat_list[0 ]; +struct hif_scatter_item scat_list[]; };struct ath6kl_irq_proc_registers {
drivers/net/wireless/ath/ath6kl/wmi.h +13 -13
@@ -1637,7 +1637,7 @@ struct bss_bias {struct bss_bias_info {u8 num_bss; -struct bss_bias bss_bias[0 ]; +struct bss_bias bss_bias[]; } __packed;struct low_rssi_scan_params {
@@ -1720,7 +1720,7 @@ struct wmi_neighbor_info {struct wmi_neighbor_report_event {u8 num_neighbors; -struct wmi_neighbor_info neighbor[0 ]; +struct wmi_neighbor_info neighbor[]; } __packed;/* TKIP MIC Error Event */
@@ -2051,7 +2051,7 @@ struct wmi_get_keepalive_cmd {struct wmi_set_appie_cmd {u8 mgmt_frm_type;/* enum wmi_mgmt_frame_type */ u8 ie_len; -u8 ie_info[0 ]; +u8 ie_info[]; } __packed;struct wmi_set_ie_cmd {
@@ -2059,7 +2059,7 @@ struct wmi_set_ie_cmd {u8 ie_field;/* enum wmi_ie_field_type */ u8 ie_len;u8 reserved; -u8 ie_info[0 ]; +u8 ie_info[]; } __packed;/* Notify the WSC registration status to the target */
@@ -2127,7 +2127,7 @@ struct wmi_add_wow_pattern_cmd {u8 filter_list_id;u8 filter_size;u8 filter_offset; -u8 filter[0 ]; +u8 filter[]; } __packed;struct wmi_del_wow_pattern_cmd {
@@ -2360,7 +2360,7 @@ struct wmi_send_action_cmd {__le32 freq;__le32 wait;__le16 len; -u8 data[0 ]; +u8 data[]; } __packed;struct wmi_send_mgmt_cmd {
@@ -2369,7 +2369,7 @@ struct wmi_send_mgmt_cmd {__le32 wait;__le32 no_cck;__le16 len; -u8 data[0 ]; +u8 data[]; } __packed;struct wmi_tx_status_event {
@@ -2389,7 +2389,7 @@ struct wmi_set_appie_extended_cmd {u8 role_id;u8 mgmt_frm_type;u8 ie_len; -u8 ie_info[0 ]; +u8 ie_info[]; } __packed;struct wmi_remain_on_chnl_event {
@@ -2406,18 +2406,18 @@ struct wmi_cancel_remain_on_chnl_event {struct wmi_rx_action_event {__le32 freq;__le16 len; -u8 data[0 ]; +u8 data[]; } __packed;struct wmi_p2p_capabilities_event {__le16 len; -u8 data[0 ]; +u8 data[]; } __packed;struct wmi_p2p_rx_probe_req_event {__le32 freq;__le16 len; -u8 data[0 ]; +u8 data[]; } __packed;#define P2P_FLAG_CAPABILITIES_REQ (0x00000001)
@@ -2431,7 +2431,7 @@ struct wmi_get_p2p_info {struct wmi_p2p_info_event {__le32 info_req_flags;__le16 len; -u8 data[0 ]; +u8 data[]; } __packed;struct wmi_p2p_capabilities {
@@ -2450,7 +2450,7 @@ struct wmi_p2p_probe_response_cmd {__le32 freq;u8 destination_addr[ETH_ALEN ];__le16 len; -u8 data[0 ]; +u8 data[]; } __packed;/* Extended WMI (WMIX)
drivers/net/wireless/ath/carl9170/fwcmd.h +1 -1
@@ -127,7 +127,7 @@ struct carl9170_write_reg {struct carl9170_write_reg_byte {__le32 addr;__le32 count; -u8 val[0 ]; +u8 val[]; } __packed;#define CARL9170FW_PHY_HT_ENABLE 0x4
drivers/net/wireless/ath/carl9170/fwdesc.h +1 -1
@@ -149,7 +149,7 @@ struct carl9170fw_fix_entry {struct carl9170fw_fix_desc {struct carl9170fw_desc_head head; -struct carl9170fw_fix_entry data[0 ]; +struct carl9170fw_fix_entry data[]; } __packed;#define CARL9170FW_FIX_DESC_SIZE \ (sizeof(struct carl9170fw_fix_desc))
drivers/net/wireless/ath/carl9170/hw.h +1 -1
@@ -851,7 +851,7 @@ struct ar9170_stream {__le16 length;__le16 tag; -u8 payload[0 ]; +u8 payload[]; } __packed__aligned(4) ;#define AR9170_STREAM_LEN 4
drivers/net/wireless/ath/carl9170/wlan.h +1 -1
@@ -327,7 +327,7 @@ struct _carl9170_tx_superdesc {struct _carl9170_tx_superframe {struct _carl9170_tx_superdesc s;struct _ar9170_tx_hwdesc f; -u8 frame_data[0 ]; +u8 frame_data[]; } __packed__aligned(4) ;#define CARL9170_TX_SUPERDESC_LEN 24
drivers/net/wireless/ath/spectral_common.h +1 -1
@@ -107,7 +107,7 @@ struct fft_sample_ath10k {u8 avgpwr_db;u8 max_exp; - u8 data[0]; + u8 data[]; } __packed;#endif /* SPECTRAL_COMMON_H */
drivers/net/wireless/ath/wcn36xx/hal.h +2 -2
@@ -2240,7 +2240,7 @@ struct wcn36xx_hal_process_ptt_msg_req_msg {struct wcn36xx_hal_msg_header header;/* Actual FTM Command body */ -u8 ptt_msg[0 ]; +u8 ptt_msg[]; } __packed;struct wcn36xx_hal_process_ptt_msg_rsp_msg {
@@ -2249,7 +2249,7 @@ struct wcn36xx_hal_process_ptt_msg_rsp_msg {/* FTM Command response status */ u32 ptt_msg_resp_status;/* Actual FTM Command body */ -u8 ptt_msg[0 ]; +u8 ptt_msg[]; } __packed;struct update_edca_params_req_msg {
drivers/net/wireless/ath/wcn36xx/testmode.h +1 -1
@@ -20,7 +20,7 @@ struct ftm_rsp_msg {u16 msg_id;u16 msg_body_length;u32 resp_status; -u8 msg_response[0 ]; +u8 msg_response[]; } __packed;/* The request buffer of FTM which contains a byte of command and the request */
drivers/net/wireless/ath/wil6210/fw.h +8 -8
@@ -33,7 +33,7 @@ struct wil_fw_record_head {*/ struct wil_fw_record_data {/* type == wil_fw_type_data */ __le32 addr; -__le32 data[0 ];/* [data_size], see above */ +__le32 data[];/* [data_size], see above */ } __packed;/* fill with constant @value, @size bytes starting from @addr */
@@ -61,7 +61,7 @@ struct wil_fw_record_capabilities { /* type == wil_fw_type_comment *//* identifies capabilities record */ struct wil_fw_record_comment_hdr hdr;/* capabilities (variable size), see enum wmi_fw_capability */ -u8 capabilities[0 ]; +u8 capabilities[]; } __packed;/* FW VIF concurrency encoded inside a comment record
@@ -80,7 +80,7 @@ struct wil_fw_concurrency_combo {u8 n_diff_channels;/* total number of different channels allowed */ u8 same_bi;/* for APs, 1 if all APs must have same BI */ /* keep last - concurrency limits, variable size by n_limits */ -struct wil_fw_concurrency_limit limits[0 ]; +struct wil_fw_concurrency_limit limits[]; } __packed;struct wil_fw_record_concurrency {/* type == wil_fw_type_comment */
@@ -93,7 +93,7 @@ struct wil_fw_record_concurrency { /* type == wil_fw_type_comment *//* number of concurrency combinations that follow */ __le16 n_combos;/* keep last - combinations, variable size by n_combos */ -struct wil_fw_concurrency_combo combos[0 ]; +struct wil_fw_concurrency_combo combos[]; } __packed;/* brd file info encoded inside a comment record */
@@ -108,7 +108,7 @@ struct wil_fw_record_brd_file { /* type == wil_fw_type_comment *//* identifies brd file record */ struct wil_fw_record_comment_hdr hdr;__le32 version; -struct brd_info brd_info[0 ]; +struct brd_info brd_info[]; } __packed;/* perform action
@@ -116,7 +116,7 @@ struct wil_fw_record_brd_file { /* type == wil_fw_type_comment */*/ struct wil_fw_record_action {/* type == wil_fw_type_action */ __le32 action;/* action to perform: reset, wait for fw ready etc. */ -__le32 data[0 ];/* action specific, [data_size], see above */ +__le32 data[];/* action specific, [data_size], see above */ } __packed;/* data block for struct wil_fw_record_direct_write */
@@ -179,7 +179,7 @@ struct wil_fw_record_gateway_data { /* type == wil_fw_type_gateway_data */#define WIL_FW_GW_CTL_BUSY BIT(29)/* gateway busy performing operation */ #define WIL_FW_GW_CTL_RUN BIT(30)/* start gateway operation */ __le32 command; -struct wil_fw_data_gw data[0 ];/* total size [data_size], see above */ +struct wil_fw_data_gw data[];/* total size [data_size], see above */ } __packed;/* 4-dword gateway */
@@ -201,7 +201,7 @@ struct wil_fw_record_gateway_data4 { /* type == wil_fw_type_gateway_data4 */__le32 gateway_cmd_addr;__le32 gateway_ctrl_address;/* same logic as for 1-dword gw */ __le32 command; - struct wil_fw_data_gw4 data[0]; /* total size [data_size], see above */ + struct wil_fw_data_gw4 data[]; /* total size [data_size], see above */ } __packed;#endif /* __WIL_FW_H__ */
drivers/net/wireless/ath/wil6210/wmi.c +1 -1
@@ -222,7 +222,7 @@ struct auth_no_hdr {__le16 auth_transaction;__le16 status_code;/* possibly followed by Challenge text */ -u8 variable[0 ]; +u8 variable[]; } __packed;u8 led_polarity =LED_POLARITY_LOW_ACTIVE ;
drivers/net/wireless/ath/wil6210/wmi.h +29 -29
232 lines not on this page · raw message
Signature · 7 lines
2.25.0 _______________________________________________ ath11k mailing list [email protected] http://lists.infradead.org/mailman/listinfo/ath11k
Quoted 22 lines · Gustavo A. R. Silva
The current codebase makes use of the zero-length array language extension to the C90 standard, but the preferred mechanism to declare variable-length types such as these ones is a flexible array member[1][2], introduced in C99:
struct foo { int stuff; struct boo array[]; };By making use of the mechanism above, we will get a compiler warning in case the flexible array does not occur last in the structure, which will help us prevent some kind of undefined behavior bugs from being inadvertently introduced[3] to the codebase from now on.
Also, notice that, dynamic memory allocations won't be affected by this change:
"Flexible array members have incomplete type, and so the sizeof operator may not be applied. As a quirk of the original implementation of zero-length arrays, sizeof evaluates to zero."[1]
Quoted 7 lines
This issue was detected with the help of Coccinelle.
[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[2] https://github.com/KSPP/linux/issues/21
[3] commit76497732932f("cxgb3/l2t: Fix undefined behaviour")Signed-off-by Gustavo A. R. Silva <[email protected]>
Fails to apply, please rebase on top of my ath.git master branch.
error: patch failed: drivers/net/wireless/ath/ath10k/core.h:1223
error: drivers/net/wireless/ath/ath10k/core.h: patch does not apply
error: patch failed: drivers/net/wireless/ath/ath11k/debug.h:65
error: drivers/net/wireless/ath/ath11k/debug.h: patch does not apply
error: patch failed: drivers/net/wireless/ath/ath11k/rx_desc.h:1206
error: drivers/net/wireless/ath/ath11k/rx_desc.h: patch does not apply stg import: Diff does not apply cleanly
Patch set to Changes Requested.
Signature · 8 lines
https://patchwork.kernel.org/patch/11401227/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches _______________________________________________ ath10k mailing list [email protected] http://lists.infradead.org/mailman/listinfo/ath10k
Quoted 22 lines · Gustavo A. R. Silva
The current codebase makes use of the zero-length array language extension to the C90 standard, but the preferred mechanism to declare variable-length types such as these ones is a flexible array member[1][2], introduced in C99:
struct foo { int stuff; struct boo array[]; };By making use of the mechanism above, we will get a compiler warning in case the flexible array does not occur last in the structure, which will help us prevent some kind of undefined behavior bugs from being inadvertently introduced[3] to the codebase from now on.
Also, notice that, dynamic memory allocations won't be affected by this change:
"Flexible array members have incomplete type, and so the sizeof operator may not be applied. As a quirk of the original implementation of zero-length arrays, sizeof evaluates to zero."[1]
Quoted 7 lines
This issue was detected with the help of Coccinelle.
[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[2] https://github.com/KSPP/linux/issues/21
[3] commit76497732932f("cxgb3/l2t: Fix undefined behaviour")Signed-off-by Gustavo A. R. Silva <[email protected]>
Fails to apply, please rebase on top of my ath.git master branch.
error: patch failed: drivers/net/wireless/ath/ath10k/core.h:1223
error: drivers/net/wireless/ath/ath10k/core.h: patch does not apply
error: patch failed: drivers/net/wireless/ath/ath11k/debug.h:65
error: drivers/net/wireless/ath/ath11k/debug.h: patch does not apply
error: patch failed: drivers/net/wireless/ath/ath11k/rx_desc.h:1206
error: drivers/net/wireless/ath/ath11k/rx_desc.h: patch does not apply stg import: Diff does not apply cleanly
Patch set to Changes Requested.
Signature · 3 lines
https://patchwork.kernel.org/patch/11401227/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches