You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by bt...@apache.org on 2020/11/22 09:34:14 UTC

[incubator-nuttx] branch master updated: driver/rc: fix bug about lirc_read

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

btashton 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 670254d  driver/rc: fix bug about lirc_read
670254d is described below

commit 670254dffd8dd5127e1f59ac033e5afa34f94921
Author: dongjiuzhu <do...@xiaomi.com>
AuthorDate: Fri Nov 20 20:17:57 2020 +0800

    driver/rc: fix bug about lirc_read
    
    N/A
    
    Change-Id: I0d4f5cbea993ad0d9c29c7914c12d2c228bdebda
    Signed-off-by: dongjiuzhu <do...@xiaomi.com>
---
 drivers/rc/lirc_dev.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/drivers/rc/lirc_dev.c b/drivers/rc/lirc_dev.c
index d68a1d8..9d169ed 100644
--- a/drivers/rc/lirc_dev.c
+++ b/drivers/rc/lirc_dev.c
@@ -676,8 +676,7 @@ static ssize_t lirc_read_scancode(FAR struct file *filep, FAR char *buffer,
 {
   FAR struct lirc_fh_s *fh = filep->f_priv;
   irqstate_t flags;
-  ssize_t len;
-  int ret;
+  ssize_t ret;
 
   if (length < sizeof(struct lirc_scancode) ||
       length % sizeof(struct lirc_scancode))
@@ -703,13 +702,13 @@ static ssize_t lirc_read_scancode(FAR struct file *filep, FAR char *buffer,
             }
         }
 
-      len = circbuf_read(&fh->buffer, buffer, length);
+      ret = circbuf_read(&fh->buffer, buffer, length);
     }
-  while (len <= 0);
+  while (ret <= 0);
 
 err:
   leave_critical_section(flags);
-  return ret < 0 ? ret : len;
+  return ret;
 }
 
 static ssize_t lirc_read_mode2(FAR struct file *filep, FAR char *buffer,
@@ -717,8 +716,7 @@ static ssize_t lirc_read_mode2(FAR struct file *filep, FAR char *buffer,
 {
   FAR struct lirc_fh_s *fh = filep->f_priv;
   irqstate_t flags;
-  ssize_t len = 0;
-  int ret;
+  ssize_t ret = 0;
 
   if (length < sizeof(unsigned int) || length % sizeof(unsigned int))
     {
@@ -743,13 +741,13 @@ static ssize_t lirc_read_mode2(FAR struct file *filep, FAR char *buffer,
             }
         }
 
-      len = circbuf_read(&fh->buffer, buffer, length);
+      ret = circbuf_read(&fh->buffer, buffer, length);
     }
-  while (len <= 0);
+  while (ret <= 0);
 
 err:
   leave_critical_section(flags);
-  return ret < 0 ? ret : len;
+  return ret;
 }
 
 static ssize_t lirc_read(FAR struct file *filep, FAR char *buffer,