From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org
Subject: [Qemu-devel] [PATCH 3/3] migration/qemu-file.c: Don't shift left into sign bit
Date: Tue, 23 Dec 2014 22:26:55 +0000 [thread overview]
Message-ID: <1419373615-17989-4-git-send-email-peter.maydell@linaro.org> (raw)
In-Reply-To: <1419373615-17989-1-git-send-email-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>
---
migration/qemu-file.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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);
--
1.9.1
next prev parent reply other threads:[~2014-12-23 22:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-23 22:26 [Qemu-devel] [PATCH 0/3] miscellaneous minor clang fixes Peter Maydell
2014-12-23 22:26 ` [Qemu-devel] [PATCH 1/3] tests/hd-geo-test.c: Remove unused test_image variable Peter Maydell
2014-12-23 22:26 ` [Qemu-devel] [PATCH 2/3] translate-all: Mark map_exec() with the 'unused' attribute Peter Maydell
2014-12-23 22:26 ` Peter Maydell [this message]
2015-01-12 8:52 ` [Qemu-devel] [PATCH 0/3] miscellaneous minor clang fixes Michael Tokarev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1419373615-17989-4-git-send-email-peter.maydell@linaro.org \
--to=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).