skalibs

Mirror/fork of https://skarnet.org/software/skalibs/
git clone https://ccx.te2000.cz/git/skalibs
Log | Files | Refs | README | LICENSE

commit 422d91b2b0a2b8b3a8af510cc55b1400c60be303
parent 58b993dd48fe140047c326a82dea9ec3055cf334
Author: Laurent Bercot <ska-skaware@skarnet.org>
Date:   Mon, 24 Oct 2016 02:07:21 +0000

 This one escaped the previous commit: random_init changes

Diffstat:
Msrc/librandom/random_init.c | 24++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/src/librandom/random_init.c b/src/librandom/random_init.c @@ -34,16 +34,20 @@ int random_init () } #else -#ifdef SKALIBS_HASDEVURANDOM -#include <skalibs/djbunix.h> #include <skalibs/surf.h> #include <skalibs/random.h> #include "random-internal.h" -int random_fd = -1 ; SURFSchedule surf_here = SURFSCHEDULE_ZERO ; +#ifdef SKALIBS_HASDEVURANDOM + +#include <errno.h> +#include <skalibs/djbunix.h> + +int random_fd = -1 ; + int random_init () { int fd ; @@ -55,7 +59,13 @@ int random_init () { fd = open_readb("/dev/urandom") ; if (fd < 0) return 0 ; - if (coe(fd) < 0) { fd_close(fd) ; return 0 ; } + if (coe(fd) < 0) + { + int e = errno ; + fd_close(fd) ; + errno = e ; + return 0 ; + } random_fd = fd ; } return 1 ; @@ -63,12 +73,6 @@ int random_init () #else /* default */ -#include <skalibs/surf.h> -#include <skalibs/random.h> -#include "random-internal.h" - -SURFSchedule surf_here = SURFSCHEDULE_ZERO ; - int random_init () { char seed[160] ;