]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPg: flash driver: drop gratuitous 64-by-32 bit divisions (VS2010)
authorLaszlo Ersek <lersek@redhat.com>
Fri, 14 Nov 2014 10:23:33 +0000 (10:23 +0000)
committerlersek <lersek@Edk2>
Fri, 14 Nov 2014 10:23:33 +0000 (10:23 +0000)
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 <scott@notabs.org>
Contributed-under: TianoCore Contribution Agreement 1.0

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Build-tested-by: Scott Duplichan <scott@notabs.org>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16383 6f19259b-4bc3-4df7-8a09-765794883524

OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c

index 42060c84cf0d126c169b25675f5862a28b45e587..9160bb885b422bfdfb0837a8aca6076d4dfb5961 100644 (file)
@@ -979,7 +979,7 @@ InitializeVariableFvHeader (
     // Erase all the blocks\r
     //\r
     for (Offset = Start; Offset < Start + Length; Offset += BlockSize) {\r
-      Status = QemuFlashEraseBlock ((EFI_LBA) Offset / BlockSize);\r
+      Status = QemuFlashEraseBlock (Offset / BlockSize);\r
       ASSERT_EFI_ERROR (Status);\r
     }\r
 \r
@@ -988,7 +988,7 @@ InitializeVariableFvHeader (
     //\r
     WriteLength = GoodFwVolHeader->HeaderLength;\r
     Status = QemuFlashWrite (\r
-               (EFI_LBA) Start / BlockSize,\r
+               Start / BlockSize,\r
                0,\r
                &WriteLength,\r
                (UINT8 *) GoodFwVolHeader);\r