public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch 1/1] BaseTools/Source/Python: Verify TAB_TOD_DEFINES_FAMILY key present
@ 2021-04-20 17:43 Michael D Kinney
  2021-04-22  5:29 ` Bob Feng
  0 siblings, 1 reply; 2+ messages in thread
From: Michael D Kinney @ 2021-04-20 17:43 UTC (permalink / raw)
  To: devel; +Cc: Bob Feng, Liming Gao, Yuwei Chen

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

Veify that TAB_TOD_DEFINES_FAMILY key is present in ToolDef
dictionary before access.

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Yuwei Chen <yuwei.chen@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
---
 .../Source/Python/AutoGen/ModuleAutoGenHelper.py      | 11 ++++++++---
 BaseTools/Source/Python/AutoGen/PlatformAutoGen.py    |  9 +++++++--
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/ModuleAutoGenHelper.py b/BaseTools/Source/Python/AutoGen/ModuleAutoGenHelper.py
index 8e60643d1fd9..7477b1d77fb8 100644
--- a/BaseTools/Source/Python/AutoGen/ModuleAutoGenHelper.py
+++ b/BaseTools/Source/Python/AutoGen/ModuleAutoGenHelper.py
@@ -1,7 +1,7 @@
 ## @file
 # Create makefile for MS nmake and GNU make
 #
-# Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2019 - 2021, Intel Corporation. All rights reserved.<BR>
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 #
 from __future__ import absolute_import
@@ -178,8 +178,11 @@ class AutoGenInfo(object):
                 if ToolDef[Tool].get(TAB_TOD_DEFINES_BUILDRULEFAMILY, "") != "":
                     if Family != ToolDef[Tool][TAB_TOD_DEFINES_BUILDRULEFAMILY]:
                         continue
-                elif Family != ToolDef[Tool][TAB_TOD_DEFINES_FAMILY]:
-                    continue
+                else:
+                    if ToolDef[Tool].get(TAB_TOD_DEFINES_FAMILY, "") == "":
+                        continue
+                    if Family != ToolDef[Tool][TAB_TOD_DEFINES_FAMILY]:
+                        continue
                 FamilyMatch = True
             # expand any wildcard
             if Target == TAB_STAR or Target == self.BuildTarget:
@@ -213,6 +216,8 @@ class AutoGenInfo(object):
             if Tool not in ToolDef or Family == "":
                 continue
             # option has been added before
+            if TAB_TOD_DEFINES_FAMILY not in ToolDef[Tool]:
+                continue
             if Family != ToolDef[Tool][TAB_TOD_DEFINES_FAMILY]:
                 continue
 
diff --git a/BaseTools/Source/Python/AutoGen/PlatformAutoGen.py b/BaseTools/Source/Python/AutoGen/PlatformAutoGen.py
index c16f2e4cd8b7..e2ef3256773e 100644
--- a/BaseTools/Source/Python/AutoGen/PlatformAutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/PlatformAutoGen.py
@@ -1474,8 +1474,11 @@ class PlatformAutoGen(AutoGen):
                 if ToolDef[Tool].get(TAB_TOD_DEFINES_BUILDRULEFAMILY, "") != "":
                     if Family != ToolDef[Tool][TAB_TOD_DEFINES_BUILDRULEFAMILY]:
                         continue
-                elif Family != ToolDef[Tool][TAB_TOD_DEFINES_FAMILY]:
-                    continue
+                else:
+                    if ToolDef[Tool].get(TAB_TOD_DEFINES_FAMILY, "") == "":
+                        continue
+                    if Family != ToolDef[Tool][TAB_TOD_DEFINES_FAMILY]:
+                        continue
                 FamilyMatch = True
             # expand any wildcard
             if Target == TAB_STAR or Target == self.BuildTarget:
@@ -1509,6 +1512,8 @@ class PlatformAutoGen(AutoGen):
             if Tool not in ToolDef or Family == "":
                 continue
             # option has been added before
+            if TAB_TOD_DEFINES_FAMILY not in ToolDef[Tool]:
+                continue
             if Family != ToolDef[Tool][TAB_TOD_DEFINES_FAMILY]:
                 continue
 
-- 
2.31.1.windows.1


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

* Re: [Patch 1/1] BaseTools/Source/Python: Verify TAB_TOD_DEFINES_FAMILY key present
  2021-04-20 17:43 [Patch 1/1] BaseTools/Source/Python: Verify TAB_TOD_DEFINES_FAMILY key present Michael D Kinney
@ 2021-04-22  5:29 ` Bob Feng
  0 siblings, 0 replies; 2+ messages in thread
From: Bob Feng @ 2021-04-22  5:29 UTC (permalink / raw)
  To: Kinney, Michael D, devel@edk2.groups.io; +Cc: Liming Gao, Chen, Christine

This patch is good to me.

Reviewed-by: Bob Feng <bob.c.feng@intel.com>

-----Original Message-----
From: Kinney, Michael D <michael.d.kinney@intel.com> 
Sent: Wednesday, April 21, 2021 1:44 AM
To: devel@edk2.groups.io
Cc: Feng, Bob C <bob.c.feng@intel.com>; Liming Gao <gaoliming@byosoft.com.cn>; Chen, Christine <yuwei.chen@intel.com>
Subject: [Patch 1/1] BaseTools/Source/Python: Verify TAB_TOD_DEFINES_FAMILY key present

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

Veify that TAB_TOD_DEFINES_FAMILY key is present in ToolDef dictionary before access.

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Yuwei Chen <yuwei.chen@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
---
 .../Source/Python/AutoGen/ModuleAutoGenHelper.py      | 11 ++++++++---
 BaseTools/Source/Python/AutoGen/PlatformAutoGen.py    |  9 +++++++--
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/ModuleAutoGenHelper.py b/BaseTools/Source/Python/AutoGen/ModuleAutoGenHelper.py
index 8e60643d1fd9..7477b1d77fb8 100644
--- a/BaseTools/Source/Python/AutoGen/ModuleAutoGenHelper.py
+++ b/BaseTools/Source/Python/AutoGen/ModuleAutoGenHelper.py
@@ -1,7 +1,7 @@
 ## @file
 # Create makefile for MS nmake and GNU make  # -# Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2019 - 2021, Intel Corporation. All rights 
+reserved.<BR>
 # SPDX-License-Identifier: BSD-2-Clause-Patent  #  from __future__ import absolute_import @@ -178,8 +178,11 @@ class AutoGenInfo(object):
                 if ToolDef[Tool].get(TAB_TOD_DEFINES_BUILDRULEFAMILY, "") != "":
                     if Family != ToolDef[Tool][TAB_TOD_DEFINES_BUILDRULEFAMILY]:
                         continue
-                elif Family != ToolDef[Tool][TAB_TOD_DEFINES_FAMILY]:
-                    continue
+                else:
+                    if ToolDef[Tool].get(TAB_TOD_DEFINES_FAMILY, "") == "":
+                        continue
+                    if Family != ToolDef[Tool][TAB_TOD_DEFINES_FAMILY]:
+                        continue
                 FamilyMatch = True
             # expand any wildcard
             if Target == TAB_STAR or Target == self.BuildTarget:
@@ -213,6 +216,8 @@ class AutoGenInfo(object):
             if Tool not in ToolDef or Family == "":
                 continue
             # option has been added before
+            if TAB_TOD_DEFINES_FAMILY not in ToolDef[Tool]:
+                continue
             if Family != ToolDef[Tool][TAB_TOD_DEFINES_FAMILY]:
                 continue
 
diff --git a/BaseTools/Source/Python/AutoGen/PlatformAutoGen.py b/BaseTools/Source/Python/AutoGen/PlatformAutoGen.py
index c16f2e4cd8b7..e2ef3256773e 100644
--- a/BaseTools/Source/Python/AutoGen/PlatformAutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/PlatformAutoGen.py
@@ -1474,8 +1474,11 @@ class PlatformAutoGen(AutoGen):
                 if ToolDef[Tool].get(TAB_TOD_DEFINES_BUILDRULEFAMILY, "") != "":
                     if Family != ToolDef[Tool][TAB_TOD_DEFINES_BUILDRULEFAMILY]:
                         continue
-                elif Family != ToolDef[Tool][TAB_TOD_DEFINES_FAMILY]:
-                    continue
+                else:
+                    if ToolDef[Tool].get(TAB_TOD_DEFINES_FAMILY, "") == "":
+                        continue
+                    if Family != ToolDef[Tool][TAB_TOD_DEFINES_FAMILY]:
+                        continue
                 FamilyMatch = True
             # expand any wildcard
             if Target == TAB_STAR or Target == self.BuildTarget:
@@ -1509,6 +1512,8 @@ class PlatformAutoGen(AutoGen):
             if Tool not in ToolDef or Family == "":
                 continue
             # option has been added before
+            if TAB_TOD_DEFINES_FAMILY not in ToolDef[Tool]:
+                continue
             if Family != ToolDef[Tool][TAB_TOD_DEFINES_FAMILY]:
                 continue
 
--
2.31.1.windows.1


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

end of thread, other threads:[~2021-04-22  5:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-04-20 17:43 [Patch 1/1] BaseTools/Source/Python: Verify TAB_TOD_DEFINES_FAMILY key present Michael D Kinney
2021-04-22  5:29 ` Bob Feng

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