Skip to content

Commit

Permalink
RHEL-69075: clang-format for vioinput folder
Browse files Browse the repository at this point in the history
Signed-off-by: Vitalii Chulak <[email protected]>
  • Loading branch information
Jedoku committed Jan 8, 2025
1 parent ce2af43 commit a3e796e
Show file tree
Hide file tree
Showing 19 changed files with 1,235 additions and 1,399 deletions.
51 changes: 23 additions & 28 deletions vioinput/hidpassthrough/hidpassthrough.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,43 +34,35 @@
#include "pdo.h"

static DRIVER_ADD_DEVICE HidPassthroughAddDevice;
static DRIVER_UNLOAD HidPassthroughUnload;
static DRIVER_UNLOAD HidPassthroughUnload;

static _Dispatch_type_(IRP_MJ_POWER) DRIVER_DISPATCH HidPassthroughDispatchPower;
static _Dispatch_type_(IRP_MJ_OTHER) DRIVER_DISPATCH HidPassthroughDispatch;

DRIVER_INITIALIZE DriverEntry;

static NTSTATUS
HidPassthroughAddDevice(_In_ PDRIVER_OBJECT DriverObject,
_In_ PDEVICE_OBJECT FunctionalDeviceObject)
static NTSTATUS HidPassthroughAddDevice(_In_ PDRIVER_OBJECT DriverObject, _In_ PDEVICE_OBJECT FunctionalDeviceObject)
{
UNREFERENCED_PARAMETER(DriverObject);
FunctionalDeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;

return STATUS_SUCCESS;
}

static void
HidPassthroughUnload(_In_ PDRIVER_OBJECT DriverObject)
static void HidPassthroughUnload(_In_ PDRIVER_OBJECT DriverObject)
{
UNREFERENCED_PARAMETER(DriverObject);
}

static NTSTATUS
HidPassthroughDispatch(_In_ PDEVICE_OBJECT DeviceObject,
_Inout_ PIRP Irp)
static NTSTATUS HidPassthroughDispatch(_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp)
{
PHID_DEVICE_EXTENSION ext = DeviceObject->DeviceExtension;

IoCopyCurrentIrpStackLocationToNext(Irp);
return IoCallDriver(ext->NextDeviceObject, Irp);
}


static NTSTATUS
HidPassthroughDispatchPower(_In_ PDEVICE_OBJECT DeviceObject,
_Inout_ PIRP Irp)
static NTSTATUS HidPassthroughDispatchPower(_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp)
{
PHID_DEVICE_EXTENSION ext = DeviceObject->DeviceExtension;

Expand All @@ -79,10 +71,8 @@ HidPassthroughDispatchPower(_In_ PDEVICE_OBJECT DeviceObject,
return PoCallDriver(ext->NextDeviceObject, Irp);
}

_Dispatch_type_(IRP_MJ_INTERNAL_DEVICE_CONTROL)
static NTSTATUS
HidPassthroughDispatchIoctl(_In_ PDEVICE_OBJECT DeviceObject,
_Inout_ PIRP Irp)
_Dispatch_type_(IRP_MJ_INTERNAL_DEVICE_CONTROL) static NTSTATUS HidPassthroughDispatchIoctl(_In_ PDEVICE_OBJECT DeviceObject,
_Inout_ PIRP Irp)
{
PHID_DEVICE_EXTENSION ext = DeviceObject->DeviceExtension;
PPDO_EXTENSION ext_pdo = (PPDO_EXTENSION)ext->PhysicalDeviceObject->DeviceExtension;
Expand All @@ -92,8 +82,7 @@ HidPassthroughDispatchIoctl(_In_ PDEVICE_OBJECT DeviceObject,
}

NTSTATUS
DriverEntry (_In_ PDRIVER_OBJECT DriverObject,
_In_ PUNICODE_STRING RegistryPath)
DriverEntry(_In_ PDRIVER_OBJECT DriverObject, _In_ PUNICODE_STRING RegistryPath)
{
HID_MINIDRIVER_REGISTRATION hid;
int i;
Expand All @@ -104,21 +93,27 @@ DriverEntry (_In_ PDRIVER_OBJECT DriverObject,
* IRP_MJ_INTERNAL_DEVICE_CONTROL is forwarded to the
* parent device to handle HID IOCTLs.
*/
for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++) {
if (i == IRP_MJ_INTERNAL_DEVICE_CONTROL) {
DriverObject->MajorFunction[i] = HidPassthroughDispatchIoctl;
} else if (i == IRP_MJ_POWER) {
DriverObject->MajorFunction[i] = HidPassthroughDispatchPower;
} else {
DriverObject->MajorFunction[i] = HidPassthroughDispatch;
for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++)
{
if (i == IRP_MJ_INTERNAL_DEVICE_CONTROL)
{
DriverObject->MajorFunction[i] = HidPassthroughDispatchIoctl;
}
else if (i == IRP_MJ_POWER)
{
DriverObject->MajorFunction[i] = HidPassthroughDispatchPower;
}
else
{
DriverObject->MajorFunction[i] = HidPassthroughDispatch;
}
}

DriverObject->DriverExtension->AddDevice = HidPassthroughAddDevice;
DriverObject->DriverUnload = HidPassthroughUnload;
DriverObject->DriverUnload = HidPassthroughUnload;

RtlZeroMemory(&hid, sizeof(HID_MINIDRIVER_REGISTRATION));
hid.Revision = HID_REVISION;
hid.Revision = HID_REVISION;
hid.DriverObject = DriverObject;
hid.RegistryPath = RegistryPath;

Expand Down
6 changes: 3 additions & 3 deletions vioinput/hidpassthrough/pdo.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#pragma once
#include <wdm.h>

#define PDO_EXTENSION_V1 1
#define PDO_EXTENSION_V1 1
#define PDO_EXTENSION_VERSION PDO_EXTENSION_V1

typedef struct _tagPdoExtension
Expand All @@ -17,8 +17,8 @@ typedef struct _tagPdoExtension
* It doesn't hurt to add a version field in case we need to extend it
* in the future.
*/
ULONG Version;
ULONG Version;

/* Pointer to the bus FDO that enumerated the PDO */
PDEVICE_OBJECT BusFdo;
PDEVICE_OBJECT BusFdo;
} PDO_EXTENSION, *PPDO_EXTENSION;
10 changes: 2 additions & 8 deletions vioinput/sys/Array.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@ BOOLEAN DynamicArrayReserve(PDYNAMIC_ARRAY pArray, SIZE_T cbSize)
// initial allocation
pArray->Size = 0;
pArray->MaxSize = cbSize;
pArray->Ptr = ExAllocatePoolUninitialized(
NonPagedPool,
pArray->MaxSize,
VIOINPUT_DRIVER_MEMORY_TAG);
pArray->Ptr = ExAllocatePoolUninitialized(NonPagedPool, pArray->MaxSize, VIOINPUT_DRIVER_MEMORY_TAG);
if (pArray->Ptr == NULL)
{
// mark as failed
Expand All @@ -69,10 +66,7 @@ BOOLEAN DynamicArrayReserve(PDYNAMIC_ARRAY pArray, SIZE_T cbSize)
{
pArray->MaxSize *= 2;
}
pArray->Ptr = ExAllocatePoolUninitialized(
NonPagedPool,
pArray->MaxSize,
VIOINPUT_DRIVER_MEMORY_TAG);
pArray->Ptr = ExAllocatePoolUninitialized(NonPagedPool, pArray->MaxSize, VIOINPUT_DRIVER_MEMORY_TAG);
if (pArray->Ptr == NULL)
{
// mark as failed
Expand Down
Loading

0 comments on commit a3e796e

Please sign in to comment.