From db52c7f755885d2f42279ba0d967c5d646d017b1 Mon Sep 17 00:00:00 2001 From: Michael D Kinney Date: Sun, 5 Dec 2021 14:33:53 -0800 Subject: [PATCH] MdeModulePkg: Change complex DEBUG_CODE() to DEBUG_CODE_BEGIN/END() REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3767 Update use of DEBUG_CODE(Expression) if Expression is a complex code block with if/while/for/case statements that use {}. Cc: Andrew Fish Cc: Leif Lindholm Cc: Michael Kubacki Signed-off-by: Michael D Kinney Reviewed-by: Liming Gao --- .../Application/CapsuleApp/CapsuleOnDisk.c | 8 ++++---- .../Bus/Pci/PciHostBridgeDxe/PciHostBridge.c | 8 ++++---- MdeModulePkg/Core/Dxe/Gcd/Gcd.c | 8 ++++---- MdeModulePkg/Core/PiSmmCore/SmramProfileRecord.c | 4 ++-- .../Library/DxeCapsuleLibFmp/CapsuleOnDisk.c | 16 ++++++++-------- MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c | 4 ++-- .../Library/UefiBootManagerLib/BmDriverHealth.c | 4 ++-- .../VarCheckHiiLib/VarCheckHiiGenFromFv.c | 4 ++-- .../BootScriptExecutorDxe/IA32/SetIdtEntry.c | 5 ++--- .../Acpi/BootScriptExecutorDxe/X64/SetIdtEntry.c | 4 ++-- MdeModulePkg/Universal/BdsDxe/BdsEntry.c | 4 ++-- .../CapsuleOnDiskLoadPei/CapsuleOnDiskLoadPei.c | 4 ++-- .../Console/GraphicsConsoleDxe/GraphicsConsole.c | 4 ++-- .../Universal/Console/TerminalDxe/Terminal.c | 5 ++--- .../SecurityStubDxe/Defer3rdPartyImageLoad.c | 4 ++-- MdeModulePkg/Universal/Variable/Pei/Variable.c | 4 ++-- .../Universal/Variable/RuntimeDxe/Variable.c | 8 ++++---- 17 files changed, 48 insertions(+), 50 deletions(-) diff --git a/MdeModulePkg/Application/CapsuleApp/CapsuleOnDisk.c b/MdeModulePkg/Application/CapsuleApp/CapsuleOnDisk.c index 712cf2e1f7..77f9a1571f 100644 --- a/MdeModulePkg/Application/CapsuleApp/CapsuleOnDisk.c +++ b/MdeModulePkg/Application/CapsuleApp/CapsuleOnDisk.c @@ -336,7 +336,7 @@ GetEfiSysPartitionFromBootOptionFilePath ( break; } - DEBUG_CODE ( + DEBUG_CODE_BEGIN (); CHAR16 *DevicePathStr; DevicePathStr = ConvertDevicePathToText (CurFullPath, TRUE, TRUE); @@ -344,7 +344,7 @@ GetEfiSysPartitionFromBootOptionFilePath ( DEBUG ((DEBUG_INFO, "Full device path %s\n", DevicePathStr)); FreePool (DevicePathStr); } - ); + DEBUG_CODE_END (); Status = GetEfiSysPartitionFromDevPath (CurFullPath, &FsFullPath, Fs); } while (EFI_ERROR (Status)); @@ -468,7 +468,7 @@ GetUpdateFileSystem ( continue; } - DEBUG_CODE ( + DEBUG_CODE_BEGIN (); CHAR16 *DevicePathStr; DevicePathStr = ConvertDevicePathToText (DevicePath, TRUE, TRUE); @@ -478,7 +478,7 @@ GetUpdateFileSystem ( } else { DEBUG ((DEBUG_INFO, "DevicePathToStr failed\n")); } - ); + DEBUG_CODE_END (); Status = GetEfiSysPartitionFromBootOptionFilePath (DevicePath, &FullPath, Fs); if (!EFI_ERROR (Status)) { diff --git a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c b/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c index a71518652d..5c8f0f46a1 100644 --- a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c +++ b/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c @@ -167,7 +167,7 @@ AddIoSpace ( } } - DEBUG_CODE ( + DEBUG_CODE_BEGIN (); // // Make sure there are adjacent descriptors covering [Base, Base + Length). // It is possible that they have not been merged; merging can be prevented @@ -184,7 +184,7 @@ AddIoSpace ( ASSERT_EFI_ERROR (CheckStatus); ASSERT (Descriptor.GcdIoType == EfiGcdIoTypeIo); } - ); + DEBUG_CODE_END (); FreeIoSpaceMap: FreePool (IoSpaceMap); @@ -315,7 +315,7 @@ AddMemoryMappedIoSpace ( } } - DEBUG_CODE ( + DEBUG_CODE_BEGIN (); // // Make sure there are adjacent descriptors covering [Base, Base + Length). // It is possible that they have not been merged; merging can be prevented @@ -333,7 +333,7 @@ AddMemoryMappedIoSpace ( ASSERT (Descriptor.GcdMemoryType == EfiGcdMemoryTypeMemoryMappedIo); ASSERT ((Descriptor.Capabilities & Capabilities) == Capabilities); } - ); + DEBUG_CODE_END (); FreeMemorySpaceMap: FreePool (MemorySpaceMap); diff --git a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c index 6518921516..2224aae281 100644 --- a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c +++ b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c @@ -141,7 +141,7 @@ CoreDumpGcdMemorySpaceMap ( BOOLEAN InitialMap ) { - DEBUG_CODE ( + DEBUG_CODE_BEGIN (); EFI_STATUS Status; UINTN NumberOfDescriptors; EFI_GCD_MEMORY_SPACE_DESCRIPTOR *MemorySpaceMap; @@ -167,7 +167,7 @@ CoreDumpGcdMemorySpaceMap ( } DEBUG ((DEBUG_GCD, "\n")); FreePool (MemorySpaceMap); - ); + DEBUG_CODE_END (); } /** @@ -183,7 +183,7 @@ CoreDumpGcdIoSpaceMap ( BOOLEAN InitialMap ) { - DEBUG_CODE ( + DEBUG_CODE_BEGIN (); EFI_STATUS Status; UINTN NumberOfDescriptors; EFI_GCD_IO_SPACE_DESCRIPTOR *IoSpaceMap; @@ -208,7 +208,7 @@ CoreDumpGcdIoSpaceMap ( } DEBUG ((DEBUG_GCD, "\n")); FreePool (IoSpaceMap); - ); + DEBUG_CODE_END (); } /** diff --git a/MdeModulePkg/Core/PiSmmCore/SmramProfileRecord.c b/MdeModulePkg/Core/PiSmmCore/SmramProfileRecord.c index 5b8ce55347..002a8e4360 100644 --- a/MdeModulePkg/Core/PiSmmCore/SmramProfileRecord.c +++ b/MdeModulePkg/Core/PiSmmCore/SmramProfileRecord.c @@ -2734,12 +2734,12 @@ DumpSmramInfo ( VOID ) { - DEBUG_CODE ( + DEBUG_CODE_BEGIN (); if (IS_SMRAM_PROFILE_ENABLED) { DumpSmramProfile (); DumpFreePagesList (); DumpFreePoolList (); DumpSmramRange (); } - ); + DEBUG_CODE_END (); } diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/CapsuleOnDisk.c b/MdeModulePkg/Library/DxeCapsuleLibFmp/CapsuleOnDisk.c index 814c5400fe..060abef3ab 100644 --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/CapsuleOnDisk.c +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/CapsuleOnDisk.c @@ -489,7 +489,7 @@ GetEfiSysPartitionFromActiveBootOption( continue; } - DEBUG_CODE ( + DEBUG_CODE_BEGIN (); CHAR16 *DevicePathStr; DevicePathStr = ConvertDevicePathToText(DevicePath, TRUE, TRUE); @@ -499,7 +499,7 @@ GetEfiSysPartitionFromActiveBootOption( } else { DEBUG((DEBUG_INFO, "DevicePathToStr failed\n")); } - ); + DEBUG_CODE_END (); CurFullPath = NULL; // @@ -521,7 +521,7 @@ GetEfiSysPartitionFromActiveBootOption( break; } - DEBUG_CODE ( + DEBUG_CODE_BEGIN (); CHAR16 *DevicePathStr1; DevicePathStr1 = ConvertDevicePathToText(CurFullPath, TRUE, TRUE); @@ -529,7 +529,7 @@ GetEfiSysPartitionFromActiveBootOption( DEBUG((DEBUG_INFO, "Full device path %s\n", DevicePathStr1)); FreePool(DevicePathStr1); } - ); + DEBUG_CODE_END (); // // Make sure the boot option device path connected. @@ -587,7 +587,7 @@ GetEfiSysPartitionFromActiveBootOption( Status = EFI_NOT_FOUND; } - DEBUG_CODE ( + DEBUG_CODE_BEGIN (); CHAR16 *DevicePathStr2; if (*FsHandle != NULL) { DevicePathStr2 = ConvertDevicePathToText(CurFullPath, TRUE, TRUE); @@ -598,7 +598,7 @@ GetEfiSysPartitionFromActiveBootOption( } else { DEBUG((DEBUG_INFO, "Failed to found Active EFI System Partion\n")); } - ); + DEBUG_CODE_END (); if (CurFullPath != NULL) { FreePool(CurFullPath); @@ -990,13 +990,13 @@ GetFileImageInAlphabetFromDir( FileCount++; } - DEBUG_CODE ( + DEBUG_CODE_BEGIN (); for (Link = FileInfoList.ForwardLink; Link != &FileInfoList; Link = Link->ForwardLink) { FileInfoEntry = CR (Link, FILE_INFO_ENTRY, Link, FILE_INFO_SIGNATURE); FileInfo = FileInfoEntry->FileInfo; DEBUG((DEBUG_INFO, "Successfully read capsule file %s from disk.\n", FileInfo->FileName)); } - ); + DEBUG_CODE_END (); EXIT: diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c index a862e04a89..a7261d64f0 100644 --- a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c @@ -1387,7 +1387,7 @@ BmExpandLoadFile ( // FileBuffer = AllocateReservedPages (EFI_SIZE_TO_PAGES (BufferSize)); if (FileBuffer == NULL) { - DEBUG_CODE ( + DEBUG_CODE_BEGIN (); EFI_DEVICE_PATH *LoadFilePath; CHAR16 *LoadFileText; CHAR16 *FileText; @@ -1417,7 +1417,7 @@ BmExpandLoadFile ( if (LoadFileText != NULL) { FreePool (LoadFileText); } - ); + DEBUG_CODE_END (); return NULL; } diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmDriverHealth.c b/MdeModulePkg/Library/UefiBootManagerLib/BmDriverHealth.c index 2a850f2953..eacd45439b 100644 --- a/MdeModulePkg/Library/UefiBootManagerLib/BmDriverHealth.c +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmDriverHealth.c @@ -545,7 +545,7 @@ BmRepairAllControllers ( EfiBootManagerFreeDriverHealthInfo (DriverHealthInfo, Count); - DEBUG_CODE ( + DEBUG_CODE_BEGIN (); CHAR16 *ControllerName; DriverHealthInfo = EfiBootManagerGetDriverHealthInfo (&Count); @@ -567,7 +567,7 @@ BmRepairAllControllers ( } } EfiBootManagerFreeDriverHealthInfo (DriverHealthInfo, Count); - ); + DEBUG_CODE_END (); if (ReconnectRequired) { if (ReconnectRepairCount < MAX_RECONNECT_REPAIR) { diff --git a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGenFromFv.c b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGenFromFv.c index f32499e34b..6bac4bce9d 100644 --- a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGenFromFv.c +++ b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGenFromFv.c @@ -286,7 +286,7 @@ ParseFv ( ); ASSERT_EFI_ERROR (Status); - DEBUG_CODE ( + DEBUG_CODE_BEGIN (); EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *Fvb2; EFI_PHYSICAL_ADDRESS FvAddress; UINT64 FvSize; @@ -303,7 +303,7 @@ ParseFv ( FvSize = ((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) FvAddress)->FvLength; DEBUG ((DEBUG_INFO , "FvSize - 0x%08x\n", FvSize)); } - ); + DEBUG_CODE_END (); if (ScanAll) { // diff --git a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/IA32/SetIdtEntry.c b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/IA32/SetIdtEntry.c index 1e3c5b8499..45c9b667cb 100644 --- a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/IA32/SetIdtEntry.c +++ b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/IA32/SetIdtEntry.c @@ -38,7 +38,7 @@ SetIdtEntry ( Status = InitializeCpuExceptionHandlers (NULL); ASSERT_EFI_ERROR (Status); - DEBUG_CODE ( + DEBUG_CODE_BEGIN (); // // Update IDT entry INT3 if the instruction is valid in it // @@ -51,6 +51,5 @@ SetIdtEntry ( IdtEntry->Bits.GateType = IA32_IDT_GATE_TYPE_INTERRUPT_32; IdtEntry->Bits.OffsetHigh = (UINT16)(S3DebugBuffer >> 16); } - ); + DEBUG_CODE_END (); } - diff --git a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/SetIdtEntry.c b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/SetIdtEntry.c index 0d448cc60e..afb2d5c404 100644 --- a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/SetIdtEntry.c +++ b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/SetIdtEntry.c @@ -149,7 +149,7 @@ SetIdtEntry ( Status = InitializeCpuExceptionHandlers (NULL); ASSERT_EFI_ERROR (Status); - DEBUG_CODE ( + DEBUG_CODE_BEGIN (); // // Update IDT entry INT3 if the instruction is valid in it // @@ -164,7 +164,7 @@ SetIdtEntry ( IdtEntry->Bits.OffsetUpper = (UINT32)(S3DebugBuffer >> 32); IdtEntry->Bits.Reserved_1 = 0; } - ); + DEBUG_CODE_END (); // // If both BIOS and OS wants long mode waking vector, diff --git a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c index 4b10567eb3..f70531638d 100644 --- a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c +++ b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c @@ -941,7 +941,7 @@ BdsEntry ( OsIndication = 0; } - DEBUG_CODE ( + DEBUG_CODE_BEGIN (); EFI_BOOT_MANAGER_LOAD_OPTION_TYPE LoadOptionType; DEBUG ((DEBUG_INFO, "[Bds]OsIndication: %016x\n", OsIndication)); DEBUG ((DEBUG_INFO, "[Bds]=============Begin Load Options Dumping ...=============\n")); @@ -963,7 +963,7 @@ BdsEntry ( EfiBootManagerFreeLoadOptions (LoadOptions, LoadOptionCount); } DEBUG ((DEBUG_INFO, "[Bds]=============End Load Options Dumping=============\n")); - ); + DEBUG_CODE_END (); // // BootManagerMenu doesn't contain the correct information when return status is EFI_NOT_FOUND. diff --git a/MdeModulePkg/Universal/CapsuleOnDiskLoadPei/CapsuleOnDiskLoadPei.c b/MdeModulePkg/Universal/CapsuleOnDiskLoadPei/CapsuleOnDiskLoadPei.c index e9b1250082..aedbc663b3 100644 --- a/MdeModulePkg/Universal/CapsuleOnDiskLoadPei/CapsuleOnDiskLoadPei.c +++ b/MdeModulePkg/Universal/CapsuleOnDiskLoadPei/CapsuleOnDiskLoadPei.c @@ -282,7 +282,7 @@ InitializeCapsuleOnDiskLoad ( return EFI_ABORTED; } - DEBUG_CODE ( + DEBUG_CODE_BEGIN (); VOID *CapsuleOnDiskModePpi; if (!IsCapsuleOnDiskMode()){ @@ -302,7 +302,7 @@ InitializeCapsuleOnDiskLoad ( DEBUG((DEBUG_ERROR, "Locate CapsuleOnDiskModePpi error %x\n", Status)); return Status; } - ); + DEBUG_CODE_END (); Status = PeiServicesInstallPpi (&mCapsuleOnDiskPpiList); ASSERT_EFI_ERROR (Status); diff --git a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c index 838c3337c7..50c4d71005 100644 --- a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c +++ b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c @@ -335,12 +335,12 @@ InitializeGraphicsConsoleTextMode ( } } - DEBUG_CODE ( + DEBUG_CODE_BEGIN (); for (Index = 0; Index < ValidCount; Index++) { DEBUG ((DEBUG_INFO, "Graphics - Mode %d, Column = %d, Row = %d\n", Index, NewModeBuffer[Index].Columns, NewModeBuffer[Index].Rows)); } - ); + DEBUG_CODE_END (); // // Return valid mode count and mode information buffer. diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c index a98b690c8b..89d6e7237d 100644 --- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c +++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c @@ -327,13 +327,13 @@ InitializeTerminalConsoleTextMode ( } *TextModeCount = ARRAY_SIZE (mTerminalConsoleModeData); - DEBUG_CODE ( + DEBUG_CODE_BEGIN (); INT32 Index; for (Index = 0; Index < *TextModeCount; Index++) { DEBUG ((DEBUG_INFO, "Terminal - Mode %d, Column = %d, Row = %d\n", Index, TextModeData[Index].Columns, TextModeData[Index].Rows)); } - ); + DEBUG_CODE_END (); return TextModeData; } @@ -1380,4 +1380,3 @@ IsHotPlugDevice ( return FALSE; } - diff --git a/MdeModulePkg/Universal/SecurityStubDxe/Defer3rdPartyImageLoad.c b/MdeModulePkg/Universal/SecurityStubDxe/Defer3rdPartyImageLoad.c index 6a5f4a3b99..dfa680b035 100644 --- a/MdeModulePkg/Universal/SecurityStubDxe/Defer3rdPartyImageLoad.c +++ b/MdeModulePkg/Universal/SecurityStubDxe/Defer3rdPartyImageLoad.c @@ -330,7 +330,7 @@ Defer3rdPartyImageLoad ( ImageInfo = LookupImage (File, BootPolicy); - DEBUG_CODE ( + DEBUG_CODE_BEGIN (); CHAR16 *DevicePathStr; DevicePathStr = ConvertDevicePathToText (File, FALSE, FALSE); DEBUG (( @@ -342,7 +342,7 @@ Defer3rdPartyImageLoad ( if (DevicePathStr != NULL) { FreePool (DevicePathStr); } - ); + DEBUG_CODE_END (); if (mEndOfDxe) { mImageLoadedAfterEndOfDxe = TRUE; diff --git a/MdeModulePkg/Universal/Variable/Pei/Variable.c b/MdeModulePkg/Universal/Variable/Pei/Variable.c index 468b73215b..7e4fa60a78 100644 --- a/MdeModulePkg/Universal/Variable/Pei/Variable.c +++ b/MdeModulePkg/Universal/Variable/Pei/Variable.c @@ -512,7 +512,7 @@ GetHobVariableStore ( // // Make sure there is no more than one Variable HOB. // - DEBUG_CODE ( + DEBUG_CODE_BEGIN (); GuidHob = GetFirstGuidHob (&gEfiAuthenticatedVariableGuid); if (GuidHob != NULL) { if ((GetNextGuidHob (&gEfiAuthenticatedVariableGuid, GET_NEXT_HOB (GuidHob)) != NULL)) { @@ -531,7 +531,7 @@ GetHobVariableStore ( } } } - ); + DEBUG_CODE_END (); GuidHob = GetFirstGuidHob (&gEfiAuthenticatedVariableGuid); if (GuidHob != NULL) { diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c index 5115bcf816..adb3e97207 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c @@ -280,7 +280,7 @@ RecordVarErrorFlag ( VAR_ERROR_FLAG *VarErrFlag; VAR_ERROR_FLAG TempFlag; - DEBUG_CODE ( + DEBUG_CODE_BEGIN (); DEBUG ((DEBUG_ERROR, "RecordVarErrorFlag (0x%02x) %s:%g - 0x%08x - 0x%x\n", Flag, VariableName, VendorGuid, Attributes, VariableSize)); if (Flag == VAR_ERROR_FLAG_SYSTEM_ERROR) { if (AtRuntime ()) { @@ -291,7 +291,7 @@ RecordVarErrorFlag ( } else { DEBUG ((DEBUG_ERROR, "CommonMaxUserVariableSpace = 0x%x - CommonUserVariableTotalSize = 0x%x\n", mVariableModuleGlobal->CommonMaxUserVariableSpace, mVariableModuleGlobal->CommonUserVariableTotalSize)); } - ); + DEBUG_CODE_END (); if (!mEndOfDxe) { // @@ -3498,7 +3498,7 @@ GetHobVariableStore ( // // Make sure there is no more than one Variable HOB. // - DEBUG_CODE ( + DEBUG_CODE_BEGIN (); GuidHob = GetFirstGuidHob (&gEfiAuthenticatedVariableGuid); if (GuidHob != NULL) { if ((GetNextGuidHob (&gEfiAuthenticatedVariableGuid, GET_NEXT_HOB (GuidHob)) != NULL)) { @@ -3517,7 +3517,7 @@ GetHobVariableStore ( } } } - ); + DEBUG_CODE_END (); // // Combinations supported: -- 2.39.2