* [Patch] BaseTools: Fix one crash bug in the report for Fixed structure Pcd
@ 2018-10-18 14:25 Yonghong Zhu
2018-10-18 14:36 ` Carsey, Jaben
0 siblings, 1 reply; 3+ messages in thread
From: Yonghong Zhu @ 2018-10-18 14:25 UTC (permalink / raw)
To: edk2-devel
The case is:
in the DSC file:
SKUID_IDENTIFIER = ALL
[SkuIds]
0|DEFAULT
1|A
[PcdsFixedAtBuild.common.A]
TokenSpaceGuid.Test401|{0x0F, 0x12}
TokenSpaceGuid.Test401.TEST401INT8ARRAY[0]|'B'
in the build report, Data = OverrideValues[Keys[0]], but the Keys[0]
is the keyword "DEFAULT", and in this case the "DEFAULT" SKU doesn't
save any value, then it cause the Data is empty, in the next code
when we use the code it cause crash.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
---
BaseTools/Source/Python/build/BuildReport.py | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/BaseTools/Source/Python/build/BuildReport.py b/BaseTools/Source/Python/build/BuildReport.py
index 14143b3..5e2a664 100644
--- a/BaseTools/Source/Python/build/BuildReport.py
+++ b/BaseTools/Source/Python/build/BuildReport.py
@@ -1089,14 +1089,16 @@ class PcdReport(object):
DscOverride = False
else:
if not Pcd.SkuInfoList:
OverrideValues = Pcd.SkuOverrideValues
if OverrideValues:
- Keys = list(OverrideValues.keys())
- Data = OverrideValues[Keys[0]]
- Struct = list(Data.values())
- DscOverride = self.ParseStruct(Struct[0])
+ for key in OverrideValues.keys():
+ Data = OverrideValues[key]
+ Struct = list(Data.values())
+ if Struct:
+ DscOverride = self.ParseStruct(Struct[0])
+ break
else:
SkuList = sorted(Pcd.SkuInfoList.keys())
for Sku in SkuList:
SkuInfo = Pcd.SkuInfoList[Sku]
if TypeName in ('DYNHII', 'DEXHII'):
@@ -1265,16 +1267,17 @@ class PcdReport(object):
Value = "0x{:X} ({})".format(int(Value, 0), Value)
FileWrite(File, ' %-*s : %6s %10s = %s' % (self.MaxLen, Flag + ' ' + PcdTokenCName, TypeName, '(' + Pcd.DatumType + ')', Value))
if IsStructure:
OverrideValues = Pcd.SkuOverrideValues
if OverrideValues:
- Keys = list(OverrideValues.keys())
- Data = OverrideValues[Keys[0]]
- Struct = list(Data.values())
- if Struct:
- OverrideFieldStruct = self.OverrideFieldValue(Pcd, Struct[0])
- self.PrintStructureInfo(File, OverrideFieldStruct)
+ for key in OverrideValues.keys():
+ Data = OverrideValues[key]
+ Struct = list(Data.values())
+ if Struct:
+ OverrideFieldStruct = self.OverrideFieldValue(Pcd, Struct[0])
+ self.PrintStructureInfo(File, OverrideFieldStruct)
+ break
self.PrintPcdDefault(File, Pcd, IsStructure, DscMatch, DscDefaultValue, InfMatch, InfDefaultValue, DecMatch, DecDefaultValue)
else:
FirstPrint = True
SkuList = sorted(Pcd.SkuInfoList.keys())
for Sku in SkuList:
--
2.6.1.windows.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Patch] BaseTools: Fix one crash bug in the report for Fixed structure Pcd
2018-10-18 14:25 [Patch] BaseTools: Fix one crash bug in the report for Fixed structure Pcd Yonghong Zhu
@ 2018-10-18 14:36 ` Carsey, Jaben
2018-10-18 14:37 ` Zhu, Yonghong
0 siblings, 1 reply; 3+ messages in thread
From: Carsey, Jaben @ 2018-10-18 14:36 UTC (permalink / raw)
To: Zhu, Yonghong, edk2-devel@lists.01.org
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
Note that you could change your first 2 lines (of the new content in both places) to:
for Data in OverrideValues.values():
since you don't ever use the key later on...
-Jaben
> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> Yonghong Zhu
> Sent: Thursday, October 18, 2018 7:25 AM
> To: edk2-devel@lists.01.org
> Subject: [edk2] [Patch] BaseTools: Fix one crash bug in the report for Fixed
> structure Pcd
>
> The case is:
> in the DSC file:
> SKUID_IDENTIFIER = ALL
>
> [SkuIds]
> 0|DEFAULT
> 1|A
>
> [PcdsFixedAtBuild.common.A]
> TokenSpaceGuid.Test401|{0x0F, 0x12}
> TokenSpaceGuid.Test401.TEST401INT8ARRAY[0]|'B'
>
> in the build report, Data = OverrideValues[Keys[0]], but the Keys[0]
> is the keyword "DEFAULT", and in this case the "DEFAULT" SKU doesn't
> save any value, then it cause the Data is empty, in the next code
> when we use the code it cause crash.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
> ---
> BaseTools/Source/Python/build/BuildReport.py | 23 +++++++++++++--------
> --
> 1 file changed, 13 insertions(+), 10 deletions(-)
>
> diff --git a/BaseTools/Source/Python/build/BuildReport.py
> b/BaseTools/Source/Python/build/BuildReport.py
> index 14143b3..5e2a664 100644
> --- a/BaseTools/Source/Python/build/BuildReport.py
> +++ b/BaseTools/Source/Python/build/BuildReport.py
> @@ -1089,14 +1089,16 @@ class PcdReport(object):
> DscOverride = False
> else:
> if not Pcd.SkuInfoList:
> OverrideValues = Pcd.SkuOverrideValues
> if OverrideValues:
> - Keys = list(OverrideValues.keys())
> - Data = OverrideValues[Keys[0]]
> - Struct = list(Data.values())
> - DscOverride = self.ParseStruct(Struct[0])
> + for key in OverrideValues.keys():
> + Data = OverrideValues[key]
> + Struct = list(Data.values())
> + if Struct:
> + DscOverride = self.ParseStruct(Struct[0])
> + break
> else:
> SkuList = sorted(Pcd.SkuInfoList.keys())
> for Sku in SkuList:
> SkuInfo = Pcd.SkuInfoList[Sku]
> if TypeName in ('DYNHII', 'DEXHII'):
> @@ -1265,16 +1267,17 @@ class PcdReport(object):
> Value = "0x{:X} ({})".format(int(Value, 0), Value)
> FileWrite(File, ' %-*s : %6s %10s = %s' % (self.MaxLen, Flag + ' ' +
> PcdTokenCName, TypeName, '(' + Pcd.DatumType + ')', Value))
> if IsStructure:
> OverrideValues = Pcd.SkuOverrideValues
> if OverrideValues:
> - Keys = list(OverrideValues.keys())
> - Data = OverrideValues[Keys[0]]
> - Struct = list(Data.values())
> - if Struct:
> - OverrideFieldStruct = self.OverrideFieldValue(Pcd, Struct[0])
> - self.PrintStructureInfo(File, OverrideFieldStruct)
> + for key in OverrideValues.keys():
> + Data = OverrideValues[key]
> + Struct = list(Data.values())
> + if Struct:
> + OverrideFieldStruct = self.OverrideFieldValue(Pcd, Struct[0])
> + self.PrintStructureInfo(File, OverrideFieldStruct)
> + break
> self.PrintPcdDefault(File, Pcd, IsStructure, DscMatch, DscDefaultValue,
> InfMatch, InfDefaultValue, DecMatch, DecDefaultValue)
> else:
> FirstPrint = True
> SkuList = sorted(Pcd.SkuInfoList.keys())
> for Sku in SkuList:
> --
> 2.6.1.windows.1
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Patch] BaseTools: Fix one crash bug in the report for Fixed structure Pcd
2018-10-18 14:36 ` Carsey, Jaben
@ 2018-10-18 14:37 ` Zhu, Yonghong
0 siblings, 0 replies; 3+ messages in thread
From: Zhu, Yonghong @ 2018-10-18 14:37 UTC (permalink / raw)
To: Carsey, Jaben, edk2-devel@lists.01.org
Yes. Thanks for the comment. I will update it when push it.
Best Regards,
Zhu Yonghong
-----Original Message-----
From: Carsey, Jaben
Sent: Thursday, October 18, 2018 10:36 PM
To: Zhu, Yonghong <yonghong.zhu@intel.com>; edk2-devel@lists.01.org
Subject: RE: [edk2] [Patch] BaseTools: Fix one crash bug in the report for Fixed structure Pcd
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
Note that you could change your first 2 lines (of the new content in both places) to:
for Data in OverrideValues.values():
since you don't ever use the key later on...
-Jaben
> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> Yonghong Zhu
> Sent: Thursday, October 18, 2018 7:25 AM
> To: edk2-devel@lists.01.org
> Subject: [edk2] [Patch] BaseTools: Fix one crash bug in the report for
> Fixed structure Pcd
>
> The case is:
> in the DSC file:
> SKUID_IDENTIFIER = ALL
>
> [SkuIds]
> 0|DEFAULT
> 1|A
>
> [PcdsFixedAtBuild.common.A]
> TokenSpaceGuid.Test401|{0x0F, 0x12}
> TokenSpaceGuid.Test401.TEST401INT8ARRAY[0]|'B'
>
> in the build report, Data = OverrideValues[Keys[0]], but the Keys[0]
> is the keyword "DEFAULT", and in this case the "DEFAULT" SKU doesn't
> save any value, then it cause the Data is empty, in the next code when
> we use the code it cause crash.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
> ---
> BaseTools/Source/Python/build/BuildReport.py | 23
> +++++++++++++--------
> --
> 1 file changed, 13 insertions(+), 10 deletions(-)
>
> diff --git a/BaseTools/Source/Python/build/BuildReport.py
> b/BaseTools/Source/Python/build/BuildReport.py
> index 14143b3..5e2a664 100644
> --- a/BaseTools/Source/Python/build/BuildReport.py
> +++ b/BaseTools/Source/Python/build/BuildReport.py
> @@ -1089,14 +1089,16 @@ class PcdReport(object):
> DscOverride = False
> else:
> if not Pcd.SkuInfoList:
> OverrideValues = Pcd.SkuOverrideValues
> if OverrideValues:
> - Keys = list(OverrideValues.keys())
> - Data = OverrideValues[Keys[0]]
> - Struct = list(Data.values())
> - DscOverride = self.ParseStruct(Struct[0])
> + for key in OverrideValues.keys():
> + Data = OverrideValues[key]
> + Struct = list(Data.values())
> + if Struct:
> + DscOverride = self.ParseStruct(Struct[0])
> + break
> else:
> SkuList = sorted(Pcd.SkuInfoList.keys())
> for Sku in SkuList:
> SkuInfo = Pcd.SkuInfoList[Sku]
> if TypeName in ('DYNHII', 'DEXHII'):
> @@ -1265,16 +1267,17 @@ class PcdReport(object):
> Value = "0x{:X} ({})".format(int(Value, 0), Value)
> FileWrite(File, ' %-*s : %6s %10s = %s' % (self.MaxLen, Flag + ' ' +
> PcdTokenCName, TypeName, '(' + Pcd.DatumType + ')', Value))
> if IsStructure:
> OverrideValues = Pcd.SkuOverrideValues
> if OverrideValues:
> - Keys = list(OverrideValues.keys())
> - Data = OverrideValues[Keys[0]]
> - Struct = list(Data.values())
> - if Struct:
> - OverrideFieldStruct = self.OverrideFieldValue(Pcd, Struct[0])
> - self.PrintStructureInfo(File, OverrideFieldStruct)
> + for key in OverrideValues.keys():
> + Data = OverrideValues[key]
> + Struct = list(Data.values())
> + if Struct:
> + OverrideFieldStruct = self.OverrideFieldValue(Pcd, Struct[0])
> + self.PrintStructureInfo(File, OverrideFieldStruct)
> + break
> self.PrintPcdDefault(File, Pcd, IsStructure, DscMatch,
> DscDefaultValue, InfMatch, InfDefaultValue, DecMatch, DecDefaultValue)
> else:
> FirstPrint = True
> SkuList = sorted(Pcd.SkuInfoList.keys())
> for Sku in SkuList:
> --
> 2.6.1.windows.1
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-10-18 14:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-18 14:25 [Patch] BaseTools: Fix one crash bug in the report for Fixed structure Pcd Yonghong Zhu
2018-10-18 14:36 ` Carsey, Jaben
2018-10-18 14:37 ` Zhu, Yonghong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox