Remove the DescriptorLBAs[] array with non-constant expression to fix
non-constant aggregate initializer warning in VS tool chains.
Cc: Eric Dong <eric.dong@intel.com>
Cc: Paulo Alcantara <pcacjr@zytor.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
---
.../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
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel