commit: 703ec985801ed9e6886f8538cddc67a71e6cbda5
Author: Mike Gilbert <floppym <AT> gentoo <DOT> org>
AuthorDate: Sun Mar 9 04:52:42 2025 +0000
Commit: Mike Gilbert <floppym <AT> gentoo <DOT> org>
CommitDate: Sun Mar 9 18:22:12 2025 +0000
URL: https://gitweb.gentoo.org/proj/sandbox.git/commit/?id=703ec985
libsbutil: remove sb_close
The close(2) manpage advises us to NOT retry after it fails.
Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org>
libsandbox/libsandbox.c | 2 +-
libsbutil/sb_close.c | 20 --------------------
libsbutil/sb_write_fd.c | 2 +-
libsbutil/sbutil.h | 1 -
src/sandbox.c | 2 +-
5 files changed, 3 insertions(+), 24 deletions(-)
diff --git a/libsandbox/libsandbox.c b/libsandbox/libsandbox.c
index 9233c6c..11c6a6c 100644
--- a/libsandbox/libsandbox.c
+++ b/libsandbox/libsandbox.c
@@ -178,7 +178,7 @@ static bool write_logfile(const char *logfile, const char
*func, const char *pat
ret = true;
error:
- sb_close(logfd);
+ close(logfd);
return ret;
}
diff --git a/libsbutil/sb_close.c b/libsbutil/sb_close.c
index 5379197..5f7def7 100644
--- a/libsbutil/sb_close.c
+++ b/libsbutil/sb_close.c
@@ -10,26 +10,6 @@
#include "headers.h"
#include "sbutil.h"
-/* General purpose function to _reliably_ close a file
- *
- * Returns 0 if successful or negative number on error (and errno set)
- */
-
-int sb_close(int fd)
-{
- int res;
-
- do {
- res = close(fd);
- } while ((res < 0) && (EINTR == errno));
-
- /* Do not care about errors here */
- if (-1 != res)
- errno = 0;
-
- return res;
-}
-
/* Quickly close all the open fds (good for daemonization) */
void sb_close_all_fds(void)
{
diff --git a/libsbutil/sb_write_fd.c b/libsbutil/sb_write_fd.c
index fdcd34e..85eac13 100644
--- a/libsbutil/sb_write_fd.c
+++ b/libsbutil/sb_write_fd.c
@@ -35,6 +35,6 @@ int sb_copy_file_to_fd(const char *file, int ofd)
ret = 0;
error:
- sb_close(ifd);
+ close(ifd);
return ret;
}
diff --git a/libsbutil/sbutil.h b/libsbutil/sbutil.h
index 2be3ca5..d092868 100644
--- a/libsbutil/sbutil.h
+++ b/libsbutil/sbutil.h
@@ -107,7 +107,6 @@ extern const char sbio_fallback_path[];
int sb_open(const char *path, int flags, mode_t mode);
size_t sb_read(int fd, void *buf, size_t count);
size_t sb_write(int fd, const void *buf, size_t count);
-int sb_close(int fd);
void sb_close_all_fds(void);
int sb_copy_file_to_fd(const char *file, int ofd);
int sb_exists(int dirfd, const char *pathname, int flags);
diff --git a/src/sandbox.c b/src/sandbox.c
index 81c7ac9..4124e86 100644
--- a/src/sandbox.c
+++ b/src/sandbox.c
@@ -127,7 +127,7 @@ static void print_sandbox_log(char *sandbox_log)
break;
sb_eerror("\n%s", buffer);
}
- sb_close(sandbox_log_file);
+ close(sandbox_log_file);
sb_eerror("--------------------------------------------------------------------------------\n");
}