Skip to content

Commit

Permalink
Sync usb-darwin to upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
AtariDreams committed Aug 30, 2021
1 parent 67654f6 commit 3356b83
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions backend/usb-darwin.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,8 @@ print_device(const char *uri, /* I - Device URI */


(void)uri;
(void)argc;
(void)argv;

/*
* Catch SIGQUIT to determine who is sending it...
Expand Down Expand Up @@ -1512,12 +1514,11 @@ static kern_return_t load_printerdriver(CFStringRef *driverBundlePath)
SInt32 score;
kern_return_t kr;
printer_interface_t interface;
HRESULT res;

kr = IOCreatePlugInInterfaceForService(g.printer_obj, kIOUSBInterfaceUserClientTypeID, kIOCFPlugInInterfaceID, &iodev, &score);
if (kr == kIOReturnSuccess)
{
if ((res = (*iodev)->QueryInterface(iodev, USB_INTERFACE_KIND, (LPVOID *) &interface)) == noErr)
if ((*iodev)->QueryInterface(iodev, USB_INTERFACE_KIND, (LPVOID *) &interface) == noErr)
{
*driverBundlePath = IORegistryEntryCreateCFProperty(g.printer_obj, kUSBClassDriverProperty, NULL, kNilOptions);

Expand Down Expand Up @@ -1615,14 +1616,14 @@ static CFStringRef copy_printer_interface_deviceid(printer_interface_t printer,

if (actualLength > 2 && actualLength <= bufferLength - 2)
{
ret = CFStringCreateWithBytes(NULL, (const UInt8 *) &request.pData[2], actualLength - 2, kCFStringEncodingUTF8, false);
ret = CFStringCreateWithBytes(NULL, (const UInt8 *)request.pData + 2, actualLength - 2, kCFStringEncodingUTF8, false);
}
else if (actualLength > 2) {
err = sendRequest(actualLength);
if (err == kIOReturnSuccess && request.wLenDone > 0)
{
actualLength = OSSwapBigToHostInt16(*((UInt16 *)request.pData));
ret = CFStringCreateWithBytes(NULL, (const UInt8 *) &request.pData[2], actualLength - 2, kCFStringEncodingUTF8, false);
ret = CFStringCreateWithBytes(NULL, (const UInt8 *)request.pData + 2, actualLength - 2, kCFStringEncodingUTF8, false);
}
}
}
Expand Down Expand Up @@ -1703,13 +1704,8 @@ static CFStringRef copy_printer_interface_deviceid(printer_interface_t printer,
{
CFStringAppend(extras, ret);
CFRelease(ret);

ret = extras;
}
else
{
ret = extras;
}
ret = extras;
}
}

Expand Down Expand Up @@ -1816,7 +1812,7 @@ static CFStringRef copy_printer_interface_indexed_description(printer_interface_
if ((description[0] & 1) != 0)
description[0] &= 0xfe;

char buffer[258] = {};
char buffer[258] = {0};
unsigned int maxLength = sizeof buffer;
if (description[0] > 1)
{
Expand Down

0 comments on commit 3356b83

Please sign in to comment.