]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg: VirtioNetDxe: fix some build errors emitted by Visual Studio
authorLaszlo Ersek <lersek@redhat.com>
Fri, 14 Jun 2013 07:40:59 +0000 (07:40 +0000)
committerjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 14 Jun 2013 07:40:59 +0000 (07:40 +0000)
These were found with the gcc-4.4 option "-Wconversion" after Jordan
reported the build failure under Visual Studio. The patch was originally
posted to edk2-devel as "silence.patch":

http://thread.gmane.org/gmane.comp.bios.tianocore.devel/2804/focus=2972

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14419 6f19259b-4bc3-4df7-8a09-765794883524

OvmfPkg/VirtioNetDxe/SnpInitialize.c
OvmfPkg/VirtioNetDxe/SnpReceive.c

index 39282d9a4ac3c09bc4236356d4da625c9450e008..6cee014072e7ccd1121e9f5ad587151568b88afc 100644 (file)
@@ -120,7 +120,8 @@ VirtioNetInitTx (
 {\r
   UINTN PktIdx;\r
 \r
-  Dev->TxMaxPending = MIN (Dev->TxRing.QueueSize / 2, VNET_MAX_PENDING);\r
+  Dev->TxMaxPending = (UINT16) MIN (Dev->TxRing.QueueSize / 2,\r
+                                 VNET_MAX_PENDING);\r
   Dev->TxCurPending = 0;\r
   Dev->TxFreeStack  = AllocatePool (Dev->TxMaxPending *\r
                         sizeof *Dev->TxFreeStack);\r
@@ -141,7 +142,7 @@ VirtioNetInitTx (
     Dev->TxRing.Desc[DescIdx].Addr  = (UINTN) &Dev->TxSharedReq;\r
     Dev->TxRing.Desc[DescIdx].Len   = sizeof Dev->TxSharedReq;\r
     Dev->TxRing.Desc[DescIdx].Flags = VRING_DESC_F_NEXT;\r
-    Dev->TxRing.Desc[DescIdx].Next  = DescIdx + 1;\r
+    Dev->TxRing.Desc[DescIdx].Next  = (UINT16) (DescIdx + 1);\r
 \r
     //\r
     // The second descriptor of each pending TX packet is updated on the fly,\r
@@ -221,7 +222,7 @@ VirtioNetInitRx (
   // Limit the number of pending RX packets if the queue is big. The division\r
   // by two is due to the above "two descriptors per packet" trait.\r
   //\r
-  RxAlwaysPending = MIN (Dev->RxRing.QueueSize / 2, VNET_MAX_PENDING);\r
+  RxAlwaysPending = (UINT16) MIN (Dev->RxRing.QueueSize / 2, VNET_MAX_PENDING);\r
 \r
   Dev->RxBuf = AllocatePool (RxAlwaysPending * RxBufSize);\r
   if (Dev->RxBuf == NULL) {\r
@@ -261,11 +262,12 @@ VirtioNetInitRx (
     Dev->RxRing.Desc[DescIdx].Addr  = (UINTN) RxPtr;\r
     Dev->RxRing.Desc[DescIdx].Len   = sizeof (VIRTIO_NET_REQ);\r
     Dev->RxRing.Desc[DescIdx].Flags = VRING_DESC_F_WRITE | VRING_DESC_F_NEXT;\r
-    Dev->RxRing.Desc[DescIdx].Next  = DescIdx + 1;\r
+    Dev->RxRing.Desc[DescIdx].Next  = (UINT16) (DescIdx + 1);\r
     RxPtr += Dev->RxRing.Desc[DescIdx++].Len;\r
 \r
     Dev->RxRing.Desc[DescIdx].Addr  = (UINTN) RxPtr;\r
-    Dev->RxRing.Desc[DescIdx].Len   = RxBufSize - sizeof (VIRTIO_NET_REQ);\r
+    Dev->RxRing.Desc[DescIdx].Len   = (UINT32) (RxBufSize -\r
+                                                sizeof (VIRTIO_NET_REQ));\r
     Dev->RxRing.Desc[DescIdx].Flags = VRING_DESC_F_WRITE;\r
     RxPtr += Dev->RxRing.Desc[DescIdx++].Len;\r
   }\r
index eb3a2ba9b5ed4177da18d3af06116033e51a0df7..dcff6a09fc785b55cc87f4ea01100ff952e2a48f 100644 (file)
@@ -156,7 +156,7 @@ VirtioNetReceive (
   RxPtr += SIZE_OF_VNET (VhdrMac);\r
 \r
   if (Protocol != NULL) {\r
-    *Protocol = ((UINT16) RxPtr[0] << 8) | RxPtr[1];\r
+    *Protocol = (UINT16) ((RxPtr[0] << 8) | RxPtr[1]);\r
   }\r
   RxPtr += sizeof (UINT16);\r
 \r
@@ -169,7 +169,8 @@ RecycleDesc:
   // virtio-0.9.5, 2.4.1 Supplying Buffers to The Device\r
   //\r
   AvailIdx = *Dev->RxRing.Avail.Idx;\r
-  Dev->RxRing.Avail.Ring[AvailIdx++ % Dev->RxRing.QueueSize] = DescIdx;\r
+  Dev->RxRing.Avail.Ring[AvailIdx++ % Dev->RxRing.QueueSize] =\r
+    (UINT16) DescIdx;\r
 \r
   MemoryFence ();\r
   *Dev->RxRing.Avail.Idx = AvailIdx;\r