Skip to content

Commit 9c65ee1

Browse files
bdwaltongitster
authored andcommitted
compat/bswap.h: fix endianness detection
The changes to make detection of endianness more portable had a bug that breaks on (at least) Solaris x86. The bug appears to be a simple copy/paste typo. It checks for _BIG_ENDIAN and not _LITTLE_ENDIAN for both the case where we would decide the system is big endian and little endian. Instead, the second test should be for _LITTLE_ENDIAN and not _BIG_ENDIAN. Two fixes were possible: 1. Change the negation order of the conditions in the second test. 2. Reverse the order of the conditions in the second test. Use the second option so that the condition we expect is always a positive check. Signed-off-by: Ben Walton <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 839fa9c commit 9c65ee1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

compat/bswap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ static inline uint64_t git_bswap64(uint64_t x)
120120

121121
# if defined(_BIG_ENDIAN) && !defined(_LITTLE_ENDIAN)
122122
# define GIT_BYTE_ORDER GIT_BIG_ENDIAN
123-
# elif defined(_BIG_ENDIAN) && !defined(_LITTLE_ENDIAN)
123+
# elif defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN)
124124
# define GIT_BYTE_ORDER GIT_LITTLE_ENDIAN
125125
# else
126126
# error "Cannot determine endianness"

0 commit comments

Comments
 (0)