diff options
author | Pierre Gondois <pierre.gondois@arm.com> | 2025-04-30 14:54:22 +0200 |
---|---|---|
committer | Liming Gao <gaoliming@byosoft.com.cn> | 2025-07-01 09:51:38 +0800 |
commit | ff0162bf07b130811d833c889574e7301b17ae11 (patch) | |
tree | a1f0892215deeeec46cc4ebe27a72895c05a3459 /BaseTools/Source/Python | |
parent | 3c2f04a3c7e2058f7f0b784f365aa39e52237b44 (diff) | |
download | edk2-ff0162bf07b130811d833c889574e7301b17ae11.zip edk2-ff0162bf07b130811d833c889574e7301b17ae11.tar.gz edk2-ff0162bf07b130811d833c889574e7301b17ae11.tar.bz2 |
BaseTools: FMTT: Remove unnecessary code
Running the vulture tool on the FMTT folder gave the following
report. Remove the unnecessary code.
- FMMT/core/BinaryFactoryProduct.py:132:
unused attribute 'ROffset' (60% confidence)
- FMMT/core/BinaryFactoryProduct.py:176:
unused attribute 'ROffset' (60% confidence)
- FMMT/core/BinaryFactoryProduct.py:229:
unused attribute 'ROffset' (60% confidence)
- FMMT/core/BinaryFactoryProduct.py:365:
unused class 'ElfSectionProduct' (60% confidence)
- FMMT/core/BinaryFactoryProduct.py:369:
unused method 'ParserSectionData' (60% confidence)
- FMMT/core/BinaryFactoryProduct.py:371:
unused method 'ParserProgramData' (60% confidence)
- FMMT/core/BiosTree.py:76:
unused method 'insertRel' (60% confidence)
- FMMT/core/BiosTree.py:84:
unused method 'deleteNode' (60% confidence)
- FMMT/core/BiosTreeNode.py:63:
unused attribute 'ROffset' (60% confidence)
- FMMT/core/BiosTreeNode.py:125:
unused attribute 'ROffset' (60% confidence)
- FMMT/core/BiosTreeNode.py:182:
unused attribute 'ROffset' (60% confidence)
- FMMT/core/BiosTreeNode.py:185:
unused attribute 'SectionMaxAlignment' (60% confidence)
- FMMT/core/BiosTreeNode.py:220:
unused attribute 'ROffset' (60% confidence)
- FMMT/core/BiosTreeNode.py:223:
unused attribute 'OriHeader' (60% confidence)
- FMMT/core/BiosTreeNode.py:226:
unused attribute 'SectionMaxAlignment' (60% confidence)
- FMMT/core/BiosTreeNode.py:247:
unused attribute 'ROffset' (60% confidence)
- FMMT/FMMT.py:52:
unused attribute 'firmware_packet' (60% confidence)
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Diffstat (limited to 'BaseTools/Source/Python')
-rw-r--r-- | BaseTools/Source/Python/FMMT/FMMT.py | 2 | ||||
-rw-r--r-- | BaseTools/Source/Python/FMMT/core/BinaryFactoryProduct.py | 12 | ||||
-rw-r--r-- | BaseTools/Source/Python/FMMT/core/BiosTree.py | 30 | ||||
-rw-r--r-- | BaseTools/Source/Python/FMMT/core/BiosTreeNode.py | 8 |
4 files changed, 1 insertions, 51 deletions
diff --git a/BaseTools/Source/Python/FMMT/FMMT.py b/BaseTools/Source/Python/FMMT/FMMT.py index 7505b6c..d4fa07a 100644 --- a/BaseTools/Source/Python/FMMT/FMMT.py +++ b/BaseTools/Source/Python/FMMT/FMMT.py @@ -49,7 +49,7 @@ def print_banner(): class FMMT():
def __init__(self) -> None:
- self.firmware_packet = {}
+ pass
def SetConfigFilePath(self, configfilepath:str) -> str:
os.environ['FmmtConfPath'] = os.path.abspath(configfilepath)
diff --git a/BaseTools/Source/Python/FMMT/core/BinaryFactoryProduct.py b/BaseTools/Source/Python/FMMT/core/BinaryFactoryProduct.py index 7ebe11d..9dd717c 100644 --- a/BaseTools/Source/Python/FMMT/core/BinaryFactoryProduct.py +++ b/BaseTools/Source/Python/FMMT/core/BinaryFactoryProduct.py @@ -129,7 +129,6 @@ class SectionProduct(BinaryProduct): Section_Info.Data = Whole_Data[Rel_Offset+Section_Info.HeaderLength: Rel_Offset+Section_Info.Size]
Section_Info.DOffset = Section_Offset + Section_Info.HeaderLength + Rel_Whole_Offset
Section_Info.HOffset = Section_Offset + Rel_Whole_Offset
- Section_Info.ROffset = Rel_Offset
if Section_Info.Header.Type == 0:
break
# The final Section in parent Section does not need to add padding, else must be 4-bytes align with parent Section start offset
@@ -173,7 +172,6 @@ class FfsProduct(BinaryProduct): Section_Info.Data = Whole_Data[Rel_Offset+Section_Info.HeaderLength: Rel_Offset+Section_Info.Size]
Section_Info.DOffset = Section_Offset + Section_Info.HeaderLength + Rel_Whole_Offset
Section_Info.HOffset = Section_Offset + Rel_Whole_Offset
- Section_Info.ROffset = Rel_Offset
if Section_Info.Header.Type == 0:
break
# The final Section in Ffs does not need to add padding, else must be 4-bytes align with Ffs start offset
@@ -226,7 +224,6 @@ class FvProduct(BinaryProduct): Ffs_Tree = BIOSTREE(Ffs_Info.Name)
Ffs_Info.HOffset = Ffs_Offset + Rel_Whole_Offset
Ffs_Info.DOffset = Ffs_Offset + Ffs_Info.Header.HeaderLength + Rel_Whole_Offset
- Ffs_Info.ROffset = Rel_Offset
if Ffs_Info.Name == PADVECTOR:
Ffs_Tree.type = FFS_PAD
Ffs_Info.Data = Whole_Data[Rel_Offset+Ffs_Info.Header.HeaderLength: Rel_Offset+Ffs_Info.Size]
@@ -362,15 +359,6 @@ class FdProduct(BinaryProduct): tmp_index += 1
return Fd_Struct
-class ElfSectionProduct(BinaryProduct):
- ## Decompress the compressed section.
- def ParserData(self, Section_Tree, whole_Data: bytes, Rel_Whole_Offset: int=0) -> None:
- pass
- def ParserSectionData(self, Section_Tree, whole_Data: bytes, Rel_Whole_Offset: int=0) -> None:
- pass
- def ParserProgramData(self, Section_Tree, whole_Data: bytes, Rel_Whole_Offset: int=0) -> None:
- pass
-
class ElfProduct(BinaryProduct):
def ParserData(self, ParTree, Whole_Data: bytes, Rel_Whole_Offset: int=0) -> None:
diff --git a/BaseTools/Source/Python/FMMT/core/BiosTree.py b/BaseTools/Source/Python/FMMT/core/BiosTree.py index c5a7b01..d99f964 100644 --- a/BaseTools/Source/Python/FMMT/core/BiosTree.py +++ b/BaseTools/Source/Python/FMMT/core/BiosTree.py @@ -72,36 +72,6 @@ class BIOSTREE: self.Child.insert(pos, newNode)
newNode.Parent = self
- # lastNode.insertRel(newNode)
- def insertRel(self, newNode) -> None:
- if self.Parent:
- parentTree = self.Parent
- new_index = parentTree.Child.index(self) + 1
- parentTree.Child.insert(new_index, newNode)
- self.NextRel = newNode
- newNode.LastRel = self
-
- def deleteNode(self, deletekey: str) -> None:
- FindStatus, DeleteTree = self.FindNode(deletekey)
- if FindStatus:
- parentTree = DeleteTree.Parent
- lastTree = DeleteTree.LastRel
- nextTree = DeleteTree.NextRel
- if parentTree:
- index = parentTree.Child.index(DeleteTree)
- del parentTree.Child[index]
- if lastTree and nextTree:
- lastTree.NextRel = nextTree
- nextTree.LastRel = lastTree
- elif lastTree:
- lastTree.NextRel = None
- elif nextTree:
- nextTree.LastRel = None
- return DeleteTree
- else:
- logger.error('Could not find the target tree')
- return None
-
def FindNode(self, key: str, Findlist: list) -> None:
if self.key == key or (self.Data and self.Data.Name == key) or (self.type == FFS_TREE and self.Data.UiName == key):
Findlist.append(self)
diff --git a/BaseTools/Source/Python/FMMT/core/BiosTreeNode.py b/BaseTools/Source/Python/FMMT/core/BiosTreeNode.py index 5ca4c20..92611f8 100644 --- a/BaseTools/Source/Python/FMMT/core/BiosTreeNode.py +++ b/BaseTools/Source/Python/FMMT/core/BiosTreeNode.py @@ -60,7 +60,6 @@ class ElfNode: self.HeaderLength = len(struct2stream(self.Header))
self.HOffset = 0
self.DOffset = 0
- self.ROffset = 0
self.Data = b''
self.PadData = b''
self.Upld_Info_Align = False
@@ -122,7 +121,6 @@ class FvNode: self.HeaderLength = self.Header.HeaderLength
self.HOffset = 0
self.DOffset = 0
- self.ROffset = 0
self.Data = b''
if self.Header.Signature != 1213613663:
logger.error('Invalid Fv Header! Fv {} signature {} is not "_FVH".'.format(struct2stream(self.Header), self.Header.Signature))
@@ -179,10 +177,8 @@ class FfsNode: self.HeaderLength = self.Header.HeaderLength
self.HOffset = 0
self.DOffset = 0
- self.ROffset = 0
self.Data = b''
self.PadData = b''
- self.SectionMaxAlignment = SECTION_COMMON_ALIGNMENT # 4-align
def ModCheckSum(self) -> None:
HeaderData = struct2stream(self.Header)
@@ -217,13 +213,10 @@ class SectionNode: self.Type = self.Header.Type
self.HOffset = 0
self.DOffset = 0
- self.ROffset = 0
self.Data = b''
self.OriData = b''
- self.OriHeader = b''
self.PadData = b''
self.IsPadSection = False
- self.SectionMaxAlignment = SECTION_COMMON_ALIGNMENT # 4-align
def GetExtHeader(self, Type: int, buffer: bytes, nums: int=0) -> None:
if Type == 0x01:
@@ -244,5 +237,4 @@ class FreeSpaceNode: self.Size = len(buffer)
self.HOffset = 0
self.DOffset = 0
- self.ROffset = 0
self.PadData = b''
|