From patchwork Sat Jun 11 20:48:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Baldwin X-Patchwork-Id: 12989 Received: (qmail 103770 invoked by alias); 11 Jun 2016 20:49:34 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 103545 invoked by uid 89); 11 Jun 2016 20:49:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.2 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_SOFTFAIL autolearn=no version=3.3.2 spammy=2.7.0 X-Spam-User: qpsmtpd, 2 recipients X-HELO: bigwig.baldwin.cx Received: from bigwig.baldwin.cx (HELO bigwig.baldwin.cx) (96.47.65.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Sat, 11 Jun 2016 20:49:31 +0000 Received: from ralph.baldwin.cx.net (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id E68C3B9C8; Sat, 11 Jun 2016 16:49:28 -0400 (EDT) From: John Baldwin To: gdb-patches@sourceware.org, binutils@sourceware.org Subject: [PATCH 8/8] Use unsigned integer constant with left shifts. Date: Sat, 11 Jun 2016 13:48:35 -0700 Message-Id: <1465678115-58170-9-git-send-email-jhb@FreeBSD.org> In-Reply-To: <1465678115-58170-1-git-send-email-jhb@FreeBSD.org> References: <1465678115-58170-1-git-send-email-jhb@FreeBSD.org> X-IsSubscribed: yes This avoids undefined behavior. gdb/ChangeLog: * ada-lang.c (ada_unpack_from_contents): Use unsigned constants with left shifts. --- gdb/ChangeLog | 5 +++++ gdb/ada-lang.c | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 4c4389d..1077e2f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 2016-06-11 John Baldwin + * ada-lang.c (ada_unpack_from_contents): Use unsigned constants with + left shifts. + +2016-06-11 John Baldwin + * v850-tdep.c (v850_use_struct_convention): Trim type length checks. 2016-06-11 John Baldwin diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 412aa97..0e951a4 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -2486,7 +2486,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; @@ -2500,7 +2500,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;