diff options
author | Alex Richardson <arichardson@FreeBSD.org> | 2022-08-08 19:17:12 +0000 |
---|---|---|
committer | Simon McVittie <smcv@collabora.com> | 2022-08-10 11:18:20 +0000 |
commit | a7fe9438c453859ff9bd4960f4a18537ade45243 (patch) | |
tree | b120214aa0c6c01b57cae950a01f0689d5b6af2c /dbus | |
parent | aa90d09940afce95be5b3cc96e2cdf1d8ff80d19 (diff) | |
download | dbus-a7fe9438c453859ff9bd4960f4a18537ade45243.tar.gz |
dbus-sysdeps-unix.c: Fix unused function warning on FreeBSD
The function close_ignore_error() is only used in some cases. To avoid
duplicating the #ifdef condition, this patch moves the check just before
the definition of _dbus_close_all().
Diffstat (limited to 'dbus')
-rw-r--r-- | dbus/dbus-sysdeps-unix.c | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index 252798e3..b702d935 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -4741,12 +4741,6 @@ _dbus_socket_can_pass_unix_fd (DBusSocket fd) #endif } -static void -close_ignore_error (int fd) -{ - close (fd); -} - /* * Similar to Solaris fdwalk(3), but without the ability to stop iteration, * and may call func for integers that are not actually valid fds. @@ -4812,6 +4806,25 @@ act_on_fds_3_and_up (void (*func) (int fd)) func (i); } +/* Some library implementations of closefrom() are not async-signal-safe, + * and we call _dbus_close_all() after forking, so we only do this on + * operating systems where we know that closefrom() is a system call */ +#if defined(HAVE_CLOSEFROM) && ( \ + defined(__FreeBSD__) || \ + defined(__NetBSD__) || \ + defined(__OpenBSD__) || \ + defined(__sun__) && defined(F_CLOSEFROM) \ +) +#define CLOSEFROM_SIGNAL_SAFE 1 +#else +#define CLOSEFROM_SIGNAL_SAFE 0 +static void +close_ignore_error (int fd) +{ + close (fd); +} +#endif + /** * Closes all file descriptors except the first three (i.e. stdin, * stdout, stderr). @@ -4824,15 +4837,7 @@ _dbus_close_all (void) return; #endif - /* Some library implementations of closefrom() are not async-signal-safe, - * and we call _dbus_close_all() after forking, so we only do this on - * operating systems where we know that closefrom() is a system call */ -#if defined(HAVE_CLOSEFROM) && ( \ - defined(__FreeBSD__) || \ - defined(__NetBSD__) || \ - defined(__OpenBSD__) || \ - defined(__sun__) && defined(F_CLOSEFROM) \ -) +#if CLOSEFROM_SIGNAL_SAFE closefrom (3); #else act_on_fds_3_and_up (close_ignore_error); |