Skip to content

Fix build with musl - #6

Merged
mupfdev merged 1 commit into
CANopenTerm:mainfrom
passgat:fix_build_with_musl
Sep 25, 2026
Merged

mupfdev merged 1 commit into
CANopenTerm:mainfrom
passgat:fix_build_with_musl

Conversation

@passgat

@passgat passgat commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

This was exposed while integrating the package into Buildroot and testing its compilation with a musl-based toolchain:

CANvenient_SocketCAN.c: In function 'socketcan_open':
CANvenient_SocketCAN.c:186:24: error: storage size of 'tv' isn't known
186 | struct timeval tv;
| ^~
CANvenient_SocketCAN.c: In function 'socketcan_recv':
CANvenient_SocketCAN.c:364:36: error: invalid application of 'sizeof' to incomplete type 'struct timeval'
364 | char ctrlmsg[CMSG_SPACE(sizeof(struct timeval))];
| ^~~~~~
CANvenient_SocketCAN.c:406:28: error: invalid use of undefined type 'const struct timeval'
406 | *timestamp = tv->tv_sec * 1000000ULL + tv->tv_usec;
| ^~

Include <sys/time.h> to fix the build.

This was exposed while integrating the package into Buildroot and
testing its compilation with a musl-based toolchain:

  CANvenient_SocketCAN.c: In function 'socketcan_open':
  CANvenient_SocketCAN.c:186:24: error: storage size of 'tv' isn't known
    186 |         struct timeval tv;
        |                        ^~
  CANvenient_SocketCAN.c: In function 'socketcan_recv':
  CANvenient_SocketCAN.c:364:36: error: invalid application of 'sizeof' to incomplete type 'struct timeval'
    364 |     char ctrlmsg[CMSG_SPACE(sizeof(struct timeval))];
        |                                    ^~~~~~
  CANvenient_SocketCAN.c:406:28: error: invalid use of undefined type 'const struct timeval'
    406 |             *timestamp = tv->tv_sec * 1000000ULL + tv->tv_usec;
        |                            ^~

Include <sys/time.h> to fix the build.

Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@passgat

passgat commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

A gentle ping.

The patch has been applied in the Buildroot integration of CANopenterm package.
https://patchwork.ozlabs.org/project/buildroot/list/?series=519871

@mupfdev

mupfdev commented Sep 25, 2026

Copy link
Copy Markdown
Member

Thanks!

@mupfdev
mupfdev merged commit f1214f4 into CANopenTerm:main Sep 25, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants