mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Replace NULL with nullptr (#1321)
This commit is contained in:
@@ -182,33 +182,33 @@ void sect_AddSection(Section *section)
|
||||
Section *sect_GetSection(std::string const &name)
|
||||
{
|
||||
auto search = sections.find(name);
|
||||
return search != sections.end() ? search->second : NULL;
|
||||
return search != sections.end() ? search->second : nullptr;
|
||||
}
|
||||
|
||||
static void doSanityChecks(Section *section)
|
||||
{
|
||||
// Sanity check the section's type
|
||||
if (section->type < 0 || section->type >= SECTTYPE_INVALID) {
|
||||
error(NULL, 0, "Section \"%s\" has an invalid type", section->name.c_str());
|
||||
error(nullptr, 0, "Section \"%s\" has an invalid type", section->name.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
if (is32kMode && section->type == SECTTYPE_ROMX) {
|
||||
if (section->isBankFixed && section->bank != 1)
|
||||
error(NULL, 0, "%s: ROMX sections must be in bank 1 (if any) with option -t",
|
||||
error(nullptr, 0, "%s: ROMX sections must be in bank 1 (if any) with option -t",
|
||||
section->name.c_str());
|
||||
else
|
||||
section->type = SECTTYPE_ROM0;
|
||||
}
|
||||
if (isWRAM0Mode && section->type == SECTTYPE_WRAMX) {
|
||||
if (section->isBankFixed && section->bank != 1)
|
||||
error(NULL, 0, "%s: WRAMX sections must be in bank 1 with options -w or -d",
|
||||
error(nullptr, 0, "%s: WRAMX sections must be in bank 1 with options -w or -d",
|
||||
section->name.c_str());
|
||||
else
|
||||
section->type = SECTTYPE_WRAM0;
|
||||
}
|
||||
if (isDmgMode && section->type == SECTTYPE_VRAM && section->bank == 1)
|
||||
error(NULL, 0, "%s: VRAM bank 1 can't be used with option -d",
|
||||
error(nullptr, 0, "%s: VRAM bank 1 can't be used with option -d",
|
||||
section->name.c_str());
|
||||
|
||||
// Check if alignment is reasonable, this is important to avoid UB
|
||||
@@ -218,21 +218,21 @@ static void doSanityChecks(Section *section)
|
||||
|
||||
// Too large an alignment may not be satisfiable
|
||||
if (section->isAlignFixed && (section->alignMask & sectionTypeInfo[section->type].startAddr))
|
||||
error(NULL, 0, "%s: %s sections cannot be aligned to $%04x bytes",
|
||||
error(nullptr, 0, "%s: %s sections cannot be aligned to $%04x bytes",
|
||||
section->name.c_str(), sectionTypeInfo[section->type].name.c_str(),
|
||||
section->alignMask + 1);
|
||||
|
||||
uint32_t minbank = sectionTypeInfo[section->type].firstBank, maxbank = sectionTypeInfo[section->type].lastBank;
|
||||
|
||||
if (section->isBankFixed && section->bank < minbank && section->bank > maxbank)
|
||||
error(NULL, 0, minbank == maxbank
|
||||
error(nullptr, 0, minbank == maxbank
|
||||
? "Cannot place section \"%s\" in bank %" PRIu32 ", it must be %" PRIu32
|
||||
: "Cannot place section \"%s\" in bank %" PRIu32 ", it must be between %" PRIu32 " and %" PRIu32,
|
||||
section->name.c_str(), section->bank, minbank, maxbank);
|
||||
|
||||
// Check if section has a chance to be placed
|
||||
if (section->size > sectionTypeInfo[section->type].size)
|
||||
error(NULL, 0, "Section \"%s\" is bigger than the max size for that type: $%"
|
||||
error(nullptr, 0, "Section \"%s\" is bigger than the max size for that type: $%"
|
||||
PRIx16 " > $%" PRIx16,
|
||||
section->name.c_str(), section->size, sectionTypeInfo[section->type].size);
|
||||
|
||||
@@ -247,7 +247,7 @@ static void doSanityChecks(Section *section)
|
||||
// It doesn't make sense to have both org and alignment set
|
||||
if (section->isAlignFixed) {
|
||||
if ((section->org & section->alignMask) != section->alignOfs)
|
||||
error(NULL, 0, "Section \"%s\"'s fixed address doesn't match its alignment",
|
||||
error(nullptr, 0, "Section \"%s\"'s fixed address doesn't match its alignment",
|
||||
section->name.c_str());
|
||||
section->isAlignFixed = false;
|
||||
}
|
||||
@@ -255,12 +255,12 @@ static void doSanityChecks(Section *section)
|
||||
// Ensure the target address is valid
|
||||
if (section->org < sectionTypeInfo[section->type].startAddr
|
||||
|| section->org > endaddr(section->type))
|
||||
error(NULL, 0, "Section \"%s\"'s fixed address $%04" PRIx16 " is outside of range [$%04"
|
||||
error(nullptr, 0, "Section \"%s\"'s fixed address $%04" PRIx16 " is outside of range [$%04"
|
||||
PRIx16 "; $%04" PRIx16 "]", section->name.c_str(), section->org,
|
||||
sectionTypeInfo[section->type].startAddr, endaddr(section->type));
|
||||
|
||||
if (section->org + section->size > endaddr(section->type) + 1)
|
||||
error(NULL, 0, "Section \"%s\"'s end address $%04x is greater than last address $%04x",
|
||||
error(nullptr, 0, "Section \"%s\"'s end address $%04x is greater than last address $%04x",
|
||||
section->name.c_str(), section->org + section->size,
|
||||
endaddr(section->type) + 1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user