public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Mike Gilbert" <floppym@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/sandbox:master commit in: libsandbox/, libsbutil/, src/
Date: Sun, 09 Mar 2025 18:27:21 +0000 (UTC)	[thread overview]
Message-ID: <1741544532.703ec985801ed9e6886f8538cddc67a71e6cbda5.floppym@gentoo> (raw)

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");
 }


             reply	other threads:[~2025-03-09 18:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-09 18:27 Mike Gilbert [this message]
  -- strict thread matches above, loose matches on Subject: below --
2021-10-22  7:21 [gentoo-commits] proj/sandbox:master commit in: libsandbox/, libsbutil/, src/ Michał Górny

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1741544532.703ec985801ed9e6886f8538cddc67a71e6cbda5.floppym@gentoo \
    --to=floppym@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox