]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg:Fix VS2012 build failure
authorDandan Bi <dandan.bi@intel.com>
Fri, 23 Mar 2018 03:21:56 +0000 (11:21 +0800)
committerLiming Gao <liming.gao@intel.com>
Wed, 28 Mar 2018 01:58:49 +0000 (09:58 +0800)
Initialize local variable to suppress warning C4701/C4703:
potentially uninitialized local variable/pointer variable.

1.In VirtualMemory.c:
Read of "PageMapLevel4Entry" in SetMemoryEncDe() is only
reached when "PageMapLevel4Entry" is got correctly.

2.In VirtioBlk.c:
Reads (dereferences) of "BufferMapping" and "BufferDeviceAddress"
in SynchronousRequest() are only reached if "BufferSize > 0" *and*
we map the data buffer successfully.

3.In VirtioScsi.c:
Reads (dereferences) of "InDataMapping" and "InDataDeviceAddress",
in VirtioScsiPassThru() are only reached if
"Packet->InTransferLength > 0" on input, *and* we map the
input buffer successfully. The similar reason for "OutDataMapping"
and "OutDataDeviceAddress".

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
OvmfPkg/Library/BaseMemEncryptSevLib/X64/VirtualMemory.c
OvmfPkg/VirtioBlkDxe/VirtioBlk.c
OvmfPkg/VirtioScsiDxe/VirtioScsi.c

index c1bfa35d7a300a013ee1b53dcea9b6930ad33085..5d6289df10d9f85c2ecdbcf7f1acc5f58017ae8a 100644 (file)
@@ -2,7 +2,7 @@
 \r
   Virtual Memory Management Services to set or clear the memory encryption bit\r
 \r
-  Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
   Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>\r
 \r
   This program and the accompanying materials are licensed and made available\r
@@ -596,6 +596,11 @@ SetMemoryEncDec (
   BOOLEAN                        IsWpEnabled;\r
   RETURN_STATUS                  Status;\r
 \r
+  //\r
+  // Set PageMapLevel4Entry to suppress incorrect compiler/analyzer warnings.\r
+  //\r
+  PageMapLevel4Entry = NULL;\r
+\r
   DEBUG ((\r
     DEBUG_VERBOSE,\r
     "%a:%a: Cr3Base=0x%Lx Physical=0x%Lx Length=0x%Lx Mode=%a CacheFlush=%u\n",\r
index 55598843455dd9165678626bf1744086dafffc2a..95e42ef3dcc0a5da816fe7650cfc118029dfa2b9 100644 (file)
@@ -11,7 +11,7 @@
     synchronous requests and EFI_BLOCK_IO_PROTOCOL for now.\r
 \r
   Copyright (C) 2012, Red Hat, Inc.\r
-  Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2012 - 2018, Intel Corporation. All rights reserved.<BR>\r
   Copyright (c) 2017, AMD Inc, All rights reserved.<BR>\r
 \r
   This program and the accompanying materials are licensed and made available\r
@@ -264,6 +264,13 @@ SynchronousRequest (
 \r
   BlockSize = Dev->BlockIoMedia.BlockSize;\r
 \r
+  //\r
+  // Set BufferMapping and BufferDeviceAddress to suppress incorrect\r
+  // compiler/analyzer warnings.\r
+  //\r
+  BufferMapping       = NULL;\r
+  BufferDeviceAddress = 0;\r
+\r
   //\r
   // ensured by VirtioBlkInit()\r
   //\r
index 1a68f062106c00132f1c9a32002fb52f1cee3820..e773ecf7cc009dbe39056610cf93fd6704586420 100644 (file)
@@ -26,7 +26,7 @@
     unreasonable for now.\r
 \r
   Copyright (C) 2012, Red Hat, Inc.\r
-  Copyright (c) 2012 - 2014, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2012 - 2018, Intel Corporation. All rights reserved.<BR>\r
   Copyright (c) 2017, AMD Inc, All rights reserved.<BR>\r
 \r
   This program and the accompanying materials are licensed and made available\r
@@ -455,6 +455,15 @@ VirtioScsiPassThru (
   UINTN                     InDataNumPages;\r
   BOOLEAN                   OutDataBufferIsMapped;\r
 \r
+  //\r
+  // Set InDataMapping,OutDataMapping,InDataDeviceAddress and OutDataDeviceAddress to\r
+  // suppress incorrect compiler/analyzer warnings.\r
+  //\r
+  InDataMapping        = NULL;\r
+  OutDataMapping       = NULL;\r
+  InDataDeviceAddress  = 0;\r
+  OutDataDeviceAddress = 0;\r
+\r
   ZeroMem ((VOID*) &Request, sizeof (Request));\r
 \r
   Dev = VIRTIO_SCSI_FROM_PASS_THRU (This);\r