summaryrefslogtreecommitdiff
path: root/util/libreboot-utils
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-03-28 03:08:52 +0000
committerLeah Rowe <leah@libreboot.org>2026-03-28 03:08:52 +0000
commitf4f167090964186d65d1ee8b9676b7123b015e3b (patch)
tree0c1bd7656424229f351f3b282a0795c2e834d513 /util/libreboot-utils
parent998528c4045ec711e3b6c2b92e227db333f3b020 (diff)
util/nvmutil: tidy up hextonum
i had a bunch of hacks in here because i was previously using very buggy rand. now it's ok. Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util/libreboot-utils')
-rw-r--r--util/libreboot-utils/lib/num.c36
1 files changed, 6 insertions, 30 deletions
diff --git a/util/libreboot-utils/lib/num.c b/util/libreboot-utils/lib/num.c
index 79d6b409..d297ab86 100644
--- a/util/libreboot-utils/lib/num.c
+++ b/util/libreboot-utils/lib/num.c
@@ -33,44 +33,20 @@ hextonum(char ch_s)
ch = (unsigned char)ch_s;
- if ((unsigned int)(ch - '0') <= 9) {
-
- rval = ch - '0';
- goto hextonum_success;
- }
+ if ((unsigned int)(ch - '0') <= 9)
+ return ch - '0';
ch |= 0x20;
- if ((unsigned int)(ch - 'a') <= 5) {
-
- rval = ch - 'a' + 10;
- goto hextonum_success;
- }
+ if ((unsigned int)(ch - 'a') <= 5)
+ return ch - 'a' + 10;
if (ch == '?' || ch == 'x') {
-
rset(&rval, sizeof(rval));
-
- goto hextonum_success;
+ return rval & 0xf;
}
- goto err_hextonum;
-
-hextonum_success:
-
- errno = saved_errno;
- return (unsigned short)rval & 0xf;
-
-err_hextonum:
-
- if (errno == saved_errno)
- errno = EINVAL;
- else
- return 17; /* 17 indicates getrandom/urandom fail */
-
- return 16; /* invalid character */
-
- /* caller just checks >15. */
+ return 16;
}
void