linux/drivers/net/ethernet/toshiba
Gustavo A. R. Silva 3f1071ec39 net: spider_net: Use struct_size() helper
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 spider_net_card {
	...
        struct spider_net_descr darray[0];
};

Make use of the struct_size() helper instead of an open-coded version
in order to avoid any potential type mistakes.

So, replace the following form:

sizeof(struct spider_net_card) + (tx_descriptors + rx_descriptors) * sizeof(struct spider_net_descr)

with:

struct_size(card, darray, tx_descriptors + rx_descriptors)

Notice that, in this case, variable alloc_size is not necessary, hence it
is removed.

Building: allmodconfig powerpc.

This code was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-08-29 17:53:59 -07:00
..
Kconfig treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
ps3_gelic_net.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 153 2019-05-30 11:26:32 -07:00
ps3_gelic_net.h ps3_gelic: Use [] to denote a flexible array member 2019-06-18 10:43:20 -07:00
ps3_gelic_wireless.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 176 2019-05-30 11:29:19 -07:00
ps3_gelic_wireless.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 301 2019-06-05 17:37:00 +02:00
spider_net_ethtool.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 153 2019-05-30 11:26:32 -07:00
spider_net.c net: spider_net: Use struct_size() helper 2019-08-29 17:53:59 -07:00
spider_net.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 153 2019-05-30 11:26:32 -07:00
tc35815.c net: tc35815: Explicitly check NET_IP_ALIGN is not zero in tc35815_rx 2019-08-11 21:41:48 -07:00