summaryrefslogtreecommitdiff
path: root/util/nvmutil
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-03-04 10:45:00 +0000
committerLeah Rowe <leah@libreboot.org>2026-03-04 10:45:00 +0000
commit2f2295fc374b011889ddc3ca854b37c3cc13db67 (patch)
tree857cc8cf354070667bb0ab5d42e5bfdaefdb022a /util/nvmutil
parentaceafd684a37a6a35bdd4f0aa4aecdf29c9711db (diff)
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 <leah@libreboot.org>
Diffstat (limited to 'util/nvmutil')
-rw-r--r--util/nvmutil/nvmutil.c4
1 files changed, 2 insertions, 2 deletions
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);