From: "Ni, Ruiyu" <ruiyu.ni@intel.com>
To: "Bi, Dandan" <dandan.bi@intel.com>,
"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Dong, Eric" <eric.dong@intel.com>,
Paulo Alcantara <pcacjr@zytor.com>,
"Zeng, Star" <star.zeng@intel.com>
Subject: Re: [patch 1/3] MdeModulePkg/PartitionDxe: Don't use non-constant expression in array
Date: Mon, 11 Sep 2017 06:08:59 +0000 [thread overview]
Message-ID: <734D49CCEBEEF84792F5B80ED585239D5BA2A215@SHSMSX104.ccr.corp.intel.com> (raw)
In-Reply-To: <1505108680-375928-2-git-send-email-dandan.bi@intel.com>
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: edk2-devel@lists.01.org
> Cc: Dong, Eric <eric.dong@intel.com>; Paulo Alcantara <pcacjr@zytor.com>;
> Ni, Ruiyu <ruiyu.ni@intel.com>; Zeng, Star <star.zeng@intel.com>
> 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 <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>
> ---
> 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
next prev parent reply other threads:[~2017-09-11 6:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-11 5:44 [patch 0/3] MdeModulePkg/Udf: Fix VS tool chain build failures Dandan Bi
2017-09-11 5:44 ` [patch 1/3] MdeModulePkg/PartitionDxe: Don't use non-constant expression in array Dandan Bi
2017-09-11 6:08 ` Ni, Ruiyu [this message]
2017-09-11 5:44 ` [patch 2/3] MdeModulePkg/UdfDxe: " Dandan Bi
2017-09-11 5:44 ` [patch 3/3] MdeModulePkg/UdfDxe: Add type cast to fix build failure in VS tools Dandan Bi
2017-09-12 1:46 ` [patch 0/3] MdeModulePkg/Udf: Fix VS tool chain build failures Paulo Alcantara
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=734D49CCEBEEF84792F5B80ED585239D5BA2A215@SHSMSX104.ccr.corp.intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox