[PATCH:xscope 12/24] ILong: shift each byte individually, then OR them together

Alan Coopersmith alan.coopersmith at oracle.com
Fri Aug 31 22:17:54 PDT 2012


instead of shifting the whole word as each byte is loaded into place

Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 x11.h |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/x11.h b/x11.h
index ed0f3d6..a3c8cb9 100644
--- a/x11.h
+++ b/x11.h
@@ -547,8 +547,8 @@ ILong(const unsigned char buf[])
 {
     /* check for byte-swapping */
     if (littleEndian)
-        return ((((((buf[3] << 8) | buf[2]) << 8) | buf[1]) << 8) | buf[0]);
-    return ((((((buf[0] << 8) | buf[1]) << 8) | buf[2]) << 8) | buf[3]);
+        return ((buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0]);
+    return ((buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]);
 }
 
 static inline uint16_t
-- 
1.7.9.2



More information about the xorg-devel mailing list