mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-11 05:52:36 +02:00
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>
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user