Commit Graph

134 Commits (f855611c99bb8a4291de637c56a9e47a581a2f9a)

Author SHA1 Message Date
Leah Rowe b495aa0987 util/nvmutil: consistent parentheses on comparison 2022-12-08 21:34:19 +00:00
Leah Rowe 17fa25e5af util/nvmutil file reads: skip reading if errno!=0
*This condition will probably never be met, but it is theoretically
possible that the code could still fail at this point. Catch all errors,
and exit, ruthlessly.
2022-12-08 21:29:36 +00:00
Leah Rowe 27876c6421 util/nvmutil: return error when fstat() is -1
Another oversight in my error handling.
2022-12-08 21:20:53 +00:00
Leah Rowe 960af2d6e8 util/nvmutil: rhex(): fail if errno not zero
The code was only checking whether all of the bytes were read,
but there are other errors that can be caught via errno.

Enforce strict errno handling, when generating random
numbers for command `setmac`.
2022-12-07 22:30:55 +00:00
Leah Rowe 3d01cf28d6 util/nvmutil: minor code formatting cleanup 2022-12-05 03:26:18 +00:00
Leah Rowe a5e4416a14 util/nvmutil: remove errant line break 2022-12-03 12:43:13 +00:00
Leah Rowe c100dd1f81 util/nvmutil: missing paretheses on if statement 2022-12-03 12:30:13 +00:00
Leah Rowe 036d710776 util/nvmutil: don't initialise rbuf unless needed
previously, it was always initialised, but now it's only
initialised if '?' is used on a mac address character in
command `setmac`

this is done by simply moving mac address character
randomisation to a separate function
2022-12-03 12:28:20 +00:00
Leah Rowe 851892b464 util/nvmutil: rename variable in hextonum 2022-12-03 12:17:16 +00:00
Leah Rowe 0bf3f1ed61 util/nvmutil: don't reallocate memory in hextonum 2022-12-03 12:11:15 +00:00
Leah Rowe e5a46b464d util/nvmutil: dont report bad size if /dev/urandom 2022-12-03 12:00:25 +00:00
Leah Rowe ededa5ddda util/nvmutil: rename variables in hextonum 2022-12-03 11:58:07 +00:00
Leah Rowe e2e321fc20 util/nvmutil: use BUFSIZ for rmac size in hextonum
I will be using this function elsewhere, and in general
I want this to be usable for lots of programs.
2022-12-03 11:55:38 +00:00
Leah Rowe a6d0112d86 util/nvtutil: fix out of bounds error
the error would have never been triggered, because it never
went over 11, but if this code were to be copied elsewhere,
it would be problematic
2022-12-03 11:49:52 +00:00
Leah Rowe 85937f3f4c util/nvmutil: reset errno on cmd_swap
If one of the checksums was valid, but the other was not,
errno would be set to E_CANCELED, but then the buffer would
be modified anyway; this is acceptable behaviour, and errno
would later be reset writing the GBE file, which is done
only on the condition that the buffer was modified, but
it's also a good idea to reset it here just in case.

This is not a bugfix, and no behavioural changes will be
observed by the user, but this may *prevent* a bug in the
future, so let's pre-fix that bug now.
2022-12-01 13:16:05 +00:00
Leah Rowe e8eee6dd8a util/nvmutil: mild refactoring 2022-11-27 09:43:47 +00:00
Leah Rowe 342e5abe5e util/nvmutil: improved errno handling in main 2022-11-27 09:36:18 +00:00
Leah Rowe d7465efbb0 util/nvmutil: put hextonum in its own function 2022-11-27 09:29:37 +00:00
Leah Rowe 9e5ff5e4e6 util/nvmutil: move ENOTDIR check to function 2022-11-27 09:01:57 +00:00
Leah Rowe ff88cb1ac3 util/nvmutil: further improved errno handling 2022-11-27 00:48:37 +00:00
Leah Rowe b81b51f98b util/nvmutil: remove errant code 2022-11-27 00:39:06 +00:00
Leah Rowe a94bac81f3 util/nvmutil: improved error handling 2022-11-27 00:27:07 +00:00
Leah Rowe 55a951a718 util/nvmutil: fix off by one bug 2022-11-26 23:50:04 +00:00
Leah Rowe 0108615f37 nvmutil copy/swap: actually set nvmPartModified 2022-11-26 23:48:01 +00:00
Leah Rowe 82300f4f1e util/nvmutil: move cmd copy to own function 2022-11-26 23:42:45 +00:00
Leah Rowe ddf3b76c83 util/nvmutil: move cmd swap to own function 2022-11-26 23:34:13 +00:00
Leah Rowe c2ed251ca6 util/nvmutil: move cmd brick to own function 2022-11-26 23:29:41 +00:00
Leah Rowe eaad16edad util/nvmutil: cmd setchecksum in own function 2022-11-26 23:25:23 +00:00
Leah Rowe cea1beeac5 util/nvmutil: split "dump" into smaller functions 2022-11-26 23:19:57 +00:00
Leah Rowe 0ae00e881e util/nvmutil: re-factor to reduce code indentation 2022-11-26 11:26:07 +00:00
Leah Rowe 0bbd4f1f26 util/nvmutil: write gbe files in a function
in any C program, main() should not contain detailed logic.

ideally, the main() function should only be a skeleton, showing
the overall logic flow of the program. split writing gbe files
into a separate function, to satisfy this criteria.
2022-11-26 11:03:04 +00:00
Leah Rowe b0f9f47e9a util/nvmutil: human-friendly exit messages, part 2 2022-11-26 10:35:10 +00:00
Leah Rowe 6c12afa996 util/nvmutil: more human-friendly exit messages 2022-11-18 20:07:13 +00:00
Leah Rowe b3b3642fe2 assimilate nvmutil 2022-11-17 12:07:09 +00:00