This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new ba05c7f1339 sched/signal: Fix nxsig_ismember() return value behavior
ba05c7f1339 is described below

commit ba05c7f13391fd81a40e8cff0fbd8f34621ca9c3
Author: wangchengdong <[email protected]>
AuthorDate: Fri Nov 21 15:44:59 2025 +0800

    sched/signal: Fix nxsig_ismember() return value behavior
    
    nxsig_ismember() has a return type of int, but the current
    implementation returns a boolean value, which is incorrect.
    
    All callers should determine membership by checking whether
    the return value is 1 or 0, which is also consistent with the POSIX 
sigismember() API.
    
    Signed-off-by: Chengdong Wang [email protected]
---
 fs/vfs/fs_signalfd.c            | 6 +++---
 libs/libc/signal/sig_ismember.c | 2 +-
 sched/group/group_signal.c      | 2 +-
 sched/signal/sig_dispatch.c     | 2 +-
 sched/signal/sig_lowest.c       | 2 +-
 sched/signal/sig_timedwait.c    | 2 +-
 6 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/fs/vfs/fs_signalfd.c b/fs/vfs/fs_signalfd.c
index ad8ab46a2dc..15561701e27 100644
--- a/fs/vfs/fs_signalfd.c
+++ b/fs/vfs/fs_signalfd.c
@@ -149,7 +149,7 @@ static int signalfd_file_close(FAR struct file *filep)
 
   for (signo = MIN_SIGNO; signo <= MAX_SIGNO; signo++)
     {
-      if (nxsig_ismember(&dev->sigmask, signo))
+      if (nxsig_ismember(&dev->sigmask, signo) == 1)
         {
           signal(signo, SIG_DFL);
         }
@@ -379,7 +379,7 @@ int signalfd(int fd, FAR const sigset_t *mask, int flags)
       dev = filep->f_priv;
       for (signo = MIN_SIGNO; signo <= MAX_SIGNO; signo++)
         {
-          if (nxsig_ismember(&dev->sigmask, signo))
+          if (nxsig_ismember(&dev->sigmask, signo) == 1)
             {
               signal(signo, SIG_DFL);
             }
@@ -394,7 +394,7 @@ int signalfd(int fd, FAR const sigset_t *mask, int flags)
   act.sa_user = dev;
   for (signo = MIN_SIGNO; signo <= MAX_SIGNO; signo++)
     {
-      if (nxsig_ismember(&dev->sigmask, signo))
+      if (nxsig_ismember(&dev->sigmask, signo) == 1)
         {
           nxsig_action(signo, &act, NULL, false);
         }
diff --git a/libs/libc/signal/sig_ismember.c b/libs/libc/signal/sig_ismember.c
index 0b760c728c3..d0333ddb1b9 100644
--- a/libs/libc/signal/sig_ismember.c
+++ b/libs/libc/signal/sig_ismember.c
@@ -68,7 +68,7 @@ int nxsig_ismember(FAR const sigset_t *set, int signo)
     {
       /* Check if the signal is in the set */
 
-      return ((set->_elem[_SIGSET_NDX(signo)] & _SIGNO2SET(signo)) != 0);
+      return (set->_elem[_SIGSET_NDX(signo)] & _SIGNO2SET(signo)) ? 1 : 0;
     }
 }
 
diff --git a/sched/group/group_signal.c b/sched/group/group_signal.c
index a0197ebf0d9..a15b364ae86 100644
--- a/sched/group/group_signal.c
+++ b/sched/group/group_signal.c
@@ -127,7 +127,7 @@ static int group_signal_handler(pid_t pid, FAR void *arg)
 
   /* Is this signal unblocked on this thread? */
 
-  if (!nxsig_ismember(&tcb->sigprocmask, info->siginfo->si_signo) &&
+  if ((nxsig_ismember(&tcb->sigprocmask, info->siginfo->si_signo) != 1) &&
       !info->ptcb && tcb != info->atcb)
     {
       /* Yes.. remember this TCB if we have not encountered any
diff --git a/sched/signal/sig_dispatch.c b/sched/signal/sig_dispatch.c
index e1cd559f49a..723799c17df 100644
--- a/sched/signal/sig_dispatch.c
+++ b/sched/signal/sig_dispatch.c
@@ -550,7 +550,7 @@ int nxsig_tcbdispatch(FAR struct tcb_s *stcb, siginfo_t 
*info,
 
       if (stcb->task_state == TSTATE_WAIT_SIG &&
           (masked == 0 ||
-           nxsig_ismember(&stcb->sigwaitmask, info->si_signo)))
+           (nxsig_ismember(&stcb->sigwaitmask, info->si_signo) == 1)))
         {
           if (stcb->sigunbinfo != NULL)
             {
diff --git a/sched/signal/sig_lowest.c b/sched/signal/sig_lowest.c
index 0cabc1b34b8..9816031ca77 100644
--- a/sched/signal/sig_lowest.c
+++ b/sched/signal/sig_lowest.c
@@ -50,7 +50,7 @@ int nxsig_lowest(sigset_t *set)
 
   for (signo = MIN_SIGNO; signo <= MAX_SIGNO; signo++)
     {
-      if (nxsig_ismember(set, signo))
+      if (nxsig_ismember(set, signo) == 1)
         {
           return signo;
         }
diff --git a/sched/signal/sig_timedwait.c b/sched/signal/sig_timedwait.c
index 234e472fb07..19f9f400385 100644
--- a/sched/signal/sig_timedwait.c
+++ b/sched/signal/sig_timedwait.c
@@ -419,7 +419,7 @@ int nxsig_timedwait(FAR const sigset_t *set, FAR struct 
siginfo *info,
            * that we were waiting for?
            */
 
-          if (nxsig_ismember(set, rtcb->sigunbinfo->si_signo))
+          if (nxsig_ismember(set, rtcb->sigunbinfo->si_signo) == 1)
             {
               /* Yes.. the return value is the number of the signal that
                * awakened us.

Reply via email to