drivers/serial/pty.c: Fix coverity issue

Coverity report that `ntotal` may be a negative value.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
This commit is contained in:
Huang Qi 2023-05-17 09:29:07 +08:00 committed by Alin Jerpelea
parent e1096bd35c
commit 23ad4700a9

View File

@ -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); 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); pty_write(filep, buffer, ntotal);
} }