Author: tfaber Date: Mon May 28 10:34:45 2012 New Revision: 56667
URL: http://svn.reactos.org/svn/reactos?rev=56667&view=rev Log: [LIBUSB][USBCCGP][USBEHCI] - Return the actual number of bytes copied for configuration descriptor requests - Fix MSVC warnings and NULL vs 0 vs FALSE issues
Modified: trunk/reactos/drivers/usb/usbccgp/pdo.c trunk/reactos/drivers/usb/usbehci/usb_request.cpp trunk/reactos/lib/drivers/libusb/hub_controller.cpp trunk/reactos/lib/drivers/libusb/usb_device.cpp
Modified: trunk/reactos/drivers/usb/usbccgp/pdo.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbccgp/pdo.c?r... ============================================================================== --- trunk/reactos/drivers/usb/usbccgp/pdo.c [iso-8859-1] (original) +++ trunk/reactos/drivers/usb/usbccgp/pdo.c [iso-8859-1] Mon May 28 10:34:45 2012 @@ -473,6 +473,7 @@ PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor; PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor; ULONG TotalSize, Index; + ULONG Size; PURB Urb; PVOID Buffer; PUCHAR BufferPtr; @@ -640,7 +641,7 @@ // modify configuration descriptor // ConfigurationDescriptor = Buffer; - ConfigurationDescriptor->wTotalLength = TotalSize; + ConfigurationDescriptor->wTotalLength = (USHORT)TotalSize; ConfigurationDescriptor->bNumInterfaces = PDODeviceExtension->FunctionDescriptor->NumberOfInterfaces;
// @@ -652,12 +653,13 @@ // // copy descriptor // - RtlCopyMemory(Urb->UrbControlDescriptorRequest.TransferBuffer, Buffer, min(TotalSize, Urb->UrbControlDescriptorRequest.TransferBufferLength)); + Size = min(TotalSize, Urb->UrbControlDescriptorRequest.TransferBufferLength); + RtlCopyMemory(Urb->UrbControlDescriptorRequest.TransferBuffer, Buffer, Size);
// // store final size // - Urb->UrbControlDescriptorRequest.TransferBufferLength = TotalSize; + Urb->UrbControlDescriptorRequest.TransferBufferLength = Size;
// // free buffer @@ -846,7 +848,7 @@ // // now prepare interface urb // - UsbBuildSelectInterfaceRequest(NewUrb, GET_SELECT_INTERFACE_REQUEST_SIZE(InterfaceInformation->NumberOfPipes), PDODeviceExtension->ConfigurationHandle, InterfaceInformation->InterfaceNumber, InterfaceInformation->AlternateSetting); + UsbBuildSelectInterfaceRequest(NewUrb, (USHORT)GET_SELECT_INTERFACE_REQUEST_SIZE(InterfaceInformation->NumberOfPipes), PDODeviceExtension->ConfigurationHandle, InterfaceInformation->InterfaceNumber, InterfaceInformation->AlternateSetting);
// // now select the interface
Modified: trunk/reactos/drivers/usb/usbehci/usb_request.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbehci/usb_req... ============================================================================== --- trunk/reactos/drivers/usb/usbehci/usb_request.cpp [iso-8859-1] (original) +++ trunk/reactos/drivers/usb/usbehci/usb_request.cpp [iso-8859-1] Mon May 28 10:34:45 2012 @@ -538,7 +538,7 @@ // initialized with setup packet, must be a control transfer // TransferType = USB_ENDPOINT_TYPE_CONTROL; - ASSERT(m_EndpointDescriptor == FALSE); + ASSERT(m_EndpointDescriptor == NULL); }
//
Modified: trunk/reactos/lib/drivers/libusb/hub_controller.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/libusb/hub_cont... ============================================================================== --- trunk/reactos/lib/drivers/libusb/hub_controller.cpp [iso-8859-1] (original) +++ trunk/reactos/lib/drivers/libusb/hub_controller.cpp [iso-8859-1] Mon May 28 10:34:45 2012 @@ -1293,7 +1293,6 @@ // generate setup packet // CtrlSetup.bRequest = USB_REQUEST_GET_STATUS; - CtrlSetup.wValue.LowByte = Urb->UrbControlVendorClassRequest.Index; CtrlSetup.wValue.W = Urb->UrbControlVendorClassRequest.Value; CtrlSetup.wIndex.W = Urb->UrbControlVendorClassRequest.Index; CtrlSetup.wLength = (USHORT)Urb->UrbControlGetStatusRequest.TransferBufferLength; @@ -1410,7 +1409,7 @@ CtrlSetup.bRequest = Urb->UrbControlVendorClassRequest.Request; CtrlSetup.wValue.W = Urb->UrbControlVendorClassRequest.Value; CtrlSetup.wIndex.W = Urb->UrbControlVendorClassRequest.Index; - CtrlSetup.wLength = Urb->UrbControlVendorClassRequest.TransferBufferLength; + CtrlSetup.wLength = (USHORT)Urb->UrbControlVendorClassRequest.TransferBufferLength;
if (Urb->UrbControlVendorClassRequest.TransferFlags & USBD_TRANSFER_DIRECTION_IN) { @@ -1758,7 +1757,7 @@ CtrlSetup.bRequest = Urb->UrbControlVendorClassRequest.Request; CtrlSetup.wValue.W = Urb->UrbControlVendorClassRequest.Value; CtrlSetup.wIndex.W = Urb->UrbControlVendorClassRequest.Index; - CtrlSetup.wLength = Urb->UrbControlVendorClassRequest.TransferBufferLength; + CtrlSetup.wLength = (USHORT)Urb->UrbControlVendorClassRequest.TransferBufferLength;
if (Urb->UrbControlVendorClassRequest.TransferFlags & USBD_TRANSFER_DIRECTION_IN) { @@ -1830,7 +1829,7 @@ CtrlSetup.bRequest = Urb->UrbControlVendorClassRequest.Request; CtrlSetup.wValue.W = Urb->UrbControlVendorClassRequest.Value; CtrlSetup.wIndex.W = Urb->UrbControlVendorClassRequest.Index; - CtrlSetup.wLength = Urb->UrbControlVendorClassRequest.TransferBufferLength; + CtrlSetup.wLength = (USHORT)Urb->UrbControlVendorClassRequest.TransferBufferLength;
if (Urb->UrbControlVendorClassRequest.TransferFlags & USBD_TRANSFER_DIRECTION_IN) { @@ -2096,7 +2095,7 @@ CtrlSetup.bRequest = Urb->UrbControlVendorClassRequest.Request; CtrlSetup.wValue.W = Urb->UrbControlVendorClassRequest.Value; CtrlSetup.wIndex.W = Urb->UrbControlVendorClassRequest.Index; - CtrlSetup.wLength = Urb->UrbControlVendorClassRequest.TransferBufferLength; + CtrlSetup.wLength = (USHORT)Urb->UrbControlVendorClassRequest.TransferBufferLength;
if (Urb->UrbControlVendorClassRequest.TransferFlags & USBD_TRANSFER_DIRECTION_IN) {
Modified: trunk/reactos/lib/drivers/libusb/usb_device.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/libusb/usb_devi... ============================================================================== --- trunk/reactos/lib/drivers/libusb/usb_device.cpp [iso-8859-1] (original) +++ trunk/reactos/lib/drivers/libusb/usb_device.cpp [iso-8859-1] Mon May 28 10:34:45 2012 @@ -323,7 +323,7 @@ CtrlSetup->wValue.W = DeviceAddress;
// set device address - Status = CommitSetupPacket(CtrlSetup, 0, 0, 0); + Status = CommitSetupPacket(CtrlSetup, NULL, 0, NULL);
// free setup packet ExFreePoolWithTag(CtrlSetup, TAG_USBLIB); @@ -640,7 +640,7 @@ // // commit setup packet // - Status = CommitSetupPacket(&CtrlSetup, 0, sizeof(USB_DEVICE_DESCRIPTOR), Mdl); + Status = CommitSetupPacket(&CtrlSetup, NULL, sizeof(USB_DEVICE_DESCRIPTOR), Mdl);
// // now free the mdl @@ -713,7 +713,7 @@ // // commit packet // - Status = CommitSetupPacket(&CtrlSetup, 0, BufferSize, Mdl); + Status = CommitSetupPacket(&CtrlSetup, NULL, BufferSize, Mdl);
// // free mdl @@ -809,6 +809,8 @@ IN ULONG BufferLength, OUT PULONG OutBufferLength) { + ULONG Length; + // sanity check ASSERT(BufferLength >= sizeof(USB_CONFIGURATION_DESCRIPTOR)); ASSERT(ConfigDescriptorBuffer); @@ -821,8 +823,9 @@ PC_ASSERT(m_DeviceDescriptor.bNumConfigurations == 1);
// copy configuration descriptor - RtlCopyMemory(ConfigDescriptorBuffer, m_ConfigurationDescriptors[0].ConfigurationDescriptor, min(m_ConfigurationDescriptors[0].ConfigurationDescriptor->wTotalLength, BufferLength)); - *OutBufferLength = m_ConfigurationDescriptors[0].ConfigurationDescriptor->wTotalLength; + Length = min(m_ConfigurationDescriptors[0].ConfigurationDescriptor->wTotalLength, BufferLength); + RtlCopyMemory(ConfigDescriptorBuffer, m_ConfigurationDescriptors[0].ConfigurationDescriptor, Length); + *OutBufferLength = Length; }
//---------------------------------------------------------------------------------------- @@ -904,7 +907,7 @@ // // commit setup packet // - Status = CommitSetupPacket(SetupPacket, 0, BufferLength, Mdl); + Status = CommitSetupPacket(SetupPacket, NULL, BufferLength, Mdl);
if (Mdl != NULL) { @@ -1055,7 +1058,7 @@ CtrlSetup.wValue.W = bConfigurationValue;
// select configuration - Status = CommitSetupPacket(&CtrlSetup, 0, 0, 0); + Status = CommitSetupPacket(&CtrlSetup, NULL, 0, NULL);
if (!ConfigurationDescriptor) { @@ -1174,7 +1177,7 @@ CtrlSetup.bmRequestType.B = 0x01;
// issue request - Status = CommitSetupPacket(&CtrlSetup, 0, 0, 0); + Status = CommitSetupPacket(&CtrlSetup, NULL, 0, NULL);
// informal debug print DPRINT1("CUSBDevice::SelectInterface AlternateSetting %x InterfaceNumber %x Status %x\n", InterfaceInfo->AlternateSetting, InterfaceInfo->InterfaceNumber, Status);