Skip to content

Commit ba05c7f

Browse files
wangchdoxiaoxiang781216
authored andcommitted
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]
1 parent 817e4ee commit ba05c7f

File tree

6 files changed

+8
-8
lines changed

6 files changed

+8
-8
lines changed

fs/vfs/fs_signalfd.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ static int signalfd_file_close(FAR struct file *filep)
149149

150150
for (signo = MIN_SIGNO; signo <= MAX_SIGNO; signo++)
151151
{
152-
if (nxsig_ismember(&dev->sigmask, signo))
152+
if (nxsig_ismember(&dev->sigmask, signo) == 1)
153153
{
154154
signal(signo, SIG_DFL);
155155
}
@@ -379,7 +379,7 @@ int signalfd(int fd, FAR const sigset_t *mask, int flags)
379379
dev = filep->f_priv;
380380
for (signo = MIN_SIGNO; signo <= MAX_SIGNO; signo++)
381381
{
382-
if (nxsig_ismember(&dev->sigmask, signo))
382+
if (nxsig_ismember(&dev->sigmask, signo) == 1)
383383
{
384384
signal(signo, SIG_DFL);
385385
}
@@ -394,7 +394,7 @@ int signalfd(int fd, FAR const sigset_t *mask, int flags)
394394
act.sa_user = dev;
395395
for (signo = MIN_SIGNO; signo <= MAX_SIGNO; signo++)
396396
{
397-
if (nxsig_ismember(&dev->sigmask, signo))
397+
if (nxsig_ismember(&dev->sigmask, signo) == 1)
398398
{
399399
nxsig_action(signo, &act, NULL, false);
400400
}

libs/libc/signal/sig_ismember.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ int nxsig_ismember(FAR const sigset_t *set, int signo)
6868
{
6969
/* Check if the signal is in the set */
7070

71-
return ((set->_elem[_SIGSET_NDX(signo)] & _SIGNO2SET(signo)) != 0);
71+
return (set->_elem[_SIGSET_NDX(signo)] & _SIGNO2SET(signo)) ? 1 : 0;
7272
}
7373
}
7474

sched/group/group_signal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ static int group_signal_handler(pid_t pid, FAR void *arg)
127127

128128
/* Is this signal unblocked on this thread? */
129129

130-
if (!nxsig_ismember(&tcb->sigprocmask, info->siginfo->si_signo) &&
130+
if ((nxsig_ismember(&tcb->sigprocmask, info->siginfo->si_signo) != 1) &&
131131
!info->ptcb && tcb != info->atcb)
132132
{
133133
/* Yes.. remember this TCB if we have not encountered any

sched/signal/sig_dispatch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ int nxsig_tcbdispatch(FAR struct tcb_s *stcb, siginfo_t *info,
550550

551551
if (stcb->task_state == TSTATE_WAIT_SIG &&
552552
(masked == 0 ||
553-
nxsig_ismember(&stcb->sigwaitmask, info->si_signo)))
553+
(nxsig_ismember(&stcb->sigwaitmask, info->si_signo) == 1)))
554554
{
555555
if (stcb->sigunbinfo != NULL)
556556
{

sched/signal/sig_lowest.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ int nxsig_lowest(sigset_t *set)
5050

5151
for (signo = MIN_SIGNO; signo <= MAX_SIGNO; signo++)
5252
{
53-
if (nxsig_ismember(set, signo))
53+
if (nxsig_ismember(set, signo) == 1)
5454
{
5555
return signo;
5656
}

sched/signal/sig_timedwait.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ int nxsig_timedwait(FAR const sigset_t *set, FAR struct siginfo *info,
419419
* that we were waiting for?
420420
*/
421421

422-
if (nxsig_ismember(set, rtcb->sigunbinfo->si_signo))
422+
if (nxsig_ismember(set, rtcb->sigunbinfo->si_signo) == 1)
423423
{
424424
/* Yes.. the return value is the number of the signal that
425425
* awakened us.

0 commit comments

Comments
 (0)