[1/3] Remove useless #ifdefs from sysdeps/unix/sysv/linux/sigprocmask.c
diff mbox series

Message ID 20171016043407.1142-2-ynorov@caviumnetworks.com
State New
Headers show
Series
  • Cleanup and consolidate sigprocmask() for Linux
Related show

Commit Message

Yury Norov Oct. 16, 2017, 4:34 a.m. UTC
The sysdeps/unix/sysv/linux/sigprocmask.c includes nptl-signals.h
via nptl/pthreadP.h, and so SIGCANCEL and SIGSETXID become defined
unconditionally. But later in the code, there are some checks weither
symbols defined, which is useless. This patch removes useless checks.

	* sysdeps/unix/sysv/linux/sigprocmask.c: Remove useless #ifdefs

---
 sysdeps/unix/sysv/linux/sigprocmask.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

Comments

Andreas Schwab Oct. 16, 2017, 9:04 a.m. UTC | #1
On Okt 16 2017, Yury Norov <ynorov@caviumnetworks.com> wrote:

> 	* sysdeps/unix/sysv/linux/sigprocmask.c: Remove useless #ifdefs

Ok.

Andreas.
Yury Norov Oct. 20, 2017, 3:38 p.m. UTC | #2
On Mon, Oct 16, 2017 at 11:04:49AM +0200, Andreas Schwab wrote:
> On Okt 16 2017, Yury Norov <ynorov@caviumnetworks.com> wrote:
> 
> > 	* sysdeps/unix/sysv/linux/sigprocmask.c: Remove useless #ifdefs
> 
> Ok.

Hi Andreas, all,

Thank you for your review. I looked at the code again and found
another syscalls that check SIGCANCEl and SIGSETXID. So below is
more generic version. Also notice that all syscalls below do the
same thing - clear nptl-internal bits in sigset. I think  it is
worth to create a helper for it, and I'll send the patch little
later.

Yury


From ed0d0bc461662c2d91b2c7fbb46415a0e0051cbc Mon Sep 17 00:00:00 2001
From: Yury Norov <ynorov@caviumnetworks.com>
Date: Mon, 16 Oct 2017 02:39:20 +0300
Subject: [PATCH v2 1/3] Remove useless #ifdefs from Linux sig*.c  syscalls

sigprocmask.c, sigtimedwait.c, sigwait.c and sigwaitinfo.c files from
sysdeps/unix/sysv/linux include nptl-signals.h via nptl/pthreadP.h,
and so SIGCANCEL and SIGSETXID become defined unconditionally. But
later in the code, there are some checks weither symbols defined,
which is useless. This patch removes useless checks.

	* sysdeps/unix/sysv/linux/sigprocmask.c: Remove useless #ifdefs;
	* sysdeps/unix/sysv/linux/sigtimedwait.c: Likewise;
	* sysdeps/unix/sysv/linux/sigwait.c: Likewise;
	* sysdeps/unix/sysv/linux/sigwaitinfo.c: Likewise.

Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>
---
 sysdeps/unix/sysv/linux/sigprocmask.c  | 9 +--------
 sysdeps/unix/sysv/linux/sigtimedwait.c | 9 +--------
 sysdeps/unix/sysv/linux/sigwait.c      | 9 +--------
 sysdeps/unix/sysv/linux/sigwaitinfo.c  | 9 +--------
 4 files changed, 4 insertions(+), 32 deletions(-)
diff --git a/sysdeps/unix/sysv/linux/sigprocmask.c b/sysdeps/unix/sysv/linux/sigprocmask.c
index d0b8e049b2..e776563336 100644
--- a/sysdeps/unix/sysv/linux/sigprocmask.c
+++ b/sysdeps/unix/sysv/linux/sigprocmask.c
@@ -30,26 +30,19 @@
 int
 __sigprocmask (int how, const sigset_t *set, sigset_t *oset)
 {
-#ifdef SIGCANCEL
   sigset_t local_newmask;
 
   /* The only thing we have to make sure here is that SIGCANCEL and
      SIGSETXID are not blocked.  */
   if (set != NULL
       && (__builtin_expect (__sigismember (set, SIGCANCEL), 0)
-# ifdef SIGSETXID
-	  || __builtin_expect (__sigismember (set, SIGSETXID), 0)
-# endif
-	  ))
+	  || __builtin_expect (__sigismember (set, SIGSETXID), 0)))
     {
       local_newmask = *set;
       __sigdelset (&local_newmask, SIGCANCEL);
-# ifdef SIGSETXID
       __sigdelset (&local_newmask, SIGSETXID);
-# endif
       set = &local_newmask;
     }
-#endif
 
   return INLINE_SYSCALL (rt_sigprocmask, 4, how, set, oset, _NSIG / 8);
 }
diff --git a/sysdeps/unix/sysv/linux/sigtimedwait.c b/sysdeps/unix/sysv/linux/sigtimedwait.c
index ab1a84ef1c..42afbce22c 100644
--- a/sysdeps/unix/sysv/linux/sigtimedwait.c
+++ b/sysdeps/unix/sysv/linux/sigtimedwait.c
@@ -29,25 +29,18 @@ int
 __sigtimedwait (const sigset_t *set, siginfo_t *info,
 		const struct timespec *timeout)
 {
-#ifdef SIGCANCEL
   sigset_t tmpset;
   if (set != NULL
       && (__builtin_expect (__sigismember (set, SIGCANCEL), 0)
-# ifdef SIGSETXID
-	  || __builtin_expect (__sigismember (set, SIGSETXID), 0)
-# endif
-	  ))
+	  || __builtin_expect (__sigismember (set, SIGSETXID), 0)))
     {
       /* Create a temporary mask without the bit for SIGCANCEL set.  */
       // We are not copying more than we have to.
       memcpy (&tmpset, set, _NSIG / 8);
       __sigdelset (&tmpset, SIGCANCEL);
-# ifdef SIGSETXID
       __sigdelset (&tmpset, SIGSETXID);
-# endif
       set = &tmpset;
     }
-#endif
 
     /* XXX The size argument hopefully will have to be changed to the
        real size of the user-level sigset_t.  */
diff --git a/sysdeps/unix/sysv/linux/sigwait.c b/sysdeps/unix/sysv/linux/sigwait.c
index 48bcd2fda7..395bd9feb6 100644
--- a/sysdeps/unix/sysv/linux/sigwait.c
+++ b/sysdeps/unix/sysv/linux/sigwait.c
@@ -33,25 +33,18 @@ do_sigwait (const sigset_t *set, int *sig)
 {
   int ret;
 
-#ifdef SIGCANCEL
   sigset_t tmpset;
   if (set != NULL
       && (__builtin_expect (__sigismember (set, SIGCANCEL), 0)
-# ifdef SIGSETXID
-	  || __builtin_expect (__sigismember (set, SIGSETXID), 0)
-# endif
-	  ))
+	  || __builtin_expect (__sigismember (set, SIGSETXID), 0)))
     {
       /* Create a temporary mask without the bit for SIGCANCEL set.  */
       // We are not copying more than we have to.
       memcpy (&tmpset, set, _NSIG / 8);
       __sigdelset (&tmpset, SIGCANCEL);
-# ifdef SIGSETXID
       __sigdelset (&tmpset, SIGSETXID);
-# endif
       set = &tmpset;
     }
-#endif
 
   /* XXX The size argument hopefully will have to be changed to the
      real size of the user-level sigset_t.  */
diff --git a/sysdeps/unix/sysv/linux/sigwaitinfo.c b/sysdeps/unix/sysv/linux/sigwaitinfo.c
index 5a044f08e3..0062d3ea86 100644
--- a/sysdeps/unix/sysv/linux/sigwaitinfo.c
+++ b/sysdeps/unix/sysv/linux/sigwaitinfo.c
@@ -31,25 +31,18 @@
 int
 __sigwaitinfo (const sigset_t *set, siginfo_t *info)
 {
-#ifdef SIGCANCEL
   sigset_t tmpset;
   if (set != NULL
       && (__builtin_expect (__sigismember (set, SIGCANCEL), 0)
-# ifdef SIGSETXID
-	  || __builtin_expect (__sigismember (set, SIGSETXID), 0)
-# endif
-	  ))
+	  || __builtin_expect (__sigismember (set, SIGSETXID), 0)))
     {
       /* Create a temporary mask without the bit for SIGCANCEL set.  */
       // We are not copying more than we have to.
       memcpy (&tmpset, set, _NSIG / 8);
       __sigdelset (&tmpset, SIGCANCEL);
-# ifdef SIGSETXID
       __sigdelset (&tmpset, SIGSETXID);
-# endif
       set = &tmpset;
     }
-#endif
 
   /* XXX The size argument hopefully will have to be changed to the
      real size of the user-level sigset_t.  */
Andreas Schwab Oct. 23, 2017, 8:07 a.m. UTC | #3
On Okt 20 2017, Yury Norov <ynorov@caviumnetworks.com> wrote:

> 	* sysdeps/unix/sysv/linux/sigprocmask.c: Remove useless #ifdefs;
> 	* sysdeps/unix/sysv/linux/sigtimedwait.c: Likewise;
> 	* sysdeps/unix/sysv/linux/sigwait.c: Likewise;
> 	* sysdeps/unix/sysv/linux/sigwaitinfo.c: Likewise.

Ok.

Andreas.
Adhemerval Zanella Oct. 31, 2017, 7:54 p.m. UTC | #4
On 23/10/2017 06:07, Andreas Schwab wrote:
> On Okt 20 2017, Yury Norov <ynorov@caviumnetworks.com> wrote:
> 
>> 	* sysdeps/unix/sysv/linux/sigprocmask.c: Remove useless #ifdefs;
>> 	* sysdeps/unix/sysv/linux/sigtimedwait.c: Likewise;
>> 	* sysdeps/unix/sysv/linux/sigwait.c: Likewise;
>> 	* sysdeps/unix/sysv/linux/sigwaitinfo.c: Likewise.
> 
> Ok.
> 
> Andreas.
> 

Pushed upstream as 87bbc4c.

Patch
diff mbox series

diff --git a/sysdeps/unix/sysv/linux/sigprocmask.c b/sysdeps/unix/sysv/linux/sigprocmask.c
index d0b8e049b2..e776563336 100644
--- a/sysdeps/unix/sysv/linux/sigprocmask.c
+++ b/sysdeps/unix/sysv/linux/sigprocmask.c
@@ -30,26 +30,19 @@ 
 int
 __sigprocmask (int how, const sigset_t *set, sigset_t *oset)
 {
-#ifdef SIGCANCEL
   sigset_t local_newmask;
 
   /* The only thing we have to make sure here is that SIGCANCEL and
      SIGSETXID are not blocked.  */
   if (set != NULL
       && (__builtin_expect (__sigismember (set, SIGCANCEL), 0)
-# ifdef SIGSETXID
-	  || __builtin_expect (__sigismember (set, SIGSETXID), 0)
-# endif
-	  ))
+	  || __builtin_expect (__sigismember (set, SIGSETXID), 0)))
     {
       local_newmask = *set;
       __sigdelset (&local_newmask, SIGCANCEL);
-# ifdef SIGSETXID
       __sigdelset (&local_newmask, SIGSETXID);
-# endif
       set = &local_newmask;
     }
-#endif
 
   return INLINE_SYSCALL (rt_sigprocmask, 4, how, set, oset, _NSIG / 8);
 }