mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-21 02:32:06 +00:00
A few stylistic tweaks
- `goto free_romx` -> the more typical `goto cleanup` - `goto fail` -> the more typical `goto finish` - Remove a redundant `todo` variable
This commit is contained in:
@@ -2257,8 +2257,8 @@ static int skipIfBlock(bool toEndc)
|
|||||||
}
|
}
|
||||||
} while (!atLineStart);
|
} while (!atLineStart);
|
||||||
}
|
}
|
||||||
finish:
|
|
||||||
|
|
||||||
|
finish:
|
||||||
lexerState->disableMacroArgs = false;
|
lexerState->disableMacroArgs = false;
|
||||||
lexerState->disableInterpolation = false;
|
lexerState->disableInterpolation = false;
|
||||||
lexerState->atLineStart = false;
|
lexerState->atLineStart = false;
|
||||||
@@ -2344,8 +2344,8 @@ static int yylex_SKIP_TO_ENDR(void)
|
|||||||
}
|
}
|
||||||
} while (!atLineStart);
|
} while (!atLineStart);
|
||||||
}
|
}
|
||||||
finish:
|
|
||||||
|
|
||||||
|
finish:
|
||||||
lexerState->disableMacroArgs = false;
|
lexerState->disableMacroArgs = false;
|
||||||
lexerState->disableInterpolation = false;
|
lexerState->disableInterpolation = false;
|
||||||
lexerState->atLineStart = false;
|
lexerState->atLineStart = false;
|
||||||
|
|||||||
@@ -951,9 +951,7 @@ void sect_BinaryFileSlice(char const *s, int32_t start_pos, int32_t length)
|
|||||||
(void)fgetc(f);
|
(void)fgetc(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t todo = length;
|
while (length--) {
|
||||||
|
|
||||||
while (todo--) {
|
|
||||||
int byte = fgetc(f);
|
int byte = fgetc(f);
|
||||||
|
|
||||||
if (byte != EOF) {
|
if (byte != EOF) {
|
||||||
@@ -962,7 +960,7 @@ void sect_BinaryFileSlice(char const *s, int32_t start_pos, int32_t length)
|
|||||||
error("Error reading INCBIN file '%s': %s\n", s, strerror(errno));
|
error("Error reading INCBIN file '%s': %s\n", s, strerror(errno));
|
||||||
} else {
|
} else {
|
||||||
error("Premature end of file (%" PRId32 " bytes left to read)\n",
|
error("Premature end of file (%" PRId32 " bytes left to read)\n",
|
||||||
todo + 1);
|
length + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1016,8 +1016,7 @@ static void processFile(int input, int output, char const *name, off_t fileSize)
|
|||||||
static_assert(0x10000 * BANK_SIZE <= SSIZE_MAX, "Max input file size too large for OS");
|
static_assert(0x10000 * BANK_SIZE <= SSIZE_MAX, "Max input file size too large for OS");
|
||||||
if (nbBanks == 0x10000) {
|
if (nbBanks == 0x10000) {
|
||||||
report("FATAL: \"%s\" has more than 65536 banks\n", name);
|
report("FATAL: \"%s\" has more than 65536 banks\n", name);
|
||||||
free(romx);
|
goto cleanup;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
nbBanks++;
|
nbBanks++;
|
||||||
|
|
||||||
@@ -1106,7 +1105,7 @@ static void processFile(int input, int output, char const *name, off_t fileSize)
|
|||||||
if (input == output) {
|
if (input == output) {
|
||||||
if (lseek(output, 0, SEEK_SET) == (off_t)-1) {
|
if (lseek(output, 0, SEEK_SET) == (off_t)-1) {
|
||||||
report("FATAL: Failed to rewind \"%s\": %s\n", name, strerror(errno));
|
report("FATAL: Failed to rewind \"%s\": %s\n", name, strerror(errno));
|
||||||
goto free_romx;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
// If modifying the file in-place, we only need to edit the header
|
// If modifying the file in-place, we only need to edit the header
|
||||||
// However, padding may have modified ROM0 (added padding), so don't in that case
|
// However, padding may have modified ROM0 (added padding), so don't in that case
|
||||||
@@ -1117,11 +1116,11 @@ static void processFile(int input, int output, char const *name, off_t fileSize)
|
|||||||
|
|
||||||
if (writeLen == -1) {
|
if (writeLen == -1) {
|
||||||
report("FATAL: Failed to write \"%s\"'s ROM0: %s\n", name, strerror(errno));
|
report("FATAL: Failed to write \"%s\"'s ROM0: %s\n", name, strerror(errno));
|
||||||
goto free_romx;
|
goto cleanup;
|
||||||
} else if (writeLen < rom0Len) {
|
} else if (writeLen < rom0Len) {
|
||||||
report("FATAL: Could only write %jd of \"%s\"'s %jd ROM0 bytes\n",
|
report("FATAL: Could only write %jd of \"%s\"'s %jd ROM0 bytes\n",
|
||||||
(intmax_t)writeLen, name, (intmax_t)rom0Len);
|
(intmax_t)writeLen, name, (intmax_t)rom0Len);
|
||||||
goto free_romx;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Output ROMX if it was buffered
|
// Output ROMX if it was buffered
|
||||||
@@ -1131,11 +1130,11 @@ static void processFile(int input, int output, char const *name, off_t fileSize)
|
|||||||
writeLen = writeBytes(output, romx, totalRomxLen);
|
writeLen = writeBytes(output, romx, totalRomxLen);
|
||||||
if (writeLen == -1) {
|
if (writeLen == -1) {
|
||||||
report("FATAL: Failed to write \"%s\"'s ROMX: %s\n", name, strerror(errno));
|
report("FATAL: Failed to write \"%s\"'s ROMX: %s\n", name, strerror(errno));
|
||||||
goto free_romx;
|
goto cleanup;
|
||||||
} else if ((size_t)writeLen < totalRomxLen) {
|
} else if ((size_t)writeLen < totalRomxLen) {
|
||||||
report("FATAL: Could only write %jd of \"%s\"'s %zu ROMX bytes\n",
|
report("FATAL: Could only write %jd of \"%s\"'s %zu ROMX bytes\n",
|
||||||
(intmax_t)writeLen, name, totalRomxLen);
|
(intmax_t)writeLen, name, totalRomxLen);
|
||||||
goto free_romx;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1145,7 +1144,7 @@ static void processFile(int input, int output, char const *name, off_t fileSize)
|
|||||||
if (lseek(output, 0, SEEK_END) == (off_t)-1) {
|
if (lseek(output, 0, SEEK_END) == (off_t)-1) {
|
||||||
report("FATAL: Failed to seek to end of \"%s\": %s\n",
|
report("FATAL: Failed to seek to end of \"%s\": %s\n",
|
||||||
name, strerror(errno));
|
name, strerror(errno));
|
||||||
goto free_romx;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
memset(bank, padValue, sizeof(bank));
|
memset(bank, padValue, sizeof(bank));
|
||||||
@@ -1167,7 +1166,7 @@ static void processFile(int input, int output, char const *name, off_t fileSize)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free_romx:
|
cleanup:
|
||||||
free(romx);
|
free(romx);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1192,7 +1191,7 @@ static bool processFilename(char const *name)
|
|||||||
if (input == -1) {
|
if (input == -1) {
|
||||||
report("FATAL: Failed to open \"%s\" for reading+writing: %s\n",
|
report("FATAL: Failed to open \"%s\" for reading+writing: %s\n",
|
||||||
name, strerror(errno));
|
name, strerror(errno));
|
||||||
goto fail;
|
goto finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fstat(input, &stat) == -1) {
|
if (fstat(input, &stat) == -1) {
|
||||||
@@ -1211,8 +1210,8 @@ static bool processFilename(char const *name)
|
|||||||
|
|
||||||
close(input);
|
close(input);
|
||||||
}
|
}
|
||||||
|
finish:
|
||||||
if (nbErrors)
|
if (nbErrors)
|
||||||
fail:
|
|
||||||
fprintf(stderr, "Fixing \"%s\" failed with %u error%s\n",
|
fprintf(stderr, "Fixing \"%s\" failed with %u error%s\n",
|
||||||
name, nbErrors, nbErrors == 1 ? "" : "s");
|
name, nbErrors, nbErrors == 1 ? "" : "s");
|
||||||
return nbErrors;
|
return nbErrors;
|
||||||
|
|||||||
Reference in New Issue
Block a user