On Fri, Mar 8, 2013 at 1:55 PM, Xiaofan Chen <xiaof...@gmail.com> wrote:
> On Thu, Mar 7, 2013 at 11:34 AM, Xiaofan Chen <xiaof...@gmail.com> wrote:
>> I have removed some of the Mac OS X thingy from 1.0.15. They
>> are good to have but not necessary.
>
> Now only issue #83, issue #98 and issue #102 are listed under
> 1.0.15 milestone.
> https://github.com/libusbx/libusbx/issues?milestone=11&state=open
>
> If possible, I will see if I can get #97 and #99 Darwin bug fixes into
> 1.0.15 or not. If not, they can be in next release. They look
> relatively simple to me.
>

The following is the patch for #97, recreated from Nathan's patch
against libusbx.git.

>From 857328fb70839494a2d195ec2561a2e749d14682 Mon Sep 17 00:00:00 2001
From: Nathan Hjelm <hje...@cs.unm.edu>
Date: Tue, 12 Mar 2013 23:09:07 +0800
Subject: [PATCH] Use kCFNumberSInt32Type when reading device location from
 the IO registry

---
 libusb/os/darwin_usb.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 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);

-- 
1.7.12.4 (Apple Git-37)





-- 
Xiaofan

Attachment: fix_location_darwin.patch
Description: Binary data

------------------------------------------------------------------------------
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester  
Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the  
endpoint security space. For insight on selecting the right partner to 
tackle endpoint security challenges, access the full report. 
http://p.sf.net/sfu/symantec-dev2dev
_______________________________________________
libusbx-devel mailing list
libusbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusbx-devel

Reply via email to