mirror of
https://github.com/transmission/transmission.git
synced 2025-12-20 02:18:42 +00:00
chore: fix warnings when compiling macOS client with either Xcode or CMake (#6676)
* chore: fix CGFloat comparison warnings in macOS code.
There are 2 cases:
1. Speed comparisons.
The lowest significant value displayed in UI is 0.1 bytes per sec.
See [NSString stringForSpeed] and [NSString stringForSpeedCompact].
2. Ratio limit comparison.
The lowest significant value displayed in UI is 0.01 (no unit).
This is based on maximumFractionDigits=2 set in related XIB file.
Signed-off-by: Dzmitry Neviadomski <nevack.d@gmail.com>
* chore: fix warning about shadowed variable
CGFloat const difference was used twice in the same scope
Signed-off-by: Dzmitry Neviadomski <nevack.d@gmail.com>
* chore: fix unused block parameter warnings
Signed-off-by: Dzmitry Neviadomski <nevack.d@gmail.com>
* chore: disable GCC_WARN_64_TO_32_BIT_CONVERSION for libtransmission
This warnings are not reported with CMake build.
Signed-off-by: Dzmitry Neviadomski <nevack.d@gmail.com>
* chore: disable CLANG_WARN_STRICT_PROTOTYPES for dht
This is third party target, warning is not enabled with CMake build.
Signed-off-by: Dzmitry Neviadomski <nevack.d@gmail.com>
* chore: disable '-Wexit-time-destructors' warning with CMake.
There are two cases when this is reported in libtransmission:
1. `log_state` in anonymous namespace in `log.cc`.
2. static inline `dh_pool_mutex` in `tr_handshake` in `handshake.h`.
I don't see how this may be improved or how this affects correctness,
so don't nag about that.
Signed-off-by: Dzmitry Neviadomski <nevack.d@gmail.com>
---------
Signed-off-by: Dzmitry Neviadomski <nevack.d@gmail.com>
This commit is contained in:
committed by
GitHub
parent
45d3c678bc
commit
8e35e526c6
@@ -5,6 +5,7 @@
|
||||
#import "BadgeView.h"
|
||||
#import "NSStringAdditions.h"
|
||||
#import "NSImageAdditions.h"
|
||||
#import "Utils.h"
|
||||
|
||||
static CGFloat const kBetweenPadding = 2.0;
|
||||
static NSImage* kWhiteUpArrow = [[NSImage imageNamed:@"UpArrowTemplate"] imageWithColor:NSColor.whiteColor];
|
||||
@@ -61,7 +62,7 @@ typedef NS_ENUM(NSInteger, ArrowDirection) {
|
||||
- (BOOL)setRatesWithDownload:(CGFloat)downloadRate upload:(CGFloat)uploadRate
|
||||
{
|
||||
//only needs update if the badges were displayed or are displayed now
|
||||
if (self.fDownloadRate == downloadRate && self.fUploadRate == uploadRate)
|
||||
if (isSpeedEqual(self.fDownloadRate, downloadRate) && isSpeedEqual(self.fUploadRate, uploadRate))
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
@@ -191,6 +191,8 @@ target_sources(${TR_NAME}-mac
|
||||
TrackerTableView.mm
|
||||
URLSheetWindowController.h
|
||||
URLSheetWindowController.mm
|
||||
Utils.h
|
||||
Utils.mm
|
||||
WebSeedTableView.h
|
||||
WebSeedTableView.mm)
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#import "InfoOptionsViewController.h"
|
||||
#import "NSStringAdditions.h"
|
||||
#import "Torrent.h"
|
||||
#import "Utils.h"
|
||||
|
||||
typedef NS_ENUM(NSInteger, OptionPopupType) {
|
||||
OptionPopupTypeGlobal = 0,
|
||||
@@ -295,7 +296,7 @@ static CGFloat const kStackViewSpacing = 8.0;
|
||||
checkRatio = kInvalidValue;
|
||||
}
|
||||
|
||||
if (!multipleRatioLimits && ratioLimit != torrent.ratioLimit)
|
||||
if (!multipleRatioLimits && isRatioEqual(ratioLimit, torrent.ratioLimit))
|
||||
{
|
||||
multipleRatioLimits = YES;
|
||||
}
|
||||
|
||||
@@ -351,9 +351,9 @@ typedef NS_ENUM(NSUInteger, TabTag) {
|
||||
viewRect = [self.fOptionsViewController viewRect];
|
||||
}
|
||||
|
||||
CGFloat const difference = NSHeight(viewRect) - oldHeight;
|
||||
windowRect.origin.y -= difference;
|
||||
windowRect.size.height += difference;
|
||||
CGFloat const viewHeightDifference = NSHeight(viewRect) - oldHeight;
|
||||
windowRect.origin.y -= viewHeightDifference;
|
||||
windowRect.size.height += viewHeightDifference;
|
||||
windowRect.size.width = MAX(NSWidth(windowRect), minWindowWidth);
|
||||
|
||||
if ([self.fViewController respondsToSelector:@selector(saveViewSize)]) //a little bit hacky, but avoids requiring an extra method
|
||||
@@ -363,11 +363,11 @@ typedef NS_ENUM(NSUInteger, TabTag) {
|
||||
CGFloat const screenHeight = NSHeight(window.screen.visibleFrame);
|
||||
if (NSHeight(windowRect) > screenHeight)
|
||||
{
|
||||
CGFloat const difference = screenHeight - NSHeight(windowRect);
|
||||
windowRect.origin.y -= difference;
|
||||
windowRect.size.height += difference;
|
||||
CGFloat const windowHeightDifference = screenHeight - NSHeight(windowRect);
|
||||
windowRect.origin.y -= windowHeightDifference;
|
||||
windowRect.size.height += windowHeightDifference;
|
||||
|
||||
viewRect.size.height += difference;
|
||||
viewRect.size.height += windowHeightDifference;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ static NSTimeInterval const kCheckFireInterval = 3.0;
|
||||
timeoutInterval:15.0];
|
||||
|
||||
_fTask = [_fSession dataTaskWithRequest:portProbeRequest
|
||||
completionHandler:^(NSData* _Nullable data, NSURLResponse* _Nullable response, NSError* _Nullable error) {
|
||||
completionHandler:^(NSData* _Nullable data, NSURLResponse* _Nullable, NSError* _Nullable error) {
|
||||
if (error)
|
||||
{
|
||||
NSLog(@"Unable to get port status: connection failed (%@)", error.localizedDescription);
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#import "StatusBarController.h"
|
||||
#import "NSStringAdditions.h"
|
||||
#import "Utils.h"
|
||||
|
||||
typedef NSString* StatusRatioType NS_TYPED_EXTENSIBLE_ENUM;
|
||||
|
||||
@@ -77,13 +78,13 @@ typedef NS_ENUM(NSUInteger, StatusTag) {
|
||||
- (void)updateWithDownload:(CGFloat)dlRate upload:(CGFloat)ulRate
|
||||
{
|
||||
//set rates
|
||||
if (dlRate != self.fPreviousDownloadRate)
|
||||
if (!isSpeedEqual(self.fPreviousDownloadRate, dlRate))
|
||||
{
|
||||
self.fTotalDLField.stringValue = [NSString stringForSpeed:dlRate];
|
||||
self.fPreviousDownloadRate = dlRate;
|
||||
}
|
||||
|
||||
if (ulRate != self.fPreviousUploadRate)
|
||||
if (!isSpeedEqual(self.fPreviousUploadRate, ulRate))
|
||||
{
|
||||
self.fTotalULField.stringValue = [NSString stringForSpeed:ulRate];
|
||||
self.fPreviousUploadRate = ulRate;
|
||||
|
||||
@@ -125,7 +125,7 @@ static NSTimeInterval const kToggleProgressSeconds = 0.175;
|
||||
NSIndexSet* fullIndexSet = [NSIndexSet indexSetWithIndexesInRange:fullRange];
|
||||
NSMutableIndexSet* visibleIndexSet = [[NSMutableIndexSet alloc] init];
|
||||
|
||||
[fullIndexSet enumerateIndexesUsingBlock:^(NSUInteger row, BOOL* stop) {
|
||||
[fullIndexSet enumerateIndexesUsingBlock:^(NSUInteger row, BOOL*) {
|
||||
id rowView = [self rowViewAtRow:row makeIfNecessary:NO];
|
||||
if ([rowView isGroupRowStyle])
|
||||
{
|
||||
@@ -151,7 +151,7 @@ static NSTimeInterval const kToggleProgressSeconds = 0.175;
|
||||
|
||||
//redraw fControlButton
|
||||
BOOL minimal = [self.fDefaults boolForKey:@"SmallView"];
|
||||
[rowIndexes enumerateIndexesUsingBlock:^(NSUInteger row, BOOL* stop) {
|
||||
[rowIndexes enumerateIndexesUsingBlock:^(NSUInteger row, BOOL*) {
|
||||
id rowView = [self rowViewAtRow:row makeIfNecessary:NO];
|
||||
if (![rowView isGroupRowStyle])
|
||||
{
|
||||
|
||||
8
macosx/Utils.h
Normal file
8
macosx/Utils.h
Normal file
@@ -0,0 +1,8 @@
|
||||
// This file Copyright © Transmission authors and contributors.
|
||||
// It may be used under the MIT (SPDX: MIT) license.
|
||||
// License text can be found in the licenses/ folder.
|
||||
|
||||
#import <CoreFoundation/CoreFoundation.h>
|
||||
|
||||
bool isSpeedEqual(CGFloat old_speed, CGFloat new_speed);
|
||||
bool isRatioEqual(CGFloat old_ratio, CGFloat new_ratio);
|
||||
19
macosx/Utils.mm
Normal file
19
macosx/Utils.mm
Normal file
@@ -0,0 +1,19 @@
|
||||
// This file Copyright © Transmission authors and contributors.
|
||||
// It may be used under the MIT (SPDX: MIT) license.
|
||||
// License text can be found in the licenses/ folder.
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#import "Utils.h"
|
||||
|
||||
bool isSpeedEqual(CGFloat old_speed, CGFloat new_speed)
|
||||
{
|
||||
static CGFloat constexpr kSpeedCompareEps = 0.1 / 2;
|
||||
return std::abs(new_speed - old_speed) < kSpeedCompareEps;
|
||||
}
|
||||
|
||||
bool isRatioEqual(CGFloat old_ratio, CGFloat new_ratio)
|
||||
{
|
||||
static CGFloat constexpr kRatioCompareEps = 0.01 / 2;
|
||||
return std::abs(new_ratio - old_ratio) < kRatioCompareEps;
|
||||
}
|
||||
Reference in New Issue
Block a user