PVS V1028: cast result of operation instead of operands
If an overflow occurs before the cast, we can't fix it. If we cast first, we can rely on integer promotion to make the result use the appropriate size. Change-Id: I7462e28422456c07f179f94d39c10c408d9bec36 Reviewed-on: https://review.haiku-os.org/c/1623 Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
parent
fbe53d9249
commit
72bfb14432
|
@ -1454,7 +1454,7 @@ cdda_scan_partition(int fd, partition_data* partition, void* _cookie)
|
|||
uint32 lastTrack = toc->last_track + 1 - toc->first_track;
|
||||
scsi_cd_msf& end = toc->tracks[lastTrack].start.time;
|
||||
|
||||
partition->content_size = off_t(end.minute * kFramesPerMinute
|
||||
partition->content_size = ((off_t)end.minute * kFramesPerMinute
|
||||
+ end.second * kFramesPerSecond + end.frame) * kFrameSize;
|
||||
partition->block_size = kFrameSize;
|
||||
|
||||
|
|
|
@ -96,9 +96,9 @@ exfat_identify_partition(int fd, partition_data* partition, void** _cookie)
|
|||
uint32 rootDirCluster = superBlock.RootDirCluster();
|
||||
uint32 blockSize = 1 << superBlock.BlockShift();
|
||||
uint32 clusterSize = blockSize << superBlock.BlocksPerClusterShift();
|
||||
uint64 rootDirectoryOffset = (uint64)(EXFAT_SUPER_BLOCK_OFFSET
|
||||
+ superBlock.FirstDataBlock() * blockSize
|
||||
+ (rootDirCluster - 2) * clusterSize);
|
||||
uint64 rootDirectoryOffset = EXFAT_SUPER_BLOCK_OFFSET
|
||||
+ (uint64)superBlock.FirstDataBlock() * blockSize
|
||||
+ (rootDirCluster - 2) * clusterSize;
|
||||
struct exfat_entry entry;
|
||||
size_t entrySize = sizeof(struct exfat_entry);
|
||||
for (uint32 i = 0; read_pos(fd, rootDirectoryOffset + i * entrySize,
|
||||
|
|
|
@ -634,10 +634,10 @@ SonixCamDevice::MinRawFrameSize()
|
|||
{
|
||||
// if (fCompressionEnabled) { ... return ; }
|
||||
BRect vf(VideoFrame());
|
||||
int w = vf.IntegerWidth()+1;
|
||||
int h = vf.IntegerHeight()+1;
|
||||
size_t w = vf.IntegerWidth()+1;
|
||||
size_t h = vf.IntegerHeight()+1;
|
||||
// 1 byte/pixel
|
||||
return (size_t)(w*h);
|
||||
return w * h;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1713,7 +1713,7 @@ time_t dos_to_unix_time(dosdatetime)
|
|||
++days; /* OK through 2199 */
|
||||
|
||||
/* convert date & time to seconds relative to 00:00:00, 01/01/YRBASE */
|
||||
m_time = (time_t)((unsigned long)(days + dy) * 86400L +
|
||||
m_time = (time_t)(((unsigned long)days + dy) * 86400L +
|
||||
(unsigned long)hh * 3600L +
|
||||
(unsigned long)(mm * 60 + ss));
|
||||
/* - 1; MS-DOS times always rounded up to nearest even second */
|
||||
|
|
|
@ -157,7 +157,7 @@ PackageFileHeapReader::ReadAndDecompressChunk(size_t chunkIndex,
|
|||
{
|
||||
uint64 offset = fOffsets[chunkIndex];
|
||||
bool isLastChunk
|
||||
= uint64(chunkIndex + 1) * kChunkSize >= fUncompressedHeapSize;
|
||||
= ((uint64)chunkIndex + 1) * kChunkSize >= fUncompressedHeapSize;
|
||||
size_t compressedSize = isLastChunk
|
||||
? fCompressedHeapSize - offset
|
||||
: fOffsets[chunkIndex + 1] - offset;
|
||||
|
|
|
@ -1731,7 +1731,7 @@ GenericAttributeText::CommitEditedTextFlavor(BTextView* textView)
|
|||
switch (type) {
|
||||
case B_STRING_TYPE:
|
||||
size = fModel->WriteAttr(columnName, type, 0, textView->Text(),
|
||||
(size_t)(textView->TextLength() + 1));
|
||||
(size_t)textView->TextLength() + 1);
|
||||
break;
|
||||
|
||||
case B_BOOL_TYPE:
|
||||
|
|
|
@ -597,7 +597,7 @@ ns_name_pack(const u_char *src, u_char *dst, int dstsiz,
|
|||
if (dstp + 1 + n >= eob) {
|
||||
goto cleanup;
|
||||
}
|
||||
memcpy(dstp, srcp, (size_t)(n + 1));
|
||||
memcpy(dstp, srcp, (size_t)n + 1);
|
||||
srcp += n + 1;
|
||||
dstp += n + 1;
|
||||
} while (n != 0);
|
||||
|
|
|
@ -154,7 +154,7 @@ ns_sprintrrf(const u_char *msg, size_t msglen,
|
|||
addlen((size_t)x, &buf, &buflen);
|
||||
len = SPRINTF((tmp, " %s %s", p_class(class), p_type(type)));
|
||||
T(addstr(tmp, (size_t)len, &buf, &buflen));
|
||||
T(spaced = addtab((size_t)(x + len), (size_t)16, spaced, &buf, &buflen));
|
||||
T(spaced = addtab((size_t)x + len, (size_t)16, spaced, &buf, &buflen));
|
||||
|
||||
/*
|
||||
* RData.
|
||||
|
|
Loading…
Reference in New Issue