summaryrefslogtreecommitdiff
path: root/util/libreboot-utils/lib/num.c
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-03-26 04:25:51 +0000
committerLeah Rowe <leah@libreboot.org>2026-03-26 04:25:51 +0000
commit0a7014c6025733e0f8cf11aac513c3daa982c944 (patch)
tree684d41dc4bc584fed36083a2b74f286d3941116d /util/libreboot-utils/lib/num.c
parent333a23b18b8e0a8508148d4699574380f1108a62 (diff)
cleanup
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util/libreboot-utils/lib/num.c')
-rw-r--r--util/libreboot-utils/lib/num.c40
1 files changed, 2 insertions, 38 deletions
diff --git a/util/libreboot-utils/lib/num.c b/util/libreboot-utils/lib/num.c
index 92710c35..faf06121 100644
--- a/util/libreboot-utils/lib/num.c
+++ b/util/libreboot-utils/lib/num.c
@@ -1,12 +1,8 @@
/* SPDX-License-Identifier: MIT
* Copyright (c) 2026 Leah Rowe <leah@libreboot.org>
*
- * Numerical functions.
- * NOTE: randomness was moved to rand.c
- */
-
-/*
-TODO: properly handle errno in this file
+ * Non-randomisation-related numerical functions.
+ * For rand functions, see: rand.c
*/
#ifdef __OpenBSD__
@@ -27,42 +23,11 @@ TODO: properly handle errno in this file
#include "../include/common.h"
-/* TODO:
- * make this and errno handling more
- * flexible
-
- in particular:
- hextonum could be modified to
- write into a buffer instead,
- with the converted numbers,
- of an arbitrary length
- */
unsigned short
hextonum(char ch_s)
{
int saved_errno = errno;
- /* rlong() can return error,
- but preserves errno if no
- error. we need to detect
- this because it handles
- /dev/urandom sometimes
-
- therefore, if it's zero
- at start, we know if there
- was an err at the end, by
- return value zero, if errno
- was set; this is technically
- valid, since zero is also
- a valid random number!
-
- it's an edge case that i had
- to fix. i'll rewrite the code
- better later. for now, it
- should be ok.
- */
- errno = 0;
-
unsigned char ch;
size_t rval;
@@ -95,7 +60,6 @@ hextonum(char ch_s)
hextonum_success:
- errno = saved_errno;
return (unsigned short)rval & 0xf;
err_hextonum: