mirror of
https://github.com/dingusdev/dingusppc.git
synced 2026-04-19 10:20:36 +00:00
Fix compiler warnings: cast loses precision.
Use explicit cast when converting large integer types to smaller integer types when it is known that the most significant bytes are not required. For pcidevice, check the ROM file size before casting to int. We'll allow expansion ROM sizes up to 4MB but usually they are 64K, sometimes 128K, rarely 256K. for machinefactory, change the type to size_t so that it can correctly get the size of files that are larger than 4GB; it already checks the file size is 4MB before we need to cast to uint32_t. For floppyimg, check the image size before casting to int. For raw images, only allow files up to 2MB. For DiskCopy42 images, it already checks the file size, so do the cast after that.
This commit is contained in:
@@ -52,7 +52,7 @@ using namespace std;
|
||||
|
||||
static uint32_t str2addr(string& addr_str) {
|
||||
try {
|
||||
return stoul(addr_str, NULL, 0);
|
||||
return (uint32_t)stoul(addr_str, NULL, 0);
|
||||
} catch (invalid_argument& exc) {
|
||||
throw invalid_argument(string("Cannot convert ") + addr_str);
|
||||
}
|
||||
@@ -60,7 +60,7 @@ static uint32_t str2addr(string& addr_str) {
|
||||
|
||||
static uint32_t str2num(string& num_str) {
|
||||
try {
|
||||
return stol(num_str, NULL, 0);
|
||||
return (uint32_t)stol(num_str, NULL, 0);
|
||||
} catch (invalid_argument& exc) {
|
||||
throw invalid_argument(string("Cannot convert ") + num_str);
|
||||
}
|
||||
@@ -512,7 +512,7 @@ void enter_debugger() {
|
||||
}
|
||||
} else if (cmd == "next" || cmd == "ni") {
|
||||
addr_str = "PC";
|
||||
addr = get_reg(addr_str) + 4;
|
||||
addr = (uint32_t)get_reg(addr_str) + 4;
|
||||
ppc_exec_until(addr);
|
||||
} else if (cmd == "until") {
|
||||
ss >> addr_str;
|
||||
@@ -588,7 +588,7 @@ void enter_debugger() {
|
||||
#endif
|
||||
} else {
|
||||
addr_str = "PC";
|
||||
addr = get_reg(addr_str);
|
||||
addr = (uint32_t)get_reg(addr_str);
|
||||
disasm(1, addr);
|
||||
}
|
||||
} catch (invalid_argument& exc) {
|
||||
|
||||
Reference in New Issue
Block a user