summary refs log tree commit diff
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2016-10-24 02:07:21 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2016-10-24 02:07:21 +0000
commit422d91b2b0a2b8b3a8af510cc55b1400c60be303 (patch)
tree6b59d85a122691aa3d2f24fd57ec933380115da4
parent58b993dd48fe140047c326a82dea9ec3055cf334 (diff)
downloadskalibs-422d91b2b0a2b8b3a8af510cc55b1400c60be303.tar.gz
skalibs-422d91b2b0a2b8b3a8af510cc55b1400c60be303.tar.xz
skalibs-422d91b2b0a2b8b3a8af510cc55b1400c60be303.zip
This one escaped the previous commit: random_init changes
-rw-r--r--src/librandom/random_init.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/librandom/random_init.c b/src/librandom/random_init.c
index 6a30db1..4c9fce7 100644
--- 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] ;