From 18f39ab6fafde132af48350d7c976afa5716038f Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Thu, 1 Jun 2023 11:56:01 +0100 Subject: util/nvmutil: clean up rhex() Signed-off-by: Leah Rowe --- util/nvmutil/nvmutil.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'util/nvmutil/nvmutil.c') diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c index d047e2aa..fcdab9e8 100644 --- a/util/nvmutil/nvmutil.c +++ b/util/nvmutil/nvmutil.c @@ -140,10 +140,9 @@ rhex(void) { static int rfd = -1, n = 0; static uint8_t rnum[16]; - if (!n) { - xopen(rfd, "/dev/urandom", O_RDONLY); + xopen(rfd, "/dev/urandom", O_RDONLY); + if (!n) xpread(rfd, (uint8_t *) &rnum, (n = 15) + 1, 0, "/dev/urandom"); - } return rnum[n--] & 0xf; } -- cgit v1.2.1