From 06f0472f81600459cbe5ae74d7a5253523fd2fc2 Mon Sep 17 00:00:00 2001 From: Ben10do Date: Tue, 24 Jan 2017 10:48:38 +0000 Subject: [PATCH] Emit a single error when using BANK incorrectly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- src/asm/asmy.y | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/asm/asmy.y b/src/asm/asmy.y index f75f5ffb..29dd9f01 100644 --- a/src/asm/asmy.y +++ b/src/asm/asmy.y @@ -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); }