summaryrefslogtreecommitdiff
path: root/util/nvmutil/lib/num.c
diff options
context:
space:
mode:
Diffstat (limited to 'util/nvmutil/lib/num.c')
-rw-r--r--util/nvmutil/lib/num.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/util/nvmutil/lib/num.c b/util/nvmutil/lib/num.c
index 374cc9a0..0442b86c 100644
--- a/util/nvmutil/lib/num.c
+++ b/util/nvmutil/lib/num.c
@@ -9,17 +9,15 @@
#include <sys/param.h>
#endif
#include <sys/types.h>
-#include <sys/stat.h>
#include <errno.h>
-#include <fcntl.h>
+#if !((defined(__OpenBSD__) && (OpenBSD) >= 201) || \
+ defined(__FreeBSD__) || \
+ defined(__NetBSD__) || defined(__APPLE__))
+#include <fcntl.h> /* if not arc4random: /dev/urandom */
+#endif
#include <limits.h>
-#include <stdarg.h>
#include <stddef.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
#include <unistd.h>
#include "../include/common.h"
@@ -82,7 +80,7 @@ rlong(void)
sizeof(unsigned long), 0, IO_READ, LOOP_EAGAIN,
LOOP_EINTR, MAX_ZERO_RW_RETRY, OFF_ERR);
- if (x_i_close(fd) < 0)
+ if (close_on_eintr(fd) < 0)
err(errno, "Can't close randomness fd");
if (nr != sizeof(unsigned long))