Skip to content

canutils/candump: guard SOF_TIMESTAMPING macros with ifndef - #3788

Merged
xiaoxiang781216 merged 1 commit into
apache:masterfrom
wenquan2015:so-timestamping-fix
Sep 18, 2026
Merged

xiaoxiang781216 merged 1 commit into
apache:masterfrom
wenquan2015:so-timestamping-fix

Conversation

@wenquan2015

Copy link
Copy Markdown

Summary

candump.c locally defines SOF_TIMESTAMPING_SOFTWARE, SOF_TIMESTAMPING_RX_SOFTWARE and SOF_TIMESTAMPING_RAW_HARDWARE for use with CAN
socket timestamping. After apache/nuttx#20161 (apache/nuttx#20161) added these macros to sys/socket.h as
part of the SO_TIMESTAMPING support, the build fails with -Werror=redefine:

candump.c:82: error: "SOF_TIMESTAMPING_SOFTWARE" redefined [-Werror]
/nuttx/include/sys/socket.h:240: note: this is the location of the previous definition

Wrap the local defines with #ifndef guards so they are only used when the system header does not provide them.

Impact

No behavioral change. The same macro values are used regardless of whether they come from the system header or the local fallback
definitions.

This is a companion fix for apache/nuttx#20161 (apache/nuttx#20161) (net: add SO_TIMESTAMPING support for
PKT sockets). Both PRs should be merged together.

Testing

Build: sim:can with CONFIG_NET_TIMESTAMP=y

Before: build fails with -Werror=redefine on SOF_TIMESTAMPING_SOFTWARE and SOF_TIMESTAMPING_RAW_HARDWARE.

After: build succeeds, no warnings.

wenquan2015 pushed a commit to wenquan2015/nuttx that referenced this pull request Sep 17, 2026
depends-on: apache/nuttx-apps/pull/3788
Signed-off-by: wenquan1 <wenquan1@xiaomi.com>
@wenquan2015

Copy link
Copy Markdown
Author

@xiaoxiang781216 This is a companion fix for apache/nuttx#20161. Could you please review?

candump.c locally defines SOF_TIMESTAMPING_SOFTWARE,
SOF_TIMESTAMPING_RX_SOFTWARE and SOF_TIMESTAMPING_RAW_HARDWARE.
After nuttx added these macros to sys/socket.h, the build fails
with -Werror=redefine. Wrap the local defines with #ifndef guards
so they are only used when the system header does not provide them.

Signed-off-by: wenquan1 <wenquan1@xiaomi.com>
GUIDINGLI
GUIDINGLI previously approved these changes Sep 18, 2026

@GUIDINGLI GUIDINGLI 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.

LGTM

@github-actions github-actions Bot added Size: S and removed Size: XS labels Sep 18, 2026
@wenquan2015
wenquan2015 force-pushed the so-timestamping-fix branch 2 times, most recently from 0056cc6 to 2ff27e3 Compare September 18, 2026 06:30
@wenquan2015

Copy link
Copy Markdown
Author

The CI nxstyle check fails because the entire candump.c file uses Linux kernel coding style (tabs, K&R braces, etc.),is it possible to bypass the nxstyle check for this file?

@github-actions github-actions Bot added Size: XS and removed Size: S labels Sep 18, 2026
@xiaoxiang781216

Copy link
Copy Markdown
Contributor

The CI nxstyle check fails because the entire candump.c file uses Linux kernel coding style (tabs, K&R braces, etc.),is it possible to bypass the nxstyle check for this file?

Ok, let's ignore the style check in candump.c

@xiaoxiang781216
xiaoxiang781216 merged commit 6e12c3d into apache:master Sep 18, 2026
74 of 121 checks passed
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.

3 participants