You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by gn...@apache.org on 2020/05/03 18:16:12 UTC

[incubator-nuttx] 07/09: sched: task_init as internal function shouldn't modify errno

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

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

commit 3c84278aa742e398115c724f87e29fb1fe91758f
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Sun May 3 19:56:49 2020 +0800

    sched: task_init as internal function shouldn't modify errno
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 binfmt/binfmt_execmodule.c |  1 -
 sched/task/task_init.c     | 10 ++--------
 2 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/binfmt/binfmt_execmodule.c b/binfmt/binfmt_execmodule.c
index 88f1edd..dd19c82 100644
--- a/binfmt/binfmt_execmodule.c
+++ b/binfmt/binfmt_execmodule.c
@@ -170,7 +170,6 @@ int exec_module(FAR const struct binary_s *binp)
                   stack, binp->stacksize, binp->entrypt, binp->argv);
   if (ret < 0)
     {
-      ret = -get_errno();
       berr("task_init() failed: %d\n", ret);
       kumm_free(stack);
       goto errout_with_addrenv;
diff --git a/sched/task/task_init.c b/sched/task/task_init.c
index d544508..08462ab 100644
--- a/sched/task/task_init.c
+++ b/sched/task/task_init.c
@@ -65,7 +65,7 @@
  *                parameters are required, argv may be NULL.
  *
  * Returned Value:
- *   OK on success; ERROR on failure with errno set appropriately.  (See
+ *   OK on success; negative error value on failure appropriately.  (See
  *   nxtask_schedsetup() for possible failure conditions).  On failure, the
  *   caller is responsible for freeing the stack memory and for calling
  *   sched_releasetcb() to free the TCB (which could be in most any state).
@@ -77,7 +77,6 @@ int task_init(FAR struct tcb_s *tcb, const char *name, int priority,
               main_t entry, FAR char * const argv[])
 {
   FAR struct task_tcb_s *ttcb = (FAR struct task_tcb_s *)tcb;
-  int errcode;
   int ret;
 
   /* Only tasks and kernel threads can be initialized in this way */
@@ -92,7 +91,6 @@ int task_init(FAR struct tcb_s *tcb, const char *name, int priority,
   ret = group_allocate(ttcb, tcb->flags);
   if (ret < 0)
     {
-      errcode = -ret;
       goto errout;
     }
 
@@ -101,7 +99,6 @@ int task_init(FAR struct tcb_s *tcb, const char *name, int priority,
   ret = group_setuptaskfiles(ttcb);
   if (ret < 0)
     {
-      errcode = -ret;
       goto errout_with_group;
     }
 
@@ -115,7 +112,6 @@ int task_init(FAR struct tcb_s *tcb, const char *name, int priority,
                           TCB_FLAG_TTYPE_TASK);
   if (ret < OK)
     {
-      errcode = -ret;
       goto errout_with_group;
     }
 
@@ -128,7 +124,6 @@ int task_init(FAR struct tcb_s *tcb, const char *name, int priority,
   ret = group_initialize(ttcb);
   if (ret < 0)
     {
-      errcode = -ret;
       goto errout_with_group;
     }
 
@@ -138,6 +133,5 @@ errout_with_group:
   group_leave(tcb);
 
 errout:
-  set_errno(errcode);
-  return ERROR;
+  return ret;
 }