]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools: enhance error check for DatumType format
authorYonghong Zhu <yonghong.zhu@intel.com>
Fri, 2 Feb 2018 07:46:08 +0000 (15:46 +0800)
committerYonghong Zhu <yonghong.zhu@intel.com>
Tue, 6 Feb 2018 05:48:42 +0000 (13:48 +0800)
Add a check for DatumType format, eg: VOID *, original Tool will crash
but no detail error message which cause confusion to user.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
BaseTools/Source/Python/Workspace/DecBuildData.py

index 2fd3820dcc8676902eeee4ad4b67a1597a0e8f94..2266b0b7a623ccd16fd8cb869d6f8e15f3d244ed 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # This file is used to create a database used by build tool\r
 #\r
 ## @file\r
 # This file is used to create a database used by build tool\r
 #\r
-# Copyright (c) 2008 - 2017, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>\r
 # (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
@@ -423,6 +423,11 @@ class DecBuildData(PackageBuildClassObject):
                 continue\r
 \r
             DefaultValue, DatumType, TokenNumber = AnalyzePcdData(Setting)\r
                 continue\r
 \r
             DefaultValue, DatumType, TokenNumber = AnalyzePcdData(Setting)\r
+            if DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, TAB_VOID, "BOOLEAN"]:\r
+                StructPattern = re.compile(r'[_a-zA-Z][0-9A-Za-z_]*$')\r
+                if StructPattern.match(DatumType) == None:\r
+                    EdkLogger.error('build', FORMAT_INVALID, "DatumType only support BOOLEAN, UINT8, UINT16, UINT32, UINT64, VOID* or a valid struct name.", File=self.MetaFile, Line=LineNo)\r
+\r
             validateranges, validlists, expressions = self._RawData.GetValidExpression(TokenSpaceGuid, PcdCName)\r
             PcdObj = PcdClassObject(\r
                                         PcdCName,\r
             validateranges, validlists, expressions = self._RawData.GetValidExpression(TokenSpaceGuid, PcdCName)\r
             PcdObj = PcdClassObject(\r
                                         PcdCName,\r