Placate/fool Clang static analysis in DDHidLib

This commit is contained in:
Aaron Culliney 2016-09-10 11:35:20 -06:00
parent cb31ccaf9c
commit f3324c0b2b
2 changed files with 9 additions and 3 deletions

View File

@ -50,10 +50,12 @@
CFMutableDictionaryRef hidMatchDictionary = CFMutableDictionaryRef hidMatchDictionary =
IOServiceMatching("AppleIRController"); IOServiceMatching("AppleIRController");
return id ret =
[DDHidDevice allDevicesMatchingCFDictionary: hidMatchDictionary [DDHidDevice allDevicesMatchingCFDictionary: hidMatchDictionary
withClass: self withClass: self
skipZeroLocations: YES]; skipZeroLocations: YES];
CFRelease(hidMatchDictionary);// free our +1retain to placate static analysis ... (it is also freed by IOServiceGetMatchingServices() )
return ret;
} }
+ (DDHidAppleRemote *) firstRemote; + (DDHidAppleRemote *) firstRemote;

View File

@ -29,6 +29,7 @@
#import "NSDictionary+DDHidExtras.h" #import "NSDictionary+DDHidExtras.h"
#import "NSXReturnThrowError.h" #import "NSXReturnThrowError.h"
#import <objc/message.h>
#include <IOKit/hid/IOHIDUsageTables.h> #include <IOKit/hid/IOHIDUsageTables.h>
@interface DDHidDevice (Private) @interface DDHidDevice (Private)
@ -120,7 +121,7 @@
retVal = [self allDevicesMatchingCFDictionary: hidMatchDictionary retVal = [self allDevicesMatchingCFDictionary: hidMatchDictionary
withClass: [DDHidDevice class] withClass: [DDHidDevice class]
skipZeroLocations: NO]; skipZeroLocations: NO];
//CFRelease(hidMatchDictionary);//dont free, it is freed by IOServiceGetMatchingServices CFRelease(hidMatchDictionary);// free our +1retain to placate static analysis ... (it is also freed by IOServiceGetMatchingServices() )
} }
return retVal; return retVal;
} }
@ -145,7 +146,7 @@
retVal = [self allDevicesMatchingCFDictionary: hidMatchDictionary retVal = [self allDevicesMatchingCFDictionary: hidMatchDictionary
withClass: hidClass withClass: hidClass
skipZeroLocations: skipZeroLocations]; skipZeroLocations: skipZeroLocations];
//CFRelease(hidMatchDictionary);//dont free, it is freed by IOServiceGetMatchingServices CFRelease(hidMatchDictionary);// free our +1retain to placate static analysis ... (it is also freed by IOServiceGetMatchingServices() )
} }
return retVal; return retVal;
} }
@ -154,6 +155,9 @@ return retVal;
withClass: (Class) hidClass withClass: (Class) hidClass
skipZeroLocations: (BOOL) skipZeroLocations; skipZeroLocations: (BOOL) skipZeroLocations;
{ {
(void)((id(*)(id, SEL))objc_msgSend((id)matchDictionary, @selector(retain)));
// Now search I/O Registry for matching devices. // Now search I/O Registry for matching devices.
io_iterator_t hidObjectIterator = MACH_PORT_NULL; io_iterator_t hidObjectIterator = MACH_PORT_NULL;
NSMutableArray * devices = [NSMutableArray array]; NSMutableArray * devices = [NSMutableArray array];