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 8572E1A1E8B for ; Wed, 26 Oct 2016 20:12:15 -0700 (PDT) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga105.jf.intel.com with ESMTP; 26 Oct 2016 20:12:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,404,1473145200"; d="scan'208";a="24135129" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga006.fm.intel.com with ESMTP; 26 Oct 2016 20:12:15 -0700 Received: from fmsmsx123.amr.corp.intel.com (10.18.125.38) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.248.2; Wed, 26 Oct 2016 20:12:14 -0700 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by fmsmsx123.amr.corp.intel.com (10.18.125.38) with Microsoft SMTP Server (TLS) id 14.3.248.2; Wed, 26 Oct 2016 20:12:09 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.206]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.139]) with mapi id 14.03.0248.002; Thu, 27 Oct 2016 11:12:07 +0800 From: "Fan, Jeff" To: Laszlo Ersek , edk2-devel-01 Thread-Topic: [PATCH 16/47] IntelFrameworkModulePkg/BdsDxe: rebase to ARRAY_SIZE() Thread-Index: AQHSL7v+x9pH3Jix90aNfkdtOgohmaC7oEww Date: Thu, 27 Oct 2016 03:12:06 +0000 Message-ID: <542CF652F8836A4AB8DBFAAD40ED192A4A2B7A19@shsmsx102.ccr.corp.intel.com> References: <20161026190504.9888-1-lersek@redhat.com> <20161026190504.9888-17-lersek@redhat.com> In-Reply-To: <20161026190504.9888-17-lersek@redhat.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiOTVhYTAyYTYtZDNjZS00NDliLWIzYzMtZWI5MGVlYjZjMTI3IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6IlhGZ0FmbDYxK0RzSWZ3Z2xuSVVWNzY0M0FVb2YzOXdrdnZ0NmVVaTdjQWs9In0= x-ctpclassification: CTP_IC x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH 16/47] IntelFrameworkModulePkg/BdsDxe: rebase to ARRAY_SIZE() X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Oct 2016 03:12:15 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Jeff Fan -----Original Message----- From: Laszlo Ersek [mailto:lersek@redhat.com]=20 Sent: Thursday, October 27, 2016 3:05 AM To: edk2-devel-01 Cc: Fan, Jeff Subject: [PATCH 16/47] IntelFrameworkModulePkg/BdsDxe: rebase to ARRAY_SIZE= () Cc: Jeff Fan Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek --- IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c | 2 +- IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.c | 4 ++= -- IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c | 8 ++= ++---- IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootOption.c | 2 +- IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/ConsoleOption.c | 6 ++= +--- IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/UpdatePage.c | 10 ++= +++----- IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/Variable.c | 2 +- IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManager.c | 2 +- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c b/IntelFra= meworkModulePkg/Universal/BdsDxe/BdsEntry.c index ae7ad2153c51..bf81de40a31d 100644 --- a/IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c +++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c @@ -581,7 +581,7 @@ BdsEntry ( Status =3D gBS->LocateProtocol (&gEdkiiVariableLockProtocolGuid, NULL, (= VOID **) &VariableLock); DEBUG ((EFI_D_INFO, "[BdsDxe] Locate Variable Lock protocol - %r\n", Sta= tus)); if (!EFI_ERROR (Status)) { - for (Index =3D 0; Index < sizeof (mReadOnlyVariables) / sizeof (mReadO= nlyVariables[0]); Index++) { + for (Index =3D 0; Index < ARRAY_SIZE (mReadOnlyVariables); Index++) { Status =3D VariableLock->RequestToLock (VariableLock, mReadOnlyVaria= bles[Index], &gEfiGlobalVariableGuid); ASSERT_EFI_ERROR (Status); } diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.= c b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.c index 6a0b525f1581..2ef9cf13ebb8 100644 --- a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.c +++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.c @@ -206,7 +206,7 @@ GroupMultipleLegacyBootOption4SameType ( // // Legacy Boot Option // - ASSERT ((((BBS_BBS_DEVICE_PATH *) BootOption->DevicePath)->DeviceTyp= e & 0xF) < sizeof (DeviceTypeIndex) / sizeof (DeviceTypeIndex[0])); + ASSERT ((((BBS_BBS_DEVICE_PATH *)=20 + BootOption->DevicePath)->DeviceType & 0xF) < ARRAY_SIZE=20 + (DeviceTypeIndex)); NextIndex =3D &DeviceTypeIndex[((BBS_BBS_DEVICE_PATH *) BootOption->= DevicePath)->DeviceType & 0xF]; =20 if (*NextIndex =3D=3D (UINTN) -1) { @@ -225,7 +225,7 @@ GroupMultipleLegacyBootOption4SameType ( // // Update the DeviceTypeIndex array to reflect the right shift ope= ration // - for (DeviceIndex =3D 0; DeviceIndex < sizeof (DeviceTypeIndex) / s= izeof (DeviceTypeIndex[0]); DeviceIndex++) { + for (DeviceIndex =3D 0; DeviceIndex < ARRAY_SIZE=20 + (DeviceTypeIndex); DeviceIndex++) { if (DeviceTypeIndex[DeviceIndex] !=3D (UINTN) -1 && DeviceTypeIn= dex[DeviceIndex] >=3D *NextIndex) { DeviceTypeIndex[DeviceIndex]++; } diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c= b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c index 96f84ece2a9a..d5ea0f457705 100644 --- a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c +++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c @@ -520,16 +520,16 @@ BootMaintRouteConfig ( ASSERT (NewMenuEntry !=3D NULL); NewTerminalContext =3D (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableC= ontext; NewTerminalContext->BaudRateIndex =3D NewBmmData->COMBaudRate[Index]; - ASSERT (NewBmmData->COMBaudRate[Index] < (sizeof (BaudRateList) / size= of (BaudRateList[0]))); + ASSERT (NewBmmData->COMBaudRate[Index] < (ARRAY_SIZE=20 + (BaudRateList))); NewTerminalContext->BaudRate =3D BaudRateList[NewBmmData->COMBaud= Rate[Index]].Value; NewTerminalContext->DataBitsIndex =3D NewBmmData->COMDataRate[Index]; - ASSERT (NewBmmData->COMDataRate[Index] < (sizeof (DataBitsList) / size= of (DataBitsList[0]))); + ASSERT (NewBmmData->COMDataRate[Index] < (ARRAY_SIZE=20 + (DataBitsList))); NewTerminalContext->DataBits =3D (UINT8) DataBitsList[NewBmmData-= >COMDataRate[Index]].Value; NewTerminalContext->StopBitsIndex =3D NewBmmData->COMStopBits[Index]; - ASSERT (NewBmmData->COMStopBits[Index] < (sizeof (StopBitsList) / size= of (StopBitsList[0]))); + ASSERT (NewBmmData->COMStopBits[Index] < (ARRAY_SIZE=20 + (StopBitsList))); NewTerminalContext->StopBits =3D (UINT8) StopBitsList[NewBmmData-= >COMStopBits[Index]].Value; NewTerminalContext->ParityIndex =3D NewBmmData->COMParity[Index]; - ASSERT (NewBmmData->COMParity[Index] < (sizeof (ParityList) / sizeof (= ParityList[0]))); + ASSERT (NewBmmData->COMParity[Index] < (ARRAY_SIZE (ParityList))); NewTerminalContext->Parity =3D (UINT8) ParityList[NewBmmData->C= OMParity[Index]].Value; NewTerminalContext->TerminalType =3D NewBmmData->COMTerminalType[Inde= x]; NewTerminalContext->FlowControl =3D NewBmmData->COMFlowControl[Index= ]; diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootOption.= c b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootOption.c index 56bcfab23f43..5898fb31bb2b 100644 --- a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootOption.c +++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootOption.c @@ -1702,7 +1702,7 @@ GetLegacyDeviceOrder ( LegacyOrder =3D NULL; OldData =3D NULL; DisMap =3D ZeroMem (CallbackData->BmmFakeNvData.DisableMap, sizeof = (CallbackData->BmmFakeNvData.DisableMap)); - PageNum =3D sizeof (PageIdList) / sizeof (PageIdList[0]); + PageNum =3D ARRAY_SIZE (PageIdList); VarData =3D BdsLibGetVariableAndSize ( VAR_LEGACY_DEV_ORDER, &gEfiLegacyDevOrderVariableGuid, diff --git a/IntelFrame= workModulePkg/Universal/BdsDxe/BootMaint/ConsoleOption.c b/IntelFrameworkMo= dulePkg/Universal/BdsDxe/BootMaint/ConsoleOption.c index 1854b98c360f..126feeb9ae51 100644 --- a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/ConsoleOption.c +++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/ConsoleOption.c @@ -1167,21 +1167,21 @@ GetTerminalAttribute ( break; } } - for (AttributeIndex =3D 0; AttributeIndex < sizeof (DataBitsList) / si= zeof (DataBitsList[0]); AttributeIndex++) { + for (AttributeIndex =3D 0; AttributeIndex < ARRAY_SIZE=20 + (DataBitsList); AttributeIndex++) { if (NewTerminalContext->DataBits =3D=3D (UINT64) (DataBitsList[Attri= buteIndex].Value)) { NewTerminalContext->DataBitsIndex =3D AttributeIndex; break; } } =20 =20 - for (AttributeIndex =3D 0; AttributeIndex < sizeof (ParityList) / size= of (ParityList[0]); AttributeIndex++) { + for (AttributeIndex =3D 0; AttributeIndex < ARRAY_SIZE (ParityList);=20 + AttributeIndex++) { if (NewTerminalContext->Parity =3D=3D (UINT64) (ParityList[Attribute= Index].Value)) { NewTerminalContext->ParityIndex =3D AttributeIndex; break; } } =20 =20 - for (AttributeIndex =3D 0; AttributeIndex < sizeof (StopBitsList) / si= zeof (StopBitsList[0]); AttributeIndex++) { + for (AttributeIndex =3D 0; AttributeIndex < ARRAY_SIZE=20 + (StopBitsList); AttributeIndex++) { if (NewTerminalContext->StopBits =3D=3D (UINT64) (StopBitsList[Attri= buteIndex].Value)) { NewTerminalContext->StopBitsIndex =3D AttributeIndex; break; diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/UpdatePage.= c b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/UpdatePage.c index b13ed116303b..02efefd2a614 100644 --- a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/UpdatePage.c +++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/UpdatePage.c @@ -830,7 +830,7 @@ UpdateConModePage ( // UnicodeValueToString (ModeString, 0, Col, 0); PStr =3D &ModeString[0]; - StrCatS (PStr, sizeof (ModeString) / sizeof (ModeString[0]), L" x "); + StrCatS (PStr, ARRAY_SIZE (ModeString), L" x "); PStr =3D PStr + StrLen (PStr); UnicodeValueToString (PStr , 0, Row, 0); =20 @@ -939,7 +939,7 @@ UpdateTerminalPage ( OptionsOpCodeHandle =3D HiiAllocateOpCodeHandle (); ASSERT (OptionsOpCodeHandle !=3D NULL); =20 - for (Index =3D 0; Index < sizeof (DataBitsList) / sizeof (DataBitsList[0= ]); Index++) { + for (Index =3D 0; Index < ARRAY_SIZE (DataBitsList); Index++) { CheckFlags =3D 0; =20 if (DataBitsList[Index].Value =3D=3D 8) { @@ -972,7 +972,7 @@ UpdateTe= rminalPage ( OptionsOpCodeHandle =3D HiiAllocateOpCodeHandle (); ASSERT (OptionsOpCodeHandle !=3D NULL); =20 - for (Index =3D 0; Index < sizeof (ParityList) / sizeof (ParityList[0]); = Index++) { + for (Index =3D 0; Index < ARRAY_SIZE (ParityList); Index++) { CheckFlags =3D 0; if (ParityList[Index].Value =3D=3D NoParity) { CheckFlags |=3D EFI_IFR_OPTION_DEFAULT; @@ -1004,7 +1004,7 @@ Update= TerminalPage ( OptionsOpCodeHandle =3D HiiAllocateOpCodeHandle (); ASSERT (OptionsOpCodeHandle !=3D NULL); =20 - for (Index =3D 0; Index < sizeof (StopBitsList) / sizeof (StopBitsList[0= ]); Index++) { + for (Index =3D 0; Index < ARRAY_SIZE (StopBitsList); Index++) { CheckFlags =3D 0; if (StopBitsList[Index].Value =3D=3D OneStopBit) { CheckFlags |=3D EFI_IFR_OPTION_DEFAULT; @@ -1068,7 +1068,7 @@ Update= TerminalPage ( OptionsOpCodeHandle =3D HiiAllocateOpCodeHandle (); ASSERT (OptionsOpCodeHandle !=3D NULL); =20 - for (Index =3D 0; Index < sizeof (mFlowControlType) / sizeof (mFlowContr= olType[0]); Index++) { + for (Index =3D 0; Index < ARRAY_SIZE (mFlowControlType); Index++) { CheckFlags =3D 0; if (Index =3D=3D 0) { CheckFlags |=3D EFI_IFR_OPTION_DEFAULT; diff --git a/IntelFrameworkM= odulePkg/Universal/BdsDxe/BootMaint/Variable.c b/IntelFrameworkModulePkg/Un= iversal/BdsDxe/BootMaint/Variable.c index b933dd9699cb..414367cf2387 100644 --- a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/Variable.c +++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/Variable.c @@ -448,7 +448,7 @@ Var_UpdateConsoleOption ( Vendor.Header.Type =3D MESSAGING_DEVICE_PATH; Vendor.Header.SubType =3D MSG_VENDOR_DP; =20 - ASSERT (NewTerminalContext->TerminalType < (sizeof (TerminalTypeGuid= ) / sizeof (TerminalTypeGuid[0]))); + ASSERT (NewTerminalContext->TerminalType < (ARRAY_SIZE=20 + (TerminalTypeGuid))); CopyMem ( &Vendor.Guid, &TerminalTypeGuid[NewTerminalContext->TerminalType], diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManager.= c b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManager.c index 6efd783ab219..9ee063859ce1 100644 --- a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManager.c +++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManager.c @@ -305,7 +305,7 @@ CallBootManager ( HiiHandle, 0, mDeviceTypeStr[ - MIN (DeviceType & 0xF, sizeof (mDeviceTypeStr) / si= zeof (mDeviceTypeStr[0]) - 1) + MIN (DeviceType & 0xF, ARRAY_SIZE=20 + (mDeviceTypeStr) - 1) ], NULL ); -- 2.9.2