{"thread":{"id":"36791","subject":"[PATCH] Fix a bug in compat/bswap.h endianness detection","startedAt":"2014-05-30T15:22:40Z","lastAt":"2014-05-30T18:50:30Z","messageCount":2,"participants":["Ben Walton","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"243013","messageId":"1401463360-26972-1-git-send-email-bdwalton@gmail.com","threadId":"36791","inReplyTo":null,"subject":"[PATCH] Fix a bug in compat/bswap.h endianness detection","fromName":"Ben Walton","fromEmail":"bdwalton@gmail.com","sentAt":"2014-05-30T15:22:40Z","receivedAt":"2014-05-30T15:22:40Z","isPatch":true,"sender":{"key":"bdwalton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/396061?v=4"},"body":"The changes to make detection of endianness more portable had a bug\nthat breaks on (at least) Solaris x86. The bug appears to be a simple\ncopy/paste typo. It checks for _BIG_ENDIAN and not _LITTLE_ENDIAN for\nboth the case where we would decide the system is big endian and\nlittle endian. Instead, the second test should be for _LITTLE_ENDIAN\nand not _BIG_ENDIAN.\n\nTwo fixes were possible:\n1. Change the negation order of the conditions in the second test.\n2. Reverse the order of the conditions in the second test.\n\nUse the second option so that the condition we expect is always a\npositive check.\n\nSigned-off-by: Ben Walton <bdwalton@gmail.com>\n---\nI think that this should be applied to cb/byte-swap and re-merged\nwith next.\n\n compat/bswap.h | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/compat/bswap.h b/compat/bswap.h\nindex c4293db..f6fd9a6 100644\n--- a/compat/bswap.h\n+++ b/compat/bswap.h\n@@ -120,7 +120,7 @@ static inline uint64_t git_bswap64(uint64_t x)\n \n # if defined(_BIG_ENDIAN) && !defined(_LITTLE_ENDIAN)\n #  define GIT_BYTE_ORDER GIT_BIG_ENDIAN\n-# elif defined(_BIG_ENDIAN) && !defined(_LITTLE_ENDIAN)\n+# elif defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN)\n #  define GIT_BYTE_ORDER GIT_LITTLE_ENDIAN\n # else\n #  error \"Cannot determine endianness\"\n-- \n1.9.1\n"},{"id":"243038","messageId":"xmqq61kn9k3t.fsf@gitster.dls.corp.google.com","threadId":"36791","inReplyTo":"1401463360-26972-1-git-send-email-bdwalton@gmail.com","subject":"Re: [PATCH] Fix a bug in compat/bswap.h endianness detection","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-05-30T18:50:30Z","receivedAt":"2014-05-30T18:50:30Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thanks; this should have been caught during the review.\n\n+# if defined(_BIG_ENDIAN) && !defined(_LITTLE_ENDIAN)\n+#  ...\n+# elif defined(_BIG_ENDIAN) && !defined(_LITTLE_ENDIAN)\n+#  ...\n+# else\n"}]}