Skip to content

Commit 2c16044

Browse files
committed
linux/smbios: use endian.h htole16/32()
Instead of reimplementing it ourself. Thanks to Guillaume Mercier for the suggestion. Improves d70f784 Refs #637 Signed-off-by: Brice Goglin <[email protected]>
1 parent d70f784 commit 2c16044

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

hwloc/topology-linux.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7166,13 +7166,8 @@ static const char *dmi_memory_device_type(uint8_t code)
71667166
/* SMBIOS structures are stored in little-endian, at least since 2.8.
71677167
* Only used for memory size and extended_size so far.
71687168
*/
7169-
#if __BYTE_ORDER == __BIG_ENDIAN
7170-
#define get_smbios_uint16_t(x) (uint16_t)((x)[0] + ((x)[1] << 8))
7171-
#define get_smbios_uint32_t(x) (uint32_t)((x)[0] + ((x)[1] << 8) + ((x)[2] << 16) + ((x)[3] << 24))
7172-
#else
7173-
#define get_smbios_uint16_t(x) (uint16_t)(*(uint16_t *)(x))
7174-
#define get_smbios_uint32_t(x) (uint32_t)(*(uint32_t *)(x))
7175-
#endif
7169+
#define get_smbios_uint16_t(x) htole16(*(uint16_t*)(x))
7170+
#define get_smbios_uint32_t(x) htole32(*(uint32_t*)(x))
71767171

71777172
static int dmi_memory_device_size(char *buffer, size_t len,
71787173
const struct hwloc_firmware_dmi_mem_device_header *header)

0 commit comments

Comments
 (0)