summaryrefslogtreecommitdiff
path: root/drivers/media/common/videobuf2
diff options
context:
space:
mode:
authorYu Liao <liaoyu15@huawei.com>2023-08-16 09:31:43 +0300
committerHans Verkuil <hverkuil-cisco@xs4all.nl>2023-09-27 10:40:01 +0300
commitba85aea885a195b1b6c802a4ff8edf4e014e54b5 (patch)
treef59f3ffc38bcc8edad9d92bc2a7923fe04643fa3 /drivers/media/common/videobuf2
parent6c4ef82846066bf70a07026fe56e9f209a9a5953 (diff)
downloadlinux-ba85aea885a195b1b6c802a4ff8edf4e014e54b5.tar.xz
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>
Diffstat (limited to 'drivers/media/common/videobuf2')
-rw-r--r--drivers/media/common/videobuf2/frame_vector.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/media/common/videobuf2/frame_vector.c b/drivers/media/common/videobuf2/frame_vector.c
index fd87747be9b1..41f289c75cbb 100644
--- a/drivers/media/common/videobuf2/frame_vector.c
+++ b/drivers/media/common/videobuf2/frame_vector.c
@@ -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;