commit 2ddd93b4423b94578868e2701c265f8da4350965
parent 38da4384d3b4630787430b9b38bd4726e00cc7d9
Author: Laurent Bercot <ska-skaware@skarnet.org>
Date: Fri, 4 Dec 2020 14:40:52 +0000
Fix iobufferk_init on recent Linux; remove last superfluous coe
Diffstat:
3 files changed, 9 insertions(+), 20 deletions(-)
diff --git a/src/librandom/random_init.c b/src/librandom/random_init.c
@@ -6,6 +6,7 @@
#include <skalibs/nonposix.h>
#include <stdlib.h>
+
#include <skalibs/random.h>
int random_init ()
@@ -45,29 +46,20 @@ SURFSchedule surf_here = SURFSCHEDULE_ZERO ;
#ifdef SKALIBS_HASDEVURANDOM
#include <errno.h>
+
#include <skalibs/djbunix.h>
int random_fd = -1 ;
int random_init ()
{
- int fd ;
char seed[160] ;
+ if (random_fd >= 0) return 1 ;
random_makeseed(seed) ;
surf_init(&surf_here, seed) ;
openwritenclose_unsafe("/dev/urandom", seed, 160) ;
- if (random_fd < 0)
- {
- fd = open_readb("/dev/urandom") ;
- if (fd < 0) return 0 ;
- if (coe(fd) < 0)
- {
- fd_close(fd) ;
- return 0 ;
- }
- random_fd = fd ;
- }
- return 1 ;
+ random_fd = openc_readb("/dev/urandom") ;
+ return random_fd >= 0 ;
}
#else /* default */
diff --git a/src/libstddjb/fd_cat.c b/src/libstddjb/fd_cat.c
@@ -1,6 +1,7 @@
/* ISC license. */
#include <sys/types.h>
+
#include <skalibs/iobuffer.h>
#include <skalibs/djbunix.h>
diff --git a/src/libstddjb/iobufferk_init.c b/src/libstddjb/iobufferk_init.c
@@ -6,18 +6,14 @@
#include <sys/stat.h>
#include <fcntl.h>
+
#include <skalibs/djbunix.h>
#include <skalibs/iobuffer.h>
static int iobufferk_init_0 (iobufferk *k)
{
- int fd = open_write("/dev/null") ;
+ int fd = openc_write("/dev/null") ;
if (fd < 0) return 0 ;
- if (coe(fd) < 0)
- {
- fd_close(fd) ;
- return 0 ;
- }
k->p[0] = -1 ;
k->p[1] = fd ;
return 1 ;
@@ -31,7 +27,7 @@ static int iobufferk_nofd (iobufferk *k)
static int iobufferk_init_3 (iobufferk *k)
{
- return (pipenbcoe(k->p) >= 0) ;
+ return (pipecoe(k->p) >= 0) ;
}
static iobufferk_output_func_t_ref iobufferk_init_f[4] =