summaryrefslogtreecommitdiffstats
path: root/fs/inode.c
diff options
context:
space:
mode:
authorGustavo A. R. Silva2019-03-06 00:41:48 +0100
committerLinus Torvalds2019-03-06 06:07:13 +0100
commitf402cf03fc4c5576df379e1e252a6afc17658414 (patch)
tree4ab2a4841c2a371756deb49ec33aff600060c6be /fs/inode.c
parentocfs2: fix the application IO timeout when fstrim is running (diff)
downloadkernel-qcow2-linux-f402cf03fc4c5576df379e1e252a6afc17658414.tar.gz
kernel-qcow2-linux-f402cf03fc4c5576df379e1e252a6afc17658414.tar.xz
kernel-qcow2-linux-f402cf03fc4c5576df379e1e252a6afc17658414.zip
ocfs2: Use zero-sized array and struct_size() in kzalloc()
Update the code to use a zero-sized array instead of a pointer in structure ocfs2_slot_info and use struct_size() in kzalloc(). Notice that 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; void *entry[]; }; instance = kzalloc(sizeof(struct foo) + sizeof(void *) * count, GFP_KERNEL); Instead of leaving these open-coded and prone to type mistakes, we can now use the new struct_size() helper: instance = kzalloc(struct_size(instance, entry, count), GFP_KERNEL); This code was detected with the help of Coccinelle. Link: http://lkml.kernel.org/r/20190108191903.GA22056@embeddedor Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com> Reviewed-by: Andrew Morton <akpm@linux-foundation.org> Cc: Mark Fasheh <mfasheh@versity.com> Cc: Joel Becker <jlbec@evilplan.org> Cc: Junxiao Bi <junxiao.bi@oracle.com> Cc: Joseph Qi <joseph.qi@huawei.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/inode.c')
0 files changed, 0 insertions, 0 deletions