mirror of
https://github.com/dingusdev/dingusppc.git
synced 2025-01-10 13:29:38 +00:00
Fix compiler warnings.
Xcode build has compiler warnings involving loss of precision. Remove them by adding type casts. Check results in some cases for overflow.
This commit is contained in:
parent
1903c8b557
commit
fe05b1de12
@ -909,7 +909,7 @@ static inline uint32_t calc_dec_value() {
|
||||
uint32_t dec_adj_lo;
|
||||
uint64_t diff = get_virt_time_ns() - dec_wr_timestamp;
|
||||
_u32xu64(tbr_freq_ghz, diff, dec_adj, dec_adj_lo);
|
||||
return (dec_wr_value - dec_adj);
|
||||
return (dec_wr_value - static_cast<uint32_t>(dec_adj));
|
||||
}
|
||||
|
||||
static void update_timebase(uint64_t mask, uint64_t new_val)
|
||||
|
@ -46,7 +46,11 @@ void ScsiHardDisk::insert_image(std::string filename) {
|
||||
ABORT_F("%s: could not open image file %s", this->name.c_str(), filename.c_str());
|
||||
|
||||
this->img_size = this->hdd_img.size();
|
||||
this->total_blocks = (this->img_size + HDD_SECTOR_SIZE - 1) / HDD_SECTOR_SIZE;
|
||||
uint64_t tb = (this->img_size + HDD_SECTOR_SIZE - 1) / HDD_SECTOR_SIZE;
|
||||
this->total_blocks = static_cast<int>(tb);
|
||||
if (this->total_blocks < 0 || tb != this->total_blocks) {
|
||||
ABORT_F("ScsiHardDisk: file size is too large");
|
||||
}
|
||||
}
|
||||
|
||||
void ScsiHardDisk::process_command() {
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
DingusPPC - The Experimental PowerPC Macintosh emulator
|
||||
Copyright (C) 2018-23 divingkatae and maximum
|
||||
Copyright (C) 2018-24 divingkatae and maximum
|
||||
(theweirdo) spatium
|
||||
|
||||
(Contact divingkatae#1017 or powermax#2286 on Discord for more info)
|
||||
@ -174,12 +174,12 @@ uint32_t AtiMach64Gx::read_reg(uint32_t reg_offset, uint32_t size)
|
||||
uint64_t result = this->regs[reg_offset >> 2];
|
||||
|
||||
if (!offset && size == 4) { // fast path
|
||||
return result;
|
||||
return static_cast<uint32_t>(result);
|
||||
} else { // slow path
|
||||
if ((offset + size) > 4) {
|
||||
result |= (uint64_t)(this->regs[(reg_offset >> 2) + 1]) << 32;
|
||||
}
|
||||
return extract_bits<uint64_t>(result, offset * 8, size * 8);
|
||||
return static_cast<uint32_t>(extract_bits<uint64_t>(result, offset * 8, size * 8));
|
||||
}
|
||||
}
|
||||
|
||||
@ -197,7 +197,7 @@ void AtiMach64Gx::write_reg(uint32_t reg_offset, uint32_t value, uint32_t size)
|
||||
}
|
||||
uint64_t old_val = this->regs[reg_offset];
|
||||
insert_bits<uint64_t>(old_val, value, offset * 8, size * 8);
|
||||
value = old_val;
|
||||
value = static_cast<uint32_t>(old_val);
|
||||
}
|
||||
|
||||
switch (reg_offset) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
DingusPPC - The Experimental PowerPC Macintosh emulator
|
||||
Copyright (C) 2018-23 divingkatae and maximum
|
||||
Copyright (C) 2018-24 divingkatae and maximum
|
||||
(theweirdo) spatium
|
||||
|
||||
(Contact divingkatae#1017 or powermax#2286 on Discord for more info)
|
||||
@ -251,12 +251,12 @@ uint32_t ATIRage::read_reg(uint32_t reg_offset, uint32_t size) {
|
||||
}
|
||||
|
||||
if (!offset && size == 4) { // fast path
|
||||
return result;
|
||||
return static_cast<uint32_t>(result);
|
||||
} else { // slow path
|
||||
if ((offset + size) > 4) {
|
||||
result |= (uint64_t)(this->regs[(reg_offset >> 2) + 1]) << 32;
|
||||
}
|
||||
return extract_bits<uint64_t>(result, offset * 8, size * 8);
|
||||
return static_cast<uint32_t>(extract_bits<uint64_t>(result, offset * 8, size * 8));
|
||||
}
|
||||
}
|
||||
|
||||
@ -270,7 +270,7 @@ void ATIRage::write_reg(uint32_t reg_offset, uint32_t value, uint32_t size) {
|
||||
}
|
||||
uint64_t old_val = this->regs[reg_offset];
|
||||
insert_bits<uint64_t>(old_val, value, offset * 8, size * 8);
|
||||
value = old_val;
|
||||
value = static_cast<uint32_t>(old_val);
|
||||
}
|
||||
|
||||
switch (reg_offset) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user