diff options
| author | Leah Rowe <leah@libreboot.org> | 2026-03-07 01:01:44 +0000 |
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2026-03-07 01:01:44 +0000 |
| commit | 0084452c4a116b8860a92884752e44c74ed60f0e (patch) | |
| tree | 753e49cd5909a3b3353d609ea1b2032da5cbc735 /util/nvmutil | |
| parent | 364abddeab6c8a1e3a85388b093f0cfa32e524a9 (diff) | |
util/nvmutil: comment regarding buf
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util/nvmutil')
| -rw-r--r-- | util/nvmutil/nvmutil.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c index dd6ba72a..1cb6bdb4 100644 --- a/util/nvmutil/nvmutil.c +++ b/util/nvmutil/nvmutil.c @@ -119,7 +119,17 @@ static const char oldrandom[] = "/dev/random"; /* fallback on OLD unix */ static const char *rname = NULL; #endif -static uint8_t buf[GBE_FILE_SIZE]; /* 8KB */ +/* + * GbE files can be 8KB, 16KB or 128KB, + * but we only need the two 4KB parts + * from offset zero and offset 64KB in + * a 128KB file, or zero and 8KB in a 16KB + * file, or zero and 4KB in an 8KB file. + * + * The code will handle this properly. + */ +static uint8_t buf[GBE_FILE_SIZE]; + static uint16_t mac_buf[3]; static off_t gbe_file_size; @@ -504,6 +514,10 @@ set_mac_nib(size_t mac_str_pos, size_t mac_nib_pos) static uint8_t hextonum(char ch_s) { + /* + * We assume char is signed, hence ch_s. + * We explicitly cast to unsigned: + */ unsigned char ch = (unsigned char)ch_s; if ((unsigned)(ch - '0') <= 9) |
