From patchwork Fri Jul 1 17:40: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: 13555 Received: (qmail 63687 invoked by alias); 1 Jul 2016 17:41:17 -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 63620 invoked by uid 89); 1 Jul 2016 17:41:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.5 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_SOFTFAIL autolearn=no version=3.3.2 spammy=Hx-languages-length:1543 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; Fri, 01 Jul 2016 17:41:15 +0000 Received: from ralph.com (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 8E504B9B0 for ; Fri, 1 Jul 2016 13:41:13 -0400 (EDT) From: John Baldwin To: gdb-patches@sourceware.org Subject: [PATCH v2 3/4] Use unsigned integer constant with left shifts. Date: Fri, 1 Jul 2016 10:40:35 -0700 Message-Id: <20160701174036.90598-4-jhb@FreeBSD.org> In-Reply-To: <20160701174036.90598-1-jhb@FreeBSD.org> References: <20160701174036.90598-1-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 727cf37..97db7ef 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 2016-07-01 John Baldwin + * ada-lang.c (ada_unpack_from_contents): Use unsigned constants with + left shifts. + +2016-07-01 John Baldwin + * sh64-tdep.c (sh64_analyze_prologue): Set "uses_fp" when setting the MEDIA_FP_REGNUM register. diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index b22b7ac..05bfd7b 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;