From ca4cf68422fe25f02f353dbf26fd1cdca011dd38 Mon Sep 17 00:00:00 2001 From: Brice Goglin Date: Thu, 23 Nov 2023 11:27:07 +0100 Subject: [PATCH] linux/smbios: use endian.h htole16/32() Instead of reimplementing it ourself. Thanks to Guillaume Mercier for the suggestion. Improves d70f784de98288a6594f70964ee8878da74b2484 Refs #637 Signed-off-by: Brice Goglin (cherry picked from commit 2c16044e0c0a4d02d70323a80b6bb19e83383304) --- hwloc/topology-linux.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/hwloc/topology-linux.c b/hwloc/topology-linux.c index 854eff8d2..af6865de2 100644 --- a/hwloc/topology-linux.c +++ b/hwloc/topology-linux.c @@ -7159,13 +7159,8 @@ static const char *dmi_memory_device_type(uint8_t code) /* SMBIOS structures are stored in little-endian, at least since 2.8. * Only used for memory size and extended_size so far. */ -#if __BYTE_ORDER == __BIG_ENDIAN -#define get_smbios_uint16_t(x) (uint16_t)((x)[0] + ((x)[1] << 8)) -#define get_smbios_uint32_t(x) (uint32_t)((x)[0] + ((x)[1] << 8) + ((x)[2] << 16) + ((x)[3] << 24)) -#else -#define get_smbios_uint16_t(x) (uint16_t)(*(uint16_t *)(x)) -#define get_smbios_uint32_t(x) (uint32_t)(*(uint32_t *)(x)) -#endif +#define get_smbios_uint16_t(x) htole16(*(uint16_t*)(x)) +#define get_smbios_uint32_t(x) htole32(*(uint32_t*)(x)) static int dmi_memory_device_size(char *buffer, size_t len, const struct hwloc_firmware_dmi_mem_device_header *header)