Fix a few issues identified via static analysis

This commit is contained in:
Jeff Arena
2013-01-11 11:57:46 -05:00
parent cfbd5d711e
commit e0481096cf

View File

@@ -54,7 +54,11 @@ static RKManagedObjectStore *defaultStore = nil;
+ (void)setDefaultStore:(RKManagedObjectStore *)managedObjectStore
{
@synchronized(defaultStore) {
if (defaultStore) {
@synchronized(defaultStore) {
defaultStore = managedObjectStore;
}
} else {
defaultStore = managedObjectStore;
}
}
@@ -320,7 +324,7 @@ static RKManagedObjectStore *defaultStore = nil;
// We can only do migrations within a versioned momd
if (![[momdURL pathExtension] isEqualToString:@"momd"]) {
NSString *errorDescription = [NSString stringWithFormat:@"Migration failed: Migrations can only be performed to versioned destination models contained in a .momd package. Incompatible destination model given at path '%@'", [momdURL path]];
*error = [NSError errorWithDomain:RKErrorDomain code:NSMigrationError userInfo:@{ NSLocalizedDescriptionKey: errorDescription }];
if (error) *error = [NSError errorWithDomain:RKErrorDomain code:NSMigrationError userInfo:@{ NSLocalizedDescriptionKey: errorDescription }];
return NO;
}
@@ -349,7 +353,7 @@ static RKManagedObjectStore *defaultStore = nil;
// Cannot complete the migration as we can't find a source model
if (! sourceModel) {
NSString *errorDescription = [NSString stringWithFormat:@"Migration failed: Unable to find the source managed object model used to create the %@ store at path '%@'", storeType, [storeURL path]];
*error = [NSError errorWithDomain:RKErrorDomain code:NSMigrationMissingSourceModelError userInfo:@{ NSLocalizedDescriptionKey: errorDescription }];
if (error) *error = [NSError errorWithDomain:RKErrorDomain code:NSMigrationMissingSourceModelError userInfo:@{ NSLocalizedDescriptionKey: errorDescription }];
return NO;
}
@@ -362,8 +366,11 @@ static RKManagedObjectStore *defaultStore = nil;
RKLogError(@"%@", *error);
return NO;
}
NSString *UUID = (__bridge_transfer NSString*)CFUUIDCreateString(kCFAllocatorDefault, CFUUIDCreate(NULL));
CFUUIDRef uuid = CFUUIDCreate(kCFAllocatorDefault);
NSString *UUID = (__bridge_transfer NSString*)CFUUIDCreateString(kCFAllocatorDefault, uuid);
CFRelease(uuid);
NSString *migrationPath = [NSTemporaryDirectory() stringByAppendingFormat:@"Migration-%@.sqlite", UUID];
NSURL *migrationURL = [NSURL fileURLWithPath:migrationPath];