Skip to content

Commit ba85aea

Browse files
yuliao0214Hans Verkuil
authored andcommitted
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>
1 parent 6c4ef82 commit ba85aea

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/media/common/videobuf2/frame_vector.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ EXPORT_SYMBOL(frame_vector_to_pfns);
159159
struct frame_vector *frame_vector_create(unsigned int nr_frames)
160160
{
161161
struct frame_vector *vec;
162-
int size = sizeof(struct frame_vector) + sizeof(void *) * nr_frames;
162+
int size = struct_size(vec, ptrs, nr_frames);
163163

164164
if (WARN_ON_ONCE(nr_frames == 0))
165165
return NULL;

0 commit comments

Comments
 (0)