From patchwork Mon Feb 17 14:37:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 24773 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f71.google.com (mail-pa0-f71.google.com [209.85.220.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8F3662055C for ; Mon, 17 Feb 2014 14:37:38 +0000 (UTC) Received: by mail-pa0-f71.google.com with SMTP id kp14sf37489442pab.2 for ; Mon, 17 Feb 2014 06:37:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=ZVI/s2Js1XNQ2qCOLOlSntj+lYJc1LaiZq7QN9EhkWM=; b=YEeKqO615r2CSV96FDYSdmU0ty+2SzgrTUEcg/jcbWoW9MI41o9jAStQr+2PzcddRv PKxYS6SPiIfp9HXtUEcqwUhMHGC+eMm6GAp3lIKsJ8n3mSlG/ciO3BKqA53+MTQ3WkTy N/Nw/EZyHWWfbnkR3DGDO/pigDs82U+ho/e0cCNp4j8hV2UnD6eSXRSI1NAtI2Qd6fPl y+t6cMGPWp3eelwWCt9fTtsMZh9n68v90wEweoa+TBveHmnoY0xulWngD9o+dE1tPTr4 WvePcH5vxuLpB9u7IZ+8EKkWCNOpNxP3XIY/EpU43UKt67+3SGAWZ+Gfjlw10O2WUZPr 3n4w== X-Gm-Message-State: ALoCoQmsOqi31QjMQFTNTIpnLmqr83wddyTEQVM0GeVdgxBR8EDnocoCZNEe3MQFYsrFY/7Ppavv X-Received: by 10.66.172.103 with SMTP id bb7mr10486206pac.44.1392647857816; Mon, 17 Feb 2014 06:37:37 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.106.165 with SMTP id e34ls893173qgf.29.gmail; Mon, 17 Feb 2014 06:37:37 -0800 (PST) X-Received: by 10.52.99.227 with SMTP id et3mr735929vdb.53.1392647857714; Mon, 17 Feb 2014 06:37:37 -0800 (PST) Received: from mail-vc0-f175.google.com (mail-vc0-f175.google.com [209.85.220.175]) by mx.google.com with ESMTPS id ls10si4504478vec.95.2014.02.17.06.37.37 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 17 Feb 2014 06:37:37 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.175 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.175; Received: by mail-vc0-f175.google.com with SMTP id ij19so11696946vcb.20 for ; Mon, 17 Feb 2014 06:37:37 -0800 (PST) X-Received: by 10.52.99.227 with SMTP id et3mr735925vdb.53.1392647857622; Mon, 17 Feb 2014 06:37:37 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp143263vcz; Mon, 17 Feb 2014 06:37:37 -0800 (PST) X-Received: by 10.15.41.140 with SMTP id s12mr28127181eev.4.1392647856069; Mon, 17 Feb 2014 06:37:36 -0800 (PST) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id w5si32571192eef.67.2014.02.17.06.37.35 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 17 Feb 2014 06:37:35 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::1 as permitted sender) client-ip=2001:8b0:1d0::1; Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1WFPKA-00026h-Ai; Mon, 17 Feb 2014 14:37:34 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org Subject: [PATCH 2/3] hw/net/stellaris_enet: Avoid unintended sign extension Date: Mon, 17 Feb 2014 14:37:33 +0000 Message-Id: <1392647854-8067-3-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1392647854-8067-1-git-send-email-peter.maydell@linaro.org> References: <1392647854-8067-1-git-send-email-peter.maydell@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.175 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 */