From 699a2c30cb6e74a55f0c3f67c376460f99c201ed Mon Sep 17 00:00:00 2001 From: Dandan Bi Date: Fri, 23 Mar 2018 11:21:56 +0800 Subject: OvmfPkg:Fix VS2012 build failure 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 Reviewed-by: Laszlo Ersek --- OvmfPkg/VirtioBlkDxe/VirtioBlk.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'OvmfPkg/VirtioBlkDxe') diff --git a/OvmfPkg/VirtioBlkDxe/VirtioBlk.c b/OvmfPkg/VirtioBlkDxe/VirtioBlk.c index 5559884345..95e42ef3dc 100644 --- a/OvmfPkg/VirtioBlkDxe/VirtioBlk.c +++ b/OvmfPkg/VirtioBlkDxe/VirtioBlk.c @@ -11,7 +11,7 @@ synchronous requests and EFI_BLOCK_IO_PROTOCOL for now. Copyright (C) 2012, Red Hat, Inc. - Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2012 - 2018, Intel Corporation. All rights reserved.
Copyright (c) 2017, AMD Inc, All rights reserved.
This program and the accompanying materials are licensed and made available @@ -264,6 +264,13 @@ SynchronousRequest ( BlockSize = Dev->BlockIoMedia.BlockSize; + // + // Set BufferMapping and BufferDeviceAddress to suppress incorrect + // compiler/analyzer warnings. + // + BufferMapping = NULL; + BufferDeviceAddress = 0; + // // ensured by VirtioBlkInit() // -- cgit v1.2.3