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

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


The following commit(s) were added to refs/heads/master by this push:
     new 1b4d8b3734 sched: remove DEBUGASSERT from nx_waitpid
1b4d8b3734 is described below

commit 1b4d8b373452874e1590c23b05694b02fc6eea06
Author: Petro Karashchenko <petro.karashche...@gmail.com>
AuthorDate: Fri Apr 22 17:14:05 2022 +0200

    sched: remove DEBUGASSERT from nx_waitpid
    
    Signed-off-by: Petro Karashchenko <petro.karashche...@gmail.com>
---
 sched/sched/sched_waitpid.c | 21 ++++++++++++++-------
 sched/task/task_exithook.c  |  2 +-
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/sched/sched/sched_waitpid.c b/sched/sched/sched_waitpid.c
index a1a74fc505..aac39eeea6 100644
--- a/sched/sched/sched_waitpid.c
+++ b/sched/sched/sched_waitpid.c
@@ -55,8 +55,6 @@ pid_t nx_waitpid(pid_t pid, int *stat_loc, int options)
   bool mystat = false;
   int ret;
 
-  DEBUGASSERT(stat_loc);
-
   /* NOTE: sched_lock() is not enough for SMP
    * because the child task is running on another CPU
    */
@@ -194,8 +192,6 @@ pid_t nx_waitpid(pid_t pid, int *stat_loc, int options)
   sigset_t set;
   int ret;
 
-  DEBUGASSERT(stat_loc);
-
   /* Create a signal set that contains only SIGCHLD */
 
   sigemptyset(&set);
@@ -312,7 +308,11 @@ pid_t nx_waitpid(pid_t pid, int *stat_loc, int options)
 
               /* The child has exited. Return the saved exit status */
 
-              *stat_loc = child->ch_status << 8;
+              if (stat_loc != NULL)
+                {
+                  *stat_loc = child->ch_status << 8;
+                }
+
               pid = child->ch_pid;
 
               /* Discard the child entry and break out of the loop */
@@ -340,7 +340,10 @@ pid_t nx_waitpid(pid_t pid, int *stat_loc, int options)
             {
               /* The child has exited. Return the saved exit status */
 
-              *stat_loc = child->ch_status << 8;
+              if (stat_loc != NULL)
+                {
+                  *stat_loc = child->ch_status << 8;
+                }
 
               /* Discard the child entry and break out of the loop */
 
@@ -415,7 +418,11 @@ pid_t nx_waitpid(pid_t pid, int *stat_loc, int options)
         {
           /* Yes... return the status and PID (in the event it was -1) */
 
-          *stat_loc = info.si_status << 8;
+          if (stat_loc != NULL)
+            {
+              *stat_loc = info.si_status << 8;
+            }
+
           pid = info.si_pid;
 
 #ifdef CONFIG_SCHED_CHILD_STATUS
diff --git a/sched/task/task_exithook.c b/sched/task/task_exithook.c
index ce939b3a22..0955658f5f 100644
--- a/sched/task/task_exithook.c
+++ b/sched/task/task_exithook.c
@@ -469,7 +469,7 @@ static inline void nxtask_exitwakeup(FAR struct tcb_s *tcb, 
int status)
            *  Hmmm.. what do we return to the others?
            */
 
-          if (group->tg_statloc)
+          if (group->tg_statloc != NULL)
             {
               *group->tg_statloc = status << 8;
             }

Reply via email to