diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2013-06-27 15:03:51 +0100 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2013-07-15 16:17:30 +0100 |
commit | 8827b0fb66cab9f7978c4e66dad4cf3c0989a72e (patch) | |
tree | 12dd2050248886384769cc99dc27222437b2bb3a /hw | |
parent | 528622421eb1be95eaadfe91e8e11729d1e46431 (diff) | |
download | qemu-8827b0fb66cab9f7978c4e66dad4cf3c0989a72e.tar.gz qemu-8827b0fb66cab9f7978c4e66dad4cf3c0989a72e.tar.bz2 qemu-8827b0fb66cab9f7978c4e66dad4cf3c0989a72e.zip |
sd/pl181.c: Avoid undefined shift behaviour in RWORD macro
Add a cast to avoid potentially shifting into the sign bit of
a signed value, which is undefined behaviour in C.
(Detected with clang's -fsanitize=undefined.)
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1372341831-4264-1-git-send-email-peter.maydell@linaro.org
Diffstat (limited to 'hw')
-rw-r--r-- | hw/sd/pl181.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/hw/sd/pl181.c b/hw/sd/pl181.c index 4b1723418d..f5eb1e4012 100644 --- a/hw/sd/pl181.c +++ b/hw/sd/pl181.c @@ -175,7 +175,7 @@ static void pl181_send_command(pl181_state *s) if (rlen < 0) goto error; if (s->cmd & PL181_CMD_RESPONSE) { -#define RWORD(n) ((response[n] << 24) | (response[n + 1] << 16) \ +#define RWORD(n) (((uint32_t)response[n] << 24) | (response[n + 1] << 16) \ | (response[n + 2] << 8) | response[n + 3]) if (rlen == 0 || (rlen == 4 && (s->cmd & PL181_CMD_LONGRESP))) goto error; |