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 17:43:38 UTC

[incubator-nuttx] branch master updated: sama5/sam_tsd: Fix error: 'ret' may be used uninitialized

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 b1e661e  sama5/sam_tsd: Fix error: 'ret' may be used uninitialized
b1e661e is described below

commit b1e661e7db61c1e1234f3b637de7d72964eb25a5
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Thu Apr 30 21:58:03 2020 +0800

    sama5/sam_tsd: Fix error: 'ret' may be used uninitialized
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 arch/arm/src/sama5/sam_tsd.c | 49 +++++++++++++++++++++++---------------------
 1 file changed, 26 insertions(+), 23 deletions(-)

diff --git a/arch/arm/src/sama5/sam_tsd.c b/arch/arm/src/sama5/sam_tsd.c
index fa96185..b012898 100644
--- a/arch/arm/src/sama5/sam_tsd.c
+++ b/arch/arm/src/sama5/sam_tsd.c
@@ -196,7 +196,8 @@ struct sam_tsd_s
 /* Interrupt bottom half logic and data sampling */
 
 static void sam_tsd_notify(struct sam_tsd_s *priv);
-static int  sam_tsd_sample(struct sam_tsd_s *priv, struct sam_sample_s *sample);
+static int  sam_tsd_sample(struct sam_tsd_s *priv,
+              struct sam_sample_s *sample);
 static int  sam_tsd_waitsample(struct sam_tsd_s *priv,
               struct sam_sample_s *sample);
 static void sam_tsd_bottomhalf(void *arg);
@@ -259,17 +260,17 @@ static void sam_tsd_notify(struct sam_tsd_s *priv)
 
   if (priv->nwaiters > 0)
     {
-      /* After posting this semaphore, we need to exit because the touchscreen
-       * is no longer available.
+      /* After posting this semaphore, we need to exit because the
+       * touchscreen is no longer available.
        */
 
       nxsem_post(&priv->waitsem);
     }
 
-  /* If there are threads waiting on poll() for touchscreen data to become available,
-   * then wake them up now.  NOTE: we wake up all waiting threads because we
-   * do not know that they are going to do.  If they all try to read the data,
-   * then some make end up blocking after all.
+  /* If there are threads waiting on poll() for touchscreen data to become
+   * available, then wake them up now.  NOTE: we wake up all waiting threads
+   * because we do not know that they are going to do.  If they all try to
+   * read the data, then some make end up blocking after all.
    */
 
   for (i = 0; i < CONFIG_SAMA5_TSD_NPOLLWAITERS; i++)
@@ -288,7 +289,8 @@ static void sam_tsd_notify(struct sam_tsd_s *priv)
  * Name: sam_tsd_sample
  ****************************************************************************/
 
-static int sam_tsd_sample(struct sam_tsd_s *priv, struct sam_sample_s *sample)
+static int sam_tsd_sample(struct sam_tsd_s *priv,
+                          struct sam_sample_s *sample)
 {
   irqstate_t flags;
   int ret = -EAGAIN;
@@ -341,10 +343,11 @@ static int sam_tsd_sample(struct sam_tsd_s *priv, struct sam_sample_s *sample)
  * Name: sam_tsd_waitsample
  ****************************************************************************/
 
-static int sam_tsd_waitsample(struct sam_tsd_s *priv, struct sam_sample_s *sample)
+static int sam_tsd_waitsample(struct sam_tsd_s *priv,
+                              struct sam_sample_s *sample)
 {
   irqstate_t flags;
-  int ret;
+  int ret = 0;
 
   /* Interrupts me be disabled when this is called to (1) prevent posting
    * of semaphores from interrupt handlers, and (2) to prevent sampled data
@@ -387,7 +390,7 @@ static int sam_tsd_waitsample(struct sam_tsd_s *priv, struct sam_sample_s *sampl
   iinfo("Sampled\n");
 
   /* Re-acquire the semaphore that manages mutually exclusive access to
-   * the device structure.  We may have to wait here.  But we have our sample.
+   * the device structure. We may have to wait here. But we have our sample.
    * Interrupts and pre-emption will be re-enabled while we wait.
    */
 
@@ -420,7 +423,7 @@ errout:
  *
  * Input Parameters:
  *   priv - The touchscreen private data structure
- *   tsav - The new (shifted) value of the TSAV field of the ADC TSMR register.
+ *   tsav - The new (shifted) value of the TSAV field of ADC TSMR register
  *
  * Returned Value:
  *   None
@@ -476,9 +479,9 @@ static void sam_tsd_setaverage(struct sam_tsd_s *priv, uint32_t tsav)
  * Description:
  *   This function executes on the worker thread.  It is scheduled by
  *   sam_tsd_interrupt whenever any interesting, enabled TSD event occurs.
- *   All TSD interrupts are disabled when this function runs.  sam_tsd_bottomhalf
- *   will re-enable TSD interrupts when it completes processing all pending
- *   TSD events.
+ *   All TSD interrupts are disabled when this function runs.
+ *   sam_tsd_bottomhalf will re-enable TSD interrupts when it completes
+ *   processing all pending TSD events.
  *
  * Input Parameters:
  *   arg - The touchscreen private data structure cast to (void *)
@@ -540,8 +543,8 @@ static void sam_tsd_bottomhalf(void *arg)
 
       ier = ADC_INT_PEN;
 
-      /* Ignore the interrupt if the pen was already up (CONTACT_NONE == pen up
-       * and already reported; CONTACT_UP == pen up, but not reported)
+      /* Ignore the interrupt if the pen was already up (CONTACT_NONE == pen
+       * up and already reported; CONTACT_UP == pen up, but not reported)
        */
 
       if (priv->sample.contact == CONTACT_NONE ||
@@ -570,8 +573,8 @@ static void sam_tsd_bottomhalf(void *arg)
     }
 
   /* It is a pen down event.  If the last loss-of-contact event has not been
-   * processed yet, then we have to ignore the pen down event (or else it will
-   * look like a drag event)
+   * processed yet, then we have to ignore the pen down event (or else it
+   * will look like a drag event)
    */
 
   else if (priv->sample.contact == CONTACT_UP)
@@ -590,7 +593,7 @@ static void sam_tsd_bottomhalf(void *arg)
     }
   else
     {
-      /* The pen is down and the driver has accepted the last sample values. */
+      /* The pen is down and the driver accepted the last sample values. */
 
       /* While the pen is down we want interrupts on all data ready and pen
        * release events.
@@ -779,9 +782,9 @@ static int sam_tsd_schedule(struct sam_tsd_s *priv)
 
   sam_adc_putreg(priv->adc, SAM_ADC_IDR, ADC_TSD_ALLINTS);
 
-  /* Transfer processing to the worker thread.  Since touchscreen ADC interrupts are
-   * disabled while the work is pending, no special action should be required
-   * to protected the work queue.
+  /* Transfer processing to the worker thread.  Since touchscreen ADC
+   * interrupts are disabled while the work is pending, no special action
+   * should be required to protected the work queue.
    */
 
   DEBUGASSERT(priv->work.worker == NULL);