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

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


The following commit(s) were added to refs/heads/master by this push:
     new 952e682fd apps: Print the revents field of struct pollfd without a 
cast.
952e682fd is described below

commit 952e682fd650da9688e007e00f3c1af643ef461e
Author: Marco Casaroli <[email protected]>
AuthorDate: Tue Oct 20 12:22:26 2026 +0200

    apps: Print the revents field of struct pollfd without a cast.
    
    The events and revents fields of struct pollfd now have the type short,
    as POSIX gives them.  A short value is promoted to int, so %x prints it
    as is.  Remove the casts to unsigned int that were added while the
    fields were a 32-bit pollevent_t.
    
    Assisted-by: Claude Code:claude-opus-5-5
    Signed-off-by: Marco Casaroli <[email protected]>
---
 examples/poll/poll_listener.c                                | 6 +++---
 graphics/twm4nx/src/cinput.cxx                               | 4 ++--
 netutils/ptpd/ptpd.c                                         | 2 +-
 netutils/thttpd/fdwatch.c                                    | 3 +--
 testing/testsuites/kernel/socket/cases/net_socket_test_009.c | 2 +-
 5 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/examples/poll/poll_listener.c b/examples/poll/poll_listener.c
index 61becb00b..d9d7aa5f1 100644
--- a/examples/poll/poll_listener.c
+++ b/examples/poll/poll_listener.c
@@ -146,14 +146,14 @@ void *poll_listener(pthread_addr_t pvarg)
       for (i = 0; i < NPOLLFDS; i++)
         {
           printf("poll_listener: FIFO revents[%d]=%08x\n", i,
-                 (unsigned int)fds[i].revents);
+                 fds[i].revents);
           if (timeout)
             {
               if (fds[i].revents != 0)
                 {
                   printf("poll_listener: ERROR? expected revents=00, "
                          "received revents[%d]=%08x\n",
-                         i, (unsigned int)fds[i].revents);
+                         i, fds[i].revents);
                 }
             }
           else if (pollin)
@@ -165,7 +165,7 @@ void *poll_listener(pthread_addr_t pvarg)
               else if (fds[i].revents != 0)
                 {
                   printf("poll_listener: ERROR unexpected revents[%d]="
-                         "%08x\n", i, (unsigned int)fds[i].revents);
+                         "%08x\n", i, fds[i].revents);
                 }
             }
         }
diff --git a/graphics/twm4nx/src/cinput.cxx b/graphics/twm4nx/src/cinput.cxx
index 60aef2aa2..3977ae10c 100644
--- a/graphics/twm4nx/src/cinput.cxx
+++ b/graphics/twm4nx/src/cinput.cxx
@@ -819,7 +819,7 @@ int CInput::session(void)
       if ((pfd[KBD_INDEX].revents & (POLLERR | POLLHUP)) != 0)
         {
           twmerr("ERROR: keyboard poll() failed. revents=%08x\n",
-                 (unsigned int)pfd[KBD_INDEX].revents);
+                 pfd[KBD_INDEX].revents);
           ret = -EIO;
           break;
         }
@@ -841,7 +841,7 @@ int CInput::session(void)
       if ((pfd[MOUSE_INDEX].revents & (POLLERR | POLLHUP)) != 0)
         {
           twmerr("ERROR: Mouse poll() failed. revents=%08x\n",
-                 (unsigned int)pfd[MOUSE_INDEX].revents);
+                 pfd[MOUSE_INDEX].revents);
           ret = -EIO;
           break;
         }
diff --git a/netutils/ptpd/ptpd.c b/netutils/ptpd/ptpd.c
index 395ca478a..db8fce137 100644
--- a/netutils/ptpd/ptpd.c
+++ b/netutils/ptpd/ptpd.c
@@ -1046,7 +1046,7 @@ static int ptp_get_tx_timestamp(FAR struct ptp_state_s 
*state,
   else
     {
       ptpwarn("PTP TX HWTS: poll ret=%d revents=0x%04x errno=%d\n",
-              ret, (unsigned int)pfd.revents, errno);
+              ret, pfd.revents, errno);
     }
 
   return ERROR;
diff --git a/netutils/thttpd/fdwatch.c b/netutils/thttpd/fdwatch.c
index 35b73aab8..c1e6378cb 100644
--- a/netutils/thttpd/fdwatch.c
+++ b/netutils/thttpd/fdwatch.c
@@ -289,8 +289,7 @@ int fdwatch(struct fdwatch_s *fw, long timeout_msecs)
               /* Yes... save it in a shorter list */
 
               fwinfo("pollndx: %d fd: %d revents: %08x\n",
-                    i, fw->pollfds[i].fd,
-                    (unsigned int)fw->pollfds[i].revents);
+                    i, fw->pollfds[i].fd, fw->pollfds[i].revents);
 
               fw->ready[fw->nactive++] = fw->pollfds[i].fd;
               if (fw->nactive == ret)
diff --git a/testing/testsuites/kernel/socket/cases/net_socket_test_009.c 
b/testing/testsuites/kernel/socket/cases/net_socket_test_009.c
index 0e2f005e2..a1eb19798 100644
--- a/testing/testsuites/kernel/socket/cases/net_socket_test_009.c
+++ b/testing/testsuites/kernel/socket/cases/net_socket_test_009.c
@@ -184,7 +184,7 @@ static int handlereadfds(struct pollfd *fds, int nfds, int 
lsfd)
         }
 
       syslog(LOG_INFO, "[%d]revents: %04x", fds[i].fd,
-             (unsigned int)fds[i].revents);
+             fds[i].revents);
       if (fds[i].fd == lsfd)
         {
           ret += handleaccept(lsfd);

Reply via email to