srandom: Replace accessing /dev/random by equivalent getentropy call

/dev/random calls getentropy.  So there's no good reason to go out of
our way to open /dev/random just to call getentropy anyway.

	* random.cc (srandomdev): Drop opening /dev/random in favor of
	calling getentropy.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen 2016-03-20 22:29:03 +01:00
parent 58988463cc
commit 2519f0ef0c
1 changed files with 1 additions and 10 deletions

View File

@ -299,7 +299,6 @@ dummy (unsigned volatile long *x)
void void
srandomdev() srandomdev()
{ {
int fd, done;
size_t len; size_t len;
if (rand_type == TYPE_0) if (rand_type == TYPE_0)
@ -307,15 +306,7 @@ srandomdev()
else else
len = rand_deg * sizeof state[0]; len = rand_deg * sizeof state[0];
done = 0; if (getentropy ((void *) state, len)) {
fd = open("/dev/random", O_RDONLY, 0);
if (fd >= 0) {
if (read(fd, (void *) state, len) == (ssize_t) len)
done = 1;
close(fd);
}
if (!done) {
struct timeval tv; struct timeval tv;
unsigned long junk; unsigned long junk;