From: Scott Duplichan <sc...@notabs.org>

This patch contain type casts and replace one * operation by a
MultU64x32() call.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Scott Duplichan <sc...@notabs.org>
Signed-off-by: Anthony PERARD <anthony.per...@citrix.com>
---
 OvmfPkg/XenPvBlkDxe/BlockFront.c | 16 ++++++++--------
 OvmfPkg/XenPvBlkDxe/BlockIo.c    |  2 +-
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/OvmfPkg/XenPvBlkDxe/BlockFront.c b/OvmfPkg/XenPvBlkDxe/BlockFront.c
index c43e7af..afaa959 100644
--- a/OvmfPkg/XenPvBlkDxe/BlockFront.c
+++ b/OvmfPkg/XenPvBlkDxe/BlockFront.c
@@ -192,7 +192,7 @@ XenPvBlockFrontInitialization (
             Status));
     goto Error;
   }
-  Dev->DomainId = Value;
+  Dev->DomainId = (domid_t)Value;
   XenBusIo->EventChannelAllocate (XenBusIo, Dev->DomainId, &Dev->EventChannel);
 
   SharedRing = (blkif_sring_t*) AllocatePages (1);
@@ -258,7 +258,7 @@ Again:
   if (Status != XENSTORE_STATUS_SUCCESS || Value > MAX_UINT32) {
     goto Error2;
   }
-  Dev->MediaInfo.VDiskInfo = Value;
+  Dev->MediaInfo.VDiskInfo = (UINT32)Value;
   if (Dev->MediaInfo.VDiskInfo & VDISK_READONLY) {
     Dev->MediaInfo.ReadWrite = FALSE;
   } else {
@@ -274,7 +274,7 @@ Again:
   if (Status != XENSTORE_STATUS_SUCCESS || Value > MAX_UINT32) {
     goto Error2;
   }
-  if (Value % 512 != 0) {
+  if ((UINT32)Value % 512 != 0) {
     //
     // This is not supported by the driver.
     //
@@ -282,7 +282,7 @@ Again:
             "it must be a multiple of 512\n", Value));
     goto Error2;
   }
-  Dev->MediaInfo.SectorSize = Value;
+  Dev->MediaInfo.SectorSize = (UINT32)Value;
 
   // Default value
   Value = 0;
@@ -439,7 +439,7 @@ XenPvBlockAsyncIo (
 
   Start = (UINTN) IoData->Buffer & ~EFI_PAGE_MASK;
   End = ((UINTN) IoData->Buffer + IoData->Size + EFI_PAGE_SIZE - 1) & 
~EFI_PAGE_MASK;
-  IoData->NumRef = NumSegments = (End - Start) / EFI_PAGE_SIZE;
+  IoData->NumRef = NumSegments = (INT32)((End - Start) / EFI_PAGE_SIZE);
 
   ASSERT (NumSegments <= BLKIF_MAX_SEGMENTS_PER_REQUEST);
 
@@ -448,7 +448,7 @@ XenPvBlockAsyncIo (
   Request = RING_GET_REQUEST (&Dev->Ring, RingIndex);
 
   Request->operation = IsWrite ? BLKIF_OP_WRITE : BLKIF_OP_READ;
-  Request->nr_segments = NumSegments;
+  Request->nr_segments = (UINT8)NumSegments;
   Request->handle = Dev->DeviceId;
   Request->id = (UINTN) IoData;
   Request->sector_number = IoData->Sector;
@@ -457,9 +457,9 @@ XenPvBlockAsyncIo (
     Request->seg[Index].first_sect = 0;
     Request->seg[Index].last_sect = EFI_PAGE_SIZE / 512 - 1;
   }
-  Request->seg[0].first_sect = ((UINTN) IoData->Buffer & EFI_PAGE_MASK) / 512;
+  Request->seg[0].first_sect = (UINT8)(((UINTN) IoData->Buffer & 
EFI_PAGE_MASK) / 512);
   Request->seg[NumSegments - 1].last_sect =
-      (((UINTN) IoData->Buffer + IoData->Size - 1) & EFI_PAGE_MASK) / 512;
+      (UINT8)((((UINTN) IoData->Buffer + IoData->Size - 1) & EFI_PAGE_MASK) / 
512);
   for (Index = 0; Index < NumSegments; Index++) {
     UINTN Data = Start + Index * EFI_PAGE_SIZE;
     XenBusIo->GrantAccess (XenBusIo, Dev->DomainId,
diff --git a/OvmfPkg/XenPvBlkDxe/BlockIo.c b/OvmfPkg/XenPvBlkDxe/BlockIo.c
index 4f3bc53..7fc7a05 100644
--- a/OvmfPkg/XenPvBlkDxe/BlockIo.c
+++ b/OvmfPkg/XenPvBlkDxe/BlockIo.c
@@ -136,7 +136,7 @@ XenPvBlkDxeBlockIoReadWriteBlocks (
   }
 
   IoData.Dev = XEN_BLOCK_FRONT_FROM_BLOCK_IO (This);
-  Sector = Lba * (Media->BlockSize / 512);
+  Sector = (UINTN)MultU64x32 (Lba, Media->BlockSize / 512);
 
   while (BufferSize > 0) {
     if (((UINTN)Buffer & EFI_PAGE_MASK) == 0) {
-- 
Anthony PERARD


------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://pubads.g.doubleclick.net/gampad/clk?id=154624111&iu=/4140/ostg.clktrk
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to