mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Fix a false positive reported by scan-build
Arguably this also makes the logic a little clearer, so might as well
This commit is contained in:
@@ -128,7 +128,7 @@ static ssize_t getPlacement(Section const §ion, MemoryLocation &location) {
|
||||
std::deque<FreeSpace> &bankMem = memory[section.type][location.bank - typeInfo.firstBank];
|
||||
size_t spaceIdx = 0;
|
||||
|
||||
if (spaceIdx < bankMem.size())
|
||||
if (spaceIdx < bankMem.size()) {
|
||||
location.address = bankMem[spaceIdx].address;
|
||||
|
||||
// Process locations in that bank
|
||||
@@ -169,6 +169,7 @@ static ssize_t getPlacement(Section const §ion, MemoryLocation &location) {
|
||||
|
||||
// Try again with the new location/free space combo
|
||||
}
|
||||
}
|
||||
|
||||
// Try again in the next bank, if one is available.
|
||||
// Try scrambled banks in descending order until no bank in the scrambled range is
|
||||
@@ -182,7 +183,8 @@ static ssize_t getPlacement(Section const §ion, MemoryLocation &location) {
|
||||
location.bank = scrambleROMX + 1;
|
||||
else
|
||||
return -1;
|
||||
} else if (scrambleWRAMX && section.type == SECTTYPE_WRAMX && location.bank <= scrambleWRAMX) {
|
||||
} else if (scrambleWRAMX && section.type == SECTTYPE_WRAMX
|
||||
&& location.bank <= scrambleWRAMX) {
|
||||
if (location.bank > typeInfo.firstBank)
|
||||
location.bank--;
|
||||
else if (scrambleWRAMX < typeInfo.lastBank)
|
||||
@@ -246,8 +248,8 @@ static void placeSection(Section §ion) {
|
||||
bankMem.insert(
|
||||
bankMem.begin() + spaceIdx + 1,
|
||||
{.address = (uint16_t)(section.org + section.size),
|
||||
.size =
|
||||
(uint16_t)(freeSpace.address + freeSpace.size - section.org - section.size)}
|
||||
.size = (uint16_t)(freeSpace.address + freeSpace.size - section.org - section.size)
|
||||
}
|
||||
);
|
||||
// **`freeSpace` cannot be reused from this point on**, because `bankMem.insert`
|
||||
// invalidates all references to itself!
|
||||
|
||||
Reference in New Issue
Block a user