ubsan: csky: left shift cannot be represented in type 'int'
[deliverable/binutils-gdb.git] / opcodes / csky-dis.c
index ffdb59649586a6c6ff391bc1be82e7c18d0e778a..af830f3651999a36bd978ee4f3b52b7625133439 100644 (file)
@@ -140,11 +140,11 @@ csky_chars_to_number (unsigned char * buf, int n)
   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] & 0xff);
+  else
+    for (i = n - 1; i >= 0; i--)
+      val = val << 8 | (buf[i] & 0xff);
   return val;
 }
 
This page took 0.022799 seconds and 4 git commands to generate.