summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2023-01-27 13:54:01 +0000
committerLeah Rowe <leah@libreboot.org>2023-01-27 13:54:01 +0000
commit88a51531cf247a2825ad1a5496201972eb3eabc1 (patch)
treea06e2d899a07b82cbd9a4a9ba19755219a6134c2
parentac1cab288d5b58085c0f07b8690a6084c0003fc0 (diff)
util/nvmutil: code cleanup in rhex()
-rw-r--r--util/nvmutil/nvmutil.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c
index 1adb7cab..ef89876b 100644
--- a/util/nvmutil/nvmutil.c
+++ b/util/nvmutil/nvmutil.c
@@ -252,19 +252,20 @@ rhex(void)
static int rfd = -1;
static uint8_t *rbuf = NULL;
static size_t rindex = BUFSIZ;
+ int bsize = BUFSIZ;
- if (rindex == BUFSIZ) {
+ if (rindex == bsize) {
rindex = 0;
if (rbuf == NULL)
- if ((rbuf = (uint8_t *) malloc(BUFSIZ)) == NULL)
+ if ((rbuf = (uint8_t *) malloc(bsize)) == NULL)
err(errno, NULL);
if (rfd != -1) {
if (close(rfd))
err(errno, "/dev/urandom");
rfd = -1;
}
- if (readFromFile(&rfd, rbuf, "/dev/urandom", O_RDONLY, BUFSIZ)
- != BUFSIZ)
+ if (readFromFile(&rfd, rbuf, "/dev/urandom", O_RDONLY, bsize)
+ != bsize)
err(errno, "/dev/urandom");
if (errno != 0)
err(errno, "/dev/urandom");