lkml.org 
[lkml]   [2020]   [Jun]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] overflow.h: Add flex_array_size() helper
On Mon, Jun 08, 2020 at 03:34:52PM -0700, Joe Perches wrote:
> On Mon, 2020-06-08 at 17:17 -0500, Gustavo A. R. Silva wrote:
> > Add flex_array_size() helper for the calculation of the size, in bytes,
> > of a flexible array member contained within an enclosing structure.
> >
> > Example of usage:
> > foo
> > struct something {
> > size_t count;
> > struct foo items[];
> > };
> >
> > struct something *instance;
> []
> > diff --git a/include/linux/overflow.h b/include/linux/overflow.h
> []
> > +/**
> > + * flex_array_size() - Calculate size of a flexible array member within
> > + * an enclosing structure.
>
> These comment descriptions do not match
>
> > + * Calculates size of memory needed for flexible array @member of @count
> > + * elements within structure @p.
>
> The first comment shows the size of an array member.
> The second shows the size of an array member * count
>
> Also the struct_size and flex_array_size definitions
> are using two different forms:
>
> sizeof(*(p)->member) + __must_be_array((p)->member),\
> and
> sizeof((p)->member[0]) + __must_be_array((p)->member))
>

Good catch.

Thanks
--
Gustavo

\
 
 \ /
  Last update: 2020-06-09 02:43    [W:0.056 / U:0.056 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site