Fix warnings

svn path=/trunk/; revision=26128
This commit is contained in:
Hervé Poussineau 2007-03-18 00:27:02 +00:00
parent 2d8e002457
commit 0423e310b2
16 changed files with 194 additions and 101 deletions

View file

@ -7,9 +7,6 @@
* PROGRAMMERS: Hervé Poussineau (hpoussin@reactos.org)
*/
#define NDEBUG
#include <debug.h>
#define INITGUID
#include "kbdclass.h"
@ -328,7 +325,7 @@ CreateClassDeviceObject(
DeviceIdW = &DeviceNameU.Buffer[PrefixLength / sizeof(WCHAR)];
while (DeviceId < 9999)
{
DeviceNameU.Length = PrefixLength + swprintf(DeviceIdW, L"%lu", DeviceId) * sizeof(WCHAR);
DeviceNameU.Length = (USHORT)(PrefixLength + swprintf(DeviceIdW, L"%lu", DeviceId) * sizeof(WCHAR));
Status = IoCreateDevice(
DriverObject,
sizeof(CLASS_DEVICE_EXTENSION),
@ -438,7 +435,7 @@ FillEntries(
return Status;
}
static BOOLEAN CALLBACK
static BOOLEAN NTAPI
ClassCallback(
IN PDEVICE_OBJECT ClassDeviceObject,
IN OUT PKEYBOARD_INPUT_DATA DataStart,
@ -448,8 +445,8 @@ ClassCallback(
PCLASS_DEVICE_EXTENSION ClassDeviceExtension = ClassDeviceObject->DeviceExtension;
PIRP Irp = NULL;
KIRQL OldIrql;
ULONG InputCount = DataEnd - DataStart;
ULONG ReadSize;
SIZE_T InputCount = DataEnd - DataStart;
SIZE_T ReadSize;
ASSERT(ClassDeviceExtension->Common.IsClassDO);
@ -489,7 +486,7 @@ ClassCallback(
/* Skip the packet we just sent away */
DataStart += NumberOfEntries;
(*ConsumedCount) += NumberOfEntries;
(*ConsumedCount) += (ULONG)NumberOfEntries;
InputCount -= NumberOfEntries;
}
}
@ -520,7 +517,7 @@ ClassCallback(
/* Move the counter up */
ClassDeviceExtension->InputCount += ReadSize;
(*ConsumedCount) += ReadSize;
(*ConsumedCount) += (ULONG)ReadSize;
}
else
{
@ -827,13 +824,13 @@ SearchForLegacyDrivers(
DriverExtension = (PCLASS_DRIVER_EXTENSION)Context;
/* Create port base name, by replacing Class by Port at the end of the class base name */
Status = RtlDuplicateUnicodeString(
Status = DuplicateUnicodeString(
RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE,
&DriverExtension->DeviceBaseName,
&PortBaseName);
if (!NT_SUCCESS(Status))
{
DPRINT("RtlDuplicateUnicodeString() failed with status 0x%08lx\n", Status);
DPRINT("DuplicateUnicodeString() failed with status 0x%08lx\n", Status);
goto cleanup;
}
PortBaseName.Length -= (sizeof(L"Class") - sizeof(UNICODE_NULL));
@ -886,7 +883,7 @@ SearchForLegacyDrivers(
PDEVICE_OBJECT PortDeviceObject = NULL;
PFILE_OBJECT FileObject = NULL;
PortName.Length = PortName.MaximumLength = KeyValueInformation->NameLength;
PortName.Length = PortName.MaximumLength = (USHORT)KeyValueInformation->NameLength;
PortName.Buffer = KeyValueInformation->Name;
/* Open the device object pointer */
@ -939,13 +936,13 @@ DriverEntry(
}
RtlZeroMemory(DriverExtension, sizeof(CLASS_DRIVER_EXTENSION));
Status = RtlDuplicateUnicodeString(
Status = DuplicateUnicodeString(
RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE,
RegistryPath,
&DriverExtension->RegistryPath);
if (!NT_SUCCESS(Status))
{
DPRINT("RtlDuplicateUnicodeString() failed with status 0x%08lx\n", Status);
DPRINT("DuplicateUnicodeString() failed with status 0x%08lx\n", Status);
return Status;
}

View file

@ -1,9 +1,24 @@
#include <ntifs.h>
#include <kbdmou.h>
#include <ntddkbd.h>
#include <pseh/pseh.h>
#include <stdio.h>
#if defined(__GNUC__)
#include <pseh/pseh.h>
#include <debug.h>
#elif defined(_MSC_VER)
#define DPRINT1 DbgPrint("(%s:%d) ", __FILE__, __LINE__), DbgPrint
#define CHECKPOINT1 DbgPrint("(%s:%d)\n", __FILE__, __LINE__)
#define DPRINT
#define CHECKPOINT
#define _SEH_TRY __try
#define _SEH_HANDLE __except(1)
#define _SEH_END
#define _SEH_GetExceptionCode() GetExceptionCode()
#else
#error Unknown compiler!
#endif
#define MAX_PATH 260
#define MIN(a, b) ((a) < (b) ? (a) : (b))
@ -56,7 +71,7 @@ typedef struct _CLASS_DEVICE_EXTENSION
KSPIN_LOCK ListSpinLock;
KSPIN_LOCK SpinLock;
BOOLEAN ReadIsPending;
ULONG InputCount;
SIZE_T InputCount;
PKEYBOARD_INPUT_DATA PortData;
LPCWSTR DeviceName;
} CLASS_DEVICE_EXTENSION, *PCLASS_DEVICE_EXTENSION;
@ -72,3 +87,9 @@ NTSTATUS NTAPI
ForwardIrpAndForget(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp);
NTSTATUS
DuplicateUnicodeString(
IN ULONG Flags,
IN PCUNICODE_STRING SourceString,
OUT PUNICODE_STRING DestinationString);

View file

@ -1,6 +1,7 @@
<module name="kbdclass" type="kernelmodedriver" installbase="system32/drivers" installname="kbdclass.sys">
<bootstrap base="reactos" />
<define name="__USE_W32API" />
<define name="NDEBUG" />
<library>pseh</library>
<library>ntoskrnl</library>
<library>hal</library>

View file

@ -7,9 +7,6 @@
* PROGRAMMERS: Hervé Poussineau (hpoussin@reactos.org)
*/
#define NDEBUG
#include <debug.h>
#include "kbdclass.h"
static NTSTATUS NTAPI
@ -65,3 +62,48 @@ ForwardIrpAndForget(
IoSkipCurrentIrpStackLocation(Irp);
return IoCallDriver(LowerDevice, Irp);
}
NTSTATUS
DuplicateUnicodeString(
IN ULONG Flags,
IN PCUNICODE_STRING SourceString,
OUT PUNICODE_STRING DestinationString)
{
if (SourceString == NULL || DestinationString == NULL
|| SourceString->Length > SourceString->MaximumLength
|| (SourceString->Length == 0 && SourceString->MaximumLength > 0 && SourceString->Buffer == NULL)
|| Flags == RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING || Flags >= 4)
{
return STATUS_INVALID_PARAMETER;
}
if ((SourceString->Length == 0)
&& (Flags != (RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE |
RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING)))
{
DestinationString->Length = 0;
DestinationString->MaximumLength = 0;
DestinationString->Buffer = NULL;
}
else
{
USHORT DestMaxLength = SourceString->Length;
if (Flags & RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE)
DestMaxLength += sizeof(UNICODE_NULL);
DestinationString->Buffer = ExAllocatePool(PagedPool, DestMaxLength);
if (DestinationString->Buffer == NULL)
return STATUS_NO_MEMORY;
RtlCopyMemory(DestinationString->Buffer, SourceString->Buffer, SourceString->Length);
DestinationString->Length = SourceString->Length;
DestinationString->MaximumLength = DestMaxLength;
if (Flags & RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE)
DestinationString->Buffer[DestinationString->Length / sizeof(WCHAR)] = 0;
}
return STATUS_SUCCESS;
}

View file

@ -7,9 +7,6 @@
* PROGRAMMERS: Hervé Poussineau (hpoussin@reactos.org)
*/
#define NDEBUG
#include <debug.h>
#include "mouclass.h"
static NTSTATUS NTAPI
@ -65,3 +62,48 @@ ForwardIrpAndForget(
IoSkipCurrentIrpStackLocation(Irp);
return IoCallDriver(LowerDevice, Irp);
}
NTSTATUS
DuplicateUnicodeString(
IN ULONG Flags,
IN PCUNICODE_STRING SourceString,
OUT PUNICODE_STRING DestinationString)
{
if (SourceString == NULL || DestinationString == NULL
|| SourceString->Length > SourceString->MaximumLength
|| (SourceString->Length == 0 && SourceString->MaximumLength > 0 && SourceString->Buffer == NULL)
|| Flags == RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING || Flags >= 4)
{
return STATUS_INVALID_PARAMETER;
}
if ((SourceString->Length == 0)
&& (Flags != (RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE |
RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING)))
{
DestinationString->Length = 0;
DestinationString->MaximumLength = 0;
DestinationString->Buffer = NULL;
}
else
{
USHORT DestMaxLength = SourceString->Length;
if (Flags & RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE)
DestMaxLength += sizeof(UNICODE_NULL);
DestinationString->Buffer = ExAllocatePool(PagedPool, DestMaxLength);
if (DestinationString->Buffer == NULL)
return STATUS_NO_MEMORY;
RtlCopyMemory(DestinationString->Buffer, SourceString->Buffer, SourceString->Length);
DestinationString->Length = SourceString->Length;
DestinationString->MaximumLength = DestMaxLength;
if (Flags & RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE)
DestinationString->Buffer[DestinationString->Length / sizeof(WCHAR)] = 0;
}
return STATUS_SUCCESS;
}

View file

@ -7,9 +7,6 @@
* PROGRAMMERS: Hervé Poussineau (hpoussin@reactos.org)
*/
#define NDEBUG
#include <debug.h>
#define INITGUID
#include "mouclass.h"
@ -305,7 +302,7 @@ CreateClassDeviceObject(
DeviceIdW = &DeviceNameU.Buffer[PrefixLength / sizeof(WCHAR)];
while (DeviceId < 9999)
{
DeviceNameU.Length = PrefixLength + swprintf(DeviceIdW, L"%lu", DeviceId) * sizeof(WCHAR);
DeviceNameU.Length = (USHORT)(PrefixLength + swprintf(DeviceIdW, L"%lu", DeviceId) * sizeof(WCHAR));
Status = IoCreateDevice(
DriverObject,
sizeof(CLASS_DEVICE_EXTENSION),
@ -414,7 +411,7 @@ FillEntries(
return Status;
}
static BOOLEAN CALLBACK
static BOOLEAN NTAPI
ClassCallback(
IN PDEVICE_OBJECT ClassDeviceObject,
IN OUT PMOUSE_INPUT_DATA DataStart,
@ -424,8 +421,8 @@ ClassCallback(
PCLASS_DEVICE_EXTENSION ClassDeviceExtension = ClassDeviceObject->DeviceExtension;
PIRP Irp = NULL;
KIRQL OldIrql;
ULONG InputCount = DataEnd - DataStart;
ULONG ReadSize;
SIZE_T InputCount = DataEnd - DataStart;
SIZE_T ReadSize;
ASSERT(ClassDeviceExtension->Common.IsClassDO);
@ -465,7 +462,7 @@ ClassCallback(
/* Skip the packet we just sent away */
DataStart += NumberOfEntries;
(*ConsumedCount) += NumberOfEntries;
(*ConsumedCount) += (ULONG)NumberOfEntries;
InputCount -= NumberOfEntries;
}
}
@ -496,7 +493,7 @@ ClassCallback(
/* Move the counter up */
ClassDeviceExtension->InputCount += ReadSize;
(*ConsumedCount) += ReadSize;
(*ConsumedCount) += (ULONG)ReadSize;
}
else
{
@ -803,13 +800,13 @@ SearchForLegacyDrivers(
DriverExtension = (PCLASS_DRIVER_EXTENSION)Context;
/* Create port base name, by replacing Class by Port at the end of the class base name */
Status = RtlDuplicateUnicodeString(
Status = DuplicateUnicodeString(
RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE,
&DriverExtension->DeviceBaseName,
&PortBaseName);
if (!NT_SUCCESS(Status))
{
DPRINT("RtlDuplicateUnicodeString() failed with status 0x%08lx\n", Status);
DPRINT("DuplicateUnicodeString() failed with status 0x%08lx\n", Status);
goto cleanup;
}
PortBaseName.Length -= (sizeof(L"Class") - sizeof(UNICODE_NULL));
@ -862,7 +859,7 @@ SearchForLegacyDrivers(
PDEVICE_OBJECT PortDeviceObject = NULL;
PFILE_OBJECT FileObject = NULL;
PortName.Length = PortName.MaximumLength = KeyValueInformation->NameLength;
PortName.Length = PortName.MaximumLength = (USHORT)KeyValueInformation->NameLength;
PortName.Buffer = KeyValueInformation->Name;
/* Open the device object pointer */
@ -915,13 +912,13 @@ DriverEntry(
}
RtlZeroMemory(DriverExtension, sizeof(CLASS_DRIVER_EXTENSION));
Status = RtlDuplicateUnicodeString(
Status = DuplicateUnicodeString(
RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE,
RegistryPath,
&DriverExtension->RegistryPath);
if (!NT_SUCCESS(Status))
{
DPRINT("RtlDuplicateUnicodeString() failed with status 0x%08lx\n", Status);
DPRINT("DuplicateUnicodeString() failed with status 0x%08lx\n", Status);
return Status;
}

View file

@ -1,9 +1,24 @@
#include <ntifs.h>
#include <kbdmou.h>
#include <ntddmou.h>
#include <pseh/pseh.h>
#include <ntddkbd.h>
#include <stdio.h>
#if defined(__GNUC__)
#include <pseh/pseh.h>
#include <debug.h>
#elif defined(_MSC_VER)
#define DPRINT1 DbgPrint("(%s:%d) ", __FILE__, __LINE__), DbgPrint
#define CHECKPOINT1 DbgPrint("(%s:%d)\n", __FILE__, __LINE__)
#define DPRINT
#define CHECKPOINT
#define _SEH_TRY __try
#define _SEH_HANDLE __except(1)
#define _SEH_END
#define _SEH_GetExceptionCode() GetExceptionCode()
#else
#error Unknown compiler!
#endif
#define MAX_PATH 260
#define MIN(a, b) ((a) < (b) ? (a) : (b))
@ -56,7 +71,7 @@ typedef struct _CLASS_DEVICE_EXTENSION
KSPIN_LOCK ListSpinLock;
KSPIN_LOCK SpinLock;
BOOLEAN ReadIsPending;
ULONG InputCount;
SIZE_T InputCount;
PMOUSE_INPUT_DATA PortData;
LPCWSTR DeviceName;
} CLASS_DEVICE_EXTENSION, *PCLASS_DEVICE_EXTENSION;
@ -72,3 +87,9 @@ NTSTATUS NTAPI
ForwardIrpAndForget(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp);
NTSTATUS
DuplicateUnicodeString(
IN ULONG Flags,
IN PCUNICODE_STRING SourceString,
OUT PUNICODE_STRING DestinationString);

View file

@ -1,6 +1,7 @@
<module name="mouclass" type="kernelmodedriver" installbase="system32/drivers" installname="mouclass.sys">
<include base="mouclass">.</include>
<define name="__USE_W32API" />
<define name="NDEBUG" />
<library>pseh</library>
<library>ntoskrnl</library>
<library>hal</library>

View file

@ -6,9 +6,6 @@
* PROGRAMMERS: Copyright 2005-2006 Hervé Poussineau (hpoussin@reactos.org)
*/
#define NDEBUG
#include <debug.h>
#include "sermouse.h"
NTSTATUS NTAPI

View file

@ -8,9 +8,6 @@
Copyright 2005-2006 Hervé Poussineau (hpoussin@reactos.org)
*/
#define NDEBUG
#include <debug.h>
#include "sermouse.h"
/* Most of this file is ripped from reactos/drivers/bus/serenum/detect.c */
@ -20,9 +17,9 @@ DeviceIoControl(
IN PDEVICE_OBJECT DeviceObject,
IN ULONG CtlCode,
IN PVOID InputBuffer OPTIONAL,
IN ULONG_PTR InputBufferSize,
IN SIZE_T InputBufferSize,
IN OUT PVOID OutputBuffer OPTIONAL,
IN OUT PULONG_PTR OutputBufferSize)
IN OUT PSIZE_T OutputBufferSize)
{
KEVENT Event;
PIRP Irp;
@ -34,9 +31,9 @@ DeviceIoControl(
Irp = IoBuildDeviceIoControlRequest(CtlCode,
DeviceObject,
InputBuffer,
InputBufferSize,
(ULONG)InputBufferSize,
OutputBuffer,
(OutputBufferSize) ? *OutputBufferSize : 0,
(OutputBufferSize) ? (ULONG)*OutputBufferSize : 0,
FALSE,
&Event,
&IoStatus);
@ -57,7 +54,7 @@ DeviceIoControl(
if (OutputBufferSize)
{
*OutputBufferSize = IoStatus.Information;
*OutputBufferSize = (SIZE_T)IoStatus.Information;
}
return Status;

View file

@ -6,9 +6,6 @@
* PROGRAMMERS: Copyright 2005-2006 Hervé Poussineau (hpoussin@reactos.org)
*/
#define NDEBUG
#include <debug.h>
#include "sermouse.h"
NTSTATUS NTAPI

View file

@ -6,9 +6,6 @@
* PROGRAMMERS: Copyright 2005-2006 Hervé Poussineau (hpoussin@reactos.org)
*/
#define NDEBUG
#include <debug.h>
#include "sermouse.h"
NTSTATUS NTAPI

View file

@ -6,11 +6,10 @@
* PROGRAMMERS: Copyright 2005-2006 Hervé Poussineau (hpoussin@reactos.org)
*/
#define NDEBUG
#include <debug.h>
#include "sermouse.h"
static IO_COMPLETION_ROUTINE ForwardIrpAndWaitCompletion;
static NTSTATUS NTAPI
ForwardIrpAndWaitCompletion(
IN PDEVICE_OBJECT DeviceObject,
@ -34,7 +33,7 @@ ForwardIrpAndWait(
KeInitializeEvent(&Event, NotificationEvent, FALSE);
IoCopyCurrentIrpStackLocationToNext(Irp);
DPRINT("Calling lower device %p [%wZ]\n", LowerDevice, &LowerDevice->DriverObject->DriverName);
DPRINT("Calling lower device %p\n", LowerDevice);
IoSetCompletionRoutine(Irp, ForwardIrpAndWaitCompletion, &Event, TRUE, TRUE, TRUE);
Status = IoCallDriver(LowerDevice, Irp);

View file

@ -8,9 +8,6 @@
Copyright 2005-2006 Hervé Poussineau (hpoussin@reactos.org)
*/
#define NDEBUG
#include <debug.h>
#include "sermouse.h"
static NTSTATUS
@ -55,7 +52,7 @@ SermouseDeviceIoControl(
if (OutputBufferSize)
{
*OutputBufferSize = IoStatus.Information;
*OutputBufferSize = (ULONG)IoStatus.Information;
}
return Status;
@ -126,6 +123,7 @@ SermouseDeviceWorker(
if (!NT_SUCCESS(Status)) PsTerminateSystemThread(Status);
/* main read loop */
RtlZeroMemory(Buffer, PACKET_BUFFER_SIZE);
while (TRUE)
{
Status = KeWaitForSingleObject(

View file

@ -6,19 +6,20 @@
* PROGRAMMERS: Copyright 2005-2006 Hervé Poussineau (hpoussin@reactos.org)
*/
#define NDEBUG
#include <debug.h>
#define INITGUID
#include "sermouse.h"
VOID NTAPI
static DRIVER_UNLOAD DriverUnload;
static DRIVER_DISPATCH IrpStub;
DRIVER_INITIALIZE DriverEntry;
static VOID NTAPI
DriverUnload(IN PDRIVER_OBJECT DriverObject)
{
// nothing to do here yet
}
NTSTATUS NTAPI
static NTSTATUS NTAPI
IrpStub(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
@ -75,10 +76,11 @@ ReadRegistryEntries(
else if (Status == STATUS_OBJECT_NAME_NOT_FOUND)
{
/* Registry path doesn't exist. Set defaults */
DriverExtension->NumberOfButtons = DefaultNumberOfButtons;
DriverExtension->NumberOfButtons = (USHORT)DefaultNumberOfButtons;
Status = STATUS_SUCCESS;
}
ExFreePool(ParametersRegistryKey.Buffer);
return Status;
}

View file

@ -3,13 +3,15 @@
#include <ntddser.h>
#include <ntddmou.h>
#if defined(_MSC_VER)
/* Missing prototype */
NTSTATUS NTAPI
IoAttachDeviceToDeviceStackSafe(
IN PDEVICE_OBJECT SourceDevice,
IN PDEVICE_OBJECT TargetDevice,
OUT PDEVICE_OBJECT *AttachedToDeviceObject);
#if defined(__GNUC__)
#include <debug.h>
#elif defined(_MSC_VER)
#define DPRINT1 DbgPrint("(%s:%d) ", __FILE__, __LINE__), DbgPrint
#define CHECKPOINT1 DbgPrint("(%s:%d)\n", __FILE__, __LINE__)
#define DPRINT
#define CHECKPOINT
#else
#error Unknown compiler!
#endif
typedef enum
@ -79,20 +81,11 @@ typedef struct _SERMOUSE_DEVICE_EXTENSION
/************************************ createclose.c */
NTSTATUS NTAPI
SermouseCreate(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp);
DRIVER_DISPATCH SermouseCreate;
NTSTATUS NTAPI
SermouseClose(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp);
DRIVER_DISPATCH SermouseClose;
NTSTATUS NTAPI
SermouseCleanup(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp);
DRIVER_DISPATCH SermouseCleanup;
/************************************ detect.c */
@ -102,22 +95,13 @@ SermouseDetectLegacyDevice(
/************************************ fdo.c */
NTSTATUS NTAPI
SermouseAddDevice(
IN PDRIVER_OBJECT DriverObject,
IN PDEVICE_OBJECT Pdo);
DRIVER_ADD_DEVICE SermouseAddDevice;
NTSTATUS NTAPI
SermousePnp(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp);
DRIVER_DISPATCH SermousePnp;
/************************************ internaldevctl.c */
NTSTATUS NTAPI
SermouseInternalDeviceControl(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp);
DRIVER_DISPATCH SermouseInternalDeviceControl;
/************************************ misc.c */