public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch V3] BaseTools: Fixed bugs in CopyDict function
@ 2018-12-11  9:03 BobCF
  2018-12-11  9:36 ` Leif Lindholm
  2018-12-11 13:43 ` Gao, Liming
  0 siblings, 2 replies; 3+ messages in thread
From: BobCF @ 2018-12-11  9:03 UTC (permalink / raw)
  To: edk2-devel; +Cc: Feng, Bob C, Liming Gao, Leif Lindholm

From: "Feng, Bob C" <bob.c.feng@intel.com>

https://bugzilla.tianocore.org/show_bug.cgi?id=1387

This patch is going to fix the regression issue which is
introduced by commit bf9e636605188e291d33ab694ff1c5926b6f0800.

This patch Remove the CopyDict incorrect usage for non-dict
input data. Add a check for CopyDict input.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Leif Lindholm <leif.lindholm@linaro.org>
---
 BaseTools/Source/Python/Common/Misc.py            | 2 ++
 BaseTools/Source/Python/Workspace/DscBuildData.py | 4 ++--
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py
index b063f064fb..6a22d01012 100644
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -2137,10 +2137,12 @@ def PackByteFormatGUID(Guid):
 #
 #   @retval     new dict or orderdict
 #
 def CopyDict(ori_dict):
     dict_type = ori_dict.__class__
+    if dict_type not in (dict,OrderedDict):
+        return ori_dict
     new_dict = dict_type()
     for key in ori_dict:
         if isinstance(ori_dict[key],(dict,OrderedDict)):
             new_dict[key] = CopyDict(ori_dict[key])
         else:
diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py
index b485c75a84..4543ae7dc0 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -972,11 +972,11 @@ class DscBuildData(PlatformBuildClassObject):
             for skuid in pcd.SkuInfoList:
                 skuobj = pcd.SkuInfoList.get(skuid)
                 if TAB_DEFAULT_STORES_DEFAULT not in skuobj.DefaultStoreDict:
                     PcdDefaultStoreSet = set(defaultstorename  for defaultstorename in skuobj.DefaultStoreDict)
                     mindefaultstorename = DefaultStoreMgr.GetMin(PcdDefaultStoreSet)
-                    skuobj.DefaultStoreDict[TAB_DEFAULT_STORES_DEFAULT] = CopyDict(skuobj.DefaultStoreDict[mindefaultstorename])
+                    skuobj.DefaultStoreDict[TAB_DEFAULT_STORES_DEFAULT] = skuobj.DefaultStoreDict[mindefaultstorename]
         return Pcds
 
     def RecoverCommandLinePcd(self):
         def UpdateCommandLineValue(pcd):
             if pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD],
@@ -2767,11 +2767,11 @@ class DscBuildData(PlatformBuildClassObject):
                 for skuid in PcdObj.SkuInfoList:
                     skuobj = PcdObj.SkuInfoList[skuid]
                     mindefaultstorename = DefaultStoreObj.GetMin(set(defaultstorename for defaultstorename in skuobj.DefaultStoreDict))
                     for defaultstorename in DefaultStores:
                         if defaultstorename not in skuobj.DefaultStoreDict:
-                            skuobj.DefaultStoreDict[defaultstorename] = CopyDict(skuobj.DefaultStoreDict[mindefaultstorename])
+                            skuobj.DefaultStoreDict[defaultstorename] = skuobj.DefaultStoreDict[mindefaultstorename]
                     skuobj.HiiDefaultValue = skuobj.DefaultStoreDict[mindefaultstorename]
             for skuname, skuid in SkuIds.items():
                 if skuname not in PcdObj.SkuInfoList:
                     nextskuid = self.SkuIdMgr.GetNextSkuId(skuname)
                     while nextskuid not in PcdObj.SkuInfoList:
-- 
2.19.1.windows.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Patch V3] BaseTools: Fixed bugs in CopyDict function
  2018-12-11  9:03 [Patch V3] BaseTools: Fixed bugs in CopyDict function BobCF
@ 2018-12-11  9:36 ` Leif Lindholm
  2018-12-11 13:43 ` Gao, Liming
  1 sibling, 0 replies; 3+ messages in thread
From: Leif Lindholm @ 2018-12-11  9:36 UTC (permalink / raw)
  To: BobCF; +Cc: edk2-devel, Liming Gao

Hi Bob,

Thanks for cc.
I'm happy with all 3 commit messages.

Regards,

Leif

On Tue, Dec 11, 2018 at 05:03:25PM +0800, BobCF wrote:
> From: "Feng, Bob C" <bob.c.feng@intel.com>
> 
> https://bugzilla.tianocore.org/show_bug.cgi?id=1387
> 
> This patch is going to fix the regression issue which is
> introduced by commit bf9e636605188e291d33ab694ff1c5926b6f0800.
> 
> This patch Remove the CopyDict incorrect usage for non-dict
> input data. Add a check for CopyDict input.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Bob Feng <bob.c.feng@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Leif Lindholm <leif.lindholm@linaro.org>
> ---
>  BaseTools/Source/Python/Common/Misc.py            | 2 ++
>  BaseTools/Source/Python/Workspace/DscBuildData.py | 4 ++--
>  2 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py
> index b063f064fb..6a22d01012 100644
> --- a/BaseTools/Source/Python/Common/Misc.py
> +++ b/BaseTools/Source/Python/Common/Misc.py
> @@ -2137,10 +2137,12 @@ def PackByteFormatGUID(Guid):
>  #
>  #   @retval     new dict or orderdict
>  #
>  def CopyDict(ori_dict):
>      dict_type = ori_dict.__class__
> +    if dict_type not in (dict,OrderedDict):
> +        return ori_dict
>      new_dict = dict_type()
>      for key in ori_dict:
>          if isinstance(ori_dict[key],(dict,OrderedDict)):
>              new_dict[key] = CopyDict(ori_dict[key])
>          else:
> diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py
> index b485c75a84..4543ae7dc0 100644
> --- a/BaseTools/Source/Python/Workspace/DscBuildData.py
> +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
> @@ -972,11 +972,11 @@ class DscBuildData(PlatformBuildClassObject):
>              for skuid in pcd.SkuInfoList:
>                  skuobj = pcd.SkuInfoList.get(skuid)
>                  if TAB_DEFAULT_STORES_DEFAULT not in skuobj.DefaultStoreDict:
>                      PcdDefaultStoreSet = set(defaultstorename  for defaultstorename in skuobj.DefaultStoreDict)
>                      mindefaultstorename = DefaultStoreMgr.GetMin(PcdDefaultStoreSet)
> -                    skuobj.DefaultStoreDict[TAB_DEFAULT_STORES_DEFAULT] = CopyDict(skuobj.DefaultStoreDict[mindefaultstorename])
> +                    skuobj.DefaultStoreDict[TAB_DEFAULT_STORES_DEFAULT] = skuobj.DefaultStoreDict[mindefaultstorename]
>          return Pcds
>  
>      def RecoverCommandLinePcd(self):
>          def UpdateCommandLineValue(pcd):
>              if pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD],
> @@ -2767,11 +2767,11 @@ class DscBuildData(PlatformBuildClassObject):
>                  for skuid in PcdObj.SkuInfoList:
>                      skuobj = PcdObj.SkuInfoList[skuid]
>                      mindefaultstorename = DefaultStoreObj.GetMin(set(defaultstorename for defaultstorename in skuobj.DefaultStoreDict))
>                      for defaultstorename in DefaultStores:
>                          if defaultstorename not in skuobj.DefaultStoreDict:
> -                            skuobj.DefaultStoreDict[defaultstorename] = CopyDict(skuobj.DefaultStoreDict[mindefaultstorename])
> +                            skuobj.DefaultStoreDict[defaultstorename] = skuobj.DefaultStoreDict[mindefaultstorename]
>                      skuobj.HiiDefaultValue = skuobj.DefaultStoreDict[mindefaultstorename]
>              for skuname, skuid in SkuIds.items():
>                  if skuname not in PcdObj.SkuInfoList:
>                      nextskuid = self.SkuIdMgr.GetNextSkuId(skuname)
>                      while nextskuid not in PcdObj.SkuInfoList:
> -- 
> 2.19.1.windows.1
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Patch V3] BaseTools: Fixed bugs in CopyDict function
  2018-12-11  9:03 [Patch V3] BaseTools: Fixed bugs in CopyDict function BobCF
  2018-12-11  9:36 ` Leif Lindholm
@ 2018-12-11 13:43 ` Gao, Liming
  1 sibling, 0 replies; 3+ messages in thread
From: Gao, Liming @ 2018-12-11 13:43 UTC (permalink / raw)
  To: Feng, Bob C, edk2-devel@lists.01.org

Reviewed-by: Liming Gao <liming.gao@intel.com>

> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of BobCF
> Sent: Tuesday, December 11, 2018 5:03 PM
> To: edk2-devel@lists.01.org
> Cc: Gao, Liming <liming.gao@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
> Subject: [edk2] [Patch V3] BaseTools: Fixed bugs in CopyDict function
> 
> From: "Feng, Bob C" <bob.c.feng@intel.com>
> 
> https://bugzilla.tianocore.org/show_bug.cgi?id=1387
> 
> This patch is going to fix the regression issue which is
> introduced by commit bf9e636605188e291d33ab694ff1c5926b6f0800.
> 
> This patch Remove the CopyDict incorrect usage for non-dict
> input data. Add a check for CopyDict input.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Bob Feng <bob.c.feng@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Leif Lindholm <leif.lindholm@linaro.org>
> ---
>  BaseTools/Source/Python/Common/Misc.py            | 2 ++
>  BaseTools/Source/Python/Workspace/DscBuildData.py | 4 ++--
>  2 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py
> index b063f064fb..6a22d01012 100644
> --- a/BaseTools/Source/Python/Common/Misc.py
> +++ b/BaseTools/Source/Python/Common/Misc.py
> @@ -2137,10 +2137,12 @@ def PackByteFormatGUID(Guid):
>  #
>  #   @retval     new dict or orderdict
>  #
>  def CopyDict(ori_dict):
>      dict_type = ori_dict.__class__
> +    if dict_type not in (dict,OrderedDict):
> +        return ori_dict
>      new_dict = dict_type()
>      for key in ori_dict:
>          if isinstance(ori_dict[key],(dict,OrderedDict)):
>              new_dict[key] = CopyDict(ori_dict[key])
>          else:
> diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py
> index b485c75a84..4543ae7dc0 100644
> --- a/BaseTools/Source/Python/Workspace/DscBuildData.py
> +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
> @@ -972,11 +972,11 @@ class DscBuildData(PlatformBuildClassObject):
>              for skuid in pcd.SkuInfoList:
>                  skuobj = pcd.SkuInfoList.get(skuid)
>                  if TAB_DEFAULT_STORES_DEFAULT not in skuobj.DefaultStoreDict:
>                      PcdDefaultStoreSet = set(defaultstorename  for defaultstorename in skuobj.DefaultStoreDict)
>                      mindefaultstorename = DefaultStoreMgr.GetMin(PcdDefaultStoreSet)
> -                    skuobj.DefaultStoreDict[TAB_DEFAULT_STORES_DEFAULT] =
> CopyDict(skuobj.DefaultStoreDict[mindefaultstorename])
> +                    skuobj.DefaultStoreDict[TAB_DEFAULT_STORES_DEFAULT] = skuobj.DefaultStoreDict[mindefaultstorename]
>          return Pcds
> 
>      def RecoverCommandLinePcd(self):
>          def UpdateCommandLineValue(pcd):
>              if pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD],
> @@ -2767,11 +2767,11 @@ class DscBuildData(PlatformBuildClassObject):
>                  for skuid in PcdObj.SkuInfoList:
>                      skuobj = PcdObj.SkuInfoList[skuid]
>                      mindefaultstorename = DefaultStoreObj.GetMin(set(defaultstorename for defaultstorename in
> skuobj.DefaultStoreDict))
>                      for defaultstorename in DefaultStores:
>                          if defaultstorename not in skuobj.DefaultStoreDict:
> -                            skuobj.DefaultStoreDict[defaultstorename] =
> CopyDict(skuobj.DefaultStoreDict[mindefaultstorename])
> +                            skuobj.DefaultStoreDict[defaultstorename] = skuobj.DefaultStoreDict[mindefaultstorename]
>                      skuobj.HiiDefaultValue = skuobj.DefaultStoreDict[mindefaultstorename]
>              for skuname, skuid in SkuIds.items():
>                  if skuname not in PcdObj.SkuInfoList:
>                      nextskuid = self.SkuIdMgr.GetNextSkuId(skuname)
>                      while nextskuid not in PcdObj.SkuInfoList:
> --
> 2.19.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-12-11 13:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-11  9:03 [Patch V3] BaseTools: Fixed bugs in CopyDict function BobCF
2018-12-11  9:36 ` Leif Lindholm
2018-12-11 13:43 ` Gao, Liming

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox