mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-19 18:19:57 +02:00
util/nvmutil: don't reset errno in rw_file_exact
reset it in callers instead. this means that the main function is more generalised. we know by the time we exit that there is no error. Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
+3
-11
@@ -1015,6 +1015,7 @@ rhex(void)
|
|||||||
n = sizeof(rnum);
|
n = sizeof(rnum);
|
||||||
if (rw_file_exact(urandom_fd, rnum, n, 0, LESEN) == -1)
|
if (rw_file_exact(urandom_fd, rnum, n, 0, LESEN) == -1)
|
||||||
err(errno, "Randomisation failed");
|
err(errno, "Randomisation failed");
|
||||||
|
errno = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (uint16_t)(rnum[--n] & 0xf);
|
return (uint16_t)(rnum[--n] & 0xf);
|
||||||
@@ -1323,6 +1324,8 @@ rw_gbe_file_part(size_t p, int rw_type,
|
|||||||
rw_type) == -1)
|
rw_type) == -1)
|
||||||
err(errno, "%s: %s: part %lu",
|
err(errno, "%s: %s: part %lu",
|
||||||
fname, rw_type_str, (unsigned long)p);
|
fname, rw_type_str, (unsigned long)p);
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1440,17 +1443,6 @@ rw_file_exact(int fd, uint8_t *mem, size_t len,
|
|||||||
rc += (size_t)rval;
|
rc += (size_t)rval;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (errno == EINTR) {
|
|
||||||
/*
|
|
||||||
* EINTR is not fatal, because we
|
|
||||||
* eventually return. We rely on
|
|
||||||
* errno for general error state
|
|
||||||
* after return from rw_file_exact,
|
|
||||||
* so we don't want a false error.
|
|
||||||
*/
|
|
||||||
errno = 0;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
set_err(EIO);
|
set_err(EIO);
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
Reference in New Issue
Block a user