]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools: change the Division Operator in the expression
authorYunhua Feng <yunhuax.feng@intel.com>
Tue, 14 Aug 2018 07:57:47 +0000 (15:57 +0800)
committerYonghong Zhu <yonghong.zhu@intel.com>
Sat, 13 Oct 2018 01:54:53 +0000 (09:54 +0800)
PEP 238 -- Changing the Division Operator
x/y to return a reasonable approximation of the mathematical result
    of the division ("true division")
x//y to return the floor ("floor division")

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
14 files changed:
BaseTools/Source/Python/AutoGen/AutoGen.py
BaseTools/Source/Python/AutoGen/GenC.py
BaseTools/Source/Python/BPDG/GenVpd.py
BaseTools/Source/Python/Common/Expression.py
BaseTools/Source/Python/Common/Misc.py
BaseTools/Source/Python/GenFds/DataSection.py
BaseTools/Source/Python/GenFds/EfiSection.py
BaseTools/Source/Python/GenFds/FfsInfStatement.py
BaseTools/Source/Python/GenFds/Fv.py
BaseTools/Source/Python/GenFds/FvImageSection.py
BaseTools/Source/Python/GenFds/GenFds.py
BaseTools/Source/Python/GenFds/Region.py
BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py
BaseTools/Source/Python/build/build.py

index ac2c2cda509af41899f11df8d7dffb850c9faad7..2b3f93c3bccb3a1d48fd61b3cbe462e680708c1d 100644 (file)
@@ -3729,7 +3729,7 @@ class ModuleAutoGen(AutoGen):
                         Padding = '0x00, '\r
                         if Unicode:\r
                             Padding = Padding * 2\r
-                            ArraySize = ArraySize / 2\r
+                            ArraySize = ArraySize // 2\r
                         if ArraySize < (len(PcdValue) + 1):\r
                             if Pcd.MaxSizeUserSet:\r
                                 EdkLogger.error("build", AUTOGEN_ERROR,\r
index 067d95473f2d2069e4fb57d74102201e3520d04d..a21880f31777ba5b739e0b989ea189f2ef7b33d4 100644 (file)
@@ -1050,7 +1050,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
                     else:\r
                         NewValue = NewValue + str(ord(Value[Index]) % 0x100) + ', '\r
                 if Unicode:\r
-                    ArraySize = ArraySize / 2\r
+                    ArraySize = ArraySize // 2\r
                 Value = NewValue + '0 }'\r
             if ArraySize < ValueSize:\r
                 if Pcd.MaxSizeUserSet:\r
@@ -1060,7 +1060,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
                 else:\r
                     ArraySize = Pcd.GetPcdSize()\r
                     if Unicode:\r
-                        ArraySize = ArraySize / 2\r
+                        ArraySize = ArraySize // 2\r
             Array = '[%d]' % ArraySize\r
         #\r
         # skip casting for fixed at build since it breaks ARM assembly.\r
@@ -1919,7 +1919,7 @@ def BmpImageDecoder(File, Buffer, PaletteIndex, TransParent):
         else:\r
             ImageBuffer = pack('B', EFI_HII_IIBT_IMAGE_1BIT)\r
         ImageBuffer += pack('B', PaletteIndex)\r
-        Width = (BmpHeader.biWidth + 7)/8\r
+        Width = (BmpHeader.biWidth + 7)//8\r
         if BmpHeader.bfOffBits > BMP_IMAGE_HEADER_STRUCT.size + 2:\r
             PaletteBuffer = Buffer[BMP_IMAGE_HEADER_STRUCT.size + 2 : BmpHeader.bfOffBits]\r
     elif BmpHeader.biBitCount == 4:\r
@@ -1928,7 +1928,7 @@ def BmpImageDecoder(File, Buffer, PaletteIndex, TransParent):
         else:\r
             ImageBuffer = pack('B', EFI_HII_IIBT_IMAGE_4BIT)\r
         ImageBuffer += pack('B', PaletteIndex)\r
-        Width = (BmpHeader.biWidth + 1)/2\r
+        Width = (BmpHeader.biWidth + 1)//2\r
         if BmpHeader.bfOffBits > BMP_IMAGE_HEADER_STRUCT.size + 2:\r
             PaletteBuffer = Buffer[BMP_IMAGE_HEADER_STRUCT.size + 2 : BmpHeader.bfOffBits]\r
     elif BmpHeader.biBitCount == 8:\r
index 28bfde11513bd3ca5d6f28fca69681cb1506eb11..fc47a4b2520f3d05aa437499f75dbee308bc3e49 100644 (file)
@@ -430,7 +430,7 @@ class GenVPD :
                             EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, 'The offset value of PCD %s should be %s-byte aligned.' % (PCD.PcdCName, Alignment))\r
                 else:\r
                     if PCD.PcdOccupySize % Alignment != 0:\r
-                        PCD.PcdOccupySize = (PCD.PcdOccupySize / Alignment + 1) * Alignment\r
+                        PCD.PcdOccupySize = (PCD.PcdOccupySize // Alignment + 1) * Alignment\r
 \r
                 PackSize = PCD.PcdOccupySize\r
                 if PCD._IsBoolean(PCD.PcdValue, PCD.PcdSize):\r
@@ -508,7 +508,7 @@ class GenVPD :
             NowOffset = 0\r
             for Pcd in self.PcdUnknownOffsetList :\r
                 if NowOffset % Pcd.Alignment != 0:\r
-                    NowOffset = (NowOffset/ Pcd.Alignment + 1) * Pcd.Alignment\r
+                    NowOffset = (NowOffset // Pcd.Alignment + 1) * Pcd.Alignment\r
                 Pcd.PcdBinOffset = NowOffset\r
                 Pcd.PcdOffset    = str(hex(Pcd.PcdBinOffset))\r
                 NowOffset       += Pcd.PcdOccupySize\r
@@ -572,7 +572,7 @@ class GenVPD :
                         # Not been fixed\r
                         if eachUnfixedPcd.PcdOffset == '*' :\r
                             if LastOffset % eachUnfixedPcd.Alignment != 0:\r
-                                LastOffset = (LastOffset / eachUnfixedPcd.Alignment + 1) * eachUnfixedPcd.Alignment\r
+                                LastOffset = (LastOffset // eachUnfixedPcd.Alignment + 1) * eachUnfixedPcd.Alignment\r
                             # The offset un-fixed pcd can write into this free space\r
                             if needFixPcdSize <= (NowOffset - LastOffset) :\r
                                 # Change the offset value of un-fixed pcd\r
@@ -626,7 +626,7 @@ class GenVPD :
 \r
             NeedFixPcd.PcdBinOffset = LastPcd.PcdBinOffset + LastPcd.PcdOccupySize\r
             if NeedFixPcd.PcdBinOffset % NeedFixPcd.Alignment != 0:\r
-                NeedFixPcd.PcdBinOffset = (NeedFixPcd.PcdBinOffset / NeedFixPcd.Alignment + 1) * NeedFixPcd.Alignment\r
+                NeedFixPcd.PcdBinOffset = (NeedFixPcd.PcdBinOffset // NeedFixPcd.Alignment + 1) * NeedFixPcd.Alignment\r
 \r
             NeedFixPcd.PcdOffset    = str(hex(NeedFixPcd.PcdBinOffset))\r
 \r
index 9a98236a8c3414326739423ea04e3fd1a479cd61..5e4e66a10e7ba05c01e379c6a11055ea5a5cc32f 100644 (file)
@@ -425,6 +425,13 @@ class ValueExpression(BaseExpression):
                 else:\r
                     Val = Val3\r
                 continue\r
+            #\r
+            # PEP 238 -- Changing the Division Operator\r
+            # x/y to return a reasonable approximation of the mathematical result of the division ("true division")\r
+            # x//y to return the floor ("floor division")\r
+            #\r
+            if Op == '/':\r
+                Op = '//'\r
             try:\r
                 Val = self.Eval(Op, Val, EvalFunc())\r
             except WrnExpression as Warn:\r
@@ -898,7 +905,7 @@ class ValueExpressionEx(ValueExpression):
                     if TmpValue.bit_length() == 0:\r
                         PcdValue = '{0x00}'\r
                     else:\r
-                        for I in range((TmpValue.bit_length() + 7) / 8):\r
+                        for I in range((TmpValue.bit_length() + 7) // 8):\r
                             TmpList.append('0x%02x' % ((TmpValue >> I * 8) & 0xff))\r
                         PcdValue = '{' + ', '.join(TmpList) + '}'\r
                 except:\r
index ea0e62245fb1e04fedd14a5c852360fc976df54b..71ab6da52989d25dd27abd0f2395faf5e01e67a6 100644 (file)
@@ -1310,7 +1310,7 @@ def ParseDevPathValue (Value):
 \r
 def ParseFieldValue (Value):\r
     if isinstance(Value, type(0)):\r
-        return Value, (Value.bit_length() + 7) / 8\r
+        return Value, (Value.bit_length() + 7) // 8\r
     if not isinstance(Value, type('')):\r
         raise BadExpression('Type %s is %s' %(Value, type(Value)))\r
     Value = Value.strip()\r
@@ -1431,12 +1431,12 @@ def ParseFieldValue (Value):
             raise BadExpression("invalid hex value: %s" % Value)\r
         if Value == 0:\r
             return 0, 1\r
-        return Value, (Value.bit_length() + 7) / 8\r
+        return Value, (Value.bit_length() + 7) // 8\r
     if Value[0].isdigit():\r
         Value = int(Value, 10)\r
         if Value == 0:\r
             return 0, 1\r
-        return Value, (Value.bit_length() + 7) / 8\r
+        return Value, (Value.bit_length() + 7) // 8\r
     if Value.lower() == 'true':\r
         return 1, 1\r
     if Value.lower() == 'false':\r
index 182ea4f3da80bd3c1051f3bb4e50dbe39cdcfa71..3302c140917f570512e5b884d3b905699b96e818 100644 (file)
@@ -87,9 +87,9 @@ class DataSection (DataSectionClassObject):
             if ImageObj.SectionAlignment < 0x400:\r
                 self.Alignment = str (ImageObj.SectionAlignment)\r
             elif ImageObj.SectionAlignment < 0x100000:\r
-                self.Alignment = str (ImageObj.SectionAlignment / 0x400) + 'K'\r
+                self.Alignment = str (ImageObj.SectionAlignment // 0x400) + 'K'\r
             else:\r
-                self.Alignment = str (ImageObj.SectionAlignment / 0x100000) + 'M'\r
+                self.Alignment = str (ImageObj.SectionAlignment // 0x100000) + 'M'\r
 \r
         NoStrip = True\r
         if self.SecType in (BINARY_FILE_TYPE_TE, BINARY_FILE_TYPE_PE32):\r
index fa2148ec7b2871d93603038d5fc63a482bf5e6ab..9fe7db3f46e034903c5d710a4e7f187d1f210b92 100644 (file)
@@ -247,9 +247,9 @@ class EfiSection (EfiSectionClassObject):
                         if ImageObj.SectionAlignment < 0x400:\r
                             Align = str (ImageObj.SectionAlignment)\r
                         elif ImageObj.SectionAlignment < 0x100000:\r
-                            Align = str (ImageObj.SectionAlignment / 0x400) + 'K'\r
+                            Align = str (ImageObj.SectionAlignment // 0x400) + 'K'\r
                         else:\r
-                            Align = str (ImageObj.SectionAlignment / 0x100000) + 'M'\r
+                            Align = str (ImageObj.SectionAlignment // 0x100000) + 'M'\r
 \r
                     if File[(len(File)-4):] == '.efi':\r
                         MapFile = File.replace('.efi', '.map')\r
index e9dd5bc2c584e8cb497c4f3b6e01f1d0a1fc4833..9ef03edeccf184755673f4b781c089799918b516 100644 (file)
@@ -770,9 +770,9 @@ class FfsInfStatement(FfsInfStatementClassObject):
                     if ImageObj.SectionAlignment < 0x400:\r
                         self.Alignment = str (ImageObj.SectionAlignment)\r
                     elif ImageObj.SectionAlignment < 0x100000:\r
-                        self.Alignment = str (ImageObj.SectionAlignment / 0x400) + 'K'\r
+                        self.Alignment = str (ImageObj.SectionAlignment // 0x400) + 'K'\r
                     else:\r
-                        self.Alignment = str (ImageObj.SectionAlignment / 0x100000) + 'M'\r
+                        self.Alignment = str (ImageObj.SectionAlignment // 0x100000) + 'M'\r
 \r
                 if not NoStrip:\r
                     FileBeforeStrip = os.path.join(self.OutputPath, ModuleName + '.reloc')\r
@@ -812,9 +812,9 @@ class FfsInfStatement(FfsInfStatementClassObject):
                 if ImageObj.SectionAlignment < 0x400:\r
                     self.Alignment = str (ImageObj.SectionAlignment)\r
                 elif ImageObj.SectionAlignment < 0x100000:\r
-                    self.Alignment = str (ImageObj.SectionAlignment / 0x400) + 'K'\r
+                    self.Alignment = str (ImageObj.SectionAlignment // 0x400) + 'K'\r
                 else:\r
-                    self.Alignment = str (ImageObj.SectionAlignment / 0x100000) + 'M'\r
+                    self.Alignment = str (ImageObj.SectionAlignment // 0x100000) + 'M'\r
 \r
             if not NoStrip:\r
                 FileBeforeStrip = os.path.join(self.OutputPath, ModuleName + '.reloc')\r
index 7653cf692ba42c805463162f0dc928d8f50d9f1d..3c3cd0b308042358984aff0a6a3f668a10f9762a 100644 (file)
@@ -212,9 +212,9 @@ class FV (FvClassObject):
                         #The max alignment supported by FFS is 16M.\r
                             self.FvAlignment = "16M"\r
                         else:\r
-                            self.FvAlignment = str(FvAlignmentValue / 0x100000) + "M"\r
+                            self.FvAlignment = str(FvAlignmentValue // 0x100000) + "M"\r
                     else:\r
-                        self.FvAlignment = str(FvAlignmentValue / 0x400) + "K"\r
+                        self.FvAlignment = str(FvAlignmentValue // 0x400) + "K"\r
                 else:\r
                     # FvAlignmentValue is less than 1K\r
                     self.FvAlignment = str (FvAlignmentValue)\r
index 5f1b42b078acd337ea6434743b7a21555fda78b8..5cc5b969fd52c3add6d9bba7842932792cda8bf4 100644 (file)
@@ -70,7 +70,7 @@ class FvImageSection(FvImageSectionClassObject):
                     # PI FvHeader is 0x48 byte\r
                     FvHeaderBuffer = FvFileObj.read(0x48)\r
                     # FV alignment position.\r
-                    FvAlignmentValue = 1 << (ord (FvHeaderBuffer[0x2E]) & 0x1F)\r
+                    FvAlignmentValue = 1 << (FvHeaderBuffer[0x2E] & 0x1F)\r
                     FvFileObj.close()\r
                 if FvAlignmentValue > MaxFvAlignment:\r
                     MaxFvAlignment = FvAlignmentValue\r
@@ -86,9 +86,9 @@ class FvImageSection(FvImageSectionClassObject):
                     if MaxFvAlignment >= 0x1000000:\r
                         self.Alignment = "16M"\r
                     else:\r
-                        self.Alignment = str(MaxFvAlignment / 0x100000) + "M"\r
+                        self.Alignment = str(MaxFvAlignment // 0x100000) + "M"\r
                 else:\r
-                    self.Alignment = str (MaxFvAlignment / 0x400) + "K"\r
+                    self.Alignment = str (MaxFvAlignment // 0x400) + "K"\r
             else:\r
                 # MaxFvAlignment is less than 1K\r
                 self.Alignment = str (MaxFvAlignment)\r
@@ -126,9 +126,9 @@ class FvImageSection(FvImageSectionClassObject):
                                 if FvAlignmentValue >= 0x1000000:\r
                                     self.Alignment = "16M"\r
                                 else:\r
-                                    self.Alignment = str(FvAlignmentValue / 0x100000) + "M"\r
+                                    self.Alignment = str(FvAlignmentValue // 0x100000) + "M"\r
                             else:\r
-                                self.Alignment = str (FvAlignmentValue / 0x400) + "K"\r
+                                self.Alignment = str (FvAlignmentValue // 0x400) + "K"\r
                         else:\r
                             # FvAlignmentValue is less than 1K\r
                             self.Alignment = str (FvAlignmentValue)\r
index e135139bc19fae2c7ea1b86fe43c91f24f759d37..ed1bd33fdbb3246c23f221aee88d53d421906b42 100644 (file)
@@ -684,7 +684,7 @@ class GenFds :
                                     F.read()\r
                                     length = F.tell()\r
                                     F.seek(4)\r
-                                    TmpStr = unpack('%dh' % ((length - 4) / 2), F.read())\r
+                                    TmpStr = unpack('%dh' % ((length - 4) // 2), F.read())\r
                                     Name = ''.join(chr(c) for c in TmpStr[:-1])\r
                         else:\r
                             FileList = []\r
index cd81c6df684c3f0a0ede358d222ded04740b9b31..31c65a32a12431e30e1433e10b4a6fc158cfc5cb 100644 (file)
@@ -296,7 +296,7 @@ class Region(RegionClassObject):
             else:\r
                 # region ended within current blocks\r
                 if self.Offset + self.Size <= End:\r
-                    ExpectedList.append((BlockSize, (RemindingSize + BlockSize - 1) / BlockSize))\r
+                    ExpectedList.append((BlockSize, (RemindingSize + BlockSize - 1) // BlockSize))\r
                     break\r
                 # region not ended yet\r
                 else:\r
@@ -305,7 +305,7 @@ class Region(RegionClassObject):
                         UsedBlockNum = BlockNum\r
                     # region started in middle of current blocks\r
                     else:\r
-                        UsedBlockNum = (End - self.Offset) / BlockSize\r
+                        UsedBlockNum = (End - self.Offset) // BlockSize\r
                     Start = End\r
                     ExpectedList.append((BlockSize, UsedBlockNum))\r
                     RemindingSize -= BlockSize * UsedBlockNum\r
index 8e243aea9603f474193eaea0192c1a3b07dc4575..fb99302933f44f6f70e47a887561d55d298d419d 100644 (file)
@@ -133,7 +133,7 @@ def PatchBinaryFile(FileName, ValueOffset, TypeName, ValueString, MaxSize=0):
         #\r
         for Index in range(ValueLength):\r
             ByteList[ValueOffset + Index] = ValueNumber % 0x100\r
-            ValueNumber = ValueNumber / 0x100\r
+            ValueNumber = ValueNumber // 0x100\r
     elif TypeName == TAB_VOID:\r
         ValueString = SavedStr\r
         if ValueString.startswith('L"'):\r
index ad30c652da5825678fbc2b01d7b8c8adabdbf31f..1a2139569924b23027ecfecec5d1e10c2a92dea4 100644 (file)
@@ -724,7 +724,7 @@ class PeImageInfo():
         self.OutputDir        = OutputDir\r
         self.DebugDir         = DebugDir\r
         self.Image            = ImageClass\r
-        self.Image.Size       = (self.Image.Size / 0x1000 + 1) * 0x1000\r
+        self.Image.Size       = (self.Image.Size // 0x1000 + 1) * 0x1000\r
 \r
 ## The class implementing the EDK2 build process\r
 #\r
@@ -1597,7 +1597,7 @@ class Build():
                         RtModuleList[Module.MetaFile] = ImageInfo\r
                         #IPF runtime driver needs to be at 2 page alignment.\r
                         if IsIpfPlatform and ImageInfo.Image.Size % 0x2000 != 0:\r
-                            ImageInfo.Image.Size = (ImageInfo.Image.Size / 0x2000 + 1) * 0x2000\r
+                            ImageInfo.Image.Size = (ImageInfo.Image.Size // 0x2000 + 1) * 0x2000\r
                         RtSize += ImageInfo.Image.Size\r
                     elif Module.ModuleType in [SUP_MODULE_SMM_CORE, SUP_MODULE_DXE_SMM_DRIVER, SUP_MODULE_MM_STANDALONE, SUP_MODULE_MM_CORE_STANDALONE]:\r
                         SmmModuleList[Module.MetaFile] = ImageInfo\r
@@ -1666,21 +1666,21 @@ class Build():
             for PcdInfo in PcdTable:\r
                 ReturnValue = 0\r
                 if PcdInfo[0] == TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_PEI_PAGE_SIZE:\r
-                    ReturnValue, ErrorInfo = PatchBinaryFile (EfiImage, PcdInfo[1], TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_PEI_PAGE_SIZE_DATA_TYPE, str (PeiSize / 0x1000))\r
+                    ReturnValue, ErrorInfo = PatchBinaryFile (EfiImage, PcdInfo[1], TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_PEI_PAGE_SIZE_DATA_TYPE, str (PeiSize // 0x1000))\r
                 elif PcdInfo[0] == TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_DXE_PAGE_SIZE:\r
-                    ReturnValue, ErrorInfo = PatchBinaryFile (EfiImage, PcdInfo[1], TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_DXE_PAGE_SIZE_DATA_TYPE, str (BtSize / 0x1000))\r
+                    ReturnValue, ErrorInfo = PatchBinaryFile (EfiImage, PcdInfo[1], TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_DXE_PAGE_SIZE_DATA_TYPE, str (BtSize // 0x1000))\r
                 elif PcdInfo[0] == TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_RUNTIME_PAGE_SIZE:\r
-                    ReturnValue, ErrorInfo = PatchBinaryFile (EfiImage, PcdInfo[1], TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_RUNTIME_PAGE_SIZE_DATA_TYPE, str (RtSize / 0x1000))\r
+                    ReturnValue, ErrorInfo = PatchBinaryFile (EfiImage, PcdInfo[1], TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_RUNTIME_PAGE_SIZE_DATA_TYPE, str (RtSize // 0x1000))\r
                 elif PcdInfo[0] == TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_SMM_PAGE_SIZE and len (SmmModuleList) > 0:\r
-                    ReturnValue, ErrorInfo = PatchBinaryFile (EfiImage, PcdInfo[1], TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_SMM_PAGE_SIZE_DATA_TYPE, str (SmmSize / 0x1000))\r
+                    ReturnValue, ErrorInfo = PatchBinaryFile (EfiImage, PcdInfo[1], TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_SMM_PAGE_SIZE_DATA_TYPE, str (SmmSize // 0x1000))\r
                 if ReturnValue != 0:\r
                     EdkLogger.error("build", PARAMETER_INVALID, "Patch PCD value failed", ExtraData=ErrorInfo)\r
 \r
-        MapBuffer.write('PEI_CODE_PAGE_NUMBER      = 0x%x\n' % (PeiSize / 0x1000))\r
-        MapBuffer.write('BOOT_CODE_PAGE_NUMBER     = 0x%x\n' % (BtSize / 0x1000))\r
-        MapBuffer.write('RUNTIME_CODE_PAGE_NUMBER  = 0x%x\n' % (RtSize / 0x1000))\r
+        MapBuffer.write('PEI_CODE_PAGE_NUMBER      = 0x%x\n' % (PeiSize // 0x1000))\r
+        MapBuffer.write('BOOT_CODE_PAGE_NUMBER     = 0x%x\n' % (BtSize // 0x1000))\r
+        MapBuffer.write('RUNTIME_CODE_PAGE_NUMBER  = 0x%x\n' % (RtSize // 0x1000))\r
         if len (SmmModuleList) > 0:\r
-            MapBuffer.write('SMM_CODE_PAGE_NUMBER      = 0x%x\n' % (SmmSize / 0x1000))\r
+            MapBuffer.write('SMM_CODE_PAGE_NUMBER      = 0x%x\n' % (SmmSize // 0x1000))\r
 \r
         PeiBaseAddr = TopMemoryAddress - RtSize - BtSize\r
         BtBaseAddr  = TopMemoryAddress - RtSize\r