From: Joe Perches <joe@perches.com>
To: "Jason A. Donenfeld" <Jason@zx2c4.com>, linux-kernel@vger.kernel.org
Cc: Dominik Brodowski <linux@dominikbrodowski.net>
Subject: Re: [PATCH] random: use symbolic constants for crng_init states
Date: Sun, 08 May 2022 05:57:18 -0700 [thread overview]
Message-ID: <d0b220993b2fb1d306bb959707ceb374596de559.camel@perches.com> (raw)
In-Reply-To: <20220508112609.138889-1-Jason@zx2c4.com>
On Sun, 2022-05-08 at 13:26 +0200, Jason A. Donenfeld wrote:
> crng_init represents a state machine, with three states, and various
> rules for transitions. For the longest time, we've been managing these
> with "0", "1", and "2", and expecting people to figure it out. To make
> the code more obvious, replace these with proper enum values
> representing the transition, and then redocument what each of these
> states mean.
good idea
> diff --git a/drivers/char/random.c b/drivers/char/random.c
[]
> @@ -72,16 +72,16 @@
[]
> -/* Various types of waiters for crng_init->2 transition. */
> +static enum {
> + CRNG_EMPTY = 0, /* Little to no entropy collected */
> + CRNG_EARLY = 1, /* At least POOL_EARLY_BITS collected */
> + CRNG_READY = 2 /* Fully iniitalized with POOL_READY_BITS collected */
typo: initialized
> enum {
> POOL_BITS = BLAKE2S_HASH_SIZE * 8,
> - POOL_INIT_BITS = POOL_BITS, /* No point in settling for less. */
> - POOL_FAST_INIT_BITS = POOL_INIT_BITS / 2
> + POOL_READY_BITS = POOL_BITS, /* When crng_init->CRNG_READY */
> + POOL_EARLY_BITS = POOL_READY_BITS / 2 /* When crng_init->CRNG_EARLY */
Seems odd to use a divisor with an enum
next prev parent reply other threads:[~2022-05-08 12:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-08 11:26 Jason A. Donenfeld
2022-05-08 12:57 ` Joe Perches [this message]
2022-05-08 17:23 ` Jason A. Donenfeld
2022-05-08 17:36 ` [PATCH v2] " Jason A. Donenfeld
2022-05-09 6:06 ` Dominik Brodowski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d0b220993b2fb1d306bb959707ceb374596de559.camel@perches.com \
--to=joe@perches.com \
--cc=Jason@zx2c4.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@dominikbrodowski.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®