From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (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 50F0721959CAD for ; Sun, 10 Sep 2017 22:42:34 -0700 (PDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga105.jf.intel.com with ESMTP; 10 Sep 2017 22:45:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,376,1500966000"; d="scan'208";a="133919246" Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.135]) by orsmga002.jf.intel.com with ESMTP; 10 Sep 2017 22:45:28 -0700 From: Dandan Bi To: edk2-devel@lists.01.org Cc: Eric Dong , Paulo Alcantara , Ruiyu Ni , Star Zeng Date: Mon, 11 Sep 2017 13:44:39 +0800 Message-Id: <1505108680-375928-3-git-send-email-dandan.bi@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1505108680-375928-1-git-send-email-dandan.bi@intel.com> References: <1505108680-375928-1-git-send-email-dandan.bi@intel.com> Subject: [patch 2/3] MdeModulePkg/UdfDxe: Don't use non-constant expression in array X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Sep 2017 05:42:34 -0000 Remove the DescriptorLBAs[] array with non-constant expression to fix non-constant aggregate initializer warning in VS tool chains. Cc: Eric Dong Cc: Paulo Alcantara Cc: Ruiyu Ni Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Dandan Bi --- .../Universal/Disk/UdfDxe/FileSystemOperations.c | 93 +++++++++++++++++----- 1 file changed, 72 insertions(+), 21 deletions(-) diff --git a/MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c b/MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c index 0de9c71..03fda16 100644 --- a/MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c +++ b/MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c @@ -20,34 +20,85 @@ FindAnchorVolumeDescriptorPointer ( IN EFI_DISK_IO_PROTOCOL *DiskIo, OUT UDF_ANCHOR_VOLUME_DESCRIPTOR_POINTER *AnchorPoint ) { EFI_STATUS Status; - UINT32 BlockSize = BlockIo->Media->BlockSize; - EFI_LBA EndLBA = BlockIo->Media->LastBlock; - EFI_LBA DescriptorLBAs[] = { 256, EndLBA - 256, EndLBA, 512 }; - UINTN Index; + UINT32 BlockSize; + EFI_LBA EndLBA; - for (Index = 0; Index < ARRAY_SIZE (DescriptorLBAs); Index++) { - Status = DiskIo->ReadDisk ( - DiskIo, - BlockIo->Media->MediaId, - MultU64x32 (DescriptorLBAs[Index], BlockSize), - sizeof (UDF_ANCHOR_VOLUME_DESCRIPTOR_POINTER), - (VOID *)AnchorPoint - ); - if (EFI_ERROR (Status)) { - return Status; - } - // - // Check if read LBA has a valid AVDP descriptor. - // - if (IS_AVDP (AnchorPoint)) { - return EFI_SUCCESS; - } + BlockSize = BlockIo->Media->BlockSize; + EndLBA = BlockIo->Media->LastBlock; + + Status = DiskIo->ReadDisk ( + DiskIo, + BlockIo->Media->MediaId, + MultU64x32 (256, BlockSize), + sizeof (UDF_ANCHOR_VOLUME_DESCRIPTOR_POINTER), + (VOID *)AnchorPoint + ); + if (EFI_ERROR (Status)) { + return Status; + } + // + // Check if read LBA has a valid AVDP descriptor. + // + if (IS_AVDP (AnchorPoint)) { + return EFI_SUCCESS; + } + + Status = DiskIo->ReadDisk ( + DiskIo, + BlockIo->Media->MediaId, + MultU64x32 (EndLBA - 256, BlockSize), + sizeof (UDF_ANCHOR_VOLUME_DESCRIPTOR_POINTER), + (VOID *)AnchorPoint + ); + if (EFI_ERROR (Status)) { + return Status; } // + // Check if read LBA has a valid AVDP descriptor. + // + if (IS_AVDP (AnchorPoint)) { + return EFI_SUCCESS; + } + + Status = DiskIo->ReadDisk ( + DiskIo, + BlockIo->Media->MediaId, + MultU64x32 (EndLBA, BlockSize), + sizeof (UDF_ANCHOR_VOLUME_DESCRIPTOR_POINTER), + (VOID *)AnchorPoint + ); + if (EFI_ERROR (Status)) { + return Status; + } + // + // Check if read LBA has a valid AVDP descriptor. + // + if (IS_AVDP (AnchorPoint)) { + return EFI_SUCCESS; + } + + Status = DiskIo->ReadDisk ( + DiskIo, + BlockIo->Media->MediaId, + MultU64x32 (512, BlockSize), + sizeof (UDF_ANCHOR_VOLUME_DESCRIPTOR_POINTER), + (VOID *)AnchorPoint + ); + if (EFI_ERROR (Status)) { + return Status; + } + // + // Check if read LBA has a valid AVDP descriptor. + // + if (IS_AVDP (AnchorPoint)) { + return EFI_SUCCESS; + } + + // // No AVDP found. // return EFI_VOLUME_CORRUPTED; } -- 1.9.5.msysgit.1