gdb: fix -Wtautological-overlap-compare warning in mips-linux-tdep.c
authorSimon Marchi <simon.marchi@efficios.com>
Sat, 16 May 2020 15:21:41 +0000 (11:21 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Sat, 16 May 2020 15:21:41 +0000 (11:21 -0400)
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
gdb/mips-linux-tdep.c

index 1c4dc5c94c2a770ad4b48ebcd681451378e100e6..8d6901efe67ce640bdd22e3d9338ae516e24de9e 100644 (file)
@@ -1,3 +1,7 @@
+2020-05-16  Simon Marchi  <simon.marchi@efficios.com>
+
+       * mips-linux-tdep.c (mips_linux_in_dynsym_stub): Fix condition.
+
 2020-05-16  Pedro Alves  <palves@redhat.com>
 
        * ia64-linux-nat.c
index aa7b8d11f3fbfe946eb0c2a8de119427d0254326..3ffd53db9ead82b081a8ec64d3556315eb395053 100644 (file)
@@ -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);
This page took 0.028441 seconds and 4 git commands to generate.