From 670254dffd8dd5127e1f59ac033e5afa34f94921 Mon Sep 17 00:00:00 2001 From: dongjiuzhu Date: Fri, 20 Nov 2020 20:17:57 +0800 Subject: [PATCH] driver/rc: fix bug about lirc_read N/A Change-Id: I0d4f5cbea993ad0d9c29c7914c12d2c228bdebda Signed-off-by: dongjiuzhu --- 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 d68a1d8eab..9d169ed4e2 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,