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

jerpelea 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 23ad4700a9 drivers/serial/pty.c: Fix coverity issue
23ad4700a9 is described below

commit 23ad4700a9464a6a625d46243ceb3a694f560399
Author: Huang Qi <[email protected]>
AuthorDate: Wed May 17 09:29:07 2023 +0800

    drivers/serial/pty.c: Fix coverity issue
    
    Coverity report that `ntotal` may be a negative value.
    
    Signed-off-by: Huang Qi <[email protected]>
---
 drivers/serial/pty.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/serial/pty.c b/drivers/serial/pty.c
index 3db349cf4d..249bb1a584 100644
--- a/drivers/serial/pty.c
+++ b/drivers/serial/pty.c
@@ -471,7 +471,7 @@ static ssize_t pty_read(FAR struct file *filep, FAR char 
*buffer, size_t len)
       ntotal = file_read(&dev->pd_src, buffer, len);
     }
 
-  if (dev->pd_lflag & ECHO)
+  if ((dev->pd_lflag & ECHO) && (ntotal > 0))
     {
       pty_write(filep, buffer, ntotal);
     }

Reply via email to