From: Mike Gelfand Date: Sun, 11 Sep 2016 10:22:49 +0000 (+0300) Subject: Fix some warnings revealed by CMake configuration compiler flags X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ee0f7686b5a44d94c6bc0d6533388aa616086533;p=transmission Fix some warnings revealed by CMake configuration compiler flags --- diff --git a/macosx/AddMagnetWindowController.m b/macosx/AddMagnetWindowController.m index 8e88019ad..d02b2eeea 100644 --- a/macosx/AddMagnetWindowController.m +++ b/macosx/AddMagnetWindowController.m @@ -80,7 +80,9 @@ case TR_PRI_HIGH: priorityIndex = POPUP_PRIORITY_HIGH; break; case TR_PRI_NORMAL: priorityIndex = POPUP_PRIORITY_NORMAL; break; case TR_PRI_LOW: priorityIndex = POPUP_PRIORITY_LOW; break; - default: NSAssert1(NO, @"Unknown priority for adding torrent: %d", [fTorrent priority]); + default: + NSAssert1(NO, @"Unknown priority for adding torrent: %d", [fTorrent priority]); + priorityIndex = POPUP_PRIORITY_NORMAL; } [fPriorityPopUp selectItemAtIndex: priorityIndex]; @@ -239,7 +241,9 @@ case POPUP_PRIORITY_HIGH: priority = TR_PRI_HIGH; break; case POPUP_PRIORITY_NORMAL: priority = TR_PRI_NORMAL; break; case POPUP_PRIORITY_LOW: priority = TR_PRI_LOW; break; - default: NSAssert1(NO, @"Unknown priority tag for adding torrent: %ld", [sender tag]); + default: + NSAssert1(NO, @"Unknown priority tag for adding torrent: %ld", [sender tag]); + priority = TR_PRI_NORMAL; } [fTorrent setPriority: priority]; } diff --git a/macosx/AddWindowController.m b/macosx/AddWindowController.m index 494ae90ec..f698e209d 100644 --- a/macosx/AddWindowController.m +++ b/macosx/AddWindowController.m @@ -115,7 +115,9 @@ case TR_PRI_HIGH: priorityIndex = POPUP_PRIORITY_HIGH; break; case TR_PRI_NORMAL: priorityIndex = POPUP_PRIORITY_NORMAL; break; case TR_PRI_LOW: priorityIndex = POPUP_PRIORITY_LOW; break; - default: NSAssert1(NO, @"Unknown priority for adding torrent: %d", [fTorrent priority]); + default: + NSAssert1(NO, @"Unknown priority for adding torrent: %d", [fTorrent priority]); + priorityIndex = POPUP_PRIORITY_NORMAL; } [fPriorityPopUp selectItemAtIndex: priorityIndex]; @@ -258,7 +260,9 @@ case POPUP_PRIORITY_HIGH: priority = TR_PRI_HIGH; break; case POPUP_PRIORITY_NORMAL: priority = TR_PRI_NORMAL; break; case POPUP_PRIORITY_LOW: priority = TR_PRI_LOW; break; - default: NSAssert1(NO, @"Unknown priority tag for adding torrent: %ld", [sender tag]); + default: + NSAssert1(NO, @"Unknown priority tag for adding torrent: %ld", [sender tag]); + priority = TR_PRI_NORMAL; } [fTorrent setPriority: priority]; } diff --git a/macosx/Controller.m b/macosx/Controller.m index 9628f72d5..7dddff535 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -1490,7 +1490,7 @@ static void removeKeRangerRansomware() NSString * title, * message; - const NSInteger selected = [torrents count]; + const NSUInteger selected = [torrents count]; if (selected == 1) { NSString * torrentName = [(Torrent *)[torrents objectAtIndex: 0] name]; @@ -2620,7 +2620,7 @@ static void removeKeRangerRansomware() NSMutableIndexSet * removeIndexes = [NSMutableIndexSet indexSet]; //needs to be a signed integer - for (NSInteger indexInGroup = 0; indexInGroup < [[group torrents] count]; ++indexInGroup) + for (NSUInteger indexInGroup = 0; indexInGroup < [[group torrents] count]; ++indexInGroup) { Torrent * torrent = [[group torrents] objectAtIndex: indexInGroup]; const NSUInteger allIndex = [allTorrents indexOfObjectAtIndexes: unusedAllTorrentsIndexes options: NSEnumerationConcurrent passingTest: ^(id obj, NSUInteger idx, BOOL * stop) { @@ -4160,6 +4160,7 @@ static void removeKeRangerRansomware() break; default: NSAssert1(NO, @"Unknown sort tag received: %ld", [menuItem tag]); + sortType = SORT_ORDER; } [menuItem setState: [sortType isEqualToString: [fDefaults stringForKey: @"Sort"]] ? NSOnState : NSOffState]; diff --git a/macosx/FileNameCell.m b/macosx/FileNameCell.m index 163c4aef6..86adde543 100644 --- a/macosx/FileNameCell.m +++ b/macosx/FileNameCell.m @@ -193,7 +193,7 @@ return result; } -- (NSRect) rectForStatusWithString: (NSAttributedString *) string withTitleRect: (NSRect) titleRect inBounds: (NSRect) bounds; +- (NSRect) rectForStatusWithString: (NSAttributedString *) string withTitleRect: (NSRect) titleRect inBounds: (NSRect) bounds { const NSSize statusSize = [string size]; diff --git a/macosx/FileOutlineView.m b/macosx/FileOutlineView.m index 6b54110f0..a66d61404 100644 --- a/macosx/FileOutlineView.m +++ b/macosx/FileOutlineView.m @@ -96,7 +96,7 @@ NSPoint mouseLocation = [self convertPoint: [[self window] mouseLocationOutsideOfEventStream] fromView: nil]; - for (NSInteger row = visibleRows.location, col = [self columnWithIdentifier: @"Priority"]; row < NSMaxRange(visibleRows); row++) + for (NSInteger row = visibleRows.location, col = [self columnWithIdentifier: @"Priority"]; (NSUInteger)row < NSMaxRange(visibleRows); row++) { FilePriorityCell * cell = (FilePriorityCell *)[self preparedCellAtColumn: col row: row]; diff --git a/macosx/FilePriorityCell.m b/macosx/FilePriorityCell.m index 0982eabd2..713c7b94f 100644 --- a/macosx/FilePriorityCell.m +++ b/macosx/FilePriorityCell.m @@ -124,7 +124,7 @@ } else { - NSMutableArray * images = [NSMutableArray arrayWithCapacity: MAX(count, 1)]; + NSMutableArray * images = [NSMutableArray arrayWithCapacity: MAX(count, 1u)]; CGFloat totalWidth; if (count == 0) diff --git a/macosx/FileRenameSheetController.m b/macosx/FileRenameSheetController.m index 966628093..04eafb791 100644 --- a/macosx/FileRenameSheetController.m +++ b/macosx/FileRenameSheetController.m @@ -120,7 +120,7 @@ typedef void (^CompletionBlock)(BOOL); [self.cancelButton setFrame:newCancelFrame]; } -- (IBAction) rename: (id) sender; +- (IBAction) rename: (id) sender { void (^completionHandler)(BOOL) = ^(BOOL didRename) { if (didRename) diff --git a/macosx/GroupsController.m b/macosx/GroupsController.m index 448b23b1e..f3b29ffcf 100644 --- a/macosx/GroupsController.m +++ b/macosx/GroupsController.m @@ -120,7 +120,7 @@ GroupsController * fGroupsInstance = nil; { if (index != -1) { - for (NSInteger i = 0; i < [fGroups count]; i++) + for (NSUInteger i = 0; i < [fGroups count]; i++) if (index == [[[fGroups objectAtIndex: i] objectForKey: @"Index"] integerValue]) return i; } @@ -336,7 +336,7 @@ GroupsController * fGroupsInstance = nil; return [menu autorelease]; } -- (NSInteger) groupIndexForTorrent: (Torrent *) torrent; +- (NSInteger) groupIndexForTorrent: (Torrent *) torrent { for (NSDictionary * group in fGroups) { diff --git a/macosx/GroupsPrefsController.m b/macosx/GroupsPrefsController.m index 82993de94..d2b7ce778 100644 --- a/macosx/GroupsPrefsController.m +++ b/macosx/GroupsPrefsController.m @@ -234,7 +234,7 @@ #pragma mark - #pragma mark Rule editor -- (IBAction) toggleUseAutoAssignRules: (id) sender; +- (IBAction) toggleUseAutoAssignRules: (id) sender { NSInteger index = [[GroupsController groups] indexForRow: [fTableView selectedRow]]; if ([fAutoAssignRulesEnableCheck state] == NSOnState) @@ -250,7 +250,7 @@ [fAutoAssignRulesEditButton setEnabled: [fAutoAssignRulesEnableCheck state] == NSOnState]; } -- (IBAction) orderFrontRulesSheet: (id) sender; +- (IBAction) orderFrontRulesSheet: (id) sender { if (!fGroupRulesSheetWindow) [NSBundle loadNibNamed: @"GroupRules" owner: self]; @@ -266,7 +266,7 @@ contextInfo: NULL]; } -- (IBAction) cancelRules: (id) sender; +- (IBAction) cancelRules: (id) sender { [fGroupRulesSheetWindow orderOut: nil]; [NSApp endSheet: fGroupRulesSheetWindow]; @@ -280,7 +280,7 @@ } } -- (IBAction) saveRules: (id) sender; +- (IBAction) saveRules: (id) sender { [fGroupRulesSheetWindow orderOut: nil]; [NSApp endSheet: fGroupRulesSheetWindow]; diff --git a/macosx/MessageWindowController.m b/macosx/MessageWindowController.m index 0d0ab0bce..e436401ea 100644 --- a/macosx/MessageWindowController.m +++ b/macosx/MessageWindowController.m @@ -354,6 +354,7 @@ break; default: NSAssert1(NO, @"Unknown message log level: %ld", [fLevelButton indexOfSelectedItem]); + level = TR_LOG_INFO; } if ([[NSUserDefaults standardUserDefaults] integerForKey: @"MessageLevel"] == level) @@ -527,6 +528,7 @@ break; default: NSAssert1(NO, @"Unknown message log level: %ld", level); + levelString = @"?"; } return [NSString stringWithFormat: @"%@ %@ [%@] %@: %@", [message objectForKey: @"Date"], diff --git a/macosx/NSStringAdditions.m b/macosx/NSStringAdditions.m index d52a63949..ee38573d5 100644 --- a/macosx/NSStringAdditions.m +++ b/macosx/NSStringAdditions.m @@ -164,7 +164,7 @@ NSAssert(![NSApp isOnYosemiteOrBetter], @"you should be using NSDateComponentsFormatter on >= 10.10"); NSParameterAssert(max > 0); - NSMutableArray * timeArray = [NSMutableArray arrayWithCapacity: MIN(max, 5)]; + NSMutableArray * timeArray = [NSMutableArray arrayWithCapacity: MIN(max, 5u)]; NSUInteger remaining = seconds; //causes problems for some users when it's a uint64_t if (seconds >= 31557600) //official amount of seconds in one year diff --git a/macosx/StatusBarController.m b/macosx/StatusBarController.m index c5c80740a..75b67c8d7 100644 --- a/macosx/StatusBarController.m +++ b/macosx/StatusBarController.m @@ -234,6 +234,7 @@ typedef enum break; default: NSAssert1(NO, @"Unknown status label tag received: %ld", [menuItem tag]); + statusLabel = STATUS_RATIO_TOTAL; } [menuItem setState: [statusLabel isEqualToString: [[NSUserDefaults standardUserDefaults] stringForKey: @"StatusLabel"]] diff --git a/macosx/Torrent.m b/macosx/Torrent.m index bcb4af6cb..fca916ff3 100644 --- a/macosx/Torrent.m +++ b/macosx/Torrent.m @@ -557,7 +557,7 @@ bool trashDataFile(const char * filename, tr_error ** error) //check if moving inside itself NSArray * oldComponents = [oldFolder pathComponents], * newComponents = [folder pathComponents]; - const NSInteger oldCount = [oldComponents count]; + const NSUInteger oldCount = [oldComponents count]; if (oldCount < [newComponents count] && [[newComponents objectAtIndex: oldCount] isEqualToString: [self name]] && [folder hasPrefix: oldFolder]) @@ -721,7 +721,7 @@ bool trashDataFile(const char * filename, tr_error ** error) //recreate the tracker structure const int oldTrackerCount = fInfo->trackerCount; tr_tracker_info * trackerStructs = tr_new(tr_tracker_info, oldTrackerCount+1); - for (NSUInteger i=0; i < oldTrackerCount; ++i) + for (int i = 0; i < oldTrackerCount; ++i) trackerStructs[i] = fInfo->trackers[i]; trackerStructs[oldTrackerCount].announce = (char *)[tracker UTF8String]; @@ -1376,7 +1376,7 @@ bool trashDataFile(const char * filename, tr_error ** error) return fGroupValue; } -- (void) setGroupValue: (NSInteger) groupValue determinationType: (TorrentDeterminationType) determinationType; +- (void) setGroupValue: (NSInteger) groupValue determinationType: (TorrentDeterminationType) determinationType { if (groupValue != fGroupValue) { @@ -1447,7 +1447,7 @@ bool trashDataFile(const char * filename, tr_error ** error) - (BOOL) canChangeDownloadCheckForFile: (NSUInteger) index { - NSAssert2(index < [self fileCount], @"Index %ld is greater than file count %ld", index, [self fileCount]); + NSAssert2((NSInteger)index < [self fileCount], @"Index %ld is greater than file count %ld", index, [self fileCount]); return [self canChangeDownloadCheckForFiles: [NSIndexSet indexSetWithIndex: index]]; } @@ -1523,7 +1523,7 @@ bool trashDataFile(const char * filename, tr_error ** error) - (NSSet *) filePrioritiesForIndexes: (NSIndexSet *) indexSet { BOOL low = NO, normal = NO, high = NO; - NSMutableSet * priorities = [NSMutableSet setWithCapacity: MIN([indexSet count], 3)]; + NSMutableSet * priorities = [NSMutableSet setWithCapacity: MIN([indexSet count], 3u)]; for (NSUInteger index = [indexSet firstIndex]; index != NSNotFound; index = [indexSet indexGreaterThanIndex: index]) { diff --git a/macosx/TorrentCell.m b/macosx/TorrentCell.m index ce3d3773a..7ca0f8214 100644 --- a/macosx/TorrentCell.m +++ b/macosx/TorrentCell.m @@ -131,7 +131,7 @@ imageSize, imageSize); } -- (NSUInteger) hitTestForEvent: (NSEvent *) event inRect: (NSRect) cellFrame ofView: (NSView *) controlView +- (NSCellHitResult) hitTestForEvent: (NSEvent *) event inRect: (NSRect) cellFrame ofView: (NSView *) controlView { NSPoint point = [controlView convertPoint: [event locationInWindow] fromView: nil]; diff --git a/macosx/TorrentTableView.m b/macosx/TorrentTableView.m index 3e5de081a..baf2eca58 100644 --- a/macosx/TorrentTableView.m +++ b/macosx/TorrentTableView.m @@ -790,6 +790,7 @@ break; default: NSAssert1(NO, @"Unknown priority: %ld", [sender tag]); + priority = TR_PRI_NORMAL; } [fMenuTorrent setPriority: priority];