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 5b4e12774c sched: remove unnecessary type cast
5b4e12774c is described below

commit 5b4e12774c0aa6e7b3139ea245c216fada6e775c
Author: Petro Karashchenko <petro.karashche...@gmail.com>
AuthorDate: Thu Dec 15 01:02:44 2022 +0200

    sched: remove unnecessary type cast
    
    fix code style issues
    
    Signed-off-by: Petro Karashchenko <petro.karashche...@gmail.com>
---
 sched/sched/sched_addprioritized.c   |  8 ++++----
 sched/sched/sched_addreadytorun.c    | 12 ++++++------
 sched/sched/sched_mergepending.c     |  2 +-
 sched/sched/sched_removereadytorun.c |  7 +++----
 sched/sched/sched_setpriority.c      |  6 +++---
 sched/semaphore/sem_holder.c         |  4 ++--
 sched/signal/sig_default.c           |  4 ++--
 sched/task/task_delete.c             |  2 +-
 sched/wqueue/kwork_thread.c          |  2 +-
 9 files changed, 23 insertions(+), 24 deletions(-)

diff --git a/sched/sched/sched_addprioritized.c 
b/sched/sched/sched_addprioritized.c
index 6dfde44ce6..eeab29b066 100644
--- a/sched/sched/sched_addprioritized.c
+++ b/sched/sched/sched_addprioritized.c
@@ -86,12 +86,12 @@ bool nxsched_add_prioritized(FAR struct tcb_s *tcb, DSEG 
dq_queue_t *list)
    * is the g_pendingtasks list!
    */
 
-  if (!next)
+  if (next == NULL)
     {
       /* The tcb goes at the end of the list. */
 
       prev = (FAR struct tcb_s *)list->tail;
-      if (!prev)
+      if (prev == NULL)
         {
           /* Special case:  The list is empty */
 
@@ -115,8 +115,8 @@ bool nxsched_add_prioritized(FAR struct tcb_s *tcb, DSEG 
dq_queue_t *list)
     {
       /* The tcb goes just before next */
 
-      prev = (FAR struct tcb_s *)next->blink;
-      if (!prev)
+      prev = next->blink;
+      if (prev == NULL)
         {
           /* Special case:  Insert at the head of the list */
 
diff --git a/sched/sched/sched_addreadytorun.c 
b/sched/sched/sched_addreadytorun.c
index 03cea2e176..a4434423e0 100644
--- a/sched/sched/sched_addreadytorun.c
+++ b/sched/sched/sched_addreadytorun.c
@@ -165,7 +165,7 @@ bool nxsched_add_readytorun(FAR struct tcb_s *btcb)
     {
       /* Yes.. that is the CPU we must use */
 
-      cpu  = btcb->cpu;
+      cpu = btcb->cpu;
     }
   else
     {
@@ -178,7 +178,7 @@ bool nxsched_add_readytorun(FAR struct tcb_s *btcb)
 
   /* Get the task currently running on the CPU (may be the IDLE task) */
 
-  rtcb = (FAR struct tcb_s *)g_assignedtasks[cpu].head;
+  rtcb = current_task(cpu);
 
   /* Determine the desired new task state.  First, if the new task priority
    * is higher then the priority of the lowest priority, running task, then
@@ -198,7 +198,7 @@ bool nxsched_add_readytorun(FAR struct tcb_s *btcb)
   else if ((btcb->flags & TCB_FLAG_CPU_LOCKED) != 0)
     {
       task_state = TSTATE_TASK_ASSIGNED;
-      cpu = btcb->cpu;
+      cpu        = btcb->cpu;
     }
 
   /* Otherwise, it will be ready-to-run, but not not yet running */
@@ -206,7 +206,7 @@ bool nxsched_add_readytorun(FAR struct tcb_s *btcb)
   else
     {
       task_state = TSTATE_TASK_READYTORUN;
-      cpu = 0;  /* CPU does not matter */
+      cpu        = 0;  /* CPU does not matter */
     }
 
   /* If the selected state is TSTATE_TASK_RUNNING, then we would like to
@@ -232,7 +232,7 @@ bool nxsched_add_readytorun(FAR struct tcb_s *btcb)
 
       nxsched_add_prioritized(btcb, &g_pendingtasks);
       btcb->task_state = TSTATE_TASK_PENDING;
-      doswitch = false;
+      doswitch         = false;
     }
   else if (task_state == TSTATE_TASK_READYTORUN)
     {
@@ -316,7 +316,7 @@ bool nxsched_add_readytorun(FAR struct tcb_s *btcb)
            */
 
           DEBUGASSERT(btcb->flink != NULL);
-          next = (FAR struct tcb_s *)btcb->flink;
+          next = btcb->flink;
 
           if ((next->flags & TCB_FLAG_CPU_LOCKED) != 0)
             {
diff --git a/sched/sched/sched_mergepending.c b/sched/sched/sched_mergepending.c
index 82ee9dd0cc..5c30d3ca6c 100644
--- a/sched/sched/sched_mergepending.c
+++ b/sched/sched/sched_mergepending.c
@@ -116,7 +116,7 @@ bool nxsched_merge_pending(void)
       /* The ptcb goes just before rtcb */
 
       rprev = rtcb->blink;
-      if (!rprev)
+      if (rprev == NULL)
         {
           /* Special case: Inserting ptcb at the head of the list */
 
diff --git a/sched/sched/sched_removereadytorun.c 
b/sched/sched/sched_removereadytorun.c
index bd3c26ebd4..d4a85da7bc 100644
--- a/sched/sched/sched_removereadytorun.c
+++ b/sched/sched/sched_removereadytorun.c
@@ -146,8 +146,7 @@ bool nxsched_remove_readytorun(FAR struct tcb_s *rtcb, bool 
merge)
    * assigned to a CPU, and (2) and the g_assignedtasks[] lists which hold
    * tasks assigned a CPU, including the task that is currently running on
    * that CPU.  Only this latter list contains the currently active task
-   * only only removing the head of that list can result in a context
-   * switch.
+   * only removing the head of that list can result in a context switch.
    *
    * rtcb->blink == NULL will tell us if the TCB is at the head of the
    * ready-to-run list and, hence, a candidate for the new running task.
@@ -167,7 +166,7 @@ bool nxsched_remove_readytorun(FAR struct tcb_s *rtcb, bool 
merge)
        * after the TCB being removed.
        */
 
-      nxttcb = (FAR struct tcb_s *)rtcb->flink;
+      nxttcb = rtcb->flink;
       DEBUGASSERT(nxttcb != NULL);
 
       /* If we are modifying the head of some assigned task list other than
@@ -206,7 +205,7 @@ bool nxsched_remove_readytorun(FAR struct tcb_s *rtcb, bool 
merge)
 
           for (rtrtcb = (FAR struct tcb_s *)g_readytorun.head;
                rtrtcb != NULL && !CPU_ISSET(cpu, &rtrtcb->affinity);
-               rtrtcb = (FAR struct tcb_s *)rtrtcb->flink);
+               rtrtcb = rtrtcb->flink);
         }
 
       /* Did we find a task in the g_readytorun list?  Which task should
diff --git a/sched/sched/sched_setpriority.c b/sched/sched/sched_setpriority.c
index 0ac0b93946..15b5432b18 100644
--- a/sched/sched/sched_setpriority.c
+++ b/sched/sched/sched_setpriority.c
@@ -56,7 +56,7 @@
 #ifdef CONFIG_SMP
 static FAR struct tcb_s *nxsched_nexttcb(FAR struct tcb_s *tcb)
 {
-  FAR struct tcb_s *nxttcb = (FAR struct tcb_s *)tcb->flink;
+  FAR struct tcb_s *nxttcb = tcb->flink;
   FAR struct tcb_s *rtrtcb;
 
   /* Which task should run next?  It will be either the next tcb in the
@@ -74,7 +74,7 @@ static FAR struct tcb_s *nxsched_nexttcb(FAR struct tcb_s 
*tcb)
 
       for (rtrtcb = (FAR struct tcb_s *)g_readytorun.head;
            rtrtcb != NULL && !CPU_ISSET(tcb->cpu, &rtrtcb->affinity);
-           rtrtcb = (FAR struct tcb_s *)rtrtcb->flink);
+           rtrtcb = rtrtcb->flink);
 
       /* Return the TCB from the readyt-to-run list if it is the next
        * highest priority task.
@@ -128,7 +128,7 @@ static inline void nxsched_running_setpriority(FAR struct 
tcb_s *tcb,
 #ifdef CONFIG_SMP
   nxttcb = nxsched_nexttcb(tcb);
 #else
-  nxttcb = (FAR struct tcb_s *)tcb->flink;
+  nxttcb = tcb->flink;
 #endif
 
   DEBUGASSERT(nxttcb != NULL);
diff --git a/sched/semaphore/sem_holder.c b/sched/semaphore/sem_holder.c
index 9a79ab4ae7..181a4d32dc 100644
--- a/sched/semaphore/sem_holder.c
+++ b/sched/semaphore/sem_holder.c
@@ -322,7 +322,7 @@ static int nxsem_recoverholders(FAR struct semholder_s 
*pholder,
 static int nxsem_boostholderprio(FAR struct semholder_s *pholder,
                                  FAR sem_t *sem, FAR void *arg)
 {
-  FAR struct tcb_s *htcb = (FAR struct tcb_s *)pholder->htcb;
+  FAR struct tcb_s *htcb = pholder->htcb;
   FAR struct tcb_s *rtcb = (FAR struct tcb_s *)arg;
 
   /* If the priority of the thread that is waiting for a count is less than
@@ -357,7 +357,7 @@ static int nxsem_verifyholder(FAR struct semholder_s 
*pholder,
    */
 
 #if 0
-  FAR struct tcb_s *htcb = (FAR struct tcb_s *)pholder->htcb;
+  FAR struct tcb_s *htcb = pholder->htcb;
 
   /* Called after a semaphore has been released (incremented), the semaphore
    * could be non-negative, and there is no thread waiting for the count.
diff --git a/sched/signal/sig_default.c b/sched/signal/sig_default.c
index 2f9063ae2a..904f8161aa 100644
--- a/sched/signal/sig_default.c
+++ b/sched/signal/sig_default.c
@@ -192,7 +192,7 @@ static void nxsig_null_action(int signo)
 #ifdef HAVE_NXSIG_ABNORMAL_TERMINANTION
 static void nxsig_abnormal_termination(int signo)
 {
-  FAR struct tcb_s *rtcb = (FAR struct tcb_s *)this_task();
+  FAR struct tcb_s *rtcb = this_task();
 
   /* Careful:  In the multi-threaded task, the signal may be handled on a
    * child pthread.
@@ -248,7 +248,7 @@ static void nxsig_abnormal_termination(int signo)
 #ifdef CONFIG_SIG_SIGSTOP_ACTION
 static void nxsig_stop_task(int signo)
 {
-  FAR struct tcb_s *rtcb = (FAR struct tcb_s *)this_task();
+  FAR struct tcb_s *rtcb = this_task();
 #if defined(CONFIG_SCHED_WAITPID) && !defined(CONFIG_SCHED_HAVE_PARENT)
   FAR struct task_group_s *group;
 
diff --git a/sched/task/task_delete.c b/sched/task/task_delete.c
index 1234cec19b..95607d8fc7 100644
--- a/sched/task/task_delete.c
+++ b/sched/task/task_delete.c
@@ -81,7 +81,7 @@ int nxtask_delete(pid_t pid)
 
   /* Get the TCB of the task to be deleted */
 
-  dtcb = (FAR struct tcb_s *)nxsched_get_tcb(pid);
+  dtcb = nxsched_get_tcb(pid);
   if (dtcb == NULL)
     {
       /* The pid does not correspond to any known thread.  The task
diff --git a/sched/wqueue/kwork_thread.c b/sched/wqueue/kwork_thread.c
index fa39326327..806024d4bd 100644
--- a/sched/wqueue/kwork_thread.c
+++ b/sched/wqueue/kwork_thread.c
@@ -126,7 +126,7 @@ static int work_thread(int argc, FAR char *argv[])
 {
   FAR struct kwork_wqueue_s *wqueue;
   FAR struct work_s *work;
-  worker_t  worker;
+  worker_t worker;
   irqstate_t flags;
   FAR void *arg;
 

Reply via email to