[binutils-gdb] Don't use boolean OR in arithmetic expressions

Alan Modra amodra@sourceware.org
Wed Oct 5 23:44:00 GMT 2016


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=616ec3583b7b6ba0a4e581c426b700b0664a3027

commit 616ec3583b7b6ba0a4e581c426b700b0664a3027
Author: Alan Modra <amodra@gmail.com>
Date:   Thu Oct 6 08:08:25 2016 +1030

    Don't use boolean OR in arithmetic expressions
    
    bfd/
    	* elf32-epiphany.c (epiphany_final_link_relocate): Use bitwise
    	OR in arithmetic expression, not boolean OR.
    opcodes/
    	* cr16-dis.c (print_insn_cr16): Don't use boolean OR in arithmetic.
    	* crx-dis.c (print_insn_crx): Likewise.

Diff:
---
 bfd/ChangeLog        | 5 +++++
 bfd/elf32-epiphany.c | 5 +++--
 opcodes/ChangeLog    | 5 +++++
 opcodes/cr16-dis.c   | 2 +-
 opcodes/crx-dis.c    | 2 +-
 5 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index e54585a..7ba9597 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,8 @@
+2016-10-06  Alan Modra  <amodra@gmail.com>
+
+	* elf32-epiphany.c (epiphany_final_link_relocate): Use bitwise
+	OR in arithmetic expression, not boolean OR.
+
 2016-09-30  Alan Modra  <amodra@gmail.com>
 
 	* Makefile.am (BFD_H_FILES): Add linker.c and simple.c.  Sort
diff --git a/bfd/elf32-epiphany.c b/bfd/elf32-epiphany.c
index 420dc8b..6b798b1 100644
--- a/bfd/elf32-epiphany.c
+++ b/bfd/elf32-epiphany.c
@@ -420,9 +420,10 @@ epiphany_final_link_relocate (reloc_howto_type *  howto,
       relocation += rel->r_addend;
       if ((unsigned int) relocation > 0x7ff)
 	return bfd_reloc_outofrange;
+      /* Fall through.  */
     disp11:
-      relocation = ((relocation & 7) << 5)
-	|| ((relocation & 0x7f8 )  << 13);
+      relocation = (((relocation & 7) << 5)
+		    | ((relocation & 0x7f8 ) << 13));
       return _bfd_relocate_contents (howto, input_bfd, relocation,
 				     contents + rel->r_offset);
 
diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog
index 20ebe69..83f435c 100644
--- a/opcodes/ChangeLog
+++ b/opcodes/ChangeLog
@@ -1,3 +1,8 @@
+2016-10-06  Alan Modra  <amodra@gmail.com>
+
+	* cr16-dis.c (print_insn_cr16): Don't use boolean OR in arithmetic.
+	* crx-dis.c (print_insn_crx): Likewise.
+
 2016-09-30  H.J. Lu  <hongjiu.lu@intel.com>
 
 	PR binutils/20657
diff --git a/opcodes/cr16-dis.c b/opcodes/cr16-dis.c
index 3c901f9..1d7054a 100644
--- a/opcodes/cr16-dis.c
+++ b/opcodes/cr16-dis.c
@@ -815,7 +815,7 @@ print_insn_cr16 (bfd_vma memaddr, struct disassemble_info *info)
   /* Find a matching opcode in table.  */
   is_decoded = cr16_match_opcode ();
   /* If found, print the instruction's mnemonic and arguments.  */
-  if (is_decoded > 0 && (cr16_words[0] << 16 || cr16_words[1]) != 0)
+  if (is_decoded > 0 && (cr16_words[0] != 0 || cr16_words[1] != 0))
     {
       if (strneq (instruction->mnemonic, "cinv", 4))
         info->fprintf_func (info->stream,"%s", getcinvstring (instruction->mnemonic));
diff --git a/opcodes/crx-dis.c b/opcodes/crx-dis.c
index 2da70ed..d6b129e 100644
--- a/opcodes/crx-dis.c
+++ b/opcodes/crx-dis.c
@@ -727,7 +727,7 @@ print_insn_crx (bfd_vma memaddr, struct disassemble_info *info)
   /* Find a matching opcode in table.  */
   is_decoded = match_opcode ();
   /* If found, print the instruction's mnemonic and arguments.  */
-  if (is_decoded > 0 && (words[0] << 16 || words[1]) != 0)
+  if (is_decoded > 0 && (words[0] != 0 || words[1] != 0))
     {
       info->fprintf_func (info->stream, "%s", instruction->mnemonic);
       if ((currInsn.nargs = get_number_of_operands ()) != 0)



More information about the Binutils-cvs mailing list