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/04/30 03:40:36 UTC

[incubator-nuttx] branch master updated: sched/paging: Fix error: variable 'result' set but not used

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


The following commit(s) were added to refs/heads/master by this push:
     new 45c168c  sched/paging: Fix error: variable 'result' set but not used
45c168c is described below

commit 45c168c5ef0d7d85e91b7bdef393a45711e4dff5
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Thu Apr 30 10:00:27 2020 +0800

    sched/paging: Fix error: variable 'result' set but not used
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 sched/paging/pg_worker.c | 114 +++++++++++++++++++++++++----------------------
 1 file changed, 60 insertions(+), 54 deletions(-)

diff --git a/sched/paging/pg_worker.c b/sched/paging/pg_worker.c
index 72bc0de..a73a36b 100644
--- a/sched/paging/pg_worker.c
+++ b/sched/paging/pg_worker.c
@@ -72,7 +72,8 @@ pid_t g_pgworker;
 
 /* The page fill worker thread maintains a static variable called g_pftcb.
  * If no fill is in progress, g_pftcb will be NULL. Otherwise, g_pftcb will
- * point to the TCB of the task which is receiving the fill that is in progress.
+ * point to the TCB of the task which is receiving the fill that is in
+ * progress.
  *
  * NOTE: I think that this is the only state in which a TCB does not reside
  * in some list.  Here is it in limbo, outside of the normally queuing while
@@ -230,23 +231,24 @@ static void pg_callback(FAR struct tcb_s *tcb, int result)
 
 static inline bool pg_dequeue(void)
 {
-  /* Loop until either (1) the TCB of a task that requires a fill is found, OR
-   * (2) the g_watingforfill list becomes empty.
+  /* Loop until either (1) the TCB of a task that requires a fill is found,
+   * OR (2) the g_watingforfill list becomes empty.
    */
 
   do
     {
       /* Remove the TCB from the head of the list (if any) */
 
-      g_pftcb = (FAR struct tcb_s *)dq_remfirst((dq_queue_t *)&g_waitingforfill);
+      g_pftcb = (FAR struct tcb_s *)
+        dq_remfirst((FAR dq_queue_t *)&g_waitingforfill);
       pginfo("g_pftcb: %p\n", g_pftcb);
       if (g_pftcb != NULL)
         {
-          /* Call the architecture-specific function up_checkmapping() to see if
-           * the page fill still needs to be performed. In certain conditions,
-           * the page fault may occur on several threads for the same page and
-           * be queues multiple times. In this corner case, the blocked task will
-           * simply be restarted.
+          /* Call the architecture-specific function up_checkmapping() to see
+           * if the page fill still needs to be performed. In certain
+           * conditions, the page fault may occur on several threads for the
+           * same page and be queues multiple times. In this corner case, the
+           * blocked task will simply be restarted.
            */
 
           if (!up_checkmapping(g_pftcb))
@@ -352,10 +354,10 @@ static inline bool pg_startfill(void)
 
   if (pg_dequeue())
     {
-      /* Call up_allocpage(tcb, &vpage). This architecture-specific function will
-       * set aside page in memory and map to virtual address (vpage). If all
-       * available pages are in-use (the typical case), this function will select
-       * a page in-use, un-map it, and make it available.
+      /* Call up_allocpage(tcb, &vpage). This architecture-specific function
+       * will set aside page in memory and map to virtual address (vpage). If
+       * all available pages are in-use (the typical case), this function
+       * will select a page in-use, un-map it, and make it available.
        */
 
       pginfo("Call up_allocpage(%p)\n", g_pftcb);
@@ -363,29 +365,30 @@ static inline bool pg_startfill(void)
       DEBUGASSERT(result == OK);
 
       /* Start the fill.  The exact way that the fill is started depends upon
-       * the nature of the architecture-specific up_fillpage() function -- Is it
-       * a blocking or a non-blocking call?
+       * the nature of the architecture-specific up_fillpage() function -- Is
+       * it a blocking or a non-blocking call?
        */
 
 #ifdef CONFIG_PAGING_BLOCKINGFILL
-      /* If CONFIG_PAGING_BLOCKINGFILL is defined, then up_fillpage is blocking
-       * call. In this case, up_fillpage() will accept only (1) a reference to
-       * the TCB that requires the fill. Architecture-specific context information
-       * within the TCB will be sufficient to perform the fill. And (2) the
-       * (virtual) address of the allocated page to be filled. The resulting
-       * status of the fill will be provided by return value from up_fillpage().
+      /* If CONFIG_PAGING_BLOCKINGFILL is defined, then up_fillpage is
+       * blocking call. In this case, up_fillpage() will accept only (1) a
+       * reference to the TCB that requires the fill. Architecture-specific
+       * context information within the TCB will be sufficient to perform the
+       * fill. And (2) the (virtual) address of the allocated page to be
+       * filled. The resulting status of the fill will be provided by return
+       * value from up_fillpage().
        */
 
       pginfo("Call up_fillpage(%p)\n", g_pftcb);
       result = up_fillpage(g_pftcb, vpage);
       DEBUGASSERT(result == OK);
 #else
-      /* If CONFIG_PAGING_BLOCKINGFILL is defined, then up_fillpage is non-blocking
-       * call. In this case up_fillpage() will accept an additional argument:  The
-       * page fill worker thread will provide a callback function, pg_callback.
-       *
-       * Calling up_fillpage will start an asynchronous page fill. pg_callback
-       * ill be called when the page fill is finished (or an error occurs). This
+      /* If CONFIG_PAGING_BLOCKINGFILL is defined, then up_fillpage is non-
+       * blocking call. In this case up_fillpage() will accept an additional
+       * argument: The page fill worker thread will provide a callback
+       * function, pg_callback.
+       * up_fillpage will start an asynchronous page fill. pg_callback
+       * will be called when the page fill is finished (or an error occurs).
        * This callback will probably from interrupt level.
        */
 
@@ -393,23 +396,24 @@ static inline bool pg_startfill(void)
       result = up_fillpage(g_pftcb, vpage, pg_callback);
       DEBUGASSERT(result == OK);
 
-      /* Save the time that the fill was started.  These will be used to check for
-       * timeouts.
+      /* Save the time that the fill was started.  These will be used to
+       * check for timeouts.
        */
 
 #ifdef CONFIG_PAGING_TIMEOUT_TICKS
       g_starttime = clock_systimer();
 #endif
 
-      /* Return and wait to be signaled for the next event -- the fill completion
-       * event. While the fill is in progress, other tasks may execute. If
-       * another page fault occurs during this time, the faulting task will be
-       * blocked, its TCB will be added (in priority order) to g_waitingforfill
-       * and the priority of the page worker task may be boosted. But no action
-       * will be taken until the current page fill completes. NOTE: The IDLE task
-       * must also be fully locked in memory. The IDLE task cannot be blocked. It
-       * the case where all tasks are blocked waiting for a page fill, the IDLE
-       * task must still be available to run.
+      /* Return and wait to be signaled for the next event -- the fill
+       * completion event. While the fill is in progress, other tasks may
+       * execute. If another page fault occurs during this time, the faulting
+       * task will be blocked, its TCB will be added (in priority order) to
+       * g_waitingforfill and the priority of the page worker task may be
+       * boosted. But no action will be taken until the current page fill
+       * completes. NOTE: The IDLE task must also be fully locked in memory.
+       * The IDLE task cannot be blocked. It the case where all tasks are
+       * blocked waiting for a page fill, the IDLE task must still be
+       * available to run.
        */
 
 #endif /* CONFIG_PAGING_BLOCKINGFILL */
@@ -418,6 +422,7 @@ static inline bool pg_startfill(void)
     }
 
   pginfo("Queue empty\n");
+  UNUSED(result);
   return false;
 }
 
@@ -518,8 +523,8 @@ static inline void pg_fillcomplete(void)
 
 int pg_worker(int argc, char *argv[])
 {
-  /* Loop forever -- Notice that interrupts will be disabled at all times that
-   * this thread runs.  That is so that we can't lose signals or have
+  /* Loop forever -- Notice that interrupts will be disabled at all times
+   * that this thread runs.  That is so that we can't lose signals or have
    * asynchronous page faults.
    *
    * All interrupt logic as well as all page fill worker thread logic must
@@ -532,10 +537,10 @@ int pg_worker(int argc, char *argv[])
   up_irq_save();
   for (; ; )
     {
-      /* Wait awhile.  We will wait here until either the configurable timeout
-       * elapses or until we are awakened by a signal (which terminates the
-       * nxsig_usleep with an EINTR error).  Note that interrupts will be re-
-       * enabled while this task sleeps.
+      /* Wait awhile.  We will wait here until either the configurable
+       * timeout elapses or until we are awakened by a signal (which
+       * terminates the nxsig_usleep with an EINTR error).  Note that
+       * interrupts will be re- enabled while this task sleeps.
        *
        * The timeout is a failsafe that will handle any cases where a single
        * is lost (that would really be a bug and shouldn't happen!) and also
@@ -544,7 +549,7 @@ int pg_worker(int argc, char *argv[])
 
       nxsig_usleep(CONFIG_PAGING_WORKPERIOD);
 
-      /* The page fill worker thread will be awakened on one of three conditions:
+      /* The page fill worker thread will be awakened on one of 3 conditions:
        *
        *   - When signaled by pg_miss(), the page fill worker thread will be
        *     awakened,
@@ -556,15 +561,16 @@ int pg_worker(int argc, char *argv[])
        */
 
 #ifndef CONFIG_PAGING_BLOCKINGFILL
-      /* For the non-blocking up_fillpage(), the page fill worker thread will detect
-       * that the page fill is complete when it is awakened with g_pftcb non-NULL
-       * and fill completion status from pg_callback.
+      /* For the non-blocking up_fillpage(), the page fill worker thread will
+       * detect that the page fill is complete when it is awakened with
+       * g_pftcb non-NULL and fill completion status from pg_callback.
        */
 
       if (g_pftcb != NULL)
         {
-          /* If it is a real page fill completion event, then the result of the page
-           * fill will be in g_fillresult and will not be equal to -EBUSY.
+          /* If it is a real page fill completion event, then the result of
+           * the page fill will be in g_fillresult and will not be equal to
+           * -EBUSY.
            */
 
           if (g_fillresult != -EBUSY)
@@ -573,8 +579,8 @@ int pg_worker(int argc, char *argv[])
 
               DEBUGASSERT(g_fillresult == OK);
 
-              /* Handle the successful page fill complete event by restarting the
-               * task that was blocked waiting for this page fill.
+              /* Handle the successful page fill complete event by restarting
+               * the task that was blocked waiting for this page fill.
                */
 
               pginfo("Restarting TCB: %p\n", g_pftcb);
@@ -598,8 +604,8 @@ int pg_worker(int argc, char *argv[])
                 }
             }
 
-          /* If a configurable timeout period expires with no page fill completion
-           * event, then declare a failure.
+          /* If a configurable timeout period expires with no page fill
+           * completion event, then declare a failure.
            */
 
 #ifdef CONFIG_PAGING_TIMEOUT_TICKS