diff options
author | Nathan Hjelm <hjelmn@cs.unm.edu> | 2013-03-12 23:09:07 +0800 |
---|---|---|
committer | Pete Batard <pete@akeo.ie> | 2013-03-12 22:52:41 +0000 |
commit | 5689b7709352f82061f92cec735fe961f8d00ab0 (patch) | |
tree | 112b9f0075d47c59596663b7b030d69b387088d7 | |
parent | 894e65649cda90fd0404b816a16585e2efffb1cd (diff) | |
download | libusb-5689b7709352f82061f92cec735fe961f8d00ab0.tar.gz |
OS X: Use kCFNumberSInt32Type when reading device location from the IO registry
* Closes #97
-rw-r--r-- | libusb/os/darwin_usb.c | 10 | ||||
-rw-r--r-- | libusb/version_nano.h | 2 |
2 files changed, 7 insertions, 5 deletions
diff --git a/libusb/os/darwin_usb.c b/libusb/os/darwin_usb.c index ed4a933..47d7961 100644 --- a/libusb/os/darwin_usb.c +++ b/libusb/os/darwin_usb.c @@ -160,7 +160,7 @@ static int ep_to_pipeRef(struct libusb_device_handle *dev_handle, uint8_t ep, ui return -1; } -static int usb_setup_device_iterator (io_iterator_t *deviceIterator, long location) { +static int usb_setup_device_iterator (io_iterator_t *deviceIterator, UInt32 location) { CFMutableDictionaryRef matchingDict = IOServiceMatching(kIOUSBDeviceClassName); if (!matchingDict) @@ -172,7 +172,9 @@ static int usb_setup_device_iterator (io_iterator_t *deviceIterator, long locati &kCFTypeDictionaryValueCallBacks); if (propertyMatchDict) { - CFTypeRef locationCF = CFNumberCreate (NULL, kCFNumberLongType, &location); + /* there are no unsigned CFNumber types so treat the value as signed. the os seems to do this + internally (CFNumberType of locationID is 3) */ + CFTypeRef locationCF = CFNumberCreate (NULL, kCFNumberSInt32Type, &location); CFDictionarySetValue (propertyMatchDict, CFSTR(kUSBDevicePropertyLocationID), locationCF); /* release our reference to the CFNumber (CFDictionarySetValue retains it) */ @@ -292,7 +294,7 @@ static void darwin_devices_detached (void *ptr, io_iterator_t rem_devices) { struct darwin_device_handle_priv *priv; io_service_t device; - long location; + UInt32 location; bool locationValid; CFTypeRef locationCF; UInt32 message; @@ -309,7 +311,7 @@ static void darwin_devices_detached (void *ptr, io_iterator_t rem_devices) { continue; locationValid = CFGetTypeID(locationCF) == CFNumberGetTypeID() && - CFNumberGetValue(locationCF, kCFNumberLongType, &location); + CFNumberGetValue(locationCF, kCFNumberSInt32Type, &location); CFRelease (locationCF); diff --git a/libusb/version_nano.h b/libusb/version_nano.h index 76481d3..a4acadb 100644 --- a/libusb/version_nano.h +++ b/libusb/version_nano.h @@ -1 +1 @@ -#define LIBUSB_NANO 10626 +#define LIBUSB_NANO 10627 |