Gustavo A. R. Silva 9f208eca4f mfd: sm501: Use struct_size() in devm_kzalloc()
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[];
};

instance = devm_kzalloc(dev, sizeof(struct foo) + count * sizeof(struct boo), GFP_KERNEL);

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

instance = devm_kzalloc(dev, struct_size(instance, entry, count), GFP_KERNEL);

This code was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
2019-02-07 10:43:09 +00:00
..
2019-01-15 06:24:36 +12:00
2016-11-29 08:21:33 +00:00
2018-07-04 07:17:13 +01:00
2019-01-16 13:59:34 +00:00
2018-06-12 16:19:22 -07:00
2017-07-18 08:27:18 +01:00
2016-08-10 09:25:18 +01:00
2016-08-10 09:25:18 +01:00
2019-01-16 13:59:34 +00:00
2013-07-31 13:01:29 +01:00
2015-08-11 15:09:01 +01:00
2015-09-04 11:46:02 -07:00