summaryrefslogtreecommitdiff
path: root/util/libreboot-utils/lib/io.c
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-03-28 07:30:55 +0000
committerLeah Rowe <leah@libreboot.org>2026-03-28 07:30:55 +0000
commit63984a4a6abb7a65098f27196fcb6395fc0ada22 (patch)
tree3c7e6e562d82f735f2b27201a0b23abc9afb367e /util/libreboot-utils/lib/io.c
parentfd26c6e63163d9811a89c3a5ca27a9aa2f61b09f (diff)
libreboot-utils: much stricter close() handling
remove close_warn and close_no_err make close_on_eintr a void, and abort on error instead of returning -1. a failed file closure is a world-ending event. burn accordingly. Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util/libreboot-utils/lib/io.c')
-rw-r--r--util/libreboot-utils/lib/io.c21
1 files changed, 4 insertions, 17 deletions
diff --git a/util/libreboot-utils/lib/io.c b/util/libreboot-utils/lib/io.c
index 4fa6bf72..f69954c8 100644
--- a/util/libreboot-utils/lib/io.c
+++ b/util/libreboot-utils/lib/io.c
@@ -239,8 +239,8 @@ write_to_gbe_bin(void)
saved_errno = errno;
- f->io_err_gbe_bin |= -close_warn(&f->tmp_fd, f->tname);
- f->io_err_gbe_bin |= -close_warn(&f->gbe_fd, f->fname);
+ close_on_eintr(&f->tmp_fd);
+ close_on_eintr(&f->gbe_fd);
errno = saved_errno;
@@ -440,15 +440,8 @@ gbe_mv(void)
ret_gbe_mv:
- /* TODO: this whole section is bloat.
- it can be generalised
- */
-
if (f->gbe_fd > -1) {
- if (close_on_eintr(f->gbe_fd) < 0) {
- f->gbe_fd = -1;
- rval = -1;
- }
+ close_on_eintr(&f->gbe_fd);
f->gbe_fd = -1;
if (fsync_dir(f->fname) < 0) {
@@ -457,13 +450,7 @@ ret_gbe_mv:
}
}
- if (f->tmp_fd > -1) {
- if (close_on_eintr(f->tmp_fd) < 0) {
- f->tmp_fd = -1;
- rval = -1;
- }
- f->tmp_fd = -1;
- }
+ close_on_eintr(&f->tmp_fd);
/* before this function is called,
* tmp_fd may have been moved