Patchwork Probable boolean logic error

login
register
mail settings
Submitter Michael McConville
Date Dec. 5, 2017, 7:35 a.m.
Message ID <DD0BA049-505B-4FDC-A6B7-01389410C601@mykolab.com>
Download mbox | patch
Permalink /patch/24723/
State New
Headers show

Comments

Michael McConville - Dec. 5, 2017, 7:35 a.m.
Unless I’m misunderstanding, these two conditions reduce to “if (true)” in their current form.
The most likely explanation is that someone mistakenly typed the wrong boolean operator.

2017-12-04	Michael McConville	<mmcco@mykolab.com>

	* mips-linux-tdep.c (mips_linux_in_dynsym_stub): fix boolean typo in two conditions
Simon Marchi - Dec. 5, 2017, 2:31 p.m.
On 2017-12-05 02:35, Michael McConville wrote:
> Unless I’m misunderstanding, these two conditions reduce to “if
> (true)” in their current form.
> The most likely explanation is that someone mistakenly typed the wrong
> boolean operator.
> 
> 2017-12-04	Michael McConville	<mmcco@mykolab.com>
> 
> 	* mips-linux-tdep.c (mips_linux_in_dynsym_stub): fix boolean typo in
> two conditions
> 
> diff --git a/gdb/mips-linux-tdep.c b/gdb/mips-linux-tdep.c
> index ebdacd981e..6c236e14a1 100644
> --- a/gdb/mips-linux-tdep.c
> +++ b/gdb/mips-linux-tdep.c
> @@ -709,15 +709,15 @@ mips_linux_in_dynsym_stub (CORE_ADDR pc)
>    insn = extract_unsigned_integer (p + 4, 4, byte_order);
>    if (n64)
>      {
> -      /* 'daddu t7,ra' or 'or t7, ra, zero'*/
> -      if (insn != 0x03e0782d || insn != 0x03e07825)
> +      /* 'daddu t7,ra' and 'or t7, ra, zero'*/
> +      if (insn != 0x03e0782d && insn != 0x03e07825)
>  	return 0;
> 
>      }
>    else
>      {
> -      /* 'addu t7,ra'  or 'or t7, ra, zero'*/
> -      if (insn != 0x03e07821 || insn != 0x03e07825)
> +      /* 'addu t7,ra' and 'or t7, ra, zero'*/
> +      if (insn != 0x03e07821 && insn != 0x03e07825)
>  	return 0;
> 
>      }

I agree that the current code doesn't really make sense.  CC'ing Maciej 
(the MIPS maintainer) so he has more chance to see it.

Simon

Patch

diff --git a/gdb/mips-linux-tdep.c b/gdb/mips-linux-tdep.c
index ebdacd981e..6c236e14a1 100644
--- a/gdb/mips-linux-tdep.c
+++ b/gdb/mips-linux-tdep.c
@@ -709,15 +709,15 @@  mips_linux_in_dynsym_stub (CORE_ADDR pc)
   insn = extract_unsigned_integer (p + 4, 4, byte_order);
   if (n64)
     {
-      /* 'daddu t7,ra' or 'or t7, ra, zero'*/
-      if (insn != 0x03e0782d || insn != 0x03e07825)
+      /* 'daddu t7,ra' and 'or t7, ra, zero'*/
+      if (insn != 0x03e0782d && insn != 0x03e07825)
 	return 0;
 
     }
   else
     {
-      /* 'addu t7,ra'  or 'or t7, ra, zero'*/
-      if (insn != 0x03e07821 || insn != 0x03e07825)
+      /* 'addu t7,ra' and 'or t7, ra, zero'*/
+      if (insn != 0x03e07821 && insn != 0x03e07825)
 	return 0;
 
     }