bytevector: Add proper cast.
authorLudovic Courtès <ludo@gnu.org>
Mon, 20 Apr 2009 17:34:41 +0000 (20 19:34 +0200)
committerLudovic Courtès <ludo@gnu.org>
Mon, 20 Apr 2009 17:34:41 +0000 (20 19:34 +0200)
* src/bytevector.c (GENERIC_INTEGER_SET): Add correct cast of C_VALUE.
  This fixes a sign mismatch issue identified by GCC 4.3.1 on
  `sparc64-unknown-linux-gnu'.

src/bytevector.c

index d260f50..9d449aa 100644 (file)
@@ -831,8 +831,11 @@ bytevector_unsigned_ref (const char *c_bv, size_t c_size, SCM endianness)
                                                                        \
              swap = !scm_is_eq (endianness, native_endianness);        \
                                                                        \
-             c_value16 =                                               \
-               swap ? bswap_16 (c_value) : c_value;                    \
+             if (swap)                                                 \
+               c_value16 = (INT_TYPE (16, _sign)) bswap_16 (c_value);  \
+             else                                                      \
+               c_value16 = c_value;                                    \
+                                                                       \
              memcpy (c_bv, &c_value16, 2);                             \
            }                                                           \
          else                                                          \