summaryrefslogtreecommitdiff
path: root/payloads/libpayload/include/endian.h
diff options
context:
space:
mode:
authorPatrick Georgi <pgeorgi@google.com>2019-11-25 16:42:56 +0100
committerPatrick Georgi <pgeorgi@google.com>2020-02-05 21:48:36 +0000
commitc34ebab4108965c824de4e1271c3f15598567fc5 (patch)
tree1a2a7e5edc0348fc2796f4fcc33f8c3ccb86f642 /payloads/libpayload/include/endian.h
parentc294fe792c5be9b265236d41b381ee9e15d1d41e (diff)
downloadcoreboot-c34ebab4108965c824de4e1271c3f15598567fc5.tar.xz
libpayload: Make pci and endian handling -Wconversion safe
Change-Id: Ibd1b179d647f105579bd74b071344668ca0a41ef Signed-off-by: Patrick Georgi <pgeorgi@google.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/37202 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Diffstat (limited to 'payloads/libpayload/include/endian.h')
-rw-r--r--payloads/libpayload/include/endian.h10
1 files changed, 6 insertions, 4 deletions
diff --git a/payloads/libpayload/include/endian.h b/payloads/libpayload/include/endian.h
index dee45f227b..037517c88f 100644
--- a/payloads/libpayload/include/endian.h
+++ b/payloads/libpayload/include/endian.h
@@ -86,28 +86,30 @@ static inline uint16_t be16dec(const void *pp)
{
uint8_t const *p = (uint8_t const *)pp;
- return ((p[0] << 8) | p[1]);
+ return (uint16_t)((p[0] << 8) | p[1]);
}
static inline uint32_t be32dec(const void *pp)
{
uint8_t const *p = (uint8_t const *)pp;
- return (((unsigned)p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]);
+ return (((uint32_t)p[0] << 24) | (uint32_t)(p[1] << 16) |
+ (uint32_t)(p[2] << 8) | p[3]);
}
static inline uint16_t le16dec(const void *pp)
{
uint8_t const *p = (uint8_t const *)pp;
- return ((p[1] << 8) | p[0]);
+ return (uint16_t)((p[1] << 8) | p[0]);
}
static inline uint32_t le32dec(const void *pp)
{
uint8_t const *p = (uint8_t const *)pp;
- return ((p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0]);
+ return ((uint32_t)(p[3] << 24) | (uint32_t)(p[2] << 16) |
+ (uint32_t)(p[1] << 8) | p[0]);
}
static inline void bebitenc(void *pp, uint32_t u, uint8_t b)