This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/OpenBSC@lists.osmocom.org/.
suraev at alumni.ntnu.no suraev at alumni.ntnu.noFrom: Max <msuraev at sysmocom.de> Mark unsigned value as such. Fix unaligned access error revealed by asan on 32 bit builds. Sponsored-by: On-Waves ehf --- include/osmocom/core/bits.h | 2 +- src/bits.c | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/include/osmocom/core/bits.h b/include/osmocom/core/bits.h index 1587b05..d559185 100644 --- a/include/osmocom/core/bits.h +++ b/include/osmocom/core/bits.h @@ -75,7 +75,7 @@ uint32_t osmo_revbytebits_32(uint32_t x); uint32_t osmo_revbytebits_8(uint8_t x); /* \brief reverse the bits of each byte in a given buffer */ -void osmo_revbytebits_buf(uint8_t *buf, int len); +void osmo_revbytebits_buf(uint8_t *buf, unsigned int len); /*! \brief left circular shift * \param[in] in The 16 bit unsigned integer to be rotated diff --git a/src/bits.c b/src/bits.c index 01d7e73..e90bb71 100644 --- a/src/bits.c +++ b/src/bits.c @@ -206,10 +206,9 @@ uint32_t osmo_revbytebits_8(uint8_t x) * * This function reverses the bits in each byte of the buffer */ -void osmo_revbytebits_buf(uint8_t *buf, int len) +void osmo_revbytebits_buf(uint8_t *buf, unsigned int len) { - unsigned int i; - unsigned int unaligned_cnt; + unsigned int i, unaligned_cnt; int len_remain = len; unaligned_cnt = ((unsigned long)buf & 3); @@ -221,8 +220,7 @@ void osmo_revbytebits_buf(uint8_t *buf, int len) } for (i = unaligned_cnt; i + 3 < len; i += 4) { - uint32_t *cur = (uint32_t *) (buf + i); - *cur = osmo_revbytebits_32(*cur); + osmo_store32be(osmo_revbytebits_32(osmo_load32be(buf + i)), buf + i); len_remain -= 4; } -- 2.5.0