summaryrefslogtreecommitdiff
path: root/tools/perf/scripts/python
diff options
context:
space:
mode:
authorGustavo A. R. Silva <gustavo@embeddedor.com>2019-02-23 21:51:08 +0300
committerChristoph Hellwig <hch@lst.de>2019-04-05 09:07:57 +0300
commit6b80f1d2cc5a76f0121a43a612515bc8a8976e66 (patch)
tree248338b1b7f50bd9bab7bfd03087c6fbb1ce01ed /tools/perf/scripts/python
parentcfe03c2ec46200dfefa5167e6a2bb50c0426c5f4 (diff)
downloadlinux-6b80f1d2cc5a76f0121a43a612515bc8a8976e66.tar.xz
nvmet-fc: use zero-sized array and struct_size() in kzalloc()
Update the code to use a zero-sized array instead of a pointer in structure nvmet_fc_tgt_queue 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; struct boo entry[]; }; instance = kzalloc(sizeof(struct foo) + sizeof(struct boo) * 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. Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com> Reviewed-by: James Smart <james.smart@broadcom.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'tools/perf/scripts/python')
0 files changed, 0 insertions, 0 deletions