diff mbox

[edk2,2/7] OvmfPg: flash driver: drop gratuitous 64-by-32 bit division (VS2010)

Message ID 1415801041-17550-3-git-send-email-lersek@redhat.com
State New
Headers show

Commit Message

Laszlo Ersek Nov. 12, 2014, 2:03 p.m. UTC
In the InitializeVariableFvHeader() function, both "Start" and "BlockSize"
have type UINTN. Therefore the (Start / BlockSize) division can be
compiled on all platforms without intrinsics.

In he current expression

  (EFI_LBA) Start / BlockSize

"Start" is cast to UINT64 (== EFI_LBA), which leads to a 64-by-32 bit
division on Ia32, breaking the VS2010 / NOOPT / Ia32 build. The simplest
way to fix this is to realize we don't need a cast at all. (The prototype
of QemuFlashWrite() is visible via "QemuFlash.h", and it will easily take
our UINTN quotient as UINT64.)

Suggested-by: Scott Duplichan <scott@notabs.org>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox

Patch

diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c
index 42060c8..38be935 100644
--- a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c
+++ b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c
@@ -988,7 +988,7 @@  InitializeVariableFvHeader (
     //
     WriteLength = GoodFwVolHeader->HeaderLength;
     Status = QemuFlashWrite (
-               (EFI_LBA) Start / BlockSize,
+               Start / BlockSize,
                0,
                &WriteLength,
                (UINT8 *) GoodFwVolHeader);