You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2022/08/17 03:41:23 UTC

[incubator-nuttx-apps] 04/04: add fds initialization and buttonset comparison

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

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git

commit a9f6d66888c456d402022091002b9a2c9752b037
Author: pengyiqiang <pe...@xiaomi.com>
AuthorDate: Wed Aug 17 00:52:28 2022 +0800

    add fds initialization and buttonset comparison
---
 testing/monkey/monkey_dev.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/testing/monkey/monkey_dev.c b/testing/monkey/monkey_dev.c
index d87780406..a6f88fc09 100644
--- a/testing/monkey/monkey_dev.c
+++ b/testing/monkey/monkey_dev.c
@@ -124,8 +124,8 @@ static bool button_read(int fd, FAR uint32_t *value)
 {
   btn_buttonset_t buttonset;
 
-  int ret = read(fd, &buttonset, sizeof(buttonset));
-  if (ret < 0)
+  int nbytes = read(fd, &buttonset, sizeof(buttonset));
+  if (nbytes != sizeof(buttonset))
     {
       return false;
     }
@@ -297,13 +297,13 @@ int monkey_dev_get_available(FAR struct monkey_dev_s *devs[], int dev_num)
   int i;
   int available = 0;
   struct pollfd fds[MONKEY_DEV_MAX_NUM];
+  memset(fds, 0, sizeof(fds));
 
   for (i = 0; i < dev_num; i++)
     {
       devs[i]->is_available = false;
       fds[i].fd = devs[i]->fd;
       fds[i].events = POLLIN | POLLPRI;
-      fds[i].revents = 0;
     }
 
   if (poll(fds, dev_num, -1) < 0)