Skip to content

apps: Print the revents field of struct pollfd without a cast. - #3888

Merged
acassis merged 1 commit into
apache:masterfrom
casaroli:pollfd-revents-nocast
Oct 24, 2026
Merged

acassis merged 1 commit into
apache:masterfrom
casaroli:pollfd-revents-nocast

Conversation

@casaroli

Copy link
Copy Markdown
Contributor

Summary

apache/nuttx#20796 gives the events and revents fields of struct pollfd the type short, as POSIX does. A short value is promoted to int, so %x prints it as is. This PR removes the eight casts to unsigned int that #3878 added while the fields were a 32-bit pollevent_t, in examples/poll, graphics/twm4nx, netutils/ptpd, netutils/thttpd and the kernel socket test suite.

This PR must merge after apache/nuttx#20796: with the 32-bit pollevent_t of master, %x without the cast is a -Wformat error on 32-bit Arm.

Impact

Debug and error messages only. No change in behaviour.

Testing

qemu-armv7a:nsh with EXAMPLES_POLL, NETUTILS_PTPD (with DEBUG_PTP_WARN, NET_TIMESTAMP), NETUTILS_THTTPD (with -DCONFIG_THTTPD_FDWATCH_DEBUG and DEBUG_NET_INFO, so the fwinfo() call is compiled) and the network options they need, built with EXTRAFLAGS=-Werror and arm-gnu-toolchain 13.2.Rel1:

  • against !fs/poll: Give struct pollfd the POSIX layout. nuttx#20796 (b02ec1eca72): the build passes with no warning;
  • against nuttx master: poll_listener.c stops the build with format '%x' expects argument of type 'unsigned int', but argument 3 has type 'pollevent_t' {aka 'long unsigned int'}, as expected.

graphics/twm4nx and the kernel socket test suite are not in this build (the change there is the same). tools/checkpatch.sh -c -u -m -g passes.

depends-on: [apache/nuttx/pull/20796]

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]>

@cederom cederom left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @casaroli :-)

@github-actions

Copy link
Copy Markdown

🔗 Cross-repo PR dependencies

The read-only Build run reported the following dependent PR(s) and fetched head SHA(s):

CI run: https://github.com/apache/nuttx-apps/actions/runs/39408626194

@casaroli casaroli closed this Oct 21, 2026
@casaroli casaroli reopened this Oct 21, 2026
@github-actions

Copy link
Copy Markdown

🔗 Cross-repo PR dependencies

The read-only Build run reported the following dependent PR(s) and fetched head SHA(s):

CI run: https://github.com/apache/nuttx-apps/actions/runs/39563383186

@casaroli casaroli closed this Oct 22, 2026
@casaroli casaroli reopened this Oct 22, 2026
@github-actions

Copy link
Copy Markdown

🔗 Cross-repo PR dependencies

The read-only Build run reported the following dependent PR(s) and fetched head SHA(s):

CI run: https://github.com/apache/nuttx-apps/actions/runs/39773678139

@xiaoxiang781216
xiaoxiang781216 marked this pull request as ready for review October 24, 2026 11:15
@xiaoxiang781216
xiaoxiang781216 marked this pull request as draft October 24, 2026 11:16
@acassis
acassis marked this pull request as ready for review October 24, 2026 12:16
@acassis
acassis merged commit 952e682 into apache:master Oct 24, 2026
102 of 123 checks passed
acassis pushed a commit that referenced this pull request Oct 28, 2026
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.

This change was in #3888, which was reverted by #3909 because it merged
before apache/nuttx#20796 changed the type.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marco Casaroli <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants