Re: [PATCH v2] random: make more consistent use of integer types

From: Jason A. Donenfeld
Date: Mon Feb 21 2022 - 10:04:28 EST


On Mon, Feb 21, 2022 at 4:54 AM Eric Biggers <ebiggers@xxxxxxxxxx> wrote:
> > -static size_t crng_fast_load(const u8 *cp, size_t len)
> > +static size_t crng_fast_load(const void *cp, size_t len)
> > {
> > unsigned long flags;
> > - u8 *p;
> > + u8 *src = (u8 *)cp;
>
> This should use 'const u8 *'.

Will fix.

>
> > int __init rand_initialize(void)
> > {
> > - int i;
> > + size_t i;
> > ktime_t now = ktime_get_real();
>
> This introduces an assumption that BLAKE2S_BLOCK_SIZE % sizeof(unsigned long) ==
> 0. That happens to always be true, but it would be better to either not change
> this, or rewrite the loop to 'i = 0; i < BLAKE2S_BLOCK_SIZE; i += sizeof(rv)'

Good idea; I'll rewrite the loop. That always bothered me too.

Jason