Skip to content

Conversation

jukkar
Copy link
Member

@jukkar jukkar commented Oct 2, 2025

There is an issue when zephyr is compiled with native_sim_64 where size_t is 8 bytes. The socklen_t in specified as 4 bytes in Linux even for 64 bit builds so we have a conflict between Linux and Zephyr. To make things work properly, define socklen_t as uint32_t in order to align with Linux. Four bytes is enough for socket address length anyway.

@zephyrbot zephyrbot added area: Networking size: XS A PR changing only a single line of code labels Oct 2, 2025
@jukkar
Copy link
Member Author

jukkar commented Oct 2, 2025

Discussion about the issue is here #96815

pdgendt
pdgendt previously approved these changes Oct 2, 2025
@pdgendt
Copy link
Contributor

pdgendt commented Oct 2, 2025

CI isn't happy with this change..

There is an issue when zephyr is compiled with native_sim_64 where
size_t is 8 bytes. The socklen_t in specified as 4 bytes in Linux
even for 64 bit builds so we have a conflict between Linux and Zephyr.
To make things work properly, define socklen_t as uint32_t in order to
align with Linux. Four bytes is enough for socket address length anyway.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
@jukkar jukkar force-pushed the fix/socklen_t_type branch from 4f74b4c to 9e5f175 Compare October 2, 2025 09:20
@pdgendt pdgendt removed the size: XS A PR changing only a single line of code label Oct 2, 2025
@zephyrbot zephyrbot added area: Sockets Networking sockets area: Tests Issues related to a particular existing or missing test labels Oct 2, 2025
@zephyrbot zephyrbot requested a review from nashif October 2, 2025 10:35
rlubos
rlubos previously approved these changes Oct 2, 2025
@jukkar jukkar requested a review from pdgendt October 2, 2025 14:10
pdgendt
pdgendt previously approved these changes Oct 2, 2025
@pdgendt
Copy link
Contributor

pdgendt commented Oct 2, 2025

This does modify public APIs, do we need some notes?

@jukkar
Copy link
Member Author

jukkar commented Oct 2, 2025

This does modify public APIs, do we need some notes?

The various socket option APIs in net_context are not public so they should be fine to change. If user uses socklen_t type, then there should be no problem either. But perhaps it makes sense to mention this in migration guide, I will add information to that.

jukkar added 4 commits October 2, 2025 17:51
Add information that the socklen_t was changed from size_t, which
can be either 32 or 64 bit long depending on system configuration,
to always be 32 bit long. This is now aligned to way Linux is defining
socklen_t.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
There was extra parameter when calling zassert_ok() which caused
compilation warning.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
There was extra parameter when calling zassert_not_equal() which caused
compilation warning.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Printing long int requires %ld when priting error.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
@jukkar jukkar dismissed stale reviews from pdgendt and rlubos via 2f3628a October 2, 2025 14:51
@jukkar jukkar force-pushed the fix/socklen_t_type branch from 8555b65 to 2f3628a Compare October 2, 2025 14:51
@jukkar
Copy link
Member Author

jukkar commented Oct 2, 2025

  • Added information to migration guide

@zephyrbot zephyrbot added the Release Notes To be mentioned in the release notes label Oct 2, 2025
Copy link

sonarqubecloud bot commented Oct 2, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Networking area: Sockets Networking sockets area: Tests Issues related to a particular existing or missing test Release Notes To be mentioned in the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants