From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id F0357386F442 for ; Sat, 16 May 2020 15:23:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org F0357386F442 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark@simark.ca Received: from [10.0.0.193] (unknown [192.222.164.54]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id E46A91ED39; Sat, 16 May 2020 11:23:16 -0400 (EDT) Subject: Re: [PATCH] gdb: fix -Wtautological-overlap-compare warning in mips-linux-tdep.c To: "Maciej W. Rozycki" , Simon Marchi Cc: gdb-patches@sourceware.org, Andreas Schwab References: <20200516020151.34919-1-simon.marchi@efficios.com> From: Simon Marchi Message-ID: <78758ac2-ffe6-0675-3c4f-b0177de4738f@simark.ca> Date: Sat, 16 May 2020 11:23:16 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: tl Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 May 2020 15:23:19 -0000 On 2020-05-16 9:29 a.m., Maciej W. Rozycki wrote: > On Fri, 15 May 2020, Simon Marchi wrote: > >> diff --git a/gdb/mips-linux-tdep.c b/gdb/mips-linux-tdep.c >> index aa7b8d11f3fb..ae067c19dfa7 100644 >> --- a/gdb/mips-linux-tdep.c >> +++ b/gdb/mips-linux-tdep.c >> @@ -633,16 +633,14 @@ mips_linux_in_dynsym_stub (CORE_ADDR pc) >> if (n64) >> { >> /* 'daddu t7,ra' or 'or t7, ra, zero'*/ >> - if (insn != 0x03e0782d || insn != 0x03e07825) >> + if (insn == 0x03e0782d || insn == 0x03e07825) > > Nope, this ought to be: > > if (insn != 0x03e0782d && insn != 0x03e07825) > >> return 0; >> - >> } >> else >> { >> /* 'addu t7,ra' or 'or t7, ra, zero'*/ >> - if (insn != 0x03e07821 || insn != 0x03e07825) >> + if (insn == 0x03e07821 || insn == 0x03e07825) > > Likewise: > > if (insn != 0x03e07821 && insn != 0x03e07825) > > Thanks for looking into it (and for cc-ing me)! > > Maciej > Ah so I misinterpreted the intent. Thanks to you and Andreas for pointing it out! I modified the patch and pushed it as below. Simon >From 59f7bd8d2b855162db6784c9724ead9e2377f32c Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Sat, 16 May 2020 11:21:41 -0400 Subject: [PATCH] gdb: fix -Wtautological-overlap-compare warning in mips-linux-tdep.c When building with clang 11, I get: CXX mips-linux-tdep.o /home/smarchi/src/binutils-gdb/gdb/mips-linux-tdep.c:643:30: error: overlapping comparisons always evaluate to true [-Werror,-Wtautological-overlap-compare] if (insn != 0x03e07821 || insn != 0x03e07825) ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~ /home/smarchi/src/binutils-gdb/gdb/mips-linux-tdep.c:636:30: error: overlapping comparisons always evaluate to true [-Werror,-Wtautological-overlap-compare] if (insn != 0x03e0782d || insn != 0x03e07825) ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~ Indeed, given two different values, `insn` will always be different to one of them, and these conditions always be true. This code is meant to return if `insn` isn't one of these two values, so the `||` should be replaced with `&&`. gdb/ChangeLog: * mips-linux-tdep.c (mips_linux_in_dynsym_stub): Fix condition. --- gdb/ChangeLog | 4 ++++ gdb/mips-linux-tdep.c | 6 ++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 1c4dc5c94c2a..8d6901efe67c 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,7 @@ +2020-05-16 Simon Marchi + + * mips-linux-tdep.c (mips_linux_in_dynsym_stub): Fix condition. + 2020-05-16 Pedro Alves * ia64-linux-nat.c diff --git a/gdb/mips-linux-tdep.c b/gdb/mips-linux-tdep.c index aa7b8d11f3fb..3ffd53db9ead 100644 --- a/gdb/mips-linux-tdep.c +++ b/gdb/mips-linux-tdep.c @@ -633,16 +633,14 @@ mips_linux_in_dynsym_stub (CORE_ADDR pc) if (n64) { /* 'daddu t7,ra' or 'or t7, ra, zero'*/ - if (insn != 0x03e0782d || insn != 0x03e07825) + if (insn != 0x03e0782d && insn != 0x03e07825) return 0; - } else { /* 'addu t7,ra' or 'or t7, ra, zero'*/ - if (insn != 0x03e07821 || insn != 0x03e07825) + if (insn != 0x03e07821 && insn != 0x03e07825) return 0; - } insn = extract_unsigned_integer (p + 8, 4, byte_order); -- 2.26.2