On 2023/8/16 13:12, Tomasz Figa wrote: > Hi Yu, > > > On Wed, Aug 16, 2023 at 10:52 AM Yu Liao <liaoyu15@xxxxxxxxxx> wrote: >> >> Prefer struct_size_t() 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. > > Thanks for the patch. Please see my comment inline. > >> >> Signed-off-by: Yu Liao <liaoyu15@xxxxxxxxxx> >> --- >> drivers/media/common/videobuf2/frame_vector.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/media/common/videobuf2/frame_vector.c b/drivers/media/common/videobuf2/frame_vector.c >> index 0f430ddc1f67..c6bb88859e2a 100644 >> --- a/drivers/media/common/videobuf2/frame_vector.c >> +++ b/drivers/media/common/videobuf2/frame_vector.c >> @@ -157,7 +157,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_t(struct frame_vector, ptrs, nr_frames); > > Would struct_size() be more appropriate here, since we have vec declared above? > > Best regards, > Tomasz Hi Tomasz, Thank you for the review. I'll make the suggested changes and send you the V2. Best regards, Yu > >> >> if (WARN_ON_ONCE(nr_frames == 0)) >> return NULL; >> -- >> 2.25.1 >>