Re: Static Analyzer and Core Foundation
Re: Static Analyzer and Core Foundation
- Subject: Re: Static Analyzer and Core Foundation
- From: Jean-Daniel Dupas <email@hidden>
- Date: Sat, 19 Sep 2009 12:05:21 +0200
Le 19 sept. 2009 à 02:25, Steve Cronin a écrit :
Luke;
I've adapted the code to accomodate your's and Chris' answer to
question 2.
Here's the entire method, which now shows not static analyzer issues
but I still would like to understand why not.
+ (NSDictionary *)metadataForFilePath:(NSString *)thisPath {
NSDictionary *md = [NSDictionary dictionary];
if (![[NSFileManager defaultManager] fileExistsAtPath:thisPath]) {
NSLog(@"file does not existl");
} else {
MDItemRef mdi = MDItemCreate( nil, (CFStringRef)thisPath );
if ( mdi != nil ) {
CFArrayRef arrayRef = MDItemCopyAttributeNames(mdi);
CFDictionaryRef dictRef = MDItemCopyAttributes( mdi, arrayRef);
md = [NSDictionary dictionaryWithDictionary:(NSDictionary *)
dictRef];
CFRelease(dictRef);
CFRelease(arrayRef);
} else {
NSLog(@"mdi is nil");
}
}
return md;
}
Is this the 'best' this can be?
Thanks for helping me learn,
Steve
Currently, the static analyzer doesn't know what types are reference
counted CF based object, so it does not know that MDItemRef is an
CFTypeRef and so it doesn't try to track reference counting for it.
This is true with for all cf based types, but CoreGraphic one and is
noted as a FIXME in the clang code. Maybe filling a radar about it may
prioritize it ?
-- Jean-Daniel
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden