Hi Eric, I think we should keep the Getxxx() functions to make the code easier to read and we have matched Get/Set functions to access these PCDs.
Mike > -----Original Message----- > From: Dong, Eric > Sent: Tuesday, August 15, 2017 6:04 PM > To: [email protected] > Cc: Ni, Ruiyu <[email protected]>; Shao, Ming > <[email protected]>; Kinney, Michael D > <[email protected]> > Subject: [Patch] UefiCpuPkg RegisterCpuFeaturesLib: Fix buffer > pointer error usage. > > Current code allocate buffer for the pointer which later get > value > from PCD database. but current code error use "=" for this case. > Use AllocateCopyPool instead to fix it. > > V2 enhanced to directly use AllocateCopyPool to get the PCD > value. > V3 enhanced to avoid using local temp variable. > > Cc: Ruiyu Ni <[email protected]> > Cc: Shao Ming <[email protected]> > Cc: Kinney Michael D <[email protected]> > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Eric Dong <[email protected]> > --- > .../RegisterCpuFeaturesLib/CpuFeaturesInitialize.c | 55 +++++-- > --------------- > 1 file changed, 11 insertions(+), 44 deletions(-) > > diff --git > a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitializ > e.c > b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitializ > e.c > index 474aea3..a7e1852 100644 > --- > a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitializ > e.c > +++ > b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitializ > e.c > @@ -51,48 +51,6 @@ SetSettingPcd ( > } > > /** > - Worker function to get PcdCpuFeaturesSupport. > - > - @return The pointer to CPU feature bits mask buffer. > -**/ > -UINT8 * > -GetSupportPcds ( > - VOID > - ) > -{ > - UINTN BitMaskSize; > - UINT8 *SupportBitMask; > - > - BitMaskSize = PcdGetSize (PcdCpuFeaturesSupport); > - SupportBitMask = AllocateZeroPool (BitMaskSize); > - ASSERT (SupportBitMask != NULL); > - SupportBitMask = (UINT8 *) PcdGetPtr (PcdCpuFeaturesSupport); > - > - return SupportBitMask; > -} > - > -/** > - Worker function to get PcdCpuFeaturesUserConfiguration. > - > - @return The pointer to CPU feature bits mask buffer. > -**/ > -UINT8 * > -GetConfigurationPcds ( > - VOID > - ) > -{ > - UINTN BitMaskSize; > - UINT8 *SupportBitMask; > - > - BitMaskSize = PcdGetSize (PcdCpuFeaturesUserConfiguration); > - SupportBitMask = AllocateZeroPool (BitMaskSize); > - ASSERT (SupportBitMask != NULL); > - SupportBitMask = (UINT8 *) PcdGetPtr > (PcdCpuFeaturesUserConfiguration); > - > - return SupportBitMask; > -} > - > -/** > Collects CPU type and feature information. > > @param[in, out] CpuInfo The pointer to CPU feature > information > @@ -180,8 +138,17 @@ CpuInitDataInitialize ( > // > // Get support and configuration PCDs > // > - CpuFeaturesData->SupportPcds = GetSupportPcds (); > - CpuFeaturesData->ConfigurationPcds = GetConfigurationPcds (); > + CpuFeaturesData->SupportPcds = AllocateCopyPool ( > + PcdGetSize (PcdCpuFeaturesSupport), > + PcdGetPtr (PcdCpuFeaturesSupport) > + ); > + ASSERT (CpuFeaturesData->SupportPcds != NULL); > + > + CpuFeaturesData->ConfigurationPcds = AllocateCopyPool ( > + PcdGetSize (PcdCpuFeaturesUserConfiguration), > + PcdGetPtr (PcdCpuFeaturesUserConfiguration) > + ); > + ASSERT (CpuFeaturesData->ConfigurationPcds != NULL); > } > > /** > -- > 2.7.0.windows.1 _______________________________________________ edk2-devel mailing list [email protected] https://lists.01.org/mailman/listinfo/edk2-devel

