diff mbox series

[4/5] Stop using deprecated function sigsetmask()

Message ID 20181016164220.29413-5-ao2@ao2.it (mailing list archive)
State Superseded
Delegated to: Herbert Xu
Headers show
Series Build system updates and gcc warnings fixes | expand

Commit Message

Antonio Ospite Oct. 16, 2018, 4:42 p.m. UTC
sigsetmask() is deprecated, at least on recent glibc; stop using it to
silence the following compiler warning:

-----------------------------------------------------------------------
system.h:40:2: warning: ‘sigsetmask’ is deprecated [-Wdeprecated-declarations]
  sigsetmask(0);
  ^~~~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/sys/param.h:28,
                 from shell.h:52,
                 from nodes.c:46:
/usr/include/signal.h:173:12: note: declared here
 extern int sigsetmask (int __mask) __THROW __attribute_deprecated__;
            ^~~~~~~~~~
-----------------------------------------------------------------------

Using sigprocmask() and friends unconditionally should not be a problem,
as commit e94a964 (eval: Add vfork support, 2018-05-19) also does it.

Signed-off-by: Antonio Ospite <ao2@ao2.it>
---
 configure.ac | 2 +-
 src/system.h | 4 ----
 2 files changed, 1 insertion(+), 5 deletions(-)

Comments

Jilles Tjoelker Oct. 16, 2018, 8:37 p.m. UTC | #1
On Tue, Oct 16, 2018 at 06:42:19PM +0200, Antonio Ospite wrote:
> sigsetmask() is deprecated, at least on recent glibc; stop using it to
> silence the following compiler warning:

> -----------------------------------------------------------------------
> system.h:40:2: warning: ‘sigsetmask’ is deprecated [-Wdeprecated-declarations]
>   sigsetmask(0);
>   ^~~~~~~~~~
> In file included from /usr/include/x86_64-linux-gnu/sys/param.h:28,
>                  from shell.h:52,
>                  from nodes.c:46:
> /usr/include/signal.h:173:12: note: declared here
>  extern int sigsetmask (int __mask) __THROW __attribute_deprecated__;
>             ^~~~~~~~~~
> -----------------------------------------------------------------------

> Using sigprocmask() and friends unconditionally should not be a problem,
> as commit e94a964 (eval: Add vfork support, 2018-05-19) also does it.

The git history starts (in 2005) after HAVE_SIGSETMASK was added, but I
expect it was done this way to save a few bytes in the executable. With
ProPolice, the effect may be a bit more since a local variable of type
sigset_t often contains an array and may cause functions to be compiled
with stack protection when they otherwise wouldn't (note that
sigclearmask() is inline).

Both FreeBSD and NetBSD simply changed the sigsetmask() call to a
sigprocmask() call very early on (1995-1996).

Personally, I think clean code that compiles without warnings is more
important than making the executable as small as possible, but the
maintainer may not agree.
diff mbox series

Patch

diff --git a/configure.ac b/configure.ac
index 036730d..32ef456 100644
--- a/configure.ac
+++ b/configure.ac
@@ -89,7 +89,7 @@  AC_CHECK_DECL([PRIdMAX],,
 dnl Checks for library functions.
 AC_CHECK_FUNCS(bsearch faccessat getpwnam getrlimit isalpha killpg \
 	       mempcpy \
-	       sigsetmask stpcpy strchrnul strsignal strtod strtoimax \
+	       stpcpy strchrnul strsignal strtod strtoimax \
 	       strtoumax sysconf)
 
 dnl Check whether it's worth working around FreeBSD PR kern/125009.
diff --git a/src/system.h b/src/system.h
index a8d09b3..6950e6e 100644
--- a/src/system.h
+++ b/src/system.h
@@ -36,13 +36,9 @@ 
 
 static inline void sigclearmask(void)
 {
-#ifdef HAVE_SIGSETMASK
-	sigsetmask(0);
-#else
 	sigset_t set;
 	sigemptyset(&set);
 	sigprocmask(SIG_SETMASK, &set, 0);
-#endif
 }
 
 #ifndef HAVE_MEMPCPY