mirror of
https://github.com/transmission/transmission
synced 2024-12-22 07:42:37 +00:00
fix: implicit conversion loses integer precision (#6466)
This commit is contained in:
parent
9c4d28dd08
commit
e5e768e2ab
7 changed files with 10 additions and 10 deletions
|
@ -19,8 +19,8 @@ void tr_block_info::init_sizes(uint64_t const total_size_in, uint32_t const piec
|
|||
|
||||
total_size_ = total_size_in;
|
||||
piece_size_ = piece_size_in;
|
||||
n_pieces_ = (total_size_ + piece_size_ - 1) / piece_size_;
|
||||
n_blocks_ = (total_size_ + BlockSize - 1) / BlockSize;
|
||||
n_pieces_ = static_cast<tr_piece_index_t>((total_size_ + piece_size_ - 1) / piece_size_);
|
||||
n_blocks_ = static_cast<tr_block_index_t>((total_size_ + BlockSize - 1) / BlockSize);
|
||||
|
||||
uint32_t remainder = total_size_ % piece_size_;
|
||||
final_piece_size_ = remainder != 0U ? remainder : piece_size_;
|
||||
|
|
|
@ -88,8 +88,8 @@ public:
|
|||
}
|
||||
else
|
||||
{
|
||||
loc.block = byte_idx / BlockSize;
|
||||
loc.piece = byte_idx / piece_size();
|
||||
loc.block = static_cast<tr_block_index_t>(byte_idx / BlockSize);
|
||||
loc.piece = static_cast<tr_piece_index_t>(byte_idx / piece_size());
|
||||
}
|
||||
|
||||
loc.block_offset = static_cast<uint32_t>(loc.byte - (uint64_t{ loc.block } * BlockSize));
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace
|
|||
return var != nullptr && (var->holds_alternative<tr_variant::Vector>() || var->holds_alternative<tr_variant::Map>());
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr int variant_index(tr_variant const* const var)
|
||||
[[nodiscard]] constexpr size_t variant_index(tr_variant const* const var)
|
||||
{
|
||||
if (var != nullptr)
|
||||
{
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
struct tr_variant
|
||||
{
|
||||
public:
|
||||
enum Type
|
||||
enum Type : size_t
|
||||
{
|
||||
NoneIndex = 0,
|
||||
BoolIndex = 1,
|
||||
|
|
|
@ -899,7 +899,7 @@ void onTorrentCompletenessChanged(tr_torrent* tor, tr_completeness status, bool
|
|||
//registering the Web UI to Bonjour
|
||||
if ([self.fDefaults boolForKey:@"RPC"] && [self.fDefaults boolForKey:@"RPCWebDiscovery"])
|
||||
{
|
||||
[BonjourController.defaultController startWithPort:[self.fDefaults integerForKey:@"RPCPort"]];
|
||||
[BonjourController.defaultController startWithPort:static_cast<int>([self.fDefaults integerForKey:@"RPCPort"])];
|
||||
}
|
||||
|
||||
//shamelessly ask for donations
|
||||
|
|
|
@ -791,7 +791,7 @@ static NSString* const kWebUIURLFormat = @"http://localhost:%ld/";
|
|||
return static_cast<int>(components.hour * 60 + components.minute);
|
||||
}
|
||||
|
||||
+ (NSDate*)timeSumToDate:(int)sum
|
||||
+ (NSDate*)timeSumToDate:(NSInteger)sum
|
||||
{
|
||||
NSDateComponents* comps = [[NSDateComponents alloc] init];
|
||||
comps.hour = sum / 60;
|
||||
|
@ -1515,7 +1515,7 @@ static NSString* const kWebUIURLFormat = @"http://localhost:%ld/";
|
|||
self.fQueueSeedField.integerValue = seedQueueNum;
|
||||
|
||||
//check stalled handled by bindings
|
||||
self.fStalledField.intValue = stalledMinutes;
|
||||
self.fStalledField.integerValue = stalledMinutes;
|
||||
}
|
||||
|
||||
[NSNotificationCenter.defaultCenter postNotificationName:@"SpeedLimitUpdate" object:nil];
|
||||
|
|
|
@ -88,7 +88,7 @@ bool trashDataFile(char const* filename, void* /*user_data*/, tr_error* error)
|
|||
NSError* localError;
|
||||
if (![Torrent trashFile:@(filename) error:&localError])
|
||||
{
|
||||
error->set(localError.code, localError.description.UTF8String);
|
||||
error->set(static_cast<int>(localError.code), localError.description.UTF8String);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue