From accf50ce07a3d9b842d48a8b07eb827fb424adf9 Mon Sep 17 00:00:00 2001 From: Kaspar Schleiser Date: Thu, 23 Aug 2018 10:34:21 +0200 Subject: [PATCH] core/byteorder: fix byteorder_htobebufs, byteorder_bebuftohs Logic was swapping byte order on Big Endian platforms --- core/include/byteorder.h | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/core/include/byteorder.h b/core/include/byteorder.h index d4d0edd613..a666bd2a80 100644 --- a/core/include/byteorder.h +++ b/core/include/byteorder.h @@ -445,22 +445,13 @@ static inline uint64_t ntohll(uint64_t v) static inline uint16_t byteorder_bebuftohs(const uint8_t *buf) { -#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ - return (uint16_t)((buf[0] << 8) | buf[1]); -#else - return (uint16_t)((buf[1] << 8) | buf[0]); -#endif + return (uint16_t)((buf[0] << 8) | (buf[1] << 0)); } static inline void byteorder_htobebufs(uint8_t *buf, uint16_t val) { -#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ buf[0] = (uint8_t)(val >> 8); - buf[1] = (uint8_t)(val & 0xff); -#else - buf[0] = (uint8_t)(val & 0xff); - buf[1] = (uint8_t)(val >> 8); -#endif + buf[1] = (uint8_t)(val >> 0); } #ifdef __cplusplus