Dandan, Thanks for fixing this. But, why not write code as below? EFI_LBA DescriptorLBAs[4];
DescriptorLBA[0] = 256; DescriptorLBA[1] = EndLBA - 256; ... Thanks/Ray > -----Original Message----- > From: Bi, Dandan > Sent: Monday, September 11, 2017 1:45 PM > To: [email protected] > Cc: Dong, Eric <[email protected]>; Paulo Alcantara <[email protected]>; > Ni, Ruiyu <[email protected]>; Zeng, Star <[email protected]> > Subject: [patch 1/3] MdeModulePkg/PartitionDxe: Don't use non-constant > expression in array > > Remove the DescriptorLBAs[] array with non-constant expression to fix non- > constant aggregate initializer warning in VS tool chains. > > Cc: Eric Dong <[email protected]> > Cc: Paulo Alcantara <[email protected]> > Cc: Ruiyu Ni <[email protected]> > Cc: Star Zeng <[email protected]> > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Dandan Bi <[email protected]> > --- > MdeModulePkg/Universal/Disk/PartitionDxe/Udf.c | 93 > ++++++++++++++++++++------ > 1 file changed, 72 insertions(+), 21 deletions(-) > > diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/Udf.c > b/MdeModulePkg/Universal/Disk/PartitionDxe/Udf.c > index 3347b48..28385f0 100644 > --- a/MdeModulePkg/Universal/Disk/PartitionDxe/Udf.c > +++ b/MdeModulePkg/Universal/Disk/PartitionDxe/Udf.c > @@ -46,34 +46,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 [email protected] https://lists.01.org/mailman/listinfo/edk2-devel

