git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ben Walton <bdwalton@gmail.com>
To: gitster@pobox.com, cbailey32@bloomberg.net
Cc: git@vger.kernel.org, Ben Walton <bdwalton@gmail.com>
Subject: [PATCH] Fix a bug in compat/bswap.h endianness detection
Date: Fri, 30 May 2014 16:22:40 +0100	[thread overview]
Message-ID: <1401463360-26972-1-git-send-email-bdwalton@gmail.com> (raw)

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 <bdwalton@gmail.com>
---
I think that this should be applied to cb/byte-swap and re-merged
with next.

 compat/bswap.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/compat/bswap.h b/compat/bswap.h
index c4293db..f6fd9a6 100644
--- a/compat/bswap.h
+++ b/compat/bswap.h
@@ -120,7 +120,7 @@ static inline uint64_t git_bswap64(uint64_t x)
 
 # if defined(_BIG_ENDIAN) && !defined(_LITTLE_ENDIAN)
 #  define GIT_BYTE_ORDER GIT_BIG_ENDIAN
-# elif defined(_BIG_ENDIAN) && !defined(_LITTLE_ENDIAN)
+# elif defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN)
 #  define GIT_BYTE_ORDER GIT_LITTLE_ENDIAN
 # else
 #  error "Cannot determine endianness"
-- 
1.9.1

             reply	other threads:[~2014-05-30 16:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-30 15:22 Ben Walton [this message]
2014-05-30 18:50 ` [PATCH] Fix a bug in compat/bswap.h endianness detection Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1401463360-26972-1-git-send-email-bdwalton@gmail.com \
    --to=bdwalton@gmail.com \
    --cc=cbailey32@bloomberg.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).