From f3324c0b2be58919013c8e216baeeb4b64c4392e Mon Sep 17 00:00:00 2001 From: Aaron Culliney Date: Sat, 10 Sep 2016 11:35:20 -0600 Subject: [PATCH] Placate/fool Clang static analysis in DDHidLib --- Apple2Mac/DDHidLib/lib/DDHidAppleRemote.m | 4 +++- Apple2Mac/DDHidLib/lib/DDHidDevice.m | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Apple2Mac/DDHidLib/lib/DDHidAppleRemote.m b/Apple2Mac/DDHidLib/lib/DDHidAppleRemote.m index 265db457..8570085f 100644 --- a/Apple2Mac/DDHidLib/lib/DDHidAppleRemote.m +++ b/Apple2Mac/DDHidLib/lib/DDHidAppleRemote.m @@ -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; diff --git a/Apple2Mac/DDHidLib/lib/DDHidDevice.m b/Apple2Mac/DDHidLib/lib/DDHidDevice.m index 387a1e5e..709e6edd 100644 --- a/Apple2Mac/DDHidLib/lib/DDHidDevice.m +++ b/Apple2Mac/DDHidLib/lib/DDHidDevice.m @@ -29,6 +29,7 @@ #import "NSDictionary+DDHidExtras.h" #import "NSXReturnThrowError.h" +#import #include @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];