linux/drivers/net/wireless/quantenna
Gustavo A. R. Silva 95336d4cb5 qtnfmac: replace qtnf_cmd_acl_data_size() with struct_size()
One of the more common cases of allocation size calculations is finding
the size of a structure that has a zero-sized array at the end, along
with memory for some number of elements for that array. For example:

struct foo {
    int stuff;
    struct boo entry[];
};

size = sizeof(struct foo) + count * sizeof(struct boo);
instance = kzalloc(size, GFP_KERNEL)

Instead of leaving these open-coded and prone to type mistakes, we can
now use the new struct_size() helper:

size = struct_size(instance, entry, count);

or

instance = kzalloc(struct_size(instance, entry, count), GFP_KERNEL)

Based on the above, replace qtnf_cmd_acl_data_size() with the
new struct_size() helper.

This code was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Reviewed-by: Sergey Matyukevich <sergey.matyukevich.os@quantenna.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
2019-04-04 19:38:36 +03:00
..
qtnfmac qtnfmac: replace qtnf_cmd_acl_data_size() with struct_size() 2019-04-04 19:38:36 +03:00
Kconfig qtnfmac: use 'help' in Kconfig 2018-10-13 20:04:45 +03:00
Makefile qtnfmac: convert to SPDX license identifiers 2019-02-01 14:12:02 +02:00