[ovs-dev] [PATCH v10 4/5] dpif-netdev: refactor generic implementation

Stokes, Ian ian.stokes at intel.com
Fri Jul 12 16:59:26 UTC 2019


> On Fri, Jul 12, 2019 at 04:20:06PM +0000, Van Haaren, Harry wrote:
> > > The sizeof operator is unique among C operators in that it accepts two
> > > very different kinds of operands: an expression or a type. In general,
> > > prefer to specify an expression, e.g. int *x = xmalloc(sizeof *x);.
> When
> > > the operand of sizeof is an expression, there is no need to
> parenthesize
> > > that operand, and please don't.
> >
> > Hmmm, I get compile failures here with "sizeof uint64_t" instead of
> "sizeof(uint64_t)".
> > There's also some ambiguity possible, see here:
> https://stackoverflow.com/a/26702432
> >
> > In short, I've left the sizeof() with brackets, as code that compiles
> wins in the end.
> 
> uint64_t is an example of a type rather than an expression.  With a
> type, the parentheses are required.

Ah, thanks for clarifying Ben/Ilya.

Regards
Ian



More information about the dev mailing list