From d71a161bc9cff3a04a1382b8113f28eca9f2f014 Mon Sep 17 00:00:00 2001 From: Sylvie <35663410+Rangi42@users.noreply.github.com> Date: Sun, 18 Feb 2024 08:52:31 -0500 Subject: [PATCH] Phrase error messages as "Failed to", not "Could not" or "Couldn't" (#1298) --- src/asm/main.cpp | 2 +- src/asm/symbol.cpp | 2 +- src/gfx/pal_spec.cpp | 4 ++-- src/gfx/process.cpp | 2 +- src/gfx/reverse.cpp | 4 ++-- src/link/main.cpp | 2 +- src/link/object.cpp | 11 +++++------ src/link/patch.cpp | 2 +- src/link/script.y | 4 ++-- src/link/sdas_obj.cpp | 2 +- test/gfx/bad_manual_pals.err | 4 ++-- test/link/cascading-errors-fatal-assert.out | 2 +- 12 files changed, 20 insertions(+), 21 deletions(-) diff --git a/src/asm/main.cpp b/src/asm/main.cpp index 55361218..e70e5704 100644 --- a/src/asm/main.cpp +++ b/src/asm/main.cpp @@ -259,7 +259,7 @@ int main(int argc, char *argv[]) dependFileName = musl_optarg; } if (dependfile == NULL) - err("Could not open dependfile %s", dependFileName); + err("Failed to open dependfile %s", dependFileName); break; case 'o': diff --git a/src/asm/symbol.cpp b/src/asm/symbol.cpp index 2fe5c3c4..9030c98c 100644 --- a/src/asm/symbol.cpp +++ b/src/asm/symbol.cpp @@ -655,7 +655,7 @@ void sym_Init(time_t now) #endif if (now == (time_t)-1) { - warn("Couldn't determine current time"); + warn("Failed to determine current time"); // Fall back by pretending we are at the Epoch now = 0; } diff --git a/src/gfx/pal_spec.cpp b/src/gfx/pal_spec.cpp index b97c3771..2ff18a65 100644 --- a/src/gfx/pal_spec.cpp +++ b/src/gfx/pal_spec.cpp @@ -468,7 +468,7 @@ static void parseACOFile(std::filebuf &file) { char buf[10]; if (file.sgetn(buf, 2) != 2) { - error("Couldn't read ACO file version"); + error("Failed to read ACO file version"); return; } if (readBE(buf) != 1) { @@ -477,7 +477,7 @@ static void parseACOFile(std::filebuf &file) { } if (file.sgetn(buf, 2) != 2) { - error("Couldn't read number of colors in palette file"); + error("Failed to read number of colors in palette file"); return; } uint16_t nbColors = readBE(buf); diff --git a/src/gfx/process.cpp b/src/gfx/process.cpp index 513211b7..62784aa3 100644 --- a/src/gfx/process.cpp +++ b/src/gfx/process.cpp @@ -606,7 +606,7 @@ static std::tuple, std::vector> if (iter == palettes.end()) { assert(!protoPal.empty()); - error("Could not fit tile colors [%s] in specified palettes", listColors(protoPal)); + error("Failed to fit tile colors [%s] in specified palettes", listColors(protoPal)); bad = true; } mappings[i] = iter - palettes.begin(); // Bogus value, but whatever diff --git a/src/gfx/reverse.cpp b/src/gfx/reverse.cpp index 4e80a7fa..d7ae966b 100644 --- a/src/gfx/reverse.cpp +++ b/src/gfx/reverse.cpp @@ -246,11 +246,11 @@ void reverse() { const_cast(static_cast(pngFile.c_str(options.input))), pngError, pngWarning); if (!png) { - fatal("Couldn't create PNG write struct: %s", strerror(errno)); + fatal("Failed to create PNG write struct: %s", strerror(errno)); } png_infop pngInfo = png_create_info_struct(png); if (!pngInfo) { - fatal("Couldn't create PNG info struct: %s", strerror(errno)); + fatal("Failed to create PNG info struct: %s", strerror(errno)); } png_set_write_fn(png, &pngFile, writePng, flushPng); diff --git a/src/link/main.cpp b/src/link/main.cpp index 968444e4..e4315e43 100644 --- a/src/link/main.cpp +++ b/src/link/main.cpp @@ -156,7 +156,7 @@ FILE *openFile(char const *fileName, char const *mode) file = fdopen(STDOUT_FILENO, mode); if (!file) - err("Could not open file \"%s\"", fileName); + err("Failed to open file \"%s\"", fileName); return file; } diff --git a/src/link/object.cpp b/src/link/object.cpp index d94c377e..8867018a 100644 --- a/src/link/object.cpp +++ b/src/link/object.cpp @@ -452,7 +452,7 @@ void obj_ReadFile(char const *fileName, unsigned int fileID) file = fdopen(STDIN_FILENO, "rb"); // `stdin` is in text mode by default if (!file) - err("Could not open file %s", fileName); + err("Failed to open file %s", fileName); // First, check if the object is a RGBDS object or a SDCC one. If the first byte is 'R', // we'll assume it's a RGBDS object file, and otherwise, that it's a SDCC object file. @@ -551,7 +551,7 @@ void obj_ReadFile(char const *fileName, unsigned int fileID) struct Symbol *symbol = (struct Symbol *)malloc(sizeof(*symbol)); if (!symbol) - err("%s: Couldn't create new symbol", fileName); + err("%s: Failed to create new symbol", fileName); readSymbol(file, symbol, fileName, nodes[fileID].nodes); fileSymbols[i] = symbol; @@ -570,7 +570,7 @@ void obj_ReadFile(char const *fileName, unsigned int fileID) // Read section fileSections[i] = (struct Section *)malloc(sizeof(*fileSections[i])); if (!fileSections[i]) - err("%s: Couldn't create new section", fileName); + err("%s: Failed to create new section", fileName); fileSections[i]->nextu = NULL; readSection(file, fileSections[i], fileName, nodes[fileID].nodes); @@ -579,8 +579,7 @@ void obj_ReadFile(char const *fileName, unsigned int fileID) fileSections[i]->symbols = (struct Symbol **)malloc(nbSymPerSect[i] * sizeof(*fileSections[i]->symbols)); if (!fileSections[i]->symbols) - err("%s: Couldn't link to symbols", - fileName); + err("%s: Failed to link to symbols", fileName); } else { fileSections[i]->symbols = NULL; } @@ -630,7 +629,7 @@ void obj_ReadFile(char const *fileName, unsigned int fileID) struct Assertion *assertion = (struct Assertion *)malloc(sizeof(*assertion)); if (!assertion) - err("%s: Couldn't create new assertion", fileName); + err("%s: Failed to create new assertion", fileName); readAssertion(file, assertion, fileName, i, nodes[fileID].nodes); linkPatchToPCSect(&assertion->patch, fileSections); assertion->fileSymbols = fileSymbols; diff --git a/src/link/patch.cpp b/src/link/patch.cpp index d028acda..a2dfe450 100644 --- a/src/link/patch.cpp +++ b/src/link/patch.cpp @@ -485,7 +485,7 @@ void patch_CheckAssertions(struct Assertion *assert) } } else if (isError && type == ASSERT_FATAL) { fatal(assert->patch.src, assert->patch.lineNo, - "couldn't evaluate assertion%s%s", + "Failed to evaluate assertion%s%s", assert->message[0] ? ": " : "", assert->message); } diff --git a/src/link/script.y b/src/link/script.y index f3c92cf9..58d9dd57 100644 --- a/src/link/script.y +++ b/src/link/script.y @@ -132,7 +132,7 @@ static void includeFile(std::string &&path) { if (!newContext.file.open(newContext.path, std::ios_base::in)) { // The order is important: report the error, increment the line number, modify the stack! - scriptError(prevContext, "Could not open included linker script \"%s\"", + scriptError(prevContext, "Failed to open included linker script \"%s\"", newContext.path.c_str()); ++prevContext.lineNo; lexerStack.pop_back(); @@ -574,7 +574,7 @@ void script_ProcessScript(char const *path) { auto &newContext = lexerStack.emplace_back(std::string(path)); if (!newContext.file.open(newContext.path, std::ios_base::in)) { - error(NULL, 0, "Could not open linker script \"%s\"", newContext.path.c_str()); + error(NULL, 0, "Failed to open linker script \"%s\"", newContext.path.c_str()); lexerStack.clear(); } else { yy::parser linkerScriptParser; diff --git a/src/link/sdas_obj.cpp b/src/link/sdas_obj.cpp index 548039b4..6d08f3c2 100644 --- a/src/link/sdas_obj.cpp +++ b/src/link/sdas_obj.cpp @@ -370,7 +370,7 @@ void sdobj_ReadFile(struct FileStackNode const *where, FILE *file) { if (!newFileSymbols) fatal(where, lineNo, "Failed to alloc extra symbols: %s", strerror(errno)); if (newFileSymbols != fileSymbols) - fatal(where, lineNo, "Couldn't handle extra 'S' lines (pointer moved)"); + fatal(where, lineNo, "Failed to handle extra 'S' lines (pointer moved)"); // No need to assign, obviously } #define symbol (fileSymbols[nbSymbols]) diff --git a/test/gfx/bad_manual_pals.err b/test/gfx/bad_manual_pals.err index 100436c6..c75d88d3 100644 --- a/test/gfx/bad_manual_pals.err +++ b/test/gfx/bad_manual_pals.err @@ -1,5 +1,5 @@ -error: Could not fit tile colors [$6c8a, $7f55, $7fff] in specified palettes -error: Could not fit tile colors [$6c8a, $7f55] in specified palettes +error: Failed to fit tile colors [$6c8a, $7f55, $7fff] in specified palettes +error: Failed to fit tile colors [$6c8a, $7f55] in specified palettes note: The following palettes were specified: [$7fff, $7f55] [$7fff, $6c8a] diff --git a/test/link/cascading-errors-fatal-assert.out b/test/link/cascading-errors-fatal-assert.out index 5a6a207f..9450aae3 100644 --- a/test/link/cascading-errors-fatal-assert.out +++ b/test/link/cascading-errors-fatal-assert.out @@ -1,3 +1,3 @@ error: cascading-errors-fatal-assert.asm(1): Unknown symbol "UnknownSymbol" -FATAL: cascading-errors-fatal-assert.asm(1): couldn't evaluate assertion +FATAL: cascading-errors-fatal-assert.asm(1): Failed to evaluate assertion Linking aborted after 2 errors