rand/noise.c (noise_devrandom): Refactor internals.
authorMark Wooding <mdw@distorted.org.uk>
Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sat, 4 Jun 2016 13:55:30 +0000 (14:55 +0100)
commitc22fa0c92e942bb1f7681cc6a28398ed1e6ddd49
treebe16e8910f847d5add79aff411f9c9b18573c014
parent9332366ee32e7c89e9d2fabbe9755cbd86877127
rand/noise.c (noise_devrandom): Refactor internals.

The objective is to make adding new ways of collecting high-quality
system entropy easier.

  * Add labels for success and exit, to make sure that whatever we add
    whatever's in the buffer to the pool, and then clear out the buffer.

  * Initialize `fd' to `-1' at the top, and close it on the way out to
    make sure it doesn't leak.

  * Change the main `open' condition to allow something to have opened the
    right file already.

This shouldn't change any observable behaviour, but it will make things
easier in future.
rand/noise.c