1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-03-11 22:52:53 +00:00
transmission/macosx/Utils.mm
Dzmitry Neviadomski 8e35e526c6
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>
2024-03-15 00:16:26 -05:00

19 lines
572 B
Text

// 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;
}