Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Yu Liao and committed by
Hans Verkuil
ba85aea8 6c4ef828

+1 -1
+1 -1
drivers/media/common/videobuf2/frame_vector.c
··· 159 159 struct frame_vector *frame_vector_create(unsigned int nr_frames) 160 160 { 161 161 struct frame_vector *vec; 162 - int size = sizeof(struct frame_vector) + sizeof(void *) * nr_frames; 162 + int size = struct_size(vec, ptrs, nr_frames); 163 163 164 164 if (WARN_ON_ONCE(nr_frames == 0)) 165 165 return NULL;