From abbced3d0d6b73cdc644e29da7b0b830d0fb3c61 Mon Sep 17 00:00:00 2001 From: Nate Weaver Date: Wed, 4 Jul 2012 23:48:35 -0500 Subject: [PATCH] Fix dead stores and other analyzer hits. --- Cocoa/Classes/ApplicationDelegate.m | 3 ++- Cocoa/Classes/AttributesFormatter.m | 2 +- Cocoa/Classes/RKSupportResourceRegistry.m | 7 +++++-- Cocoa/Classes/ResourceDocument.m | 8 ++++++++ 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Cocoa/Classes/ApplicationDelegate.m b/Cocoa/Classes/ApplicationDelegate.m index e01049d..a97548a 100644 --- a/Cocoa/Classes/ApplicationDelegate.m +++ b/Cocoa/Classes/ApplicationDelegate.m @@ -25,7 +25,8 @@ - (void)applicationWillFinishLaunching:(NSNotification *)notification { // instanciate my own subclass of NSDocumentController so I can override the open dialog - [[RKDocumentController alloc] init]; + // autorelease to fix an analyzer warning; the application already holds onto the document controller + [[[RKDocumentController alloc] init] autorelease]; [RKSupportResourceRegistry scanForSupportResources]; } diff --git a/Cocoa/Classes/AttributesFormatter.m b/Cocoa/Classes/AttributesFormatter.m index 99460f0..4237dbd 100644 --- a/Cocoa/Classes/AttributesFormatter.m +++ b/Cocoa/Classes/AttributesFormatter.m @@ -51,7 +51,7 @@ if( addComma ) [string appendString:@", "]; if( attributeCount > 2 ) [string appendString:@"Sys"]; else [string appendString:@"SysHeap"]; - addComma = YES; + /* addComma = YES; */ } return string; } diff --git a/Cocoa/Classes/RKSupportResourceRegistry.m b/Cocoa/Classes/RKSupportResourceRegistry.m index 3b1f00a..c0dfd0f 100644 --- a/Cocoa/Classes/RKSupportResourceRegistry.m +++ b/Cocoa/Classes/RKSupportResourceRegistry.m @@ -5,15 +5,18 @@ + (void)scanForSupportResources { + [RKSupportResourceRegistry scanForSupportResourcesInFolder:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Support Resources"]]; #if MAC_OS_X_VERSION_10_4 <= MAC_OS_X_VERSION_MAX_ALLOWED NSArray *dirsArray = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSAllDomainsMask, YES); dirsArray = [dirsArray arrayByMakingObjectsPerformSelector:@selector(stringByAppendingPathComponent:) withObject:@"ResKnife/Support Resources"]; // FIXME: log content of dirsArray and merge with the following: -#endif - [RKSupportResourceRegistry scanForSupportResourcesInFolder:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Support Resources"]]; + for (NSString *dir in dirsArray) + [RKSupportResourceRegistry scanForSupportResourcesInFolder:dir]; +#else [RKSupportResourceRegistry scanForSupportResourcesInFolder:[NSHomeDirectory() stringByAppendingPathComponent:@"Library/Application Support/ResKnife/Support Resources"]]; [RKSupportResourceRegistry scanForSupportResourcesInFolder:@"/Library/Application Support/ResKnife/Support Resources"]; [RKSupportResourceRegistry scanForSupportResourcesInFolder:@"/Network/Library/Application Support/ResKnife/Support Resources"]; +#endif } + (void)scanForSupportResourcesInFolder:(NSString *)path diff --git a/Cocoa/Classes/ResourceDocument.m b/Cocoa/Classes/ResourceDocument.m index 3101cb3..2aa364d 100644 --- a/Cocoa/Classes/ResourceDocument.m +++ b/Cocoa/Classes/ResourceDocument.m @@ -325,6 +325,10 @@ extern NSString *RKResourcePboardType; unichar *uniname = (unichar *) NewPtrClear(sizeof(unichar) *256); [[fileName lastPathComponent] getCharacters:uniname]; error = FSPathMakeRef((const UInt8 *)[[fileName stringByDeletingLastPathComponent] UTF8String], parentRef, nil); + + if (error != noErr) + NSLog(@"FSPathMakeRef got error %d", error); + if(fork) error = FSCreateResourceFile(parentRef, [[fileName lastPathComponent] length], (UniChar *) uniname, kFSCatInfoNone, NULL, fork->length, (UniChar *) &fork->unicode, fileRef, NULL); else error = FSCreateResourceFile(parentRef, [[fileName lastPathComponent] length], (UniChar *) uniname, kFSCatInfoNone, NULL, 0, NULL, fileRef, NULL); @@ -395,6 +399,10 @@ extern NSString *RKResourcePboardType; [[resource representedFork] getCharacters:uniname]; FSIORefNum forkRefNum = 0; error = FSOpenFork(fileRef, [[resource representedFork] length], (UniChar *) uniname, fsWrPerm, &forkRefNum); + + if (error != noErr) + NSLog(@"FSOpenFork got error %d", error); + if(!error && forkRefNum) error = FSWriteFork(forkRefNum, fsFromStart, 0, [[resource data] length], [[resource data] bytes], NULL); if(forkRefNum) FSCloseFork(forkRefNum);