[RAMDISK]

- Fix DeviceRelations allocation bug
- Code style: Use sizeof(UNICODE_NULL) where needed; use sizeof(*ptr) for size of type pointed by ptr, when allocating space for ptr.

svn path=/trunk/; revision=66020
This commit is contained in:
Hermès Bélusca-Maïto 2015-01-09 18:26:17 +00:00
parent 64f6189e30
commit 79f472a422

View file

@ -1345,7 +1345,7 @@ RamdiskQueryDeviceRelations(IN DEVICE_RELATION_TYPE Type,
/* Allocate a buffer big enough to contain only one DO */
DeviceRelations = ExAllocatePoolWithTag(PagedPool,
sizeof(DeviceRelations),
sizeof(*DeviceRelations),
'dmaR');
if (DeviceRelations != NULL)
{
@ -1795,7 +1795,7 @@ RamdiskQueryBusInformation(IN PDEVICE_OBJECT DeviceObject,
NTSTATUS Status = STATUS_SUCCESS;
/* Allocate output memory */
PnpBusInfo = ExAllocatePoolWithTag(PagedPool, sizeof(PNP_BUS_INFORMATION), 'dmaR');
PnpBusInfo = ExAllocatePoolWithTag(PagedPool, sizeof(*PnpBusInfo), 'dmaR');
if (PnpBusInfo == NULL)
{
Status = STATUS_INSUFFICIENT_RESOURCES;
@ -2301,8 +2301,7 @@ RamdiskAddDevice(IN PDRIVER_OBJECT DriverObject,
{
/* Initialize the bus FDO extension */
DeviceExtension = DeviceObject->DeviceExtension;
RtlZeroMemory(DeviceObject->DeviceExtension,
sizeof(RAMDISK_BUS_EXTENSION));
RtlZeroMemory(DeviceExtension, sizeof(*DeviceExtension));
/* Set bus FDO flags */
DeviceObject->Flags |= DO_POWER_PAGABLE | DO_DIRECT_IO;
@ -2378,7 +2377,7 @@ DriverEntry(IN PDRIVER_OBJECT DriverObject,
DriverRegistryPath = *RegistryPath;
DriverRegistryPath.Buffer = ExAllocatePoolWithTag(PagedPool,
RegistryPath->Length +
sizeof(WCHAR),
sizeof(UNICODE_NULL),
'dmaR');
if (!DriverRegistryPath.Buffer) return STATUS_INSUFFICIENT_RESOURCES;
RtlCopyUnicodeString(&DriverRegistryPath, RegistryPath);