1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-03-10 06:02:57 +00:00

fix: Implicit conversion loses integer precision (#4919)

This commit is contained in:
Cœur 2023-11-05 16:06:24 +01:00 committed by GitHub
parent 9cadcbdb86
commit 586a9eb862
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 14 deletions

View file

@ -203,7 +203,7 @@ static void removeKeRangerRansomware()
pid_t const krProcessId = [line substringFromIndex:1].intValue; pid_t const krProcessId = [line substringFromIndex:1].intValue;
if (kill(krProcessId, SIGKILL) == -1) if (kill(krProcessId, SIGKILL) == -1)
{ {
NSLog(@"Unable to forcibly terminate ransomware process (kernel_service, pid %d), please do so manually", (int)krProcessId); NSLog(@"Unable to forcibly terminate ransomware process (kernel_service, pid %d), please do so manually", krProcessId);
} }
} }
} }

View file

@ -151,22 +151,22 @@ typedef struct PieceInfo
// get the current state // get the current state
BOOL const showAvailability = [NSUserDefaults.standardUserDefaults boolForKey:@"PiecesViewShowAvailability"]; BOOL const showAvailability = [NSUserDefaults.standardUserDefaults boolForKey:@"PiecesViewShowAvailability"];
NSInteger const numCells = MIN(_torrent.pieceCount, kMaxCells); int const numCells = static_cast<int>(MIN(_torrent.pieceCount, kMaxCells));
PieceInfo info; PieceInfo info;
[self.torrent getAvailability:info.available size:numCells]; [self.torrent getAvailability:info.available size:numCells];
[self.torrent getAmountFinished:info.complete size:numCells]; [self.torrent getAmountFinished:info.complete size:numCells];
// compute bounds and color of each cell // compute bounds and color of each cell
NSInteger const across = (NSInteger)ceil(sqrt(numCells)); int const across = static_cast<int>(ceil(sqrt(numCells)));
CGFloat const fullWidth = self.bounds.size.width; CGFloat const fullWidth = self.bounds.size.width;
NSInteger const cellWidth = (NSInteger)((fullWidth - (across + 1) * kBetweenPadding) / across); NSInteger const cellWidth = (NSInteger)((fullWidth - (across + 1) * kBetweenPadding) / across);
NSInteger const extraBorder = (NSInteger)((fullWidth - ((cellWidth + kBetweenPadding) * across + kBetweenPadding)) / 2); NSInteger const extraBorder = (NSInteger)((fullWidth - ((cellWidth + kBetweenPadding) * across + kBetweenPadding)) / 2);
NSMutableArray<NSValue*>* cellBounds = [NSMutableArray arrayWithCapacity:numCells]; NSMutableArray<NSValue*>* cellBounds = [NSMutableArray arrayWithCapacity:numCells];
NSMutableArray<NSColor*>* cellColors = [NSMutableArray arrayWithCapacity:numCells]; NSMutableArray<NSColor*>* cellColors = [NSMutableArray arrayWithCapacity:numCells];
for (NSInteger index = 0; index < numCells; index++) for (int index = 0; index < numCells; index++)
{ {
NSInteger const row = index / across; int const row = index / across;
NSInteger const col = index % across; int const col = index % across;
cellBounds[index] = [NSValue valueWithRect:NSMakeRect( cellBounds[index] = [NSValue valueWithRect:NSMakeRect(
col * (cellWidth + kBetweenPadding) + kBetweenPadding + extraBorder, col * (cellWidth + kBetweenPadding) + kBetweenPadding + extraBorder,
@ -184,12 +184,12 @@ typedef struct PieceInfo
{ {
self.image = [NSImage imageWithSize:self.bounds.size flipped:NO drawingHandler:^BOOL(NSRect /*dstRect*/) { self.image = [NSImage imageWithSize:self.bounds.size flipped:NO drawingHandler:^BOOL(NSRect /*dstRect*/) {
NSRect cFillRects[numCells]; NSRect cFillRects[numCells];
for (NSInteger i = 0; i < numCells; ++i) for (int i = 0; i < numCells; ++i)
{ {
cFillRects[i] = cellBounds[i].rectValue; cFillRects[i] = cellBounds[i].rectValue;
} }
NSColor* cFillColors[numCells]; NSColor* cFillColors[numCells];
for (NSInteger i = 0; i < numCells; ++i) for (int i = 0; i < numCells; ++i)
{ {
cFillColors[i] = cellColors[i]; cFillColors[i] = cellColors[i];
} }

View file

@ -150,7 +150,7 @@ static NSInteger const kMaxPieces = 18 * 18;
return; return;
} }
NSInteger pieceCount = MIN(torrent.pieceCount, kMaxPieces); int const pieceCount = static_cast<int>(MIN(torrent.pieceCount, kMaxPieces));
float* piecesPercent = static_cast<float*>(malloc(pieceCount * sizeof(float))); float* piecesPercent = static_cast<float*>(malloc(pieceCount * sizeof(float)));
[torrent getAmountFinished:piecesPercent size:pieceCount]; [torrent getAmountFinished:piecesPercent size:pieceCount];
@ -166,7 +166,7 @@ static NSInteger const kMaxPieces = 18 * 18;
NSIndexSet* previousFinishedIndexes = torrent.previousFinishedPieces; NSIndexSet* previousFinishedIndexes = torrent.previousFinishedPieces;
NSMutableIndexSet* finishedIndexes = [NSMutableIndexSet indexSet]; NSMutableIndexSet* finishedIndexes = [NSMutableIndexSet indexSet];
for (NSInteger i = 0; i < pieceCount; i++) for (int i = 0; i < pieceCount; i++)
{ {
NSColor* pieceColor; NSColor* pieceColor;
if (piecesPercent[i] == 1.0f) if (piecesPercent[i] == 1.0f)

View file

@ -31,8 +31,8 @@ extern NSString* const kTorrentDidChangeGroupNotification;
@property(nonatomic, readonly) NSString* currentDirectory; @property(nonatomic, readonly) NSString* currentDirectory;
- (void)getAvailability:(int8_t*)tab size:(NSInteger)size; - (void)getAvailability:(int8_t*)tab size:(int)size;
- (void)getAmountFinished:(float*)tab size:(NSInteger)size; - (void)getAmountFinished:(float*)tab size:(int)size;
@property(nonatomic) NSIndexSet* previousFinishedPieces; @property(nonatomic) NSIndexSet* previousFinishedPieces;
- (void)update; - (void)update;

View file

@ -201,12 +201,12 @@ bool trashDataFile(char const* filename, void* /*user_data*/, tr_error* error)
return @(tr_torrentGetCurrentDir(self.fHandle)); return @(tr_torrentGetCurrentDir(self.fHandle));
} }
- (void)getAvailability:(int8_t*)tab size:(NSInteger)size - (void)getAvailability:(int8_t*)tab size:(int)size
{ {
tr_torrentAvailability(self.fHandle, tab, size); tr_torrentAvailability(self.fHandle, tab, size);
} }
- (void)getAmountFinished:(float*)tab size:(NSInteger)size - (void)getAmountFinished:(float*)tab size:(int)size
{ {
tr_torrentAmountFinished(self.fHandle, tab, size); tr_torrentAmountFinished(self.fHandle, tab, size);
} }