Use unsigned integer constant with left shifts.
authorJohn Baldwin <jhb@FreeBSD.org>
Sat, 11 Jun 2016 20:18:15 +0000 (13:18 -0700)
committerJohn Baldwin <jhb@FreeBSD.org>
Wed, 6 Jul 2016 13:09:19 +0000 (06:09 -0700)
This avoids undefined behavior.

gdb/ChangeLog:

* ada-lang.c (ada_unpack_from_contents): Use unsigned constants with
left shifts.

gdb/ChangeLog
gdb/ada-lang.c

index c9ad9ccb2bfb8f89b0e196897dbdc0c296fa7dbb..5adf9a8f34554d18a7272072ad0a6ce5a206af5f 100644 (file)
@@ -1,3 +1,8 @@
+2016-07-06  John Baldwin  <jhb@FreeBSD.org>
+
+       * ada-lang.c (ada_unpack_from_contents): Use unsigned constants with
+       left shifts.
+
 2016-07-06  John Baldwin  <jhb@FreeBSD.org>
 
        * sh64-tdep.c (sh64_analyze_prologue): Set "uses_fp" when setting
index b22b7ac78ce9768d448431d68464a4d6f1eb3113..05bfd7b34c74bea5645752ef2eab1f7041c9b08d 100644 (file)
@@ -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;
This page took 0.04469 seconds and 4 git commands to generate.