From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35066) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UylZX-0003cj-PW for qemu-devel@nongnu.org; Mon, 15 Jul 2013 12:24:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UylZQ-0004zi-Tg for qemu-devel@nongnu.org; Mon, 15 Jul 2013 12:24:23 -0400 Received: from 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.d.1.0.0.b.8.0.1.0.0.2.ip6.arpa ([2001:8b0:1d0::1]:58665 helo=mnementh.archaic.org.uk) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UylZQ-0004x4-Km for qemu-devel@nongnu.org; Mon, 15 Jul 2013 12:24:16 -0400 From: Peter Maydell Date: Mon, 15 Jul 2013 17:01:31 +0100 Message-Id: <1373904095-27592-4-git-send-email-peter.maydell@linaro.org> In-Reply-To: <1373904095-27592-1-git-send-email-peter.maydell@linaro.org> References: <1373904095-27592-1-git-send-email-peter.maydell@linaro.org> Subject: [Qemu-devel] [PULL 3/7] sd/pl181.c: Avoid undefined shift behaviour in RWORD macro List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: qemu-devel@nongnu.org, Paul Brook 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 Message-id: 1372341831-4264-1-git-send-email-peter.maydell@linaro.org --- hw/sd/pl181.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/sd/pl181.c b/hw/sd/pl181.c index 4b17234..f5eb1e4 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; -- 1.7.9.5