mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-18 14:12:44 +02:00
util/nvmutil: explain errval handling in err()
Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
@@ -1373,6 +1373,21 @@ rw_file_exact(int fd, uint8_t *mem, size_t len,
|
|||||||
static void
|
static void
|
||||||
err(int nvm_errval, const char *msg, ...)
|
err(int nvm_errval, const char *msg, ...)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* We need to ensure that files are closed
|
||||||
|
* on exit, including error exits. This
|
||||||
|
* would otherwise recurse, because the
|
||||||
|
* close_files() function also calls err(),
|
||||||
|
* but with -1 on nvm_errval. It's the only
|
||||||
|
* one that does this.
|
||||||
|
*
|
||||||
|
* Since the errval is for setting errno, -1
|
||||||
|
* would be incorrect. Therefore, set_err()
|
||||||
|
* avoids overriding errno if the given value
|
||||||
|
* is negative.
|
||||||
|
*
|
||||||
|
* Be careful modifying err() and close_files().
|
||||||
|
*/
|
||||||
if (nvm_errval != -1)
|
if (nvm_errval != -1)
|
||||||
close_files();
|
close_files();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user