Skip to content

Commit

Permalink
Fix analyzer warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Gorbach committed Nov 29, 2010
1 parent d5ae879 commit 765b861
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 145 deletions.
8 changes: 4 additions & 4 deletions MFCore.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,20 @@
// Try to connect to server and use the agent's bundle path
id <MFServerProtocol> server = (id <MFServerProtocol>)[NSConnection rootProxyForConnectionWithRegisteredName:kMFDistributedObjectName host:nil];
if (server) {
bundle = [NSBundle bundleWithPath: [server agentBundlePath]];
bundle = [NSBundle bundleWithPath:[server agentBundlePath]];
}
}

NSString *pathToReturn = nil;

if ([mybundleID isEqualToString:kMFMainBundleIdentifier]) {
pathToReturn = [[NSBundle mainBundle] bundlePath];
}

if ([mybundleID isEqualToString: kMFAgentBundleIdentifier] || [mybundleID isEqualToString: kMFMenulingBundleIdentifier]) {
} else if ([mybundleID isEqualToString: kMFAgentBundleIdentifier] || [mybundleID isEqualToString: kMFMenulingBundleIdentifier]) {
NSString *relativePath = @"/../../../";
NSString *fullPath = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent: relativePath];
pathToReturn = [fullPath stringByStandardizingPath];
} else if (!pathToReturn && bundle) {
pathToReturn = [bundle bundlePath];
}

return pathToReturn;
Expand Down
12 changes: 6 additions & 6 deletions MFFilesystemController.m
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ - (NSArray *)pathsToFilesystemDefs {
}
}

return [fsDefPaths copy];
return [[fsDefPaths copy] autorelease];
}

- (void)loadFilesystems {
Expand Down Expand Up @@ -202,7 +202,7 @@ - (void)loadRecentFilesystems {
}

- (void)recordRecentFilesystem:(MFServerFS *)fs {
NSMutableDictionary *params = [fs.parameters mutableCopy];
NSMutableDictionary *params = [[fs.parameters mutableCopy] autorelease];
// Strip the UUID so it never repeats
[params setValue:nil forKey:kMFFSUUIDParameter];

Expand Down Expand Up @@ -306,10 +306,10 @@ - (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(

# pragma mark Security Tokens
- (NSString *)tokenForFilesystem:(MFServerFS *)fs {
CFUUIDRef theUUID = CFUUIDCreate(NULL);
CFStringRef string = CFUUIDCreateString(NULL, theUUID);
CFRelease(theUUID);
NSString *tokenString = [(NSString *)string autorelease];
CFUUIDRef uuidObject = CFUUIDCreate(NULL);
CFStringRef uuidCFString = CFUUIDCreateString(NULL, uuidObject);
CFRelease(uuidObject);
NSString *tokenString = [NSMakeCollectable(uuidCFString) autorelease];
if ([[_tokens allValues] containsObject: fs]) {
MFLogSO(self, fs, @"Uh oh ... adding a second token for an FS already in tokens");
// MFLogSO(self, _tokens, @"Tokens Before %@", _tokens);
Expand Down
58 changes: 37 additions & 21 deletions MFServerFS.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ + (MFServerFS *)loadFilesystemAtPath:(NSString *)path error:(NSError **)error {
@"Could not read dictionary data for filesystem", NSLocalizedDescriptionKey,
[NSString stringWithFormat:@"File at path %@", path], NSLocalizedRecoverySuggestionErrorKey,
nil];
*error = [NSError errorWithDomain:kMFErrorDomain code:kMFErrorCodeDataCannotBeRead userInfo:errorDict];
if (error) {
*error = [NSError errorWithDomain:kMFErrorDomain code:kMFErrorCodeDataCannotBeRead userInfo:errorDict];
}
return nil;
}

Expand All @@ -72,7 +74,9 @@ + (MFServerFS *)loadFilesystemAtPath:(NSString *)path error:(NSError **)error {
@"Could not read plugin id key for filesystem", NSLocalizedDescriptionKey,
[NSString stringWithFormat:@"File at path %@", path], NSLocalizedRecoverySuggestionErrorKey,
nil];
*error = [NSError errorWithDomain:kMFErrorDomain code:kMFErrorCodeMissingParameter userInfo:errorDict];
if (error) {
*error = [NSError errorWithDomain:kMFErrorDomain code:kMFErrorCodeMissingParameter userInfo:errorDict];
}
return nil;
}

Expand All @@ -84,16 +88,20 @@ + (MFServerFS *)loadFilesystemAtPath:(NSString *)path error:(NSError **)error {
BOOL ok = [fs validateParametersWithError:&validationError];
if (ok) {
return fs;
} else {
*error = validationError;
} else {
if (error) {
*error = validationError;
}
return nil;
}
} else {
NSDictionary *errorDict = [NSDictionary dictionaryWithObjectsAndKeys:
@"Invalid plugin ID given", NSLocalizedDescriptionKey,
[NSString stringWithFormat:@"File at path %@", path], NSLocalizedRecoverySuggestionErrorKey,
nil];
*error = [NSError errorWithDomain:kMFErrorDomain code:kMFErrorCodeInvalidParameterValue userInfo:errorDict];
if (error) {
NSDictionary *errorDict = [NSDictionary dictionaryWithObjectsAndKeys:
@"Invalid plugin ID given", NSLocalizedDescriptionKey,
[NSString stringWithFormat:@"File at path %@", path], NSLocalizedRecoverySuggestionErrorKey,
nil];
*error = [NSError errorWithDomain:kMFErrorDomain code:kMFErrorCodeInvalidParameterValue userInfo:errorDict];
}
return nil;
}
}
Expand All @@ -102,7 +110,9 @@ + (MFServerFS *)loadFilesystemAtPath:(NSString *)path error:(NSError **)error {
+ (MFServerFS *)filesystemFromURL:(NSURL *)url plugin:(MFServerPlugin *)p error:(NSError **)error {
NSMutableDictionary* params = [[[p delegate] parameterDictionaryForURL:url error:error] mutableCopy];
if (!params) {
*error = [MFError errorWithErrorCode:kMFErrorCodeMountFaliure description:@"Plugin failed to parse URL"];
if (error) {
*error = [MFError errorWithErrorCode:kMFErrorCodeMountFaliure description:@"Plugin failed to parse URL"];
}
return nil;
}
[params setValue:[NSNumber numberWithBool:NO] forKey:kMFFSPersistentParameter];
Expand All @@ -114,7 +124,9 @@ + (MFServerFS *)filesystemFromURL:(NSURL *)url plugin:(MFServerPlugin *)p error:
NSError *validationError;
BOOL ok = [fs validateParametersWithError:&validationError];
if (!ok) {
*error = validationError;
if (error) {
*error = validationError;
}
return nil;
} else {
return fs;
Expand Down Expand Up @@ -173,11 +185,10 @@ - (NSMutableDictionary *)initializedStatusInfo {
}

- (NSString *)getNewUUID {
CFUUIDRef theUUID = CFUUIDCreate(NULL);
CFStringRef string = CFUUIDCreateString(NULL, theUUID);
CFRelease(theUUID);
NSString* uuid = [(NSString *)string autorelease];
return uuid;
CFUUIDRef uuidObject = CFUUIDCreate(NULL);
CFStringRef uuidCFString = CFUUIDCreateString(NULL, uuidObject);
CFRelease(uuidObject);
return [NSMakeCollectable(uuidCFString) autorelease];
}


Expand All @@ -201,8 +212,7 @@ - (NSMutableDictionary *)fullParametersWithDictionary:(NSDictionary *)fsParams {
}

for(NSString *parameterKey in [defaultParams allKeys]) {
id value;
if ((value = [fsParams objectForKey:parameterKey]) != nil) {
if ([fsParams objectForKey:parameterKey]) {
} else {
[params setObject:[defaultParams objectForKey:parameterKey] forKey:parameterKey];
}
Expand Down Expand Up @@ -416,15 +426,21 @@ - (BOOL)validateParameters:(NSDictionary*)params error:(NSError **)error
// MFLogS(self, @"Delegate did validate %@", impliedParams);
// Continue validation for general macfusion keys
if (![impliedParams objectForKey:kMFFSVolumeNameParameter]) {
*error = [MFError parameterMissingErrorWithParameterName:kMFFSVolumeNameParameter];
if (error) {
*error = [MFError parameterMissingErrorWithParameterName:kMFFSVolumeNameParameter];
}
return NO;
}
if (![impliedParams objectForKey:kMFFSMountPathParameter]) {
*error = [MFError parameterMissingErrorWithParameterName:kMFFSMountPathParameter];
if (error) {
*error = [MFError parameterMissingErrorWithParameterName:kMFFSMountPathParameter];
}
return NO;
}
if (![impliedParams objectForKey:kMFFSUUIDParameter]) {
*error = [MFError parameterMissingErrorWithParameterName:kMFFSUUIDParameter];
if (error) {
*error = [MFError parameterMissingErrorWithParameterName:kMFFSUUIDParameter];
}
return NO;
}
}
Expand Down
Loading

0 comments on commit 765b861

Please sign in to comment.