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 =
IOServiceMatching("AppleIRController");
return
id ret =
[DDHidDevice allDevicesMatchingCFDictionary: hidMatchDictionary
withClass: self
skipZeroLocations: YES];
CFRelease(hidMatchDictionary);// free our +1retain to placate static analysis ... (it is also freed by IOServiceGetMatchingServices() )
return ret;
}
+ (DDHidAppleRemote *) firstRemote;

View File

@ -29,6 +29,7 @@
#import "NSDictionary+DDHidExtras.h"
#import "NSXReturnThrowError.h"
#import <objc/message.h>
#include <IOKit/hid/IOHIDUsageTables.h>
@interface DDHidDevice (Private)
@ -120,7 +121,7 @@
retVal = [self allDevicesMatchingCFDictionary: hidMatchDictionary
withClass: [DDHidDevice class]
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;
}
@ -145,7 +146,7 @@
retVal = [self allDevicesMatchingCFDictionary: hidMatchDictionary
withClass: hidClass
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;
}
@ -154,6 +155,9 @@ return retVal;
withClass: (Class) hidClass
skipZeroLocations: (BOOL) skipZeroLocations;
{
(void)((id(*)(id, SEL))objc_msgSend((id)matchDictionary, @selector(retain)));
// Now search I/O Registry for matching devices.
io_iterator_t hidObjectIterator = MACH_PORT_NULL;
NSMutableArray * devices = [NSMutableArray array];