diff mbox

[PULL,04/12] migration/qemu-file.c: Don't shift left into sign bit

Message ID 90d6a6730b4dbe7d0ada9900aba8263d61376812.1421310394.git.mjt@msgid.tls.msk.ru
State Accepted
Commit 90d6a6730b4dbe7d0ada9900aba8263d61376812
Headers show

Commit Message

Michael Tokarev Jan. 15, 2015, 8:30 a.m. UTC
From: Peter Maydell <peter.maydell@linaro.org>

Add a cast in qemu_get_be32() to avoid shifting left into the sign
bit of a signed integer (which is undefined behaviour in C).

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 migration/qemu-file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox

Patch

diff --git a/migration/qemu-file.c b/migration/qemu-file.c
index d2d4007..a7f2a34 100644
--- a/migration/qemu-file.c
+++ b/migration/qemu-file.c
@@ -503,7 +503,7 @@  unsigned int qemu_get_be16(QEMUFile *f)
 unsigned int qemu_get_be32(QEMUFile *f)
 {
     unsigned int v;
-    v = qemu_get_byte(f) << 24;
+    v = (unsigned int)qemu_get_byte(f) << 24;
     v |= qemu_get_byte(f) << 16;
     v |= qemu_get_byte(f) << 8;
     v |= qemu_get_byte(f);