disas/microblaze: Avoid unintended sign extension
commit1d153a3388b150b8aeedde32242db86b79c45473
authorPeter Maydell <peter.maydell@linaro.org>
Fri, 3 Mar 2017 15:50:31 +0000 (3 15:50 +0000)
committerPeter Maydell <peter.maydell@linaro.org>
Tue, 7 Mar 2017 14:33:51 +0000 (7 14:33 +0000)
tree64fe1731167f5d3c143b0f40b318b23fbc2a6148
parent2e3883d03df167b15f2acc5345eb9a7e0150a062
disas/microblaze: Avoid unintended sign extension

In read_insn_microblaze() we assemble 4 bytes into an 'unsigned
long'.  If 'unsigned long' is 64 bits and the high byte has its top
bit set, then C's implicit conversion from 'unsigned char' to 'int'
for the shift will result in an unintended sign extension which sets
the top 32 bits in 'inst'.  Add casts to prevent this.  (Spotted by
Coverity, CID 1005401.)

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Message-id: 1488556233-31246-5-git-send-email-peter.maydell@linaro.org
disas/microblaze.c