From 5e98f817b2bcb10ad73ba38cb3bf9ec2d91b42e6 Mon Sep 17 00:00:00 2001 From: Vitalii Chulak Date: Fri, 27 Dec 2024 14:56:25 +0200 Subject: [PATCH] clang-format: Insert Braces into if statements Signed-off-by: Vitalii Chulak --- .clang-format | 2 +- Balloon/app/memstat.cpp | 2 ++ fwcfg64/power.c | 2 ++ ivshmem/Device.c | 10 ++++++++++ ivshmem/Queue.c | 6 ++++++ ivshmem/test/ivshmem-test.cpp | 8 ++++++++ pvpanic/pvpanic/bugcheck.c | 10 ++++++++++ pvpanic/pvpanic/power.c | 8 ++++++++ 8 files changed, 47 insertions(+), 1 deletion(-) diff --git a/.clang-format b/.clang-format index 1cfead996..7a3f3a97f 100644 --- a/.clang-format +++ b/.clang-format @@ -104,7 +104,7 @@ IndentPPDirectives: None IndentRequiresClause: true IndentWidth: 4 IndentWrappedFunctionNames: false -InsertBraces: false +InsertBraces: true InsertNewlineAtEOF: false InsertTrailingCommas: None IntegerLiteralSeparator: diff --git a/Balloon/app/memstat.cpp b/Balloon/app/memstat.cpp index cc74fd3a5..faee16846 100644 --- a/Balloon/app/memstat.cpp +++ b/Balloon/app/memstat.cpp @@ -199,7 +199,9 @@ BOOL CMemStat::Update() while (true) { if (enumerator == NULL) + { break; + } if (FAILED(enumerator->Next(WBEM_INFINITE, 1L, &memory, &retcnt))) { diff --git a/fwcfg64/power.c b/fwcfg64/power.c index 9ee654cc2..fcc2bae5c 100644 --- a/fwcfg64/power.c +++ b/fwcfg64/power.c @@ -48,7 +48,9 @@ NTSTATUS FwCfgEvtDeviceD0Entry(IN WDFDEVICE Device, IN WDF_POWER_DEVICE_STATE Pr PAGED_CODE(); if (!ctx->kdbg) + { return STATUS_SUCCESS; + } note->n_namesz = sizeof(VMCI_ELF_NOTE_NAME); note->n_descsz = DUMP_HDR_SIZE; diff --git a/ivshmem/Device.c b/ivshmem/Device.c index 776936f2f..99dc486a6 100644 --- a/ivshmem/Device.c +++ b/ivshmem/Device.c @@ -110,7 +110,9 @@ NTSTATUS IVSHMEMEvtDevicePrepareHardware(_In_ WDFDEVICE Device, } if (descriptor->Type == CmResourceTypeInterrupt && descriptor->Flags & CM_RESOURCE_INTERRUPT_MESSAGE) + { ++deviceContext->interruptCount; + } } if (deviceContext->interruptCount > 0) @@ -235,7 +237,9 @@ NTSTATUS IVSHMEMEvtDevicePrepareHardware(_In_ WDFDEVICE Device, } if (++deviceContext->interruptsUsed == 65) + { DEBUG_INFO("%s", "This driver does not support > 64 interrupts, they will be ignored in the ISR."); + } continue; } @@ -338,13 +342,17 @@ BOOLEAN IVSHMEMInterruptISR(_In_ WDFINTERRUPT Interrupt, _In_ ULONG MessageID) // out of range. if you have this many you're doing it wrong anyway if (MessageID > 64) + { return TRUE; + } device = WdfInterruptGetDevice(Interrupt); deviceContext = DeviceGetContext(device); if (!InterlockedOr64(&deviceContext->pendingISR, 1ULL << MessageID)) + { WdfInterruptQueueDpcForIsr(Interrupt); + } return TRUE; } @@ -362,7 +370,9 @@ void IVSHMEMInterruptDPC(_In_ WDFINTERRUPT Interrupt, _In_ WDFOBJECT AssociatedO pending = InterlockedExchange64(&deviceContext->pendingISR, 0); if (!pending) + { return; + } KeAcquireSpinLockAtDpcLevel(&deviceContext->eventListLock); PLIST_ENTRY entry = deviceContext->eventList.Flink; diff --git a/ivshmem/Queue.c b/ivshmem/Queue.c index 02b45f2c4..2e3509a13 100644 --- a/ivshmem/Queue.c +++ b/ivshmem/Queue.c @@ -190,7 +190,9 @@ VOID IVSHMEMEvtDeviceFileCleanup(_In_ WDFFILEOBJECT FileObject) KeReleaseSpinLock(&deviceContext->eventListLock, oldIRQL); if (!fileContext->shmemMap) + { return; + } MmUnmapLockedPages(fileContext->shmemMap, deviceContext->shmemMDL); fileContext->shmemMap = NULL; @@ -257,7 +259,9 @@ static NTSTATUS ioctl_request_mmap(const PDEVICE_CONTEXT DeviceContext, PFILE_CONTEXT fileContext = FileGetContext(fileObject); // only one mapping per driver handle is allowed if (fileContext->shmemMap) + { return STATUS_DEVICE_ALREADY_ATTACHED; + } if (InputBufferLength != sizeof(IVSHMEM_MMAP_CONFIG)) { @@ -481,7 +485,9 @@ static NTSTATUS ioctl_register_event(const PDEVICE_CONTEXT DeviceContext, { PIVSHMEMEventListEntry event = &DeviceContext->eventBuffer[i]; if (event->event != NULL) + { continue; + } // found one, assign the event to it and add it to the list event->owner = fileObject; diff --git a/ivshmem/test/ivshmem-test.cpp b/ivshmem/test/ivshmem-test.cpp index ea1ffe22c..86ced565e 100644 --- a/ivshmem/test/ivshmem-test.cpp +++ b/ivshmem/test/ivshmem-test.cpp @@ -255,14 +255,18 @@ int __cdecl main() bool fail = false; unsigned char *data = (unsigned char *)map.ptr; for (UINT64 i = 0; i < map.size; ++i) + { if (data[i] != 0xAA) { TEST_FAIL("Invalid data read back"); fail = true; break; } + } if (fail) + { break; + } TEST_PASS(); if (map.vectors > 0) @@ -305,10 +309,14 @@ int __cdecl main() } if (devHandle != INVALID_HANDLE_VALUE) + { CloseHandle(devHandle); + } if (infData) + { free(infData); + } SetupDiDestroyDeviceInfoList(deviceInfoSet); diff --git a/pvpanic/pvpanic/bugcheck.c b/pvpanic/pvpanic/bugcheck.c index e16dd99af..f1f0026af 100644 --- a/pvpanic/pvpanic/bugcheck.c +++ b/pvpanic/pvpanic/bugcheck.c @@ -42,9 +42,13 @@ VOID PVPanicOnBugCheck(IN PVOID Buffer, IN ULONG Length) if ((Buffer != NULL) && (Length == sizeof(PVOID)) && !bEmitCrashLoadedEvent) { if (BusType & PVPANIC_PCI) + { *(PUCHAR)Buffer = (UCHAR)(PVPANIC_PANICKED); + } else + { WRITE_PORT_UCHAR((PUCHAR)Buffer, (UCHAR)(PVPANIC_PANICKED)); + } } } @@ -60,15 +64,21 @@ VOID PVPanicOnDumpBugCheck(KBUGCHECK_CALLBACK_REASON Reason, if ((PvPanicPortOrMemAddress != NULL) && (Reason == KbCallbackDumpIo) && !bEmitCrashLoadedEvent) { if (BusType & PVPANIC_PCI) + { *PvPanicPortOrMemAddress = (UCHAR)(PVPANIC_CRASHLOADED); + } else + { WRITE_PORT_UCHAR(PvPanicPortOrMemAddress, (UCHAR)(PVPANIC_CRASHLOADED)); + } bEmitCrashLoadedEvent = TRUE; } // Deregister BugCheckReasonCallback after PVPANIC_CRASHLOADED is triggered. if (bEmitCrashLoadedEvent) + { KeDeregisterBugCheckReasonCallback(Record); + } } VOID PVPanicRegisterBugCheckCallback(IN PVOID PortAddress, PUCHAR Component) diff --git a/pvpanic/pvpanic/power.c b/pvpanic/pvpanic/power.c index 5ccfffc9f..8f0ab648a 100644 --- a/pvpanic/pvpanic/power.c +++ b/pvpanic/pvpanic/power.c @@ -94,7 +94,9 @@ NTSTATUS PVPanicEvtDevicePrepareHardware(IN WDFDEVICE Device, return STATUS_DEVICE_CONFIGURATION_ERROR; } else + { PvPanicPortOrMemAddress = (PUCHAR)context->IoBaseAddress; + } break; @@ -123,7 +125,9 @@ NTSTATUS PVPanicEvtDevicePrepareHardware(IN WDFDEVICE Device, return STATUS_DEVICE_CONFIGURATION_ERROR; } else + { PvPanicPortOrMemAddress = (PUCHAR)context->MemBaseAddress; + } break; default: @@ -217,9 +221,13 @@ NTSTATUS PVPanicEvtDeviceD0Entry(IN WDFDEVICE Device, IN WDF_POWER_DEVICE_STATE PAGED_CODE(); if (context->IoBaseAddress) + { PVPanicRegisterBugCheckCallback(context->IoBaseAddress, (PUCHAR)("PVPanic")); + } if (context->MemBaseAddress) + { PVPanicRegisterBugCheckCallback(context->MemBaseAddress, (PUCHAR)("PVPanic-PCI")); + } TraceEvents(TRACE_LEVEL_VERBOSE, DBG_POWER, "<-- %!FUNC!");