This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 1baafcc8b2288cda6fbad8adfc16ec5f39ea7dda Author: makejian <[email protected]> AuthorDate: Wed Nov 25 13:02:19 2026 +0800 signal: fix nxsig_notification misra coverity Keep one exit path in nxsig_notification(): hold the result in a local variable for the SIGEV_SIGNAL dispatch and the SIGEV_THREAD work queue entry instead of returning from the middle of the function, and cast the si_code assignment to uint8_t, as the MISRA C:2012 guidelines require. Signed-off-by: makejian <[email protected]> --- sched/signal/sig_notification.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sched/signal/sig_notification.c b/sched/signal/sig_notification.c index a7b9125763e..aa878664609 100644 --- a/sched/signal/sig_notification.c +++ b/sched/signal/sig_notification.c @@ -165,6 +165,8 @@ int nxsig_notification_source(pid_t pid, FAR struct sigevent *event, int code, FAR struct sigwork_s *work, FAR const void *source) { + int ret = event->sigev_notify == SIGEV_NONE ? OK : -ENOSYS; + sinfo("pid=%" PRIu16 " signo=%d code=%d sival_ptr=%p\n", pid, event->sigev_signo, code, event->sigev_value.sival_ptr); @@ -178,7 +180,7 @@ int nxsig_notification_source(pid_t pid, FAR struct sigevent *event, /* Yes.. Create the siginfo structure */ info.si_signo = event->sigev_signo; - info.si_code = code; + info.si_code = (uint8_t)code; info.si_errno = OK; #ifdef CONFIG_SCHED_HAVE_PARENT info.si_pid = this_task()->pid; @@ -205,7 +207,7 @@ int nxsig_notification_source(pid_t pid, FAR struct sigevent *event, /* Send the signal */ - return nxsig_dispatch(pid, &info, thread, source, false); + ret = nxsig_dispatch(pid, &info, thread, source, false); } #ifdef CONFIG_SIG_EVTHREAD @@ -224,12 +226,12 @@ int nxsig_notification_source(pid_t pid, FAR struct sigevent *event, /* Then queue the work */ - return work_queue(SIG_EVTHREAD_WORK, &work->work, - nxsig_notification_worker, work, 0); + ret = work_queue(SIG_EVTHREAD_WORK, &work->work, + nxsig_notification_worker, work, 0); } #endif - return event->sigev_notify == SIGEV_NONE ? OK : -ENOSYS; + return ret; } /****************************************************************************
