summaryrefslogtreecommitdiff
path: root/util/libreboot-utils/lib/io.c
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-03-24 07:41:45 +0000
committerLeah Rowe <leah@libreboot.org>2026-03-24 09:48:34 +0000
commitcce396a1ac3786b18f2c21d80c4e65e19481510d (patch)
tree0c6aea100e4254cd190640460ddaa39ce120a497 /util/libreboot-utils/lib/io.c
parente7ede0c75570ddd57b9d55e33764c3bdd74274b1 (diff)
libreboot-utils: general code cleanup
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.c32
1 files changed, 4 insertions, 28 deletions
diff --git a/util/libreboot-utils/lib/io.c b/util/libreboot-utils/lib/io.c
index 94bde87e..cc38e5c7 100644
--- a/util/libreboot-utils/lib/io.c
+++ b/util/libreboot-utils/lib/io.c
@@ -239,21 +239,8 @@ write_to_gbe_bin(void)
saved_errno = errno;
- if (close_on_eintr(f->tmp_fd) == -1) {
- f->tmp_fd = -1;
-
- fprintf(stderr, "FAIL: %s: close\n", f->tname);
- f->io_err_gbe_bin = 1;
- }
- f->tmp_fd = -1;
-
- if (close_on_eintr(f->gbe_fd) == -1) {
- f->gbe_fd = -1;
-
- fprintf(stderr, "FAIL: %s: close\n", f->fname);
- f->io_err_gbe_bin = 1;
- }
- f->gbe_fd = -1;
+ f->io_err_gbe_bin |= -close_warn(&f->tmp_fd, f->tname);
+ f->io_err_gbe_bin |= -close_warn(&f->gbe_fd, f->fname);
errno = saved_errno;
@@ -279,13 +266,7 @@ write_to_gbe_bin(void)
/* removed by rename
*/
-
- if (f->tname != NULL) {
- free(f->tname);
- f->tname = NULL;
- }
-
- f->tname = NULL;
+ free_if_null(&f->tname);
}
}
@@ -513,12 +494,7 @@ gbe_mv(void)
goto ret_gbe_mv;
}
- if (dest_tmp != NULL) {
- free(dest_tmp);
- dest_tmp = NULL;
- }
-
- dest_tmp = NULL;
+ free_if_null(&dest_tmp);
ret_gbe_mv: