pkg/cn-cbor: fix unaligned access#21880
Merged
crasbe merged 1 commit intoRIOT-OS:masterfrom Nov 16, 2025
Merged
Conversation
With GCC 15.2.0, the self test of cn-cbor fails. Using safe unaligned access and standard endian conversions fixes the issue.
6510c62 to
b44aea3
Compare
Member
Author
|
I just realized with the code now containing no alignment errors, we don't need to add |
Contributor
You have to run |
crasbe
reviewed
Nov 16, 2025
| - ret |= hton32p(p+4); | ||
| - return ret; | ||
| -} | ||
| +#define hton16p(p) (htobe16(unaligned_get_u16(p))) |
Contributor
There was a problem hiding this comment.
Is htobe16 etc available on all the compilers we use?
This function is missing on many platforms: glibc 2.8, macOS 14, FreeBSD 13.0, NetBSD 7.2, OpenBSD 5.5, Minix 3.1.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 1.7.x, mingw, MSVC 14.
glibc 2.8 is from 2009, so it shoooould be good?
Member
Author
There was a problem hiding this comment.
crasbe
approved these changes
Nov 16, 2025
Member
Author
|
Thx ❤️ |
Member
Author
|
Backport provided in #21881 |
37 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Contribution description
With GCC 15.2.0, the self test of cn-cbor fails. Using safe unaligned access and standard endian conversions fixes the issue.
Testing procedure
In
masterThis PR
Note
It seems that our build system does not properly update the checked out git repo when the custom patches change. As a result
$(BUILD_DIR)/pkg/cn-cborneeds to be removed by hand between builds to have correct test results.Issues/PRs references
None