From: Cyprien Laplace Date: Mon, 11 Mar 2019 02:15:59 +0000 (-0400) Subject: Fix byte_swap_16, ntohs and htons types X-Git-Url: http://git.techno-innov.fr/?a=commitdiff_plain;h=c8aa3adb219fbe4b287726e8951231c0bf5b8162;p=soft%2Flpc122x%2Fcore Fix byte_swap_16, ntohs and htons types All these functions are using 16-bits arguments and results. --- diff --git a/include/core/lpc_core.h b/include/core/lpc_core.h index 26e7bd7..fb0e5cd 100644 --- a/include/core/lpc_core.h +++ b/include/core/lpc_core.h @@ -209,7 +209,7 @@ static inline uint16_t byte_swap_16(volatile uint16_t value) { uint16_t result = 0; __asm volatile ("rev16 %0, %1" : "=l" (result) : "l" (value)); - return (result & 0xFFFF); + return result; } /* Change endianness of a 32-bit word */ static inline uint32_t byte_swap_32(volatile uint32_t value) diff --git a/include/lib/utils.h b/include/lib/utils.h index 29e5e7b..93d2630 100644 --- a/include/lib/utils.h +++ b/include/lib/utils.h @@ -61,8 +61,8 @@ uint8_t bits_set(uint32_t x); static inline uint32_t ntohl(uint32_t val) __attribute__ ((alias ("byte_swap_32"))); static inline uint32_t htonl(uint32_t val) __attribute__ ((alias ("byte_swap_32"))); /* Short versions */ -static inline uint16_t ntohs(uint32_t val) __attribute__ ((alias ("byte_swap_16"))); -static inline uint16_t htons(uint32_t val) __attribute__ ((alias ("byte_swap_16"))); +static inline uint16_t ntohs(uint16_t val) __attribute__ ((alias ("byte_swap_16"))); +static inline uint16_t htons(uint16_t val) __attribute__ ((alias ("byte_swap_16"))); /* MIN and MAX */