Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix errors extracted by the Clang static analyzer. Most are false pos…

…itives under GC (with a few real issues), but I want to keep the analyzer quiet and avoid obvious issues when not using GC (maybe for a future project)
  • Loading branch information...
commit 7e1a2d97a6c04bcd6782d9b2a9e1e750875c286d 1 parent 27fb2f7
Olivier Gutknecht authored
View
2  core/KCAbstractNode.m
@@ -125,7 +125,7 @@ - (void)addSortedObject:(KCAbstractNode*)object
return;
[self addObject:object];
[self willChangeValueForKey:@"children"];
- [self.children sortUsingDescriptors:[NSArray arrayWithObject:[[NSSortDescriptor alloc] initWithKey:@"nodeTitle" ascending:YES]]];
+ [self.children sortUsingDescriptors:[NSArray arrayWithObject:[[[NSSortDescriptor alloc] initWithKey:@"nodeTitle" ascending:YES] autorelease]]];
[self didChangeValueForKey:@"children"];
}
View
18 core/KCChefConnection.m
@@ -33,7 +33,7 @@ -(id)init
-(void)addCookbook:(KCCookbook*)node
{
- NSSortDescriptor* sort = [[NSSortDescriptor alloc] initWithKey:@"nodeTitle" ascending:YES];
+ NSSortDescriptor* sort = [[[NSSortDescriptor alloc] initWithKey:@"nodeTitle" ascending:YES] autorelease];
[self willChangeValueForKey:@"cookbooks"];
[cookbooks addObject:node];
[cookbooks sortUsingDescriptors:[NSArray arrayWithObject:sort]];
@@ -42,7 +42,7 @@ -(void)addCookbook:(KCCookbook*)node
-(void)addNode:(KCNode*)node
{
- NSSortDescriptor* sort = [[NSSortDescriptor alloc] initWithKey:@"nodeTitle" ascending:YES];
+ NSSortDescriptor* sort = [[[NSSortDescriptor alloc] initWithKey:@"nodeTitle" ascending:YES] autorelease];
[self willChangeValueForKey:@"nodes"];
[nodes addObject:node];
[nodes sortUsingDescriptors:[NSArray arrayWithObject:sort]];
@@ -67,7 +67,7 @@ -(void)processOperationResult:(KCNetworkOperation*)op
if ([op.type isEqualToString:@"get.registrations"]) {
[registrations removeAllObjects];
for (NSDictionary *element in array) {
- KCRegistration* node = [[KCRegistration alloc] init];
+ KCRegistration* node = [[[KCRegistration alloc] init] autorelease];
node.nodeTitle = [element objectForKey:@"name"];
node.content = element; // We shouldn't duplicate content and nodeTitle, fix this.
node.connection = self;
@@ -170,42 +170,42 @@ -(void)refresh:(id)sender
NSOperationQueue* queue = [(KCApplicationDelegate*)[NSApp delegate] queue];
- KCNetworkOperation* nodesOp = [[KCNetworkOperation alloc] init];
+ KCNetworkOperation* nodesOp = [[[KCNetworkOperation alloc] init] autorelease];
nodesOp.url = [NSURL URLWithString:[NSString stringWithFormat:@"%@/nodes.json", self.serverURL]];
nodesOp.type = @"get.nodes";
nodesOp.summary = @"Refreshing nodes list";
[nodesOp addObserver:self forKeyPath:@"isFinished" options:0 context:nil];
[queue addOperation:nodesOp];
- KCNetworkOperation* registrationsOp = [[KCNetworkOperation alloc] init];
+ KCNetworkOperation* registrationsOp = [[[KCNetworkOperation alloc] init] autorelease];
registrationsOp.type = @"get.registrations";
registrationsOp.summary = @"Refreshing registrations";
registrationsOp.url = [NSURL URLWithString:[NSString stringWithFormat:@"%@/registrations.json", self.serverURL]];
[registrationsOp addObserver:self forKeyPath:@"isFinished" options:0 context:nil];
[queue addOperation:registrationsOp];
- KCNetworkOperation* cookbookOp1 = [[KCNetworkOperation alloc] init];
+ KCNetworkOperation* cookbookOp1 = [[[KCNetworkOperation alloc] init] autorelease];
cookbookOp1.type = @"get.recipes";
cookbookOp1.summary = @"Refreshing recipes";
cookbookOp1.url = [NSURL URLWithString:[NSString stringWithFormat:@"%@/cookbooks/_recipe_files", self.serverURL]];
[cookbookOp1 addObserver:self forKeyPath:@"isFinished" options:0 context:nil];
[queue addOperation:cookbookOp1];
- KCNetworkOperation* cookbookOp2 = [[KCNetworkOperation alloc] init];
+ KCNetworkOperation* cookbookOp2 = [[[KCNetworkOperation alloc] init] autorelease];
cookbookOp2.type = @"get.attributes";
cookbookOp2.summary = @"Refreshing attribute files";
cookbookOp2.url = [NSURL URLWithString:[NSString stringWithFormat:@"%@/cookbooks/_attribute_files", self.serverURL]];
[cookbookOp2 addObserver:self forKeyPath:@"isFinished" options:0 context:nil];
[queue addOperation:cookbookOp2];
- KCNetworkOperation* cookbookOp3 = [[KCNetworkOperation alloc] init];
+ KCNetworkOperation* cookbookOp3 = [[[KCNetworkOperation alloc] init] autorelease];
cookbookOp3.type = @"get.definitions";
cookbookOp3.summary = @"Refreshing definitions";
cookbookOp3.url = [NSURL URLWithString:[NSString stringWithFormat:@"%@/cookbooks/_definition_files", self.serverURL]];
[cookbookOp3 addObserver:self forKeyPath:@"isFinished" options:0 context:nil];
[queue addOperation:cookbookOp3];
- KCNetworkOperation* cookbookOp4 = [[KCNetworkOperation alloc] init];
+ KCNetworkOperation* cookbookOp4 = [[[KCNetworkOperation alloc] init] autorelease];
cookbookOp4.type = @"get.libraries";
cookbookOp4.summary = @"Refreshing libraries";
cookbookOp4.url = [NSURL URLWithString:[NSString stringWithFormat:@"%@/cookbooks/_library_files", self.serverURL]];
View
8 core/KCCookbook.m
@@ -56,7 +56,7 @@ -(void)addRecipe:(NSString*)name
{
KCChefNode* node = [self recipeForName:name];
if (node==nil) {
- node = [[KCChefNode alloc] init];
+ node = [[[KCChefNode alloc] init] autorelease];
node.nodeTitle = name;
node.nodeType = @"recipe";
node.connection = self.connection;
@@ -80,7 +80,7 @@ -(void)addAttribute:(NSString*)name
{
KCChefNode* node = [self attributeForName:name];
if (node==nil) {
- node = [[KCChefNode alloc] init];
+ node = [[[KCChefNode alloc] init] autorelease];
node.nodeTitle = name;
node.nodeType = @"attribute";
node.connection = self.connection;
@@ -104,7 +104,7 @@ -(void)addDefinition:(NSString*)name
{
KCChefNode* node = [self definitionForName:name];
if (node==nil) {
- node = [[KCChefNode alloc] init];
+ node = [[[KCChefNode alloc] init] autorelease];
node.nodeTitle = name;
node.nodeType = @"definition";
node.connection = self.connection;
@@ -128,7 +128,7 @@ -(void)addLibrary:(NSString*)name
{
KCChefNode* node = [self libraryForName:name];
if (node==nil) {
- node = [[KCChefNode alloc] init];
+ node = [[[KCChefNode alloc] init] autorelease];
node.nodeTitle = name;
node.nodeType = @"library";
node.parent = self;
View
4 core/KCNetworkOperation.m
@@ -37,8 +37,8 @@ -(void)main
{
[self setData:d];
- SBJSON *parser = [[SBJSON alloc] init];
- NSString *json_string = [[NSString alloc] initWithData:d encoding:NSUTF8StringEncoding];
+ SBJSON *parser = [[[SBJSON alloc] init] autorelease];
+ NSString *json_string = [[[NSString alloc] initWithData:d encoding:NSUTF8StringEncoding] autorelease];
NSObject* r = [parser objectWithString:json_string error:nil];
[self setResult:r];
}
View
6 core/KCNode.m
@@ -128,7 +128,7 @@ -(NSMutableArray*)nodeTreeFromDictionary:(NSDictionary*)d
NSArray* keys = [[d allKeys] sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)];
for (NSString* key in keys)
{
- KCAttributeNode* n = [[KCAttributeNode alloc] init];
+ KCAttributeNode* n = [[[KCAttributeNode alloc] init] autorelease];
[n setNodeTitle:key];
id value = [d objectForKey:key];
if ([value isKindOfClass:[NSArray class]]) {
@@ -156,7 +156,7 @@ -(NSMutableArray*)nodeTreeFromArray:(NSArray*)array
NSMutableArray* result = [NSMutableArray array];
for (id value in array)
{
- KCAttributeNode* n = [[KCAttributeNode alloc] init];
+ KCAttributeNode* n = [[[KCAttributeNode alloc] init] autorelease];
[n setNodeTitle:@""];
if ([value isKindOfClass:[NSArray class]]) {
n.nodeType = @"Array";
@@ -181,7 +181,7 @@ -(NSMutableArray*)nodeTreeFromArray:(NSArray*)array
-(void)refresh:(id)sender
{
NSOperationQueue* queue = [(KCApplicationDelegate*)[NSApp delegate] queue];
- KCNetworkOperation* op = [[KCNetworkOperation alloc] init];
+ KCNetworkOperation* op = [[[KCNetworkOperation alloc] init] autorelease];
NSString* urlID = [self.nodeTitle stringByReplacingOccurrencesOfString:@"." withString:@"_"];
op.url = [NSURL URLWithString:[NSString stringWithFormat:@"%@/nodes/%@.json", self.connection.serverURL, urlID]];
View
2  core/KCRegistration.m
@@ -36,7 +36,7 @@ - (void)observeValueForKeyPath:(NSString *)keyPath
-(void)refresh:(id)sender
{
NSOperationQueue* queue = [(KCApplicationDelegate*)[NSApp delegate] queue];
- KCNetworkOperation* op = [[KCNetworkOperation alloc] init];
+ KCNetworkOperation* op = [[[KCNetworkOperation alloc] init] autorelease];
NSString* urlID = [self.nodeTitle stringByReplacingOccurrencesOfString:@"." withString:@"_"];
op.url = [NSURL URLWithString:[NSString stringWithFormat:@"%@/registrations/%@.json", self.connection.serverURL, urlID]];
View
2  gui/KCApplicationDelegate.m
@@ -22,7 +22,7 @@ + (void)initialize {
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
[self setQueue:[[NSOperationQueue alloc] init]];
- KCLoginWindowController *c = [[KCLoginWindowController alloc] initWithWindowNibName:@"LoginWindow"];
+ KCLoginWindowController *c = [[[KCLoginWindowController alloc] initWithWindowNibName:@"LoginWindow"] autorelease];
[c showWindow:self];
}
View
2  gui/KCCookbookController.m
@@ -66,7 +66,7 @@ - (IBAction)browserSingleClick:(NSBrowser*)browser {
currentOperation = nil;
}
NSOperationQueue* queue = [(KCApplicationDelegate*)[NSApp delegate] queue];
- KCNetworkStringOperation* op = [[KCNetworkStringOperation alloc] init];
+ KCNetworkStringOperation* op = [[[KCNetworkStringOperation alloc] init] autorelease];
op.url = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@", self.chefConnection.serverURL, path]];
op.type = [NSString stringWithFormat:@"refresh.%@",category];
op.summary = [NSString stringWithFormat:@"Getting %@ file %@", category, title];
View
6 gui/KCLoginWindowController.m
@@ -25,12 +25,12 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N
[a runModal];
}
else {
- KCChefConnection* chef = [[KCChefConnection alloc] init];
+ KCChefConnection* chef = [[[KCChefConnection alloc] init] autorelease];
chef.serverURL = [urlField stringValue];
[chef refresh:self];
[self close];
- KCMainWindowController *c = [[KCMainWindowController alloc] initWithWindowNibName:@"MainWindow"];
+ KCMainWindowController *c = [[[KCMainWindowController alloc] initWithWindowNibName:@"MainWindow"] autorelease];
[c setChefConnection:chef];
[c showWindow:nil];
}
@@ -47,7 +47,7 @@ -(void)connect:(id)sender
return;
NSOperationQueue* queue = [(KCApplicationDelegate*)[NSApp delegate] queue];
- KCNetworkOperation* op = [[KCNetworkOperation alloc] init];
+ KCNetworkOperation* op = [[[KCNetworkOperation alloc] init] autorelease];
op.url = [NSURL URLWithString:[NSString stringWithFormat:@"%@/nodes.json", [url description]]]; // This is baroque, let's fix it
[op addObserver:self forKeyPath:@"isFinished" options:0 context:nil];
[queue addOperation:op];
View
14 gui/KCMainWindowController.m
@@ -45,24 +45,24 @@ -(void)prepareSourceContent
KCNodesProxy *nodeProxy;
KCCookbooksProxy *cookbookProxy;
- viewNode = [[KCViewControllerNode alloc] init];
+ viewNode = [[[KCViewControllerNode alloc] init] autorelease];
viewNode.viewController = statusController;
[viewNode setIsLeaf:true];
[a addObject:viewNode];
- nodeProxy = [[KCNodesProxy alloc] init];
+ nodeProxy = [[[KCNodesProxy alloc] init] autorelease];
nodeProxy.connection = self.chefConnection;
[nodeProxy setNodeTitle:@"Nodes"];
[a addObject:nodeProxy];
- cookbookProxy = [[KCCookbooksProxy alloc] init];
+ cookbookProxy = [[[KCCookbooksProxy alloc] init] autorelease];
cookbookProxy.connection = self.chefConnection;
[cookbookProxy setNodeTitle:@"Cookbooks"];
[a addObject:cookbookProxy];
#if 0
KCChefNode *child;
- viewNode = [[KCViewControllerNode alloc] init];
+ viewNode = [[[KCViewControllerNode alloc] init] autorelease];
viewNode.viewController = cookbooksController;
[viewNode setIsLeaf:false];
child = [[KCChefNode alloc] init];
@@ -72,12 +72,12 @@ -(void)prepareSourceContent
[a addObject:viewNode];
#endif
- viewNode = [[KCViewControllerNode alloc] init];
+ viewNode = [[[KCViewControllerNode alloc] init] autorelease];
viewNode.viewController = registrationsController;
[viewNode setIsLeaf:true];
[a addObject:viewNode];
- viewNode = [[KCViewControllerNode alloc] init];
+ viewNode = [[[KCViewControllerNode alloc] init] autorelease];
((KCViewControllerNode*)viewNode).viewController = searchController;
[viewNode setIsLeaf:true];
@@ -100,7 +100,7 @@ - (void)awakeFromNib
[self setupViewControllers];
NSTableColumn *tableColumn = [sourceView tableColumnWithIdentifier:COLUMNID_NAME];
- KCImageAndTextCell *imageAndTextCell = [[KCImageAndTextCell alloc] init];
+ KCImageAndTextCell *imageAndTextCell = [[[KCImageAndTextCell alloc] init] autorelease];
[imageAndTextCell setEditable:NO];
[tableColumn setDataCell:imageAndTextCell];
View
4 gui/KCNodeController.m
@@ -73,7 +73,7 @@ - (void)outlineView:(NSOutlineView *)view willDisplayCell:(id)cell forTableColum
{
NSFont *font = [NSFont boldSystemFontOfSize:11];
NSDictionary *attrsDictionary = [NSDictionary dictionaryWithObjectsAndKeys:font, NSFontAttributeName, [NSColor yellowColor], NSBackgroundColorAttributeName, nil];
- NSMutableAttributedString* rendering = [[NSMutableAttributedString alloc] initWithString:text];
+ NSMutableAttributedString* rendering = [[[NSMutableAttributedString alloc] initWithString:text] autorelease];
while ((location < [text length])&&(location!=NSNotFound)) {
NSRange range = [text rangeOfString:searchString options:NSDiacriticInsensitiveSearch range:NSMakeRange(location,([text length]-location))];
if (range.location!=NSNotFound) {
@@ -89,7 +89,7 @@ - (void)outlineView:(NSOutlineView *)view willDisplayCell:(id)cell forTableColum
if (!rendered && ([matchingAttributes containsObject:attribute]) && [[tableColumn identifier] isEqualToString:@"key"]) {
NSFont *font = [NSFont boldSystemFontOfSize:11];
NSDictionary *attrsDictionary = [NSDictionary dictionaryWithObjectsAndKeys:font, NSFontAttributeName, [NSColor colorWithCalibratedRed:1 green:1 blue:0.75 alpha:1], NSBackgroundColorAttributeName, nil];
- NSMutableAttributedString* rendering = [[NSMutableAttributedString alloc] initWithString:text attributes:attrsDictionary];
+ NSMutableAttributedString* rendering = [[[NSMutableAttributedString alloc] initWithString:text attributes:attrsDictionary] autorelease];
[cell setAttributedStringValue:rendering];
}
}
View
9 gui/KCSearchController.m
@@ -73,15 +73,16 @@ - (void)search:(id)sender
switch ([topLevelPredicate compoundPredicateType])
{
- case NSAndPredicateType:
- join = @" AND ";
- break;
case NSOrPredicateType:
join = @" OR ";
break;
case NSNotPredicateType:
join = @" NOT ";
break;
+ case NSAndPredicateType:
+ default:
+ join = @" AND ";
+ break;
}
NSMutableArray* subexp = [NSMutableArray array];
NSArray* subpredicates = [topLevelPredicate subpredicates];
@@ -111,7 +112,7 @@ - (void)search:(id)sender
a = [attributes componentsJoinedByString:@","];
NSOperationQueue* queue = [(KCApplicationDelegate*)[NSApp delegate] queue];
- KCNetworkOperation* op = [[KCNetworkOperation alloc] init];
+ KCNetworkOperation* op = [[[KCNetworkOperation alloc] init] autorelease];
op.url = [NSURL URLWithString:[NSString stringWithFormat:@"%@/search/node.json?q=%@&a=%@", self.chefConnection.serverURL, q, a]]; // This is baroque, let's fix it
op.type = @"search.node";
op.summary = @"Searching index";
View
2  gui/KCViewController.h
@@ -7,7 +7,7 @@
//
#import <Cocoa/Cocoa.h>
-#import "KCChefConnection.h";
+#import "KCChefConnection.h"
@class KCMainWindowController;
Please sign in to comment.
Something went wrong with that request. Please try again.