Skip to content

Commit

Permalink
MdeModulePkg: Change complex DEBUG_CODE() to DEBUG_CODE_BEGIN/END()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Leif Lindholm <[email protected]>
Cc: Michael Kubacki <[email protected]>
Signed-off-by: Michael D Kinney <[email protected]>
Reviewed-by: Liming Gao <[email protected]>
  • Loading branch information
mdkinney authored and mergify[bot] committed Dec 7, 2021
1 parent 4a9d411 commit db52c7f
Show file tree
Hide file tree
Showing 17 changed files with 48 additions and 50 deletions.
8 changes: 4 additions & 4 deletions MdeModulePkg/Application/CapsuleApp/CapsuleOnDisk.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,15 +336,15 @@ GetEfiSysPartitionFromBootOptionFilePath (
break;
}

DEBUG_CODE (
DEBUG_CODE_BEGIN ();
CHAR16 *DevicePathStr;

DevicePathStr = ConvertDevicePathToText (CurFullPath, TRUE, TRUE);
if (DevicePathStr != NULL){
DEBUG ((DEBUG_INFO, "Full device path %s\n", DevicePathStr));
FreePool (DevicePathStr);
}
);
DEBUG_CODE_END ();

Status = GetEfiSysPartitionFromDevPath (CurFullPath, &FsFullPath, Fs);
} while (EFI_ERROR (Status));
Expand Down Expand Up @@ -468,7 +468,7 @@ GetUpdateFileSystem (
continue;
}

DEBUG_CODE (
DEBUG_CODE_BEGIN ();
CHAR16 *DevicePathStr;

DevicePathStr = ConvertDevicePathToText (DevicePath, TRUE, TRUE);
Expand All @@ -478,7 +478,7 @@ GetUpdateFileSystem (
} else {
DEBUG ((DEBUG_INFO, "DevicePathToStr failed\n"));
}
);
DEBUG_CODE_END ();

Status = GetEfiSysPartitionFromBootOptionFilePath (DevicePath, &FullPath, Fs);
if (!EFI_ERROR (Status)) {
Expand Down
8 changes: 4 additions & 4 deletions MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -184,7 +184,7 @@ AddIoSpace (
ASSERT_EFI_ERROR (CheckStatus);
ASSERT (Descriptor.GcdIoType == EfiGcdIoTypeIo);
}
);
DEBUG_CODE_END ();

FreeIoSpaceMap:
FreePool (IoSpaceMap);
Expand Down Expand Up @@ -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
Expand All @@ -333,7 +333,7 @@ AddMemoryMappedIoSpace (
ASSERT (Descriptor.GcdMemoryType == EfiGcdMemoryTypeMemoryMappedIo);
ASSERT ((Descriptor.Capabilities & Capabilities) == Capabilities);
}
);
DEBUG_CODE_END ();

FreeMemorySpaceMap:
FreePool (MemorySpaceMap);
Expand Down
8 changes: 4 additions & 4 deletions MdeModulePkg/Core/Dxe/Gcd/Gcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ CoreDumpGcdMemorySpaceMap (
BOOLEAN InitialMap
)
{
DEBUG_CODE (
DEBUG_CODE_BEGIN ();
EFI_STATUS Status;
UINTN NumberOfDescriptors;
EFI_GCD_MEMORY_SPACE_DESCRIPTOR *MemorySpaceMap;
Expand All @@ -167,7 +167,7 @@ CoreDumpGcdMemorySpaceMap (
}
DEBUG ((DEBUG_GCD, "\n"));
FreePool (MemorySpaceMap);
);
DEBUG_CODE_END ();
}

/**
Expand All @@ -183,7 +183,7 @@ CoreDumpGcdIoSpaceMap (
BOOLEAN InitialMap
)
{
DEBUG_CODE (
DEBUG_CODE_BEGIN ();
EFI_STATUS Status;
UINTN NumberOfDescriptors;
EFI_GCD_IO_SPACE_DESCRIPTOR *IoSpaceMap;
Expand All @@ -208,7 +208,7 @@ CoreDumpGcdIoSpaceMap (
}
DEBUG ((DEBUG_GCD, "\n"));
FreePool (IoSpaceMap);
);
DEBUG_CODE_END ();
}

/**
Expand Down
4 changes: 2 additions & 2 deletions MdeModulePkg/Core/PiSmmCore/SmramProfileRecord.c
Original file line number Diff line number Diff line change
Expand Up @@ -2734,12 +2734,12 @@ DumpSmramInfo (
VOID
)
{
DEBUG_CODE (
DEBUG_CODE_BEGIN ();
if (IS_SMRAM_PROFILE_ENABLED) {
DumpSmramProfile ();
DumpFreePagesList ();
DumpFreePoolList ();
DumpSmramRange ();
}
);
DEBUG_CODE_END ();
}
16 changes: 8 additions & 8 deletions MdeModulePkg/Library/DxeCapsuleLibFmp/CapsuleOnDisk.c
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ GetEfiSysPartitionFromActiveBootOption(
continue;
}

DEBUG_CODE (
DEBUG_CODE_BEGIN ();
CHAR16 *DevicePathStr;

DevicePathStr = ConvertDevicePathToText(DevicePath, TRUE, TRUE);
Expand All @@ -499,7 +499,7 @@ GetEfiSysPartitionFromActiveBootOption(
} else {
DEBUG((DEBUG_INFO, "DevicePathToStr failed\n"));
}
);
DEBUG_CODE_END ();

CurFullPath = NULL;
//
Expand All @@ -521,15 +521,15 @@ GetEfiSysPartitionFromActiveBootOption(
break;
}

DEBUG_CODE (
DEBUG_CODE_BEGIN ();
CHAR16 *DevicePathStr1;

DevicePathStr1 = ConvertDevicePathToText(CurFullPath, TRUE, TRUE);
if (DevicePathStr1 != NULL){
DEBUG((DEBUG_INFO, "Full device path %s\n", DevicePathStr1));
FreePool(DevicePathStr1);
}
);
DEBUG_CODE_END ();

//
// Make sure the boot option device path connected.
Expand Down Expand Up @@ -587,7 +587,7 @@ GetEfiSysPartitionFromActiveBootOption(
Status = EFI_NOT_FOUND;
}

DEBUG_CODE (
DEBUG_CODE_BEGIN ();
CHAR16 *DevicePathStr2;
if (*FsHandle != NULL) {
DevicePathStr2 = ConvertDevicePathToText(CurFullPath, TRUE, TRUE);
Expand All @@ -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);
Expand Down Expand Up @@ -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:

Expand Down
4 changes: 2 additions & 2 deletions MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1417,7 +1417,7 @@ BmExpandLoadFile (
if (LoadFileText != NULL) {
FreePool (LoadFileText);
}
);
DEBUG_CODE_END ();
return NULL;
}

Expand Down
4 changes: 2 additions & 2 deletions MdeModulePkg/Library/UefiBootManagerLib/BmDriverHealth.c
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ BmRepairAllControllers (
EfiBootManagerFreeDriverHealthInfo (DriverHealthInfo, Count);


DEBUG_CODE (
DEBUG_CODE_BEGIN ();
CHAR16 *ControllerName;

DriverHealthInfo = EfiBootManagerGetDriverHealthInfo (&Count);
Expand All @@ -567,7 +567,7 @@ BmRepairAllControllers (
}
}
EfiBootManagerFreeDriverHealthInfo (DriverHealthInfo, Count);
);
DEBUG_CODE_END ();

if (ReconnectRequired) {
if (ReconnectRepairCount < MAX_RECONNECT_REPAIR) {
Expand Down
4 changes: 2 additions & 2 deletions MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGenFromFv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
//
Expand All @@ -51,6 +51,5 @@ SetIdtEntry (
IdtEntry->Bits.GateType = IA32_IDT_GATE_TYPE_INTERRUPT_32;
IdtEntry->Bits.OffsetHigh = (UINT16)(S3DebugBuffer >> 16);
}
);
DEBUG_CODE_END ();
}

Original file line number Diff line number Diff line change
Expand Up @@ -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
//
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions MdeModulePkg/Universal/BdsDxe/BdsEntry.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ InitializeCapsuleOnDiskLoad (
return EFI_ABORTED;
}

DEBUG_CODE (
DEBUG_CODE_BEGIN ();
VOID *CapsuleOnDiskModePpi;

if (!IsCapsuleOnDiskMode()){
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 2 additions & 3 deletions MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -1380,4 +1380,3 @@ IsHotPlugDevice (

return FALSE;
}

Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ Defer3rdPartyImageLoad (

ImageInfo = LookupImage (File, BootPolicy);

DEBUG_CODE (
DEBUG_CODE_BEGIN ();
CHAR16 *DevicePathStr;
DevicePathStr = ConvertDevicePathToText (File, FALSE, FALSE);
DEBUG ((
Expand All @@ -342,7 +342,7 @@ Defer3rdPartyImageLoad (
if (DevicePathStr != NULL) {
FreePool (DevicePathStr);
}
);
DEBUG_CODE_END ();

if (mEndOfDxe) {
mImageLoadedAfterEndOfDxe = TRUE;
Expand Down
4 changes: 2 additions & 2 deletions MdeModulePkg/Universal/Variable/Pei/Variable.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -531,7 +531,7 @@ GetHobVariableStore (
}
}
}
);
DEBUG_CODE_END ();

GuidHob = GetFirstGuidHob (&gEfiAuthenticatedVariableGuid);
if (GuidHob != NULL) {
Expand Down
Loading

0 comments on commit db52c7f

Please sign in to comment.