diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2019-09-20 18:22:27 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2019-09-20 18:22:27 +0000 |
commit | 6011d413604df8224b91ca9f9b3d50663b60e117 (patch) | |
tree | ca36404ebcc87922d26664dd93e2c0ebd23bef67 /src/sysdeps/trygetrandom.c | |
parent | 98d3a523be4fff36f65e71c37df8b9e127b12b83 (diff) | |
download | skalibs-6011d413604df8224b91ca9f9b3d50663b60e117.tar.xz |
sysdeps redesign: first part: minimize clr tests
Remaining clr:
emptyregex: can be safely guessed to no
nullispointer: can't be safely guessed, but do we need the test?
devurandom: can't be safely guessed
malloc0: can more or less be safely guessed to no
Diffstat (limited to 'src/sysdeps/trygetrandom.c')
-rw-r--r-- | src/sysdeps/trygetrandom.c | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/src/sysdeps/trygetrandom.c b/src/sysdeps/trygetrandom.c index 8abe3dd..cc2426b 100644 --- a/src/sysdeps/trygetrandom.c +++ b/src/sysdeps/trygetrandom.c @@ -1,24 +1,10 @@ /* ISC license. */ -#undef _POSIX_C_SOURCE -#undef _XOPEN_SOURCE - -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif - -#include <sys/types.h> -#include <unistd.h> -#include <sys/syscall.h> - -static int getrandom (void *buf, size_t buflen, unsigned int flags) -{ - return syscall(SYS_getrandom, buf, buflen, flags) ; -} +#include <sys/random.h> int main (void) { char buf[4] ; - if (getrandom(buf, 4, 0) < 0) return 1 ; + if (getrandom(buf, 4, GRND_NONBLOCK) < 0) return 1 ; return 0 ; } |