mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-24 20:12:07 +00:00
Emit a single error when using BANK incorrectly
Previously, if BANK is used when defining a section that’s not ROMX, WRMAX, SRAM or VRAM, a second error message would appear, e.g. “(null) bank value $1 out of range $5d to $0”. This would appear due to the usage of uninitialised variables. This change ensures that the uninitialised variables are not accessed when using an invalid section. This also silences compiler warnings about usage of uninitialised variables.
This commit is contained in:
@@ -24,7 +24,7 @@ void
|
||||
bankrangecheck(char *name, ULONG secttype, SLONG org, SLONG bank)
|
||||
{
|
||||
SLONG minbank, maxbank;
|
||||
char *stype;
|
||||
char *stype = NULL;
|
||||
switch (secttype) {
|
||||
case SECT_ROMX:
|
||||
stype = "ROMX";
|
||||
@@ -51,7 +51,7 @@ bankrangecheck(char *name, ULONG secttype, SLONG org, SLONG bank)
|
||||
"ROMX, WRAMX, SRAM, or VRAM sections");
|
||||
}
|
||||
|
||||
if (bank < minbank || bank > maxbank) {
|
||||
if (stype && (bank < minbank || bank > maxbank)) {
|
||||
yyerror("%s bank value $%x out of range ($%x to $%x)",
|
||||
stype, bank, minbank, maxbank);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user