From aca3707bd8848a568dff190e155a7da31b8b5aa4 Mon Sep 17 00:00:00 2001 From: Antonio Borneo Date: Tue, 1 Nov 2022 19:21:35 +0100 Subject: [PATCH] helper/types: use unsigned type for all h_u64_to_le() and similar All the converters functions: h_u64_to_le() h_u64_to_be() h_u32_to_le() h_u32_to_be() h_u24_to_le() h_u24_to_be() h_u16_to_le() h_u16_to_be() have signed type in their prototype, while the function name and all the current use cases pass an unsigned value. Change the prototypes to use unsigned types. Change-Id: I76dcfdd7912b81f60902184712b2907eae9843f7 Signed-off-by: Antonio Borneo Reviewed-on: https://review.openocd.org/c/openocd/+/7299 Tested-by: jenkins --- src/helper/types.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/helper/types.h b/src/helper/types.h index b99ece1098..587ed22c89 100644 --- a/src/helper/types.h +++ b/src/helper/types.h @@ -151,7 +151,7 @@ static inline uint16_t be_to_h_u16(const uint8_t *buf) return (uint16_t)((uint16_t)buf[1] | (uint16_t)buf[0] << 8); } -static inline void h_u64_to_le(uint8_t *buf, int64_t val) +static inline void h_u64_to_le(uint8_t *buf, uint64_t val) { buf[7] = (uint8_t) (val >> 56); buf[6] = (uint8_t) (val >> 48); @@ -163,7 +163,7 @@ static inline void h_u64_to_le(uint8_t *buf, int64_t val) buf[0] = (uint8_t) (val >> 0); } -static inline void h_u64_to_be(uint8_t *buf, int64_t val) +static inline void h_u64_to_be(uint8_t *buf, uint64_t val) { buf[0] = (uint8_t) (val >> 56); buf[1] = (uint8_t) (val >> 48); @@ -175,7 +175,7 @@ static inline void h_u64_to_be(uint8_t *buf, int64_t val) buf[7] = (uint8_t) (val >> 0); } -static inline void h_u32_to_le(uint8_t *buf, int val) +static inline void h_u32_to_le(uint8_t *buf, uint32_t val) { buf[3] = (uint8_t) (val >> 24); buf[2] = (uint8_t) (val >> 16); @@ -183,7 +183,7 @@ static inline void h_u32_to_le(uint8_t *buf, int val) buf[0] = (uint8_t) (val >> 0); } -static inline void h_u32_to_be(uint8_t *buf, int val) +static inline void h_u32_to_be(uint8_t *buf, uint32_t val) { buf[0] = (uint8_t) (val >> 24); buf[1] = (uint8_t) (val >> 16); @@ -191,27 +191,27 @@ static inline void h_u32_to_be(uint8_t *buf, int val) buf[3] = (uint8_t) (val >> 0); } -static inline void h_u24_to_le(uint8_t *buf, int val) +static inline void h_u24_to_le(uint8_t *buf, unsigned int val) { buf[2] = (uint8_t) (val >> 16); buf[1] = (uint8_t) (val >> 8); buf[0] = (uint8_t) (val >> 0); } -static inline void h_u24_to_be(uint8_t *buf, int val) +static inline void h_u24_to_be(uint8_t *buf, unsigned int val) { buf[0] = (uint8_t) (val >> 16); buf[1] = (uint8_t) (val >> 8); buf[2] = (uint8_t) (val >> 0); } -static inline void h_u16_to_le(uint8_t *buf, int val) +static inline void h_u16_to_le(uint8_t *buf, uint16_t val) { buf[1] = (uint8_t) (val >> 8); buf[0] = (uint8_t) (val >> 0); } -static inline void h_u16_to_be(uint8_t *buf, int val) +static inline void h_u16_to_be(uint8_t *buf, uint16_t val) { buf[0] = (uint8_t) (val >> 8); buf[1] = (uint8_t) (val >> 0); -- 2.30.2