Skip to content

Commit

Permalink
clang-format: Insert Braces into if statements
Browse files Browse the repository at this point in the history
Signed-off-by: Vitalii Chulak <[email protected]>
  • Loading branch information
Jedoku authored and YanVugenfirer committed Dec 30, 2024
1 parent a1328c3 commit 5e98f81
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ IndentPPDirectives: None
IndentRequiresClause: true
IndentWidth: 4
IndentWrappedFunctionNames: false
InsertBraces: false
InsertBraces: true
InsertNewlineAtEOF: false
InsertTrailingCommas: None
IntegerLiteralSeparator:
Expand Down
2 changes: 2 additions & 0 deletions Balloon/app/memstat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,9 @@ BOOL CMemStat::Update()
while (true)
{
if (enumerator == NULL)
{
break;
}

if (FAILED(enumerator->Next(WBEM_INFINITE, 1L, &memory, &retcnt)))
{
Expand Down
2 changes: 2 additions & 0 deletions fwcfg64/power.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 10 additions & 0 deletions ivshmem/Device.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions ivshmem/Queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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))
{
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions ivshmem/test/ivshmem-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -305,10 +309,14 @@ int __cdecl main()
}

if (devHandle != INVALID_HANDLE_VALUE)
{
CloseHandle(devHandle);
}

if (infData)
{
free(infData);
}

SetupDiDestroyDeviceInfoList(deviceInfoSet);

Expand Down
10 changes: 10 additions & 0 deletions pvpanic/pvpanic/bugcheck.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
}

Expand All @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions pvpanic/pvpanic/power.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ NTSTATUS PVPanicEvtDevicePrepareHardware(IN WDFDEVICE Device,
return STATUS_DEVICE_CONFIGURATION_ERROR;
}
else
{
PvPanicPortOrMemAddress = (PUCHAR)context->IoBaseAddress;
}

break;

Expand Down Expand Up @@ -123,7 +125,9 @@ NTSTATUS PVPanicEvtDevicePrepareHardware(IN WDFDEVICE Device,
return STATUS_DEVICE_CONFIGURATION_ERROR;
}
else
{
PvPanicPortOrMemAddress = (PUCHAR)context->MemBaseAddress;
}

break;
default:
Expand Down Expand Up @@ -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!");

Expand Down

0 comments on commit 5e98f81

Please sign in to comment.