From patchwork Thu Nov 13 11:16:20 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laszlo Ersek X-Patchwork-Id: 40734 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f69.google.com (mail-wg0-f69.google.com [74.125.82.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 85D09240ED for ; Thu, 13 Nov 2014 11:16:59 +0000 (UTC) Received: by mail-wg0-f69.google.com with SMTP id l18sf7764754wgh.0 for ; Thu, 13 Nov 2014 03:16:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:subject:precedence:reply-to:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version :errors-to:x-original-sender:x-original-authentication-results :mailing-list:content-type:content-transfer-encoding; bh=i2Bf96ViB3L2OI5xLLzG/1s5KgmNKjsaZwcObmXdtU8=; b=kl6sDivg8Go1/N6RzgVGVeBGp3M6OvfxcJ7snjMuAQEs1eBEpQuEP0F6inwYRdwQJn xGtFYTLMnGj5GB5hb4Hb4KinItrMhnE6gGQRD0KsAYiJ8rBMYly15QlRkesnhbU+4Slb XzjaOzDj+J5CxTO4iGFykqmD4TIjaoa6zbqlKLBGBBrHKAv/Sajnhoo6YYAz2V4wkRi9 PMP5ejV3lHEpsBCVWPPy+qkQaO+nqyGkAEvMGpaRBvGxjvqaBtYLmTjFgtw9ZLRYHIwD Inx0voSANOCHnnjwR7z/BXVtJ4/luG5E9tAuu2CS1oC4+Yoy9n4vNUyAc4YSi1RrU06f EisQ== X-Gm-Message-State: ALoCoQnUu7RN3sUlD3/s6uFCvXQbvsvHWUd+rdE0oOzuruQO1xWYJ5HSZWw9ocNmEYMAxBSJ8gPC X-Received: by 10.180.74.196 with SMTP id w4mr7838060wiv.7.1415877418850; Thu, 13 Nov 2014 03:16:58 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.43.129 with SMTP id w1ls771808lal.34.gmail; Thu, 13 Nov 2014 03:16:58 -0800 (PST) X-Received: by 10.112.139.196 with SMTP id ra4mr1541600lbb.95.1415877418591; Thu, 13 Nov 2014 03:16:58 -0800 (PST) Received: from mail-la0-f48.google.com (mail-la0-f48.google.com. [209.85.215.48]) by mx.google.com with ESMTPS id jc4si37890832lbc.137.2014.11.13.03.16.58 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 13 Nov 2014 03:16:58 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) client-ip=209.85.215.48; Received: by mail-la0-f48.google.com with SMTP id gq15so12863988lab.21 for ; Thu, 13 Nov 2014 03:16:58 -0800 (PST) X-Received: by 10.152.42.226 with SMTP id r2mr1770936lal.29.1415877418444; Thu, 13 Nov 2014 03:16:58 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp572467lbc; Thu, 13 Nov 2014 03:16:57 -0800 (PST) X-Received: by 10.107.9.2 with SMTP id j2mr1138641ioi.82.1415877416943; Thu, 13 Nov 2014 03:16:56 -0800 (PST) Received: from lists.sourceforge.net (lists.sourceforge.net. [216.34.181.88]) by mx.google.com with ESMTPS id kx18si39976598icc.30.2014.11.13.03.16.56 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 13 Nov 2014 03:16:56 -0800 (PST) Received-SPF: pass (google.com: domain of edk2-devel-bounces@lists.sourceforge.net designates 216.34.181.88 as permitted sender) client-ip=216.34.181.88; Received: from localhost ([127.0.0.1] helo=sfs-ml-3.v29.ch3.sourceforge.com) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1XosON-0001vz-Ih; Thu, 13 Nov 2014 11:16:47 +0000 Received: from sog-mx-2.v43.ch3.sourceforge.com ([172.29.43.192] helo=mx.sourceforge.net) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1XosOL-0001vt-Rd for edk2-devel@lists.sourceforge.net; Thu, 13 Nov 2014 11:16:45 +0000 Received-SPF: pass (sog-mx-2.v43.ch3.sourceforge.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=lersek@redhat.com; helo=mx1.redhat.com; Received: from mx1.redhat.com ([209.132.183.28]) by sog-mx-2.v43.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) id 1XosOK-0008IG-SE for edk2-devel@lists.sourceforge.net; Thu, 13 Nov 2014 11:16:45 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sADBGcZY003373 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 13 Nov 2014 06:16:38 -0500 Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-83.ams2.redhat.com [10.36.116.83]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id sADBGTn0018997 for ; Thu, 13 Nov 2014 06:16:37 -0500 From: Laszlo Ersek To: edk2-devel@lists.sourceforge.net Date: Thu, 13 Nov 2014 12:16:20 +0100 Message-Id: <1415877385-18341-3-git-send-email-lersek@redhat.com> In-Reply-To: <1415877385-18341-1-git-send-email-lersek@redhat.com> References: <1415877385-18341-1-git-send-email-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Spam-Score: -2.5 (--) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -1.0 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain X-Headers-End: 1XosOK-0008IG-SE Subject: [edk2] [PATCH v2 2/7] OvmfPg: flash driver: drop gratuitous 64-by-32 bit divisions (VS2010) X-BeenThere: edk2-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list Reply-To: edk2-devel@lists.sourceforge.net List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.sourceforge.net X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: lersek@redhat.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 In the InitializeVariableFvHeader() function, all three of "Offset", "Start" and "BlockSize" have type UINTN. Therefore the (Offset / BlockSize) and (Start / BlockSize) divisions can be compiled on all platforms without intrinsics. In the current expressions (EFI_LBA) Offset / BlockSize (EFI_LBA) Start / BlockSize "Offset" and "Start" are cast to UINT64 (== EFI_LBA), which leads to 64-by-32 bit divisions on Ia32, breaking the VS2010 / NOOPT / Ia32 build. The simplest way to fix them is to realize we don't need casts at all. (The prototypes of QemuFlashEraseBlock() and QemuFlashWrite() are visible via "QemuFlash.h", and they will easily take our UINTN quotients as UINT64.) Suggested-by: Scott Duplichan Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek --- Notes: v2: - covered another division, reported by Scott OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c index 42060c8..9160bb8 100644 --- a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c +++ b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c @@ -979,7 +979,7 @@ InitializeVariableFvHeader ( // Erase all the blocks // for (Offset = Start; Offset < Start + Length; Offset += BlockSize) { - Status = QemuFlashEraseBlock ((EFI_LBA) Offset / BlockSize); + Status = QemuFlashEraseBlock (Offset / BlockSize); ASSERT_EFI_ERROR (Status); } @@ -988,7 +988,7 @@ InitializeVariableFvHeader ( // WriteLength = GoodFwVolHeader->HeaderLength; Status = QemuFlashWrite ( - (EFI_LBA) Start / BlockSize, + Start / BlockSize, 0, &WriteLength, (UINT8 *) GoodFwVolHeader);