public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Dandan Bi <dandan.bi@intel.com>
To: edk2-devel@lists.01.org
Cc: Laszlo Ersek <lersek@redhat.com>,
	Ard Biesheuvel <ard.biesheuvel@linaro.org>
Subject: [patch] OvmfPkg:Fix VS2012 build failure
Date: Fri, 23 Mar 2018 13:12:42 +0800	[thread overview]
Message-ID: <20180323051242.42332-1-dandan.bi@intel.com> (raw)

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", *and* we map the input buffer
successfully. The similar reason for "OutDataMapping" and
"OutDataDeviceAddress".

Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
---
 OvmfPkg/Library/BaseMemEncryptSevLib/X64/VirtualMemory.c |  7 ++++++-
 OvmfPkg/VirtioBlkDxe/VirtioBlk.c                         |  8 +++++++-
 OvmfPkg/VirtioScsiDxe/VirtioScsi.c                       | 10 +++++++++-
 3 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/VirtualMemory.c b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/VirtualMemory.c
index c1bfa35d7a..1f1225dd13 100644
--- a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/VirtualMemory.c
+++ b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/VirtualMemory.c
@@ -1,10 +1,10 @@
 /** @file
 
   Virtual Memory Management Services to set or clear the memory encryption bit
 
-  Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
   Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>
 
   This program and the accompanying materials are licensed and made available
   under the terms and conditions of the BSD License which accompanies this
   distribution.  The full text of the license may be found at
@@ -594,10 +594,15 @@ SetMemoryEncDec (
   UINT64                         PgTableMask;
   UINT64                         AddressEncMask;
   BOOLEAN                        IsWpEnabled;
   RETURN_STATUS                  Status;
 
+  //
+  // Set LocalVariable to suppress incorrect compiler/analyzer warnigns.
+  //
+  PageMapLevel4Entry = NULL;
+
   DEBUG ((
     DEBUG_VERBOSE,
     "%a:%a: Cr3Base=0x%Lx Physical=0x%Lx Length=0x%Lx Mode=%a CacheFlush=%u\n",
     gEfiCallerBaseName,
     __FUNCTION__,
diff --git a/OvmfPkg/VirtioBlkDxe/VirtioBlk.c b/OvmfPkg/VirtioBlkDxe/VirtioBlk.c
index 5559884345..653715fb7b 100644
--- a/OvmfPkg/VirtioBlkDxe/VirtioBlk.c
+++ b/OvmfPkg/VirtioBlkDxe/VirtioBlk.c
@@ -9,11 +9,11 @@
   - Although the non-blocking interfaces of EFI_BLOCK_IO2_PROTOCOL could be a
     good match for multiple in-flight virtio-blk requests, we stick to
     synchronous requests and EFI_BLOCK_IO_PROTOCOL for now.
 
   Copyright (C) 2012, Red Hat, Inc.
-  Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2012 - 2018, Intel Corporation. All rights reserved.<BR>
   Copyright (c) 2017, AMD Inc, All rights reserved.<BR>
 
   This program and the accompanying materials are licensed and made available
   under the terms and conditions of the BSD License which accompanies this
   distribution. The full text of the license may be found at
@@ -262,10 +262,16 @@ SynchronousRequest (
   EFI_STATUS              Status;
   EFI_STATUS              UnmapStatus;
 
   BlockSize = Dev->BlockIoMedia.BlockSize;
 
+  //
+  // Set LocalVariable to suppress incorrect compiler/analyzer warnigns.
+  //
+  BufferMapping       = NULL;
+  BufferDeviceAddress = 0;
+
   //
   // ensured by VirtioBlkInit()
   //
   ASSERT (BlockSize > 0);
   ASSERT (BlockSize % 512 == 0);
diff --git a/OvmfPkg/VirtioScsiDxe/VirtioScsi.c b/OvmfPkg/VirtioScsiDxe/VirtioScsi.c
index 1a68f06210..81aa89e6d9 100644
--- a/OvmfPkg/VirtioScsiDxe/VirtioScsi.c
+++ b/OvmfPkg/VirtioScsiDxe/VirtioScsi.c
@@ -24,11 +24,11 @@
     VIRTIO_SCSI_T_TMF_LOGICAL_UNIT_RESET could be a good match. That would
     however require client code for the control queue, which is deemed
     unreasonable for now.
 
   Copyright (C) 2012, Red Hat, Inc.
-  Copyright (c) 2012 - 2014, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2012 - 2018, Intel Corporation. All rights reserved.<BR>
   Copyright (c) 2017, AMD Inc, All rights reserved.<BR>
 
   This program and the accompanying materials are licensed and made available
   under the terms and conditions of the BSD License which accompanies this
   distribution. The full text of the license may be found at
@@ -453,10 +453,18 @@ VirtioScsiPassThru (
   EFI_PHYSICAL_ADDRESS      OutDataDeviceAddress;
   VOID                      *InDataBuffer;
   UINTN                     InDataNumPages;
   BOOLEAN                   OutDataBufferIsMapped;
 
+  //
+  // Set LocalVariable to suppress incorrect compiler/analyzer warnigns.
+  //
+  InDataMapping        = NULL;
+  OutDataMapping       = NULL;
+  InDataDeviceAddress  = 0;
+  OutDataDeviceAddress = 0;
+
   ZeroMem ((VOID*) &Request, sizeof (Request));
 
   Dev = VIRTIO_SCSI_FROM_PASS_THRU (This);
   CopyMem (&TargetValue, Target, sizeof TargetValue);
 
-- 
2.14.3.windows.1



             reply	other threads:[~2018-03-23  5:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-23  5:12 Dandan Bi [this message]
2018-03-23 10:10 ` [patch] OvmfPkg:Fix VS2012 build failure Laszlo Ersek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180323051242.42332-1-dandan.bi@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox