From: John Baldwin Date: Sat, 11 Jun 2016 20:18:15 +0000 (-0700) Subject: Use unsigned integer constant with left shifts. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=db297a6501dc44c10bff096eddcc358b48810aad;p=binutils-gdb.git Use unsigned integer constant with left shifts. This avoids undefined behavior. gdb/ChangeLog: * ada-lang.c (ada_unpack_from_contents): Use unsigned constants with left shifts. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index c9ad9ccb2bf..5adf9a8f345 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2016-07-06 John Baldwin + + * ada-lang.c (ada_unpack_from_contents): Use unsigned constants with + left shifts. + 2016-07-06 John Baldwin * sh64-tdep.c (sh64_analyze_prologue): Set "uses_fp" when setting diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index b22b7ac78ce..05bfd7b34c7 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -2525,7 +2525,7 @@ ada_unpack_from_contents (const gdb_byte *src, int bit_offset, int bit_size, accumSize += HOST_CHAR_BIT - unusedLS; if (accumSize >= HOST_CHAR_BIT) { - unpacked[unpacked_idx] = accum & ~(~0L << HOST_CHAR_BIT); + unpacked[unpacked_idx] = accum & ~(~0UL << HOST_CHAR_BIT); accumSize -= HOST_CHAR_BIT; accum >>= HOST_CHAR_BIT; unpacked_bytes_left -= 1; @@ -2539,7 +2539,7 @@ ada_unpack_from_contents (const gdb_byte *src, int bit_offset, int bit_size, while (unpacked_bytes_left > 0) { accum |= sign << accumSize; - unpacked[unpacked_idx] = accum & ~(~0L << HOST_CHAR_BIT); + unpacked[unpacked_idx] = accum & ~(~0UL << HOST_CHAR_BIT); accumSize -= HOST_CHAR_BIT; if (accumSize < 0) accumSize = 0;