diff options
author | 2019-04-03 12:02:36 -0500 | |
---|---|---|
committer | 2019-04-04 19:38:36 +0300 | |
commit | 95336d4cb588860283047e01050ae41993e0147d (patch) | |
tree | c926ac9bcd1f72c6851b15ea9ef3a31bef02df9e /tools/perf/scripts/python | |
parent | rtlwifi: move spin_lock_bh to spin_lock in tasklet (diff) | |
download | wireguard-linux-95336d4cb588860283047e01050ae41993e0147d.tar.xz wireguard-linux-95336d4cb588860283047e01050ae41993e0147d.zip |
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>
Diffstat (limited to 'tools/perf/scripts/python')
0 files changed, 0 insertions, 0 deletions