summaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/lm93.c
diff options
context:
space:
mode:
authorGustavo A. R. Silva <gustavo@embeddedor.com>2019-07-11 20:52:58 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2019-07-12 11:05:41 -0700
commit0e71666b8b9e21e4cb5d805219eb5ed7c5617ca3 (patch)
treec791bc0d2604fe47185af1228fe762ffe1928d6d /drivers/hwmon/lm93.c
parente926d8a1e8675422e53104855a7bedec82fb570f (diff)
downloadlinux-0e71666b8b9e21e4cb5d805219eb5ed7c5617ca3.tar.gz
linux-0e71666b8b9e21e4cb5d805219eb5ed7c5617ca3.tar.bz2
linux-0e71666b8b9e21e4cb5d805219eb5ed7c5617ca3.zip
ocfs2/dlm: 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 dlm_migratable_lockres { ... struct dlm_migratable_lock ml[0]; // 16 bytes each, begins at byte 112 }; 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 dlm_migratable_lockres) + (mres->num_locks * sizeof(struct dlm_migratable_lock)) with: struct_size(mres, ml, mres->num_locks) Notice that, in this case, variable sz is not necessary, hence it is removed. This code was detected with the help of Coccinelle. Link: http://lkml.kernel.org/r/20190605204926.GA24467@embeddedor Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com> Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com> Cc: Mark Fasheh <mark@fasheh.com> Cc: Joel Becker <jlbec@evilplan.org> Cc: Junxiao Bi <junxiao.bi@oracle.com> Cc: Changwei Ge <gechangwei@live.cn> Cc: Gang He <ghe@suse.com> Cc: Jun Piao <piaojun@huawei.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/hwmon/lm93.c')
0 files changed, 0 insertions, 0 deletions