From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (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 B3BB620958BEA for ; Sun, 10 Sep 2017 23:06:08 -0700 (PDT) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Sep 2017 23:09:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,376,1500966000"; d="scan'208";a="127476098" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga004.jf.intel.com with ESMTP; 10 Sep 2017 23:09:03 -0700 Received: from fmsmsx118.amr.corp.intel.com (10.18.116.18) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sun, 10 Sep 2017 23:09:03 -0700 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by fmsmsx118.amr.corp.intel.com (10.18.116.18) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sun, 10 Sep 2017 23:09:03 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.117]) by shsmsx102.ccr.corp.intel.com ([169.254.2.39]) with mapi id 14.03.0319.002; Mon, 11 Sep 2017 14:08:59 +0800 From: "Ni, Ruiyu" To: "Bi, Dandan" , "edk2-devel@lists.01.org" CC: "Dong, Eric" , Paulo Alcantara , "Zeng, Star" Thread-Topic: [patch 1/3] MdeModulePkg/PartitionDxe: Don't use non-constant expression in array Thread-Index: AQHTKsEwXxONj6Ff+ES7ccqeVlu9oKKvMaUw Date: Mon, 11 Sep 2017 06:08:59 +0000 Message-ID: <734D49CCEBEEF84792F5B80ED585239D5BA2A215@SHSMSX104.ccr.corp.intel.com> References: <1505108680-375928-1-git-send-email-dandan.bi@intel.com> <1505108680-375928-2-git-send-email-dandan.bi@intel.com> In-Reply-To: <1505108680-375928-2-git-send-email-dandan.bi@intel.com> Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [patch 1/3] MdeModulePkg/PartitionDxe: 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 06:06:08 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Dandan, Thanks for fixing this. But, why not write code as below? EFI_LBA DescriptorLBAs[4]; DescriptorLBA[0] =3D 256; DescriptorLBA[1] =3D EndLBA - 256; ... =20 Thanks/Ray > -----Original Message----- > From: Bi, Dandan > Sent: Monday, September 11, 2017 1:45 PM > To: edk2-devel@lists.01.org > Cc: Dong, Eric ; Paulo Alcantara ; > Ni, Ruiyu ; Zeng, Star > Subject: [patch 1/3] MdeModulePkg/PartitionDxe: Don't use non-constant > expression in array >=20 > Remove the DescriptorLBAs[] array with non-constant expression to fix non= - > constant aggregate initializer warning in VS tool chains. >=20 > Cc: Eric Dong > Cc: Paulo Alcantara > Cc: Ruiyu Ni > Cc: Star Zeng > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Dandan Bi > --- > MdeModulePkg/Universal/Disk/PartitionDxe/Udf.c | 93 > ++++++++++++++++++++------ > 1 file changed, 72 insertions(+), 21 deletions(-) >=20 > 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 =3D BlockIo->Media->BlockSize; > - EFI_LBA EndLBA =3D BlockIo->Media->LastBlock; > - EFI_LBA DescriptorLBAs[] =3D { 256, EndLBA - 256, EndLBA, 512 }; > - UINTN Index; > + UINT32 BlockSize; > + EFI_LBA EndLBA; >=20 > - for (Index =3D 0; Index < ARRAY_SIZE (DescriptorLBAs); Index++) { > - Status =3D 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 =3D BlockIo->Media->BlockSize; EndLBA =3D > + BlockIo->Media->LastBlock; > + > + Status =3D 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 =3D 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 =3D 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 =3D 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; > } >=20 > -- > 1.9.5.msysgit.1