From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43074) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFPKD-0007Zj-8z for qemu-devel@nongnu.org; Mon, 17 Feb 2014 09:37:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WFPKC-0002XG-6t for qemu-devel@nongnu.org; Mon, 17 Feb 2014 09:37:37 -0500 Received: from mnementh.archaic.org.uk ([2001:8b0:1d0::1]:45968) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFPKC-0002Wr-0O for qemu-devel@nongnu.org; Mon, 17 Feb 2014 09:37:36 -0500 From: Peter Maydell Date: Mon, 17 Feb 2014 14:37:33 +0000 Message-Id: <1392647854-8067-3-git-send-email-peter.maydell@linaro.org> In-Reply-To: <1392647854-8067-1-git-send-email-peter.maydell@linaro.org> References: <1392647854-8067-1-git-send-email-peter.maydell@linaro.org> Subject: [Qemu-devel] [PATCH 2/3] hw/net/stellaris_enet: Avoid unintended sign extension List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: patches@linaro.org Add a cast to avoid an unintended sign extension that would mean we returned 0xffffffff in the high 32 bits for an IA0 read if bit 31 in the MAC address was 1. (This is harmless since we'll only be doing 4 byte reads, but it could be confusing, so best avoided.) Signed-off-by: Peter Maydell --- hw/net/stellaris_enet.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/net/stellaris_enet.c b/hw/net/stellaris_enet.c index 9dd77f7..d04e6a4 100644 --- a/hw/net/stellaris_enet.c +++ b/hw/net/stellaris_enet.c @@ -176,7 +176,8 @@ static uint64_t stellaris_enet_read(void *opaque, hwaddr offset, return val; case 0x14: /* IA0 */ return s->conf.macaddr.a[0] | (s->conf.macaddr.a[1] << 8) - | (s->conf.macaddr.a[2] << 16) | (s->conf.macaddr.a[3] << 24); + | (s->conf.macaddr.a[2] << 16) + | ((uint32_t)s->conf.macaddr.a[3] << 24); case 0x18: /* IA1 */ return s->conf.macaddr.a[4] | (s->conf.macaddr.a[5] << 8); case 0x1c: /* THR */ -- 1.8.5