From e5b3c026b5b9996e955487a1323f8c3179b0c7ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Lebel?= Date: Sun, 29 Mar 2015 16:13:20 +0200 Subject: [PATCH] enable more warnings (and fixing them) --- .../Versions/A/Headers/MCPConnection.h | 1 - MongoHub.xcodeproj/project.pbxproj | 8 ++++++++ .../MHConnectionWindowController.m | 8 ++++---- .../ConnectionWindow/MHQueryViewController.m | 18 +++++++++--------- .../MHDatabaseItem.m | 5 ----- Sources/Exporter-Importer/MHFileExporter.m | 2 +- 6 files changed, 22 insertions(+), 20 deletions(-) diff --git a/Frameworks/MCPKit.framework/Versions/A/Headers/MCPConnection.h b/Frameworks/MCPKit.framework/Versions/A/Headers/MCPConnection.h index 3f32b1df..9c4c81cd 100644 --- a/Frameworks/MCPKit.framework/Versions/A/Headers/MCPConnection.h +++ b/Frameworks/MCPKit.framework/Versions/A/Headers/MCPConnection.h @@ -199,7 +199,6 @@ void pingThreadCleanup(void *pingDetails); - (NSString *)getLastErrorMessage; - (void)setLastErrorMessage:(NSString *)theErrorMessage; - (NSUInteger)getLastErrorID; -+ (BOOL)isErrorNumberConnectionError:(NSInteger)theErrorNumber; - (void)updateErrorStatuses; // Queries diff --git a/MongoHub.xcodeproj/project.pbxproj b/MongoHub.xcodeproj/project.pbxproj index a9ac43df..d8a08041 100644 --- a/MongoHub.xcodeproj/project.pbxproj +++ b/MongoHub.xcodeproj/project.pbxproj @@ -1172,12 +1172,16 @@ CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = NO; GCC_TREAT_WARNINGS_AS_ERRORS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_SHADOW = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; MACOSX_DEPLOYMENT_TARGET = 10.8; SDKROOT = macosx; @@ -1191,13 +1195,17 @@ CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = NO; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; GCC_TREAT_WARNINGS_AS_ERRORS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_SHADOW = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; MACOSX_DEPLOYMENT_TARGET = 10.8; SDKROOT = macosx; diff --git a/Sources/ConnectionWindow/MHConnectionWindowController.m b/Sources/ConnectionWindow/MHConnectionWindowController.m index 5a76bbd1..aba113e7 100644 --- a/Sources/ConnectionWindow/MHConnectionWindowController.m +++ b/Sources/ConnectionWindow/MHConnectionWindowController.m @@ -284,12 +284,12 @@ - (MODQuery *)getCollectionListForDatabaseItem:(MHDatabaseItem *)databaseItem mongoDatabase = databaseItem.database; [self.loaderIndicator startAnimation:nil]; result = [mongoDatabase collectionNamesWithCallback:^(NSArray *collectionList, MODQuery *mongoQuery) { - MHDatabaseItem *databaseItem; + MHDatabaseItem *newDatabaseItem; [self.loaderIndicator stopAnimation:nil]; - databaseItem = [self.clientItem databaseItemWithName:mongoDatabase.name]; - if (collectionList && databaseItem) { - if ([databaseItem updateChildrenWithList:collectionList]) { + newDatabaseItem = [self.clientItem databaseItemWithName:mongoDatabase.name]; + if (collectionList && newDatabaseItem) { + if ([newDatabaseItem updateChildrenWithList:collectionList]) { [self.databaseCollectionOutlineView reloadData]; } } else if (mongoQuery.error) { diff --git a/Sources/ConnectionWindow/MHQueryViewController.m b/Sources/ConnectionWindow/MHQueryViewController.m index c705db21..d7bebdcf 100644 --- a/Sources/ConnectionWindow/MHQueryViewController.m +++ b/Sources/ConnectionWindow/MHQueryViewController.m @@ -387,12 +387,12 @@ - (void)_removeQueryWithCriteria:(MODSortedDictionary *)criteria { [self.removeQueryLoaderIndicator startAnimation:nil]; [self.collection countWithCriteria:criteria readPreferences:nil callback:^(int64_t count, MODQuery *mongoQuery) { - [self.collection removeWithCriteria:criteria callback:^(MODQuery *mongoQuery) { + [self.collection removeWithCriteria:criteria callback:^(MODQuery *removeQuery) { NSColor *flashColor; - if (mongoQuery.error) { + if (removeQuery.error) { self.removeResultsTextField.stringValue = @"Error!"; - NSBeginAlertSheet(@"Error", @"OK", nil, nil, self.view.window, nil, nil, nil, NULL, @"%@", mongoQuery.error.localizedDescription); + NSBeginAlertSheet(@"Error", @"OK", nil, nil, self.view.window, nil, nil, nil, NULL, @"%@", removeQuery.error.localizedDescription); flashColor = NSColor.redColor; } else { self.removeResultsTextField.stringValue = [NSString stringWithFormat:@"Removed Documents: %lld", count]; @@ -542,8 +542,8 @@ - (IBAction)findQuery:(id)sender convertedDocuments = [MODHelper convertForOutlineWithObjects:documents bsonData:bsonData jsonKeySortOrder:self.connectionStore.jsonKeySortOrderInSearch]; [self.findDocumentOutlineViewController displayDocuments:convertedDocuments withLabel:nil]; [self.findDocumentOutlineViewController setBackButtonEnabled:self.findSkipTextField.stringValue.integerValue != 0]; - [self.collection countWithCriteria:criteria readPreferences:nil callback:^(int64_t count, MODQuery *mongoQuery) { - [self.findDocumentOutlineViewController displayLabel:[NSString stringWithFormat:@"Total Results: %lld (%0.2fs)", count, [[mongoQuery.userInfo objectForKey:@"timequery"] duration]]]; + [self.collection countWithCriteria:criteria readPreferences:nil callback:^(int64_t count, MODQuery *countQuery) { + [self.findDocumentOutlineViewController displayLabel:[NSString stringWithFormat:@"Total Results: %lld (%0.2fs)", count, [[countQuery.userInfo objectForKey:@"timequery"] duration]]]; }]; } [self.findQueryLoaderIndicator stopAnimation:nil]; @@ -912,12 +912,12 @@ - (IBAction)updateQuery:(id)sender upsert:self.updateUpsetCheckBox.state multiUpdate:self.updateMultiCheckBox.state writeConcern:nil - callback:^(MODQuery *mongoQuery) { + callback:^(MODQuery *updateQuery) { NSColor *flashColor; - if (mongoQuery.error) { + if (updateQuery.error) { self.updateResultsTextField.stringValue = @"Error!"; - NSBeginAlertSheet(@"Error", @"OK", nil, nil, self.view.window, nil, nil, nil, NULL, @"%@", mongoQuery.error.localizedDescription); + NSBeginAlertSheet(@"Error", @"OK", nil, nil, self.view.window, nil, nil, nil, NULL, @"%@", updateQuery.error.localizedDescription); flashColor = NSColor.redColor; } else { self.updateResultsTextField.stringValue = [NSString stringWithFormat:@"Updated Documents: %lld", count]; @@ -1105,7 +1105,7 @@ - (IBAction)aggregationRunAction:(id)sender [allData addObject:documentData]; return YES; } - endCallback:^(uint64_t documentCounts, BOOL cursorStopped, MODQuery *mongoQuery) { + endCallback:^(uint64_t documentCounts, BOOL cursorStopped, MODQuery *forEachQuery) { NSString *label = [NSString stringWithFormat:@"%lld documents", documentCounts]; NSArray *displayedDocuments = [MODHelper convertForOutlineWithObjects:documents bsonData:allData jsonKeySortOrder:self.connectionStore.jsonKeySortOrderInSearch]; [self.aggregationDocumentOutlineViewController displayDocuments:displayedDocuments withLabel:label]; diff --git a/Sources/DatabaseCollectionOutlineView/MHDatabaseItem.m b/Sources/DatabaseCollectionOutlineView/MHDatabaseItem.m index 646e98d5..056f15f5 100644 --- a/Sources/DatabaseCollectionOutlineView/MHDatabaseItem.m +++ b/Sources/DatabaseCollectionOutlineView/MHDatabaseItem.m @@ -63,11 +63,6 @@ - (MHCollectionItem *)collectionItemWithName:(NSString *)name return self.collectionItems[name]; } -static NSInteger collectionItemSortFunction(id element1, id element2, void *context) -{ - return [[element1 name] compare:[element2 name] options:0]; -} - - (BOOL)updateChildrenWithList:(NSArray *)list { BOOL result = NO; diff --git a/Sources/Exporter-Importer/MHFileExporter.m b/Sources/Exporter-Importer/MHFileExporter.m index 47f03354..abd559f5 100644 --- a/Sources/Exporter-Importer/MHFileExporter.m +++ b/Sources/Exporter-Importer/MHFileExporter.m @@ -75,7 +75,7 @@ - (void)export [NSNotificationCenter.defaultCenter postNotificationName:MHImporterExporterProgressNotification object:self userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithDouble:(double)self.documentProcessedCount / count], MHImporterExporterNotificationProgressKey, nil]]; } return YES; - } endCallback:^(uint64_t documentCounts, BOOL cursorStopped, MODQuery *mongoQuery) { + } endCallback:^(uint64_t documentCounts, BOOL cursorStopped, MODQuery *forEachQuery) { close(fileDescriptor); [NSNotificationCenter.defaultCenter postNotificationName:MHImporterExporterStopNotification object:self userInfo:nil]; }];