From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=66.187.233.73; helo=mx1.redhat.com; envelope-from=lersek@redhat.com; receiver=edk2-devel@lists.01.org Received: from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 63FBF223E0BA5 for ; Fri, 23 Mar 2018 03:03:45 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DCC7176FBA; Fri, 23 Mar 2018 10:10:17 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-180.rdu2.redhat.com [10.10.120.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 081C5215CDA7; Fri, 23 Mar 2018 10:10:16 +0000 (UTC) To: Dandan Bi , edk2-devel@lists.01.org Cc: Ard Biesheuvel References: <20180323051242.42332-1-dandan.bi@intel.com> From: Laszlo Ersek Message-ID: Date: Fri, 23 Mar 2018 11:10:16 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180323051242.42332-1-dandan.bi@intel.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Fri, 23 Mar 2018 10:10:17 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Fri, 23 Mar 2018 10:10:17 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'lersek@redhat.com' RCPT:'' Subject: Re: [patch] OvmfPkg:Fix VS2012 build failure X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Mar 2018 10:03:46 -0000 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 03/23/18 06:12, Dandan Bi wrote: > 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" (1) Please insert the following words right here: "on input". >, *and* we map the input buffer > successfully. The similar reason for "OutDataMapping" and > "OutDataDeviceAddress". > > Cc: Laszlo Ersek > Cc: Ard Biesheuvel > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Dandan Bi > --- > 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.
> + Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
> Copyright (c) 2017, AMD Incorporated. All rights reserved.
> > 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. > + // (2) Can you replace "LocalVariable" with "PageMapLevel4Entry"? (3) Please replace "warnigns" with "warnings". (This is my fault, I made the typo in the TianoCore BZ that suggests this kind of comment. Sorry about that.) > + 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.
> + 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 > 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. > + // (4) Please replace "LocalVariable" with "BufferMapping and BufferDeviceAddress", and please also make sure that the line length stays <= 79 characters. (5) Same as (3). > + 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.
> + 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 > 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. > + // (6) Please replace "LocalVariable" with "InDataMapping, OutDataMapping, InDataDeviceAddress and OutDataDeviceAddress", and please also make sure that the line length stays <= 79 characters. (7) Same as (3). > + 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); > > Thank you for this patch. With the above changes: Reviewed-by: Laszlo Ersek In the future, can you please split similar patches into one patch per module, or even function? While the code changes are not large, verifying the statements 1., 2., and 3. in the commit message (against the code) does take some time. To me it's easier to review such reasoning if the arguments (and the code) are separated to different, small patches. Thanks! Laszlo