mirror of
https://github.com/outbackdingo/mt76.git
synced 2026-10-24 13:26:48 +00:00
Zero-length arrays as fake flexible arrays are deprecated and we are
moving towards adopting C99 flexible-array members instead.
Address the following warnings found with GCC-13 and
-fstrict-flex-arrays=3 enabled:
drivers/net/wireless/mediatek/mt76/mt7921/acpi_sar.c:266:25: warning: array subscript 0 is outside array bounds of ‘struct mt7921_asar_dyn_limit_v2[0]’ [-Warray-bounds=]
drivers/net/wireless/mediatek/mt76/mt7921/acpi_sar.c:263:25: warning: array subscript 0 is outside array bounds of ‘struct mt7921_asar_dyn_limit[0]’ [-Warray-bounds=]
drivers/net/wireless/mediatek/mt76/mt7921/acpi_sar.c:223:28: warning: array subscript <unknown> is outside array bounds of ‘struct mt7921_asar_geo_limit_v2[0]’ [-Warray-bounds=]
drivers/net/wireless/mediatek/mt76/mt7921/acpi_sar.c:220:28: warning: array subscript <unknown> is outside array bounds of ‘struct mt7921_asar_geo_limit[0]’ [-Warray-bounds=]
drivers/net/wireless/mediatek/mt76/mt7921/acpi_sar.c:334:37: warning: array subscript i is outside array bounds of ‘u8[0]’ {aka ‘unsigned char[]’} [-Warray-bounds=]
Notice that the DECLARE_FLEX_ARRAY() helper allows for flexible-array
members in unions.
This helps with the ongoing efforts to tighten the FORTIFY_SOURCE
routines on memcpy() and help us make progress towards globally
enabling -fstrict-flex-arrays=3 [1].
Link: https://github.com/KSPP/linux/issues/21
Link: https://github.com/KSPP/linux/issues/272
Link: https://gcc.gnu.org/pipermail/gcc-patches/2022-October/602902.html [1]
Signed-off-by: Gustavo A. R. Silva <[email protected]>
Reviewed-by: Simon Horman <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
106 lines
1.8 KiB
C
106 lines
1.8 KiB
C
/* SPDX-License-Identifier: ISC */
|
|
/* Copyright (C) 2022 MediaTek Inc. */
|
|
|
|
#ifndef __MT7921_ACPI_SAR_H
|
|
#define __MT7921_ACPI_SAR_H
|
|
|
|
#define MT7921_ASAR_MIN_DYN 1
|
|
#define MT7921_ASAR_MAX_DYN 8
|
|
#define MT7921_ASAR_MIN_GEO 3
|
|
#define MT7921_ASAR_MAX_GEO 8
|
|
#define MT7921_ASAR_MIN_FG 8
|
|
|
|
#define MT7921_ACPI_MTCL "MTCL"
|
|
#define MT7921_ACPI_MTDS "MTDS"
|
|
#define MT7921_ACPI_MTGS "MTGS"
|
|
#define MT7921_ACPI_MTFG "MTFG"
|
|
|
|
struct mt7921_asar_dyn_limit {
|
|
u8 idx;
|
|
u8 frp[5];
|
|
} __packed;
|
|
|
|
struct mt7921_asar_dyn {
|
|
u8 names[4];
|
|
u8 enable;
|
|
u8 nr_tbl;
|
|
DECLARE_FLEX_ARRAY(struct mt7921_asar_dyn_limit, tbl);
|
|
} __packed;
|
|
|
|
struct mt7921_asar_dyn_limit_v2 {
|
|
u8 idx;
|
|
u8 frp[11];
|
|
} __packed;
|
|
|
|
struct mt7921_asar_dyn_v2 {
|
|
u8 names[4];
|
|
u8 enable;
|
|
u8 rsvd;
|
|
u8 nr_tbl;
|
|
DECLARE_FLEX_ARRAY(struct mt7921_asar_dyn_limit_v2, tbl);
|
|
} __packed;
|
|
|
|
struct mt7921_asar_geo_band {
|
|
u8 pwr;
|
|
u8 offset;
|
|
} __packed;
|
|
|
|
struct mt7921_asar_geo_limit {
|
|
u8 idx;
|
|
/* 0:2G, 1:5G */
|
|
struct mt7921_asar_geo_band band[2];
|
|
} __packed;
|
|
|
|
struct mt7921_asar_geo {
|
|
u8 names[4];
|
|
u8 version;
|
|
u8 nr_tbl;
|
|
DECLARE_FLEX_ARRAY(struct mt7921_asar_geo_limit, tbl);
|
|
} __packed;
|
|
|
|
struct mt7921_asar_geo_limit_v2 {
|
|
u8 idx;
|
|
/* 0:2G, 1:5G, 2:6G */
|
|
struct mt7921_asar_geo_band band[3];
|
|
} __packed;
|
|
|
|
struct mt7921_asar_geo_v2 {
|
|
u8 names[4];
|
|
u8 version;
|
|
u8 rsvd;
|
|
u8 nr_tbl;
|
|
DECLARE_FLEX_ARRAY(struct mt7921_asar_geo_limit_v2, tbl);
|
|
} __packed;
|
|
|
|
struct mt7921_asar_cl {
|
|
u8 names[4];
|
|
u8 version;
|
|
u8 mode_6g;
|
|
u8 cl6g[6];
|
|
} __packed;
|
|
|
|
struct mt7921_asar_fg {
|
|
u8 names[4];
|
|
u8 version;
|
|
u8 rsvd;
|
|
u8 nr_flag;
|
|
u8 rsvd1;
|
|
u8 flag[];
|
|
} __packed;
|
|
|
|
struct mt7921_acpi_sar {
|
|
u8 ver;
|
|
union {
|
|
struct mt7921_asar_dyn *dyn;
|
|
struct mt7921_asar_dyn_v2 *dyn_v2;
|
|
};
|
|
union {
|
|
struct mt7921_asar_geo *geo;
|
|
struct mt7921_asar_geo_v2 *geo_v2;
|
|
};
|
|
struct mt7921_asar_cl *countrylist;
|
|
struct mt7921_asar_fg *fg;
|
|
};
|
|
|
|
#endif
|