From: Klas Lindfors Date: Mon, 8 Oct 2012 06:48:48 +0000 (+0100) Subject: make error handling match that of other ykcore implementations X-Git-Tag: v1.8.1~15 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0e08c541679394e498a3c65b16ca4a7b22fb8773;p=yubikey-personalization make error handling match that of other ykcore implementations --- diff --git a/ykcore/ykcore_osx.c b/ykcore/ykcore_osx.c index f381136..4b3bac3 100644 --- a/ykcore/ykcore_osx.c +++ b/ykcore/ykcore_osx.c @@ -79,7 +79,7 @@ void *_ykusb_open_device(int vendor_id, int product_id) CFStringRef keys[2]; CFStringRef values[2]; - yk_errno = YK_EUSBERR; + int rc = YK_ENOKEY; CFNumberRef vendorID = CFNumberCreate( kCFAllocatorDefault, kCFNumberIntType, &vendor_id ); CFNumberRef productID = CFNumberCreate( kCFAllocatorDefault, kCFNumberIntType, &product_id ); @@ -94,6 +94,7 @@ void *_ykusb_open_device(int vendor_id, int product_id) CFSetRef devSet = IOHIDManagerCopyDevices( ykosxManager ); if ( devSet ) { + rc = YK_EUSBERR; CFMutableArrayRef array = CFArrayCreateMutable( kCFAllocatorDefault, 0, NULL ); @@ -104,8 +105,9 @@ void *_ykusb_open_device(int vendor_id, int product_id) if (cnt > 0) { yk = (void *) CFArrayGetValueAtIndex( array, 0 ); } - else - yk_errno = YK_ENOKEY; + else { + rc = YK_ENOKEY; + } CFRelease( array ); CFRelease( devSet ); @@ -120,13 +122,14 @@ void *_ykusb_open_device(int vendor_id, int product_id) if ( _ykusb_IOReturn != kIOReturnSuccess ) { yk_release(); - return 0; + goto error; } - yk_errno = 0; return yk; } +error: + yk_errno = rc; return 0; }