From 8f24c4876a32b4f19e459bedd1fdbbc54cb0daa9 Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Thu, 28 Nov 2024 15:16:54 +0100 Subject: Switch from detecting little endian (common) to detecting big endian (rare) This prevents a bug class where we bswap things when __LITTLE_ENDIAN__ is not defined. Almost all modern systems are little endian, so detecting __BIG_ENDIAN__ is a better strategy. --- src/plist.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/plist.c') diff --git a/src/plist.c b/src/plist.c index 79448db..0d4e077 100644 --- a/src/plist.c +++ b/src/plist.c @@ -82,26 +82,26 @@ static int plist_debug = 0; #endif #ifndef le16toh -#ifdef __LITTLE_ENDIAN__ -#define le16toh(x) (x) -#else +#ifdef __BIG_ENDIAN__ #define le16toh(x) bswap16(x) +#else +#define le16toh(x) (x) #endif #endif #ifndef le32toh -#ifdef __LITTLE_ENDIAN__ -#define le32toh(x) (x) -#else +#ifdef __BIG_ENDIAN__ #define le32toh(x) bswap32(x) +#else +#define le32toh(x) (x) #endif #endif #ifndef le64toh -#ifdef __LITTLE_ENDIAN__ -#define le64toh(x) (x) -#else +#ifdef __BIG_ENDIAN__ #define le64toh(x) bswap64(x) +#else +#define le64toh(x) (x) #endif #endif -- cgit v1.1-32-gdbae