From 2f2295fc374b011889ddc3ca854b37c3cc13db67 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Wed, 4 Mar 2026 10:45:00 +0000 Subject: util/nvmutil: rhex: don't read twice! we currently never read the 0th byte, so if we need all 12, and we do when every byte is random, we read again just to get one byte. not really a bug, but it is a performance penalty, so let's fix it! Signed-off-by: Leah Rowe --- util/nvmutil/nvmutil.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'util/nvmutil/nvmutil.c') diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c index 319fe552..577efc76 100644 --- a/util/nvmutil/nvmutil.c +++ b/util/nvmutil/nvmutil.c @@ -395,10 +395,10 @@ hextonum(char ch) static uint8_t rhex(void) { - static uint8_t n = 0; + static int n = -1; static uint8_t rnum[12]; - if (!n) { + if (n == -1) { n = sizeof(rnum) - 1; read_file_PERFECTLY_or_die(rfd, rnum, sizeof(rnum), 0, "/dev/urandom", NULL); -- cgit v1.2.1