Skip to content

Commit 3fd445a

Browse files
Len BakerKalle Valo
authored andcommitted
brcmfmac: Replace zero-length array with flexible array member
There is a regular need in the kernel to provide a way to declare having a dynamically sized set of trailing elements in a structure. Kernel code should always use "flexible array members"[1] for these cases. The older style of one-element or zero-length arrays should no longer be used[2]. Also, make use of the struct_size() helper in devm_kzalloc(). [1] https://en.wikipedia.org/wiki/Flexible_array_member [2] https://www.kernel.org/doc/html/v5.14/process/deprecated.html#zero-length-and-one-element-arrays Signed-off-by: Len Baker <len.baker@gmx.com> Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> Link: https://lore.kernel.org/r/20210904092217.2848-1-len.baker@gmx.com
1 parent 60fe1f8 commit 3fd445a

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

  • drivers/net/wireless/broadcom/brcm80211/brcmfmac
  • include/linux/platform_data

drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ static int brcmf_of_get_country_codes(struct device *dev,
2929
return (count == -EINVAL) ? 0 : count;
3030
}
3131

32-
cc = devm_kzalloc(dev, sizeof(*cc) + count * sizeof(*cce), GFP_KERNEL);
32+
cc = devm_kzalloc(dev, struct_size(cc, table, count), GFP_KERNEL);
3333
if (!cc)
3434
return -ENOMEM;
3535

include/linux/platform_data/brcmfmac.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ struct brcmfmac_pd_cc_entry {
125125
*/
126126
struct brcmfmac_pd_cc {
127127
int table_size;
128-
struct brcmfmac_pd_cc_entry table[0];
128+
struct brcmfmac_pd_cc_entry table[];
129129
};
130130

131131
/**

0 commit comments

Comments
 (0)