Leah Rowe
6e47315192
util/nvmutil: remove rval from conv_argv_part_num
...
relic from an earlier uncommitted version
Signed-off-by: Leah Rowe <leah@libreboot.org >
2026-03-06 23:42:33 +00:00
Leah Rowe
85b09c4275
util/nvmutil: set part_modified to a uint8_t
...
Signed-off-by: Leah Rowe <leah@libreboot.org >
2026-03-06 23:15:50 +00:00
Leah Rowe
e5b108a764
util/nvmutil: make invert a uint8_t
...
cleaner intention, and shorter
Signed-off-by: Leah Rowe <leah@libreboot.org >
2026-03-06 23:14:26 +00:00
Leah Rowe
69c4d70650
util/nvmutil: safer argv part number parsing
...
we now handle signedness properly, which is implementation
defined, on char integers where signed/unsigned is not
specified.
Signed-off-by: Leah Rowe <leah@libreboot.org >
2026-03-06 23:07:29 +00:00
Leah Rowe
9b6f2a2f7e
util/nvmutil: rename check_bound check_nvm_bound
...
this makes the intent clearer, because we only want to
access the 128-byte nvm area here.
Signed-off-by: Leah Rowe <leah@libreboot.org >
2026-03-06 22:39:43 +00:00
Leah Rowe
a7d7f68a5c
util/nvmutil: be clearer about GbE file sizes
...
the partsize variable is also misleading, because it
refers to the full half of a file, which might be
bigger than 4KB. this variable name is a hangover
from when nvmutil only supported 8KB files.
Signed-off-by: Leah Rowe <leah@libreboot.org >
2026-03-06 22:36:08 +00:00
Leah Rowe
e273391792
util/nvmutil: rename fd to fd_ptr in xopen()
...
clearer intent
Signed-off-by: Leah Rowe <leah@libreboot.org >
2026-03-06 22:26:22 +00:00
Leah Rowe
4635a0eae9
util/nvmutil: cleaned up a few prototypes
...
make them match how they're declared
Signed-off-by: Leah Rowe <leah@libreboot.org >
2026-03-06 22:20:15 +00:00
Leah Rowe
0f5fcbd883
util/nvmutil: more readable xopen
...
match the argument names of openbsd open(2)
Signed-off-by: Leah Rowe <leah@libreboot.org >
2026-03-06 22:18:26 +00:00
Leah Rowe
2c2bda31ea
util/nvmutil: use unsigned char in hextonum
...
char can be signed or unsigned, and this is often
implementation-defined. this could result in bad
comparisons, so we should specifically cast it.
Signed-off-by: Leah Rowe <leah@libreboot.org >
2026-03-06 22:09:56 +00:00
Leah Rowe
f57358ac1e
util/nvmutil: remove redundant break
...
err takes care of it
Signed-off-by: Leah Rowe <leah@libreboot.org >
2026-03-06 21:43:11 +00:00
Leah Rowe
f59f45893b
util/nvmutil: rename write_gbe to write_gbe_file
...
for clarity
Signed-off-by: Leah Rowe <leah@libreboot.org >
2026-03-06 21:39:58 +00:00
Leah Rowe
85877a93bb
util/nvmutil: rename read_gbe to read_gbe_file
...
Signed-off-by: Leah Rowe <leah@libreboot.org >
2026-03-06 21:39:21 +00:00
Leah Rowe
dad1f613fc
util/nvmutil: unified partnum validation
...
Signed-off-by: Leah Rowe <leah@libreboot.org >
2026-03-06 21:35:49 +00:00
Leah Rowe
ed32108613
util/nvmutil: rename global st variable
...
rename it to gbe_st, for clarity
Signed-off-by: Leah Rowe <leah@libreboot.org >
2026-03-06 21:22:50 +00:00
Leah Rowe
b65c988007
util/nvmutil: full prototypes
...
Signed-off-by: Leah Rowe <leah@libreboot.org >
2026-03-06 21:21:40 +00:00
Leah Rowe
3aa30c5039
util/nvmutil: tidy up read_gbe
...
Signed-off-by: Leah Rowe <leah@libreboot.org >
2026-03-06 21:08:47 +00:00
Leah Rowe
040eee4607
util/nvmutil: tidy up set_mac_nib
...
simplify it again
Signed-off-by: Leah Rowe <leah@libreboot.org >
2026-03-06 21:06:58 +00:00
Leah Rowe
6b924787be
util/nvmutil: remove unnecessary checck
...
the for loop exits when setting cmd
checking for NULL is pointless
Signed-off-by: Leah Rowe <leah@libreboot.org >
2026-03-06 20:59:50 +00:00
Leah Rowe
af55dd8959
Revert "util/nvmutil: make invert an unsigned char"
...
This reverts commit 5b120d71e7 .
the others are unsigned char. other variables like this one.
better be consistent.
Signed-off-by: Leah Rowe <leah@libreboot.org >
2026-03-06 20:58:04 +00:00
Leah Rowe
10c8be92aa
util/nvmutil: general code cleanup
...
Signed-off-by: Leah Rowe <leah@libreboot.org >
2026-03-06 20:52:13 +00:00
Leah Rowe
a34d430754
util/nvmutil: cleaner mac address variable names
...
Signed-off-by: Leah Rowe <leah@libreboot.org >
2026-03-06 20:34:20 +00:00
Leah Rowe
00e0197cfe
util/nvmutil: general code cleanup
...
Signed-off-by: Leah Rowe <leah@libreboot.org >
2026-03-06 20:11:30 +00:00
Leah Rowe
5b120d71e7
util/nvmutil: make invert an unsigned char
...
Signed-off-by: Leah Rowe <leah@libreboot.org >
2026-03-06 19:59:51 +00:00
Leah Rowe
4bf190a5f5
util/nvmutil: make mac_updated unsigned
...
Signed-off-by: Leah Rowe <leah@libreboot.org >
2026-03-06 19:58:37 +00:00
Leah Rowe
5c90b2453b
util/nvmutil: use size_t in setmac functions
...
not int
Signed-off-by: Leah Rowe <leah@libreboot.org >
2026-03-06 19:57:39 +00:00
Leah Rowe
fb805caf6a
util/nvmutil: extra part check in set_checksum
...
it calls word() anyway, but we should still check it here,
since this is quite a critical function.
the other bound checks are done by word(), which this
function uses to add everything up.
Signed-off-by: Leah Rowe <leah@libreboot.org >
2026-03-06 19:40:28 +00:00
Leah Rowe
f316701d74
util/nvmutil: don't set part in write_mac_part
...
make a helper for cmd_setchecksum with size_t arg,
and use it in write_mac_part.
Signed-off-by: Leah Rowe <leah@libreboot.org >
2026-03-06 19:35:54 +00:00
Leah Rowe
c6c4e5303e
util/nvmutil: fix duplicated word in comment
...
Signed-off-by: Leah Rowe <leah@libreboot.org >
2026-03-06 19:30:55 +00:00
Leah Rowe
5d05921875
util/nvmutil: make part_modified an unsigned char
...
better reflects intent
Signed-off-by: Leah Rowe <leah@libreboot.org >
2026-03-06 19:28:32 +00:00
Leah Rowe
1aa8f33d50
util/nvmutil: fix bad string in gbe_read_part()
...
Signed-off-by: Leah Rowe <leah@libreboot.org >
2026-03-06 19:25:54 +00:00
Leah Rowe
9095722079
util/nvmutil: calculate off AFTER part validation
...
because we check the part first, so we need to know it's
valid before proceeding.
Signed-off-by: Leah Rowe <leah@libreboot.org >
2026-03-06 19:23:56 +00:00
Leah Rowe
1131240d02
util/nvmutil: made a comment a bit clearer
...
Signed-off-by: Leah Rowe <leah@libreboot.org >
2026-03-06 19:21:02 +00:00
Leah Rowe
72caa5f892
util/nvmutil: fix another printf specifier
...
Signed-off-by: Leah Rowe <leah@libreboot.org >
2026-03-06 19:17:01 +00:00
Leah Rowe
efdf110317
util/nvmutil: remove unnecessary casts
...
now that part numbers are size_t, i don't need them.
Signed-off-by: Leah Rowe <leah@libreboot.org >
2026-03-06 19:08:55 +00:00
Leah Rowe
d94fbba779
util/nvmutil: fix more bad printf statements
...
Signed-off-by: Leah Rowe <leah@libreboot.org >
2026-03-06 19:04:38 +00:00
Leah Rowe
6d2a1afbd4
util/nvmutil: fix a few bad printf statements
...
Signed-off-by: Leah Rowe <leah@libreboot.org >
2026-03-06 19:03:06 +00:00
Leah Rowe
0698c6ada4
util/nvmutil: warn about partial gbe file writes
...
Signed-off-by: Leah Rowe <leah@libreboot.org >
2026-03-06 18:55:31 +00:00
Leah Rowe
397fc78e58
util/nvmutil: use size_t for part numbers
...
not int
Signed-off-by: Leah Rowe <leah@libreboot.org >
2026-03-06 18:45:26 +00:00
Leah Rowe
82fdee91fa
util/nvmutil: clean up file handling
...
inline check_read_or_die
Signed-off-by: Leah Rowe <leah@libreboot.org >
2026-03-06 18:36:29 +00:00
Leah Rowe
58b17c98fd
util/nvmutil: minor cleanup
...
Signed-off-by: Leah Rowe <leah@libreboot.org >
2026-03-06 18:25:24 +00:00
Leah Rowe
c8bd98c8a6
util/nvmutil: mem bound check on file read/write
...
Signed-off-by: Leah Rowe <leah@libreboot.org >
2026-03-06 18:17:07 +00:00
Leah Rowe
41f7f6352d
util/nvmutil: rename gbe_bound for clarity
...
Signed-off-by: Leah Rowe <leah@libreboot.org >
2026-03-06 17:47:49 +00:00
Leah Rowe
b1abef8881
util/nvmutil: make defines easier to understand
...
Signed-off-by: Leah Rowe <leah@libreboot.org >
2026-03-06 17:44:07 +00:00
Leah Rowe
edca6c2cd3
util/nvmutil: tidy up set_mac_nib
...
Signed-off-by: Leah Rowe <leah@libreboot.org >
2026-03-06 17:35:00 +00:00
Leah Rowe
123e77d07f
util/nvmutil: use portable printf on hexdump
...
lx means unsigned long, and row is size_t which often
is, but this is not guaranteed.
Signed-off-by: Leah Rowe <leah@libreboot.org >
2026-03-06 17:31:04 +00:00
Leah Rowe
c0a77a7301
util/nvmutil: make the MAC shifting easier to read
...
Signed-off-by: Leah Rowe <leah@libreboot.org >
2026-03-06 17:22:31 +00:00
Leah Rowe
596643a0d5
util/nvmutil: optimise hextonum
...
there is 0x20 of different between a and A
so we can just or 0x20 and compare only lowercase.
we can also cast char (which may me signed on some
systems) to unsigned, and then only check whether
it's lower than 10.
this code results in far less branching (in C),
but a good optimising compiler probably wouldn't
have cared about the old version anyway.
it's just nicer C code.
this also means we no longer need to check for
X, only x.
Signed-off-by: Leah Rowe <leah@libreboot.org >
2026-03-06 17:07:12 +00:00
Leah Rowe
6023d17b6e
util/nvmutil: fix parenthesis warning in GCC
...
Signed-off-by: Leah Rowe <leah@libreboot.org >
2026-03-06 17:01:48 +00:00
Leah Rowe
199dbad96d
util/nvmutil: tidy up set_mac_nib
...
Signed-off-by: Leah Rowe <leah@libreboot.org >
2026-03-06 16:55:23 +00:00