Fix the cast used to prevent compile time warning about an always false test.
[deliverable/binutils-gdb.git] / opcodes / csky-dis.c
index 9c3495f82dc2ce699adc19dd00910e5c120ef929..bc6820ae0765f0e1404d189811c7008dd98bc9e8 100644 (file)
@@ -1,5 +1,5 @@
 /* C-SKY disassembler.
-   Copyright (C) 1988-2018 Free Software Foundation, Inc.
+   Copyright (C) 1988-2020 Free Software Foundation, Inc.
    Contributed by C-SKY Microsystems and Mentor Graphics.
 
    This file is part of the GNU opcodes library.
@@ -22,7 +22,7 @@
 #include "sysdep.h"
 #include "config.h"
 #include <stdio.h>
-#include <stdint.h>
+#include "bfd_stdint.h"
 #include "disassemble.h"
 #include "elf-bfd.h"
 #include "opcode/csky.h"
@@ -134,17 +134,15 @@ csky_get_mask (struct csky_opcode_info const *pinfo)
 static unsigned int
 csky_chars_to_number (unsigned char * buf, int n)
 {
-  if (n == 0)
-    abort ();
   int i;
-  int val = 0;
+  unsigned int val = 0;
 
   if (dis_info.info->endian == BFD_ENDIAN_BIG)
-    while (n--)
-      val |= buf[n] << (n*8);
-  else
     for (i = 0; i < n; i++)
-      val |= buf[i] << (i*8);
+      val = val << 8 | buf[i];
+  else
+    for (i = n - 1; i >= 0; i--)
+      val = val << 8 | buf[i];
   return val;
 }
 
This page took 0.024931 seconds and 4 git commands to generate.