tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Patch: CPU RNG framework with stub x86 implementation



On Mon, Jan 11, 2016 at 21:59:20 -0500, Thor Lancelot Simon wrote:

> On Mon, Jan 11, 2016 at 07:58:09PM -0500, Andrew Cagney wrote:
> > On 10 January 2016 at 21:08, Thor Lancelot Simon <tls%panix.com@localhost> wrote:
> > > As requested - here's just "cpu_rng" itself for review.  I believe this
> > > version addresses all comments received so far except that I _like_ the
> > > construct "size_t cnt = <constant>; type_t foo[x]" so I've retained
> > > that.
> > 
> > According to that ever reliable wikipedia :-)
> > 
> > + size_t cnt = 2 * RND_ENTROPY_THRESHOLD / sizeof(cpu_rng_t);
> > + cpu_rng_t buf[cnt];
> > 
> > variable-length arrays were added in C99, but subsequently, in C11,
> > were relegated to a conditional feature which implementations are not
> > required to support.
> 
> That's not a variable-length array.

It definitely looks like one to me.

    6.7.5.2  Array declarators

    [#4] ... If the size is an integer constant expression and the
    element type has a known constant size, the array type is not a
    variable length array type; otherwise, the array type is a
    variable length array type.

and

    6.6  Constant expressions

    [#6] An integer constant expression shall have integer type and
    shall only have operands that are integer constants, enumeration
    constants, character constants, sizeof expressions whose results
    are integer constants, and floating constants that are the
    immediate operands of casts.  Cast operators in an integer
    constant expression shall only convert arithmetic types to integer
    types, except as part of an operand to the sizeof operator.

And gcc -ansi -pedantic complains about

    size_t cnt = 128;
    int vla[cnt];

    warning: ISO C90 forbids variable length array ?vla? [-Wvla]

Constifying cnt doesn't change that since 'cnt' is still not an
constant expression.

-uwe


Home | Main Index | Thread Index | Old Index