diff --git a/src/asm/output.c b/src/asm/output.c index 47f8c969..056da346 100644 --- a/src/asm/output.c +++ b/src/asm/output.c @@ -200,7 +200,7 @@ static uint32_t getsectid(struct Section *pSect) sec = sec->pNext; } - fatalerror("INTERNAL: Unknown section"); + fatalerror("%s: Unknown section", __func__); return (uint32_t)(-1); } diff --git a/src/link/assign.c b/src/link/assign.c index aa447c58..10ec25b9 100644 --- a/src/link/assign.c +++ b/src/link/assign.c @@ -74,7 +74,7 @@ static void do_max_bank(enum eSectionType Type, int32_t nBank) void ensureSectionTypeIsValid(enum eSectionType type) { if (type < SECT_MIN || type > SECT_MAX) - errx(1, "(INTERNAL) Invalid section type found."); + errx(1, "%s: Invalid section type found: %d", __func__, type); } int BankIndexIsROM0(int32_t bank) @@ -162,7 +162,7 @@ int32_t area_doAlloc(struct sFreeArea *pArea, int32_t org, int32_t size) pNewArea = malloc(sizeof(struct sFreeArea)); if (pNewArea == NULL) - err(1, NULL); + err(1, "%s: Failed to allocate memory", __func__); *pNewArea = *pArea; pNewArea->pPrev = pArea; @@ -627,8 +627,10 @@ void AssignSections(void) && pSection->nOrg != -1 && pSection->nBank == -1)) continue; - if (options & OPT_OVERLAY) - errx(1, "All sections must be fixed when using an overlay file."); + if (options & OPT_OVERLAY) { + errx(1, "All sections must be fixed when using an overlay file: '%s'", + pSection->pzName); + } switch (pSection->Type) { case SECT_ROMX: diff --git a/src/link/object.c b/src/link/object.c index 6a7a087e..7983f44b 100644 --- a/src/link/object.c +++ b/src/link/object.c @@ -50,7 +50,7 @@ int32_t readasciiz(char **dest, FILE *f) char *s = start; if (!s) - err(1, NULL); + err(1, "%s: Couldn't allocate memory", __func__); while (((*s++) = fgetc(f)) != 0) { r += 1; @@ -58,8 +58,10 @@ int32_t readasciiz(char **dest, FILE *f) if (r >= bufferLength) { bufferLength *= 2; start = realloc(start, bufferLength); - if (!start) - err(1, NULL); + if (!start) { + err(1, "%s: Couldn't allocate memory", + __func__); + } s = start + r; } } @@ -85,7 +87,7 @@ struct sSection *AllocSection(void) *ppSections = malloc(sizeof **ppSections); if (!*ppSections) - err(1, NULL); + err(1, "%s: Couldn't allocate memory", __func__); (*ppSections)->tSymbols = tSymbols; (*ppSections)->pNext = NULL; @@ -103,7 +105,7 @@ struct sSymbol *obj_ReadSymbol(FILE *f, char *tzObjectfile) pSym = malloc(sizeof(*pSym)); if (!pSym) - err(1, NULL); + err(1, "%s: Couldn't allocate memory", __func__); readasciiz(&pSym->pzName, f); pSym->Type = (enum eSymbolType)fgetc(f); @@ -205,14 +207,14 @@ struct sSection *obj_ReadRGBSection(FILE *f) pSection->pData = malloc(pSection->nByteSize); if (!pSection->pData) - err(1, NULL); + err(1, "%s: Couldn't allocate memory", __func__); int32_t nNumberOfPatches; struct sPatch **ppPatch, *pPatch; if (fread(pSection->pData, sizeof(uint8_t), pSection->nByteSize, f) != pSection->nByteSize) { - err(1, "Read error."); + err(1, "%s: Read error", __func__); } nNumberOfPatches = readlong(f); @@ -224,7 +226,7 @@ struct sSection *obj_ReadRGBSection(FILE *f) while (nNumberOfPatches--) { pPatch = malloc(sizeof(*pPatch)); if (!pPatch) - err(1, NULL); + err(1, "%s: Couldn't allocate memory", __func__); *ppPatch = pPatch; readasciiz(&pPatch->pzFilename, f); @@ -235,12 +237,14 @@ struct sSection *obj_ReadRGBSection(FILE *f) if (pPatch->nRPNSize > 0) { pPatch->pRPN = malloc(pPatch->nRPNSize); - if (!pPatch->pRPN) - err(1, NULL); + if (!pPatch->pRPN) { + err(1, "%s: Couldn't allocate memory", + __func__); + } if (fread(pPatch->pRPN, sizeof(uint8_t), pPatch->nRPNSize, f) != pPatch->nRPNSize) { - errx(1, "Read error."); + errx(1, "%s: Read error", __func__); } } else { pPatch->pRPN = NULL; @@ -266,7 +270,7 @@ void obj_ReadRGB(FILE *pObjfile, char *tzObjectfile) if (nNumberOfSymbols) { tSymbols = malloc(nNumberOfSymbols * sizeof(*tSymbols)); if (!tSymbols) - err(1, NULL); + err(1, "%s: Couldn't allocate memory", __func__); for (i = 0; i < nNumberOfSymbols; i += 1) tSymbols[i] = obj_ReadSymbol(pObjfile, tzObjectfile); @@ -318,7 +322,7 @@ void obj_ReadOpenFile(FILE *pObjfile, char *tzObjectfile) if (fread(tzHeader, sizeof(char), strlen(RGBDS_OBJECT_VERSION_STRING), pObjfile) != strlen(RGBDS_OBJECT_VERSION_STRING)) { - errx(1, "%s: Read error.", tzObjectfile); + errx(1, "%s: Read error", tzObjectfile); } tzHeader[strlen(RGBDS_OBJECT_VERSION_STRING)] = 0; diff --git a/src/link/script.c b/src/link/script.c index 4ba45694..bbe1a822 100644 --- a/src/link/script.c +++ b/src/link/script.c @@ -97,7 +97,7 @@ void script_SetCurrentSectionType(const char *type, uint32_t bank) { if (strcmp(type, "ROM0") == 0) { if (bank != 0) - errx(1, "(Internal) Trying to assign a bank number to ROM0.\n"); + errx(1, "Trying to assign a bank number to ROM0.\n"); current_bank = BANK_INDEX_ROM0; current_real_bank = 0; return; @@ -121,8 +121,7 @@ void script_SetCurrentSectionType(const char *type, uint32_t bank) return; } else if (strcmp(type, "WRAM0") == 0) { if (bank != 0) { - errx(1, "%s: Trying to assign a bank number to WRAM0.\n", - __func__); + errx(1, "Trying to assign a bank number to WRAM0.\n"); } current_bank = BANK_INDEX_WRAM0; current_real_bank = 0; diff --git a/test/asm/null-in-macro.out b/test/asm/null-in-macro.out index 322e4f0f..d0829f3d 100644 --- a/test/asm/null-in-macro.out +++ b/test/asm/null-in-macro.out @@ -1,2 +1,2 @@ ERROR: null-in-macro.asm(1): - Unterminated MACRO definition + Unterminated MACRO definition.