From 7bdfd2ed7a0a4027b2fce03f7ee0615d6f0a52fa Mon Sep 17 00:00:00 2001 From: Claudio Takahasi Date: Thu, 20 Mar 2014 11:42:30 -0300 Subject: [PATCH] shared: Add get_be16() Add helper to avoid possible unaligned memory access when handling uint16 value using big-endian representation. --- src/shared/util.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/shared/util.h b/src/shared/util.h index 29f6f6b14..e315f846f 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -106,6 +106,11 @@ static inline uint16_t get_le16(const void *ptr) return le16_to_cpu(get_unaligned((const uint16_t *) ptr)); } +static inline uint16_t get_be16(const void *ptr) +{ + return be16_to_cpu(get_unaligned((const uint16_t *) ptr)); +} + static inline uint32_t get_le32(const void *ptr) { return le32_to_cpu(get_unaligned((const uint32_t *) ptr)); -- 2.11.0