mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-15 08:14:15 +08:00
media: use struct_size() helper
Prefer struct_size() over open-coded versions of idiom: sizeof(struct-with-flex-array) + sizeof(typeof-flex-array-elements) * count where count is the max number of items the flexible array is supposed to contain. Signed-off-by: Yu Liao <liaoyu15@huawei.com> Reviewed-by: Tomasz Figa <tfiga@chromium.org> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
This commit is contained in:
parent
6c4ef82846
commit
ba85aea885
@ -159,7 +159,7 @@ EXPORT_SYMBOL(frame_vector_to_pfns);
|
||||
struct frame_vector *frame_vector_create(unsigned int nr_frames)
|
||||
{
|
||||
struct frame_vector *vec;
|
||||
int size = sizeof(struct frame_vector) + sizeof(void *) * nr_frames;
|
||||
int size = struct_size(vec, ptrs, nr_frames);
|
||||
|
||||
if (WARN_ON_ONCE(nr_frames == 0))
|
||||
return NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user