pkg/cn-cbor: fix unaligned access#21880
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
|
I just realized with the code now containing no alignment errors, we don't need to add |
You have to run |
| - ret |= hton32p(p+4); | ||
| - return ret; | ||
| -} | ||
| +#define hton16p(p) (htobe16(unaligned_get_u16(p))) |
There was a problem hiding this comment.
Is htobe16 etc available on all the compilers we use?
https://www.gnu.org/software/gnulib/manual/html_node/htobe16.html
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?
There was a problem hiding this comment.
We certainly have it: https://github.com/RIOT-OS/RIOT/blob/master/sys/include/endian.h
|
Thx ❤️ |
|
Backport provided in #21881 |
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