mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Exclude more lines from test coverage (#1663)
These fall into a few categories: - `_unreachable()` - Verbose print messages - Errors that should never practically occur (alloc/read/write failure, more than UINT32_MAX anonymous labels, etc)
This commit is contained in:
@@ -698,10 +698,12 @@ static char const *mbcName(MbcType type) {
|
|||||||
case MBC_WRONG_FEATURES:
|
case MBC_WRONG_FEATURES:
|
||||||
case MBC_BAD_RANGE:
|
case MBC_BAD_RANGE:
|
||||||
case MBC_BAD_TPP1:
|
case MBC_BAD_TPP1:
|
||||||
|
// LCOV_EXCL_START
|
||||||
unreachable_();
|
unreachable_();
|
||||||
}
|
}
|
||||||
|
|
||||||
unreachable_();
|
unreachable_();
|
||||||
|
// LCOV_EXCL_STOP
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool hasRAM(MbcType type) {
|
static bool hasRAM(MbcType type) {
|
||||||
@@ -763,7 +765,7 @@ static bool hasRAM(MbcType type) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
unreachable_();
|
unreachable_(); // LCOV_EXCL_LINE
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t const nintendoLogo[] = {
|
static uint8_t const nintendoLogo[] = {
|
||||||
@@ -813,8 +815,9 @@ static ssize_t readBytes(int fd, uint8_t *buf, size_t len) {
|
|||||||
while (len) {
|
while (len) {
|
||||||
ssize_t ret = read(fd, buf, len);
|
ssize_t ret = read(fd, buf, len);
|
||||||
|
|
||||||
if (ret == -1 && errno != EINTR) { // Return errors, unless we only were interrupted
|
// Return errors, unless we only were interrupted
|
||||||
return -1;
|
if (ret == -1 && errno != EINTR) {
|
||||||
|
return -1; // LCOV_EXCL_LINE
|
||||||
}
|
}
|
||||||
// EOF reached
|
// EOF reached
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
@@ -840,8 +843,9 @@ static ssize_t writeBytes(int fd, uint8_t *buf, size_t len) {
|
|||||||
while (len) {
|
while (len) {
|
||||||
ssize_t ret = write(fd, buf, len);
|
ssize_t ret = write(fd, buf, len);
|
||||||
|
|
||||||
if (ret == -1 && errno != EINTR) { // Return errors, unless we only were interrupted
|
// Return errors, unless we only were interrupted
|
||||||
return -1;
|
if (ret == -1 && errno != EINTR) {
|
||||||
|
return -1; // LCOV_EXCL_LINE
|
||||||
}
|
}
|
||||||
// If anything was written, accumulate it, and continue
|
// If anything was written, accumulate it, and continue
|
||||||
if (ret != -1) {
|
if (ret != -1) {
|
||||||
@@ -895,8 +899,10 @@ static void processFile(int input, int output, char const *name, off_t fileSize)
|
|||||||
ssize_t headerSize = (cartridgeType & 0xFF00) == TPP1 ? 0x154 : 0x150;
|
ssize_t headerSize = (cartridgeType & 0xFF00) == TPP1 ? 0x154 : 0x150;
|
||||||
|
|
||||||
if (rom0Len == -1) {
|
if (rom0Len == -1) {
|
||||||
|
// LCOV_EXCL_START
|
||||||
report("FATAL: Failed to read \"%s\"'s header: %s\n", name, strerror(errno));
|
report("FATAL: Failed to read \"%s\"'s header: %s\n", name, strerror(errno));
|
||||||
return;
|
return;
|
||||||
|
// LCOV_EXCL_STOP
|
||||||
} else if (rom0Len < headerSize) {
|
} else if (rom0Len < headerSize) {
|
||||||
report(
|
report(
|
||||||
"FATAL: \"%s\" too short, expected at least %jd ($%jx) bytes, got only %jd\n",
|
"FATAL: \"%s\" too short, expected at least %jd ($%jx) bytes, got only %jd\n",
|
||||||
@@ -1134,8 +1140,10 @@ static void processFile(int input, int output, char const *name, off_t fileSize)
|
|||||||
// write the header
|
// write the header
|
||||||
if (input == output) {
|
if (input == output) {
|
||||||
if (lseek(output, 0, SEEK_SET) == static_cast<off_t>(-1)) {
|
if (lseek(output, 0, SEEK_SET) == static_cast<off_t>(-1)) {
|
||||||
|
// LCOV_EXCL_START
|
||||||
report("FATAL: Failed to rewind \"%s\": %s\n", name, strerror(errno));
|
report("FATAL: Failed to rewind \"%s\": %s\n", name, strerror(errno));
|
||||||
return;
|
return;
|
||||||
|
// LCOV_EXCL_STOP
|
||||||
}
|
}
|
||||||
// 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
|
||||||
@@ -1146,9 +1154,12 @@ static void processFile(int input, int output, char const *name, off_t fileSize)
|
|||||||
writeLen = writeBytes(output, rom0, rom0Len);
|
writeLen = writeBytes(output, rom0, rom0Len);
|
||||||
|
|
||||||
if (writeLen == -1) {
|
if (writeLen == -1) {
|
||||||
|
// LCOV_EXCL_START
|
||||||
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));
|
||||||
return;
|
return;
|
||||||
|
// LCOV_EXCL_STOP
|
||||||
} else if (writeLen < rom0Len) {
|
} else if (writeLen < rom0Len) {
|
||||||
|
// LCOV_EXCL_START
|
||||||
report(
|
report(
|
||||||
"FATAL: Could only write %jd of \"%s\"'s %jd ROM0 bytes\n",
|
"FATAL: Could only write %jd of \"%s\"'s %jd ROM0 bytes\n",
|
||||||
static_cast<intmax_t>(writeLen),
|
static_cast<intmax_t>(writeLen),
|
||||||
@@ -1156,6 +1167,7 @@ static void processFile(int input, int output, char const *name, off_t fileSize)
|
|||||||
static_cast<intmax_t>(rom0Len)
|
static_cast<intmax_t>(rom0Len)
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
|
// LCOV_EXCL_STOP
|
||||||
}
|
}
|
||||||
|
|
||||||
// Output ROMX if it was buffered
|
// Output ROMX if it was buffered
|
||||||
@@ -1164,9 +1176,12 @@ static void processFile(int input, int output, char const *name, off_t fileSize)
|
|||||||
// so it's fine to cast to `size_t`
|
// so it's fine to cast to `size_t`
|
||||||
writeLen = writeBytes(output, romx.data(), totalRomxLen);
|
writeLen = writeBytes(output, romx.data(), totalRomxLen);
|
||||||
if (writeLen == -1) {
|
if (writeLen == -1) {
|
||||||
|
// LCOV_EXCL_START
|
||||||
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));
|
||||||
return;
|
return;
|
||||||
|
// LCOV_EXCL_STOP
|
||||||
} else if (static_cast<size_t>(writeLen) < totalRomxLen) {
|
} else if (static_cast<size_t>(writeLen) < totalRomxLen) {
|
||||||
|
// LCOV_EXCL_START
|
||||||
report(
|
report(
|
||||||
"FATAL: Could only write %jd of \"%s\"'s %zu ROMX bytes\n",
|
"FATAL: Could only write %jd of \"%s\"'s %zu ROMX bytes\n",
|
||||||
static_cast<intmax_t>(writeLen),
|
static_cast<intmax_t>(writeLen),
|
||||||
@@ -1174,6 +1189,7 @@ static void processFile(int input, int output, char const *name, off_t fileSize)
|
|||||||
totalRomxLen
|
totalRomxLen
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
|
// LCOV_EXCL_STOP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1181,8 +1197,10 @@ static void processFile(int input, int output, char const *name, off_t fileSize)
|
|||||||
if (padValue != UNSPECIFIED) {
|
if (padValue != UNSPECIFIED) {
|
||||||
if (input == output) {
|
if (input == output) {
|
||||||
if (lseek(output, 0, SEEK_END) == static_cast<off_t>(-1)) {
|
if (lseek(output, 0, SEEK_END) == static_cast<off_t>(-1)) {
|
||||||
|
// LCOV_EXCL_START
|
||||||
report("FATAL: Failed to seek to end of \"%s\": %s\n", name, strerror(errno));
|
report("FATAL: Failed to seek to end of \"%s\": %s\n", name, strerror(errno));
|
||||||
return;
|
return;
|
||||||
|
// LCOV_EXCL_STOP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
memset(bank, padValue, sizeof(bank));
|
memset(bank, padValue, sizeof(bank));
|
||||||
@@ -1196,8 +1214,10 @@ static void processFile(int input, int output, char const *name, off_t fileSize)
|
|||||||
// The return value is either -1, or at most `thisLen`,
|
// The return value is either -1, or at most `thisLen`,
|
||||||
// so it's fine to cast to `size_t`
|
// so it's fine to cast to `size_t`
|
||||||
if (static_cast<size_t>(ret) != thisLen) {
|
if (static_cast<size_t>(ret) != thisLen) {
|
||||||
|
// LCOV_EXCL_START
|
||||||
report("FATAL: Failed to write \"%s\"'s padding: %s\n", name, strerror(errno));
|
report("FATAL: Failed to write \"%s\"'s padding: %s\n", name, strerror(errno));
|
||||||
break;
|
break;
|
||||||
|
// LCOV_EXCL_STOP
|
||||||
}
|
}
|
||||||
len -= thisLen;
|
len -= thisLen;
|
||||||
}
|
}
|
||||||
@@ -1224,12 +1244,16 @@ static bool processFilename(char const *name) {
|
|||||||
Defer closeInput{[&] { close(input); }};
|
Defer closeInput{[&] { close(input); }};
|
||||||
struct stat stat;
|
struct stat stat;
|
||||||
if (fstat(input, &stat) == -1) {
|
if (fstat(input, &stat) == -1) {
|
||||||
|
// LCOV_EXCL_START
|
||||||
report("FATAL: Failed to stat \"%s\": %s\n", name, strerror(errno));
|
report("FATAL: Failed to stat \"%s\": %s\n", name, strerror(errno));
|
||||||
} else if (!S_ISREG(stat.st_mode)) { // TODO: Do we want to support other types?
|
// LCOV_EXCL_STOP
|
||||||
|
} else if (!S_ISREG(stat.st_mode)) { // TODO: Do we want to support FIFOs or symlinks?
|
||||||
|
// LCOV_EXCL_START
|
||||||
report(
|
report(
|
||||||
"FATAL: \"%s\" is not a regular file, and thus cannot be modified in-place\n",
|
"FATAL: \"%s\" is not a regular file, and thus cannot be modified in-place\n",
|
||||||
name
|
name
|
||||||
);
|
);
|
||||||
|
// LCOV_EXCL_STOP
|
||||||
} else if (stat.st_size < 0x150) {
|
} else if (stat.st_size < 0x150) {
|
||||||
// This check is in theory redundant with the one in `processFile`, but it
|
// This check is in theory redundant with the one in `processFile`, but it
|
||||||
// prevents passing a file size of 0, which usually indicates pipes
|
// prevents passing a file size of 0, which usually indicates pipes
|
||||||
@@ -1423,16 +1447,20 @@ int main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case 'V':
|
case 'V':
|
||||||
|
// LCOV_EXCL_START
|
||||||
printf("rgbfix %s\n", get_package_version_string());
|
printf("rgbfix %s\n", get_package_version_string());
|
||||||
exit(0);
|
exit(0);
|
||||||
|
// LCOV_EXCL_STOP
|
||||||
|
|
||||||
case 'v':
|
case 'v':
|
||||||
fixSpec = FIX_LOGO | FIX_HEADER_SUM | FIX_GLOBAL_SUM;
|
fixSpec = FIX_LOGO | FIX_HEADER_SUM | FIX_GLOBAL_SUM;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
// LCOV_EXCL_START
|
||||||
printUsage();
|
printUsage();
|
||||||
exit(1);
|
exit(1);
|
||||||
|
// LCOV_EXCL_STOP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ void fatal(char const *fmt, ...) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Options::verbosePrint(uint8_t level, char const *fmt, ...) const {
|
void Options::verbosePrint(uint8_t level, char const *fmt, ...) const {
|
||||||
|
// LCOV_EXCL_START
|
||||||
if (verbosity >= level) {
|
if (verbosity >= level) {
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
@@ -110,6 +111,7 @@ void Options::verbosePrint(uint8_t level, char const *fmt, ...) const {
|
|||||||
vfprintf(stderr, fmt, ap);
|
vfprintf(stderr, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
// LCOV_EXCL_STOP
|
||||||
}
|
}
|
||||||
|
|
||||||
// Short options
|
// Short options
|
||||||
@@ -586,13 +588,17 @@ static char *parseArgv(int argc, char *argv[]) {
|
|||||||
options.tilemap = musl_optarg;
|
options.tilemap = musl_optarg;
|
||||||
break;
|
break;
|
||||||
case 'V':
|
case 'V':
|
||||||
|
// LCOV_EXCL_START
|
||||||
printf("rgbgfx %s\n", get_package_version_string());
|
printf("rgbgfx %s\n", get_package_version_string());
|
||||||
exit(0);
|
exit(0);
|
||||||
|
// LCOV_EXCL_STOP
|
||||||
case 'v':
|
case 'v':
|
||||||
|
// LCOV_EXCL_START
|
||||||
if (options.verbosity < Options::VERB_VVVVVV) {
|
if (options.verbosity < Options::VERB_VVVVVV) {
|
||||||
++options.verbosity;
|
++options.verbosity;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
// LCOV_EXCL_STOP
|
||||||
case 'x':
|
case 'x':
|
||||||
options.trim = parseNumber(arg, "Number of tiles to trim", 0);
|
options.trim = parseNumber(arg, "Number of tiles to trim", 0);
|
||||||
if (*arg != '\0') {
|
if (*arg != '\0') {
|
||||||
@@ -750,6 +756,7 @@ int main(int argc, char *argv[]) {
|
|||||||
parseExternalPalSpec(localOptions.externalPalSpec);
|
parseExternalPalSpec(localOptions.externalPalSpec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LCOV_EXCL_START
|
||||||
if (options.verbosity >= Options::VERB_CFG) {
|
if (options.verbosity >= Options::VERB_CFG) {
|
||||||
fprintf(stderr, "rgbgfx %s\n", get_package_version_string());
|
fprintf(stderr, "rgbgfx %s\n", get_package_version_string());
|
||||||
|
|
||||||
@@ -862,6 +869,7 @@ int main(int argc, char *argv[]) {
|
|||||||
printPath("Output palettes", options.palettes);
|
printPath("Output palettes", options.palettes);
|
||||||
fputs("Ready.\n", stderr);
|
fputs("Ready.\n", stderr);
|
||||||
}
|
}
|
||||||
|
// LCOV_EXCL_STOP
|
||||||
|
|
||||||
// Do not do anything if option parsing went wrong.
|
// Do not do anything if option parsing went wrong.
|
||||||
requireZeroErrors();
|
requireZeroErrors();
|
||||||
|
|||||||
@@ -559,6 +559,7 @@ std::tuple<DefaultInitVec<size_t>, size_t>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LCOV_EXCL_START
|
||||||
if (options.verbosity >= Options::VERB_INTERM) {
|
if (options.verbosity >= Options::VERB_INTERM) {
|
||||||
for (auto &&assignment : assignments) {
|
for (auto &&assignment : assignments) {
|
||||||
fprintf(stderr, "{ ");
|
fprintf(stderr, "{ ");
|
||||||
@@ -571,11 +572,13 @@ std::tuple<DefaultInitVec<size_t>, size_t>
|
|||||||
fprintf(stderr, "} (volume = %zu)\n", assignment.volume());
|
fprintf(stderr, "} (volume = %zu)\n", assignment.volume());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// LCOV_EXCL_STOP
|
||||||
|
|
||||||
// "Decant" the result
|
// "Decant" the result
|
||||||
decant(assignments, protoPalettes);
|
decant(assignments, protoPalettes);
|
||||||
// Note that the result does not contain any empty palettes
|
// Note that the result does not contain any empty palettes
|
||||||
|
|
||||||
|
// LCOV_EXCL_START
|
||||||
if (options.verbosity >= Options::VERB_INTERM) {
|
if (options.verbosity >= Options::VERB_INTERM) {
|
||||||
for (auto &&assignment : assignments) {
|
for (auto &&assignment : assignments) {
|
||||||
fprintf(stderr, "{ ");
|
fprintf(stderr, "{ ");
|
||||||
@@ -588,6 +591,7 @@ std::tuple<DefaultInitVec<size_t>, size_t>
|
|||||||
fprintf(stderr, "} (volume = %zu)\n", assignment.volume());
|
fprintf(stderr, "} (volume = %zu)\n", assignment.volume());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// LCOV_EXCL_STOP
|
||||||
|
|
||||||
DefaultInitVec<size_t> mappings(protoPalettes.size());
|
DefaultInitVec<size_t> mappings(protoPalettes.size());
|
||||||
for (size_t i = 0; i < assignments.size(); ++i) {
|
for (size_t i = 0; i < assignments.size(); ++i) {
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ void sortIndexed(
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unreachable_(); // This should not be possible
|
unreachable_(); // LCOV_EXCL_LINE
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -193,13 +193,15 @@ public:
|
|||||||
PNG_LIBPNG_VER_STRING, static_cast<png_voidp>(this), handleError, handleWarning
|
PNG_LIBPNG_VER_STRING, static_cast<png_voidp>(this), handleError, handleWarning
|
||||||
);
|
);
|
||||||
if (!png) {
|
if (!png) {
|
||||||
fatal("Failed to allocate PNG structure: %s", strerror(errno));
|
fatal("Failed to create PNG read structure: %s", strerror(errno)); // LCOV_EXCL_LINE
|
||||||
}
|
}
|
||||||
|
|
||||||
info = png_create_info_struct(png);
|
info = png_create_info_struct(png);
|
||||||
if (!info) {
|
if (!info) {
|
||||||
|
// LCOV_EXCL_START
|
||||||
png_destroy_read_struct(&png, nullptr, nullptr);
|
png_destroy_read_struct(&png, nullptr, nullptr);
|
||||||
fatal("Failed to allocate PNG info structure: %s", strerror(errno));
|
fatal("Failed to create PNG info structure: %s", strerror(errno));
|
||||||
|
// LCOV_EXCL_STOP
|
||||||
}
|
}
|
||||||
|
|
||||||
png_set_read_fn(png, this, readData);
|
png_set_read_fn(png, this, readData);
|
||||||
@@ -555,6 +557,7 @@ static std::tuple<DefaultInitVec<size_t>, std::vector<Palette>>
|
|||||||
auto [mappings, nbPalettes] = overloadAndRemove(protoPalettes);
|
auto [mappings, nbPalettes] = overloadAndRemove(protoPalettes);
|
||||||
assume(mappings.size() == protoPalettes.size());
|
assume(mappings.size() == protoPalettes.size());
|
||||||
|
|
||||||
|
// LCOV_EXCL_START
|
||||||
if (options.verbosity >= Options::VERB_INTERM) {
|
if (options.verbosity >= Options::VERB_INTERM) {
|
||||||
fprintf(
|
fprintf(
|
||||||
stderr,
|
stderr,
|
||||||
@@ -566,6 +569,7 @@ static std::tuple<DefaultInitVec<size_t>, std::vector<Palette>>
|
|||||||
fprintf(stderr, "%zu -> %zu\n", i, mappings[i]);
|
fprintf(stderr, "%zu -> %zu\n", i, mappings[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// LCOV_EXCL_STOP
|
||||||
|
|
||||||
std::vector<Palette> palettes(nbPalettes);
|
std::vector<Palette> palettes(nbPalettes);
|
||||||
// If the image contains at least one transparent pixel, force transparency in the first slot of
|
// If the image contains at least one transparent pixel, force transparency in the first slot of
|
||||||
@@ -653,6 +657,7 @@ static std::tuple<DefaultInitVec<size_t>, std::vector<Palette>>
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void outputPalettes(std::vector<Palette> const &palettes) {
|
static void outputPalettes(std::vector<Palette> const &palettes) {
|
||||||
|
// LCOV_EXCL_START
|
||||||
if (options.verbosity >= Options::VERB_INTERM) {
|
if (options.verbosity >= Options::VERB_INTERM) {
|
||||||
for (auto &&palette : palettes) {
|
for (auto &&palette : palettes) {
|
||||||
fputs("{ ", stderr);
|
fputs("{ ", stderr);
|
||||||
@@ -662,6 +667,7 @@ static void outputPalettes(std::vector<Palette> const &palettes) {
|
|||||||
fputs("}\n", stderr);
|
fputs("}\n", stderr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// LCOV_EXCL_STOP
|
||||||
|
|
||||||
if (palettes.size() > options.nbPalettes) {
|
if (palettes.size() > options.nbPalettes) {
|
||||||
// If the palette generation is wrong, other (dependee) operations are likely to be
|
// If the palette generation is wrong, other (dependee) operations are likely to be
|
||||||
@@ -676,7 +682,9 @@ static void outputPalettes(std::vector<Palette> const &palettes) {
|
|||||||
if (!options.palettes.empty()) {
|
if (!options.palettes.empty()) {
|
||||||
File output;
|
File output;
|
||||||
if (!output.open(options.palettes, std::ios_base::out | std::ios_base::binary)) {
|
if (!output.open(options.palettes, std::ios_base::out | std::ios_base::binary)) {
|
||||||
|
// LCOV_EXCL_START
|
||||||
fatal("Failed to create \"%s\": %s", output.c_str(options.palettes), strerror(errno));
|
fatal("Failed to create \"%s\": %s", output.c_str(options.palettes), strerror(errno));
|
||||||
|
// LCOV_EXCL_STOP
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Palette const &palette : palettes) {
|
for (Palette const &palette : palettes) {
|
||||||
@@ -829,7 +837,9 @@ static void outputUnoptimizedTileData(
|
|||||||
) {
|
) {
|
||||||
File output;
|
File output;
|
||||||
if (!output.open(options.output, std::ios_base::out | std::ios_base::binary)) {
|
if (!output.open(options.output, std::ios_base::out | std::ios_base::binary)) {
|
||||||
|
// LCOV_EXCL_START
|
||||||
fatal("Failed to create \"%s\": %s", output.c_str(options.output), strerror(errno));
|
fatal("Failed to create \"%s\": %s", output.c_str(options.output), strerror(errno));
|
||||||
|
// LCOV_EXCL_STOP
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t widthTiles = options.inputSlice.width ? options.inputSlice.width : png.getWidth() / 8;
|
uint16_t widthTiles = options.inputSlice.width ? options.inputSlice.width : png.getWidth() / 8;
|
||||||
@@ -868,7 +878,9 @@ static void outputUnoptimizedMaps(
|
|||||||
if (!path.empty()) {
|
if (!path.empty()) {
|
||||||
file.emplace();
|
file.emplace();
|
||||||
if (!file->open(path, std::ios_base::out | std::ios_base::binary)) {
|
if (!file->open(path, std::ios_base::out | std::ios_base::binary)) {
|
||||||
|
// LCOV_EXCL_START
|
||||||
fatal("Failed to create \"%s\": %s", file->c_str(options.tilemap), strerror(errno));
|
fatal("Failed to create \"%s\": %s", file->c_str(options.tilemap), strerror(errno));
|
||||||
|
// LCOV_EXCL_STOP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -1013,7 +1025,9 @@ static UniqueTiles dedupTiles(
|
|||||||
static void outputTileData(UniqueTiles const &tiles) {
|
static void outputTileData(UniqueTiles const &tiles) {
|
||||||
File output;
|
File output;
|
||||||
if (!output.open(options.output, std::ios_base::out | std::ios_base::binary)) {
|
if (!output.open(options.output, std::ios_base::out | std::ios_base::binary)) {
|
||||||
|
// LCOV_EXCL_START
|
||||||
fatal("Failed to create \"%s\": %s", output.c_str(options.output), strerror(errno));
|
fatal("Failed to create \"%s\": %s", output.c_str(options.output), strerror(errno));
|
||||||
|
// LCOV_EXCL_STOP
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t tileID = 0;
|
uint16_t tileID = 0;
|
||||||
@@ -1035,7 +1049,9 @@ static void outputTileData(UniqueTiles const &tiles) {
|
|||||||
static void outputTilemap(DefaultInitVec<AttrmapEntry> const &attrmap) {
|
static void outputTilemap(DefaultInitVec<AttrmapEntry> const &attrmap) {
|
||||||
File output;
|
File output;
|
||||||
if (!output.open(options.tilemap, std::ios_base::out | std::ios_base::binary)) {
|
if (!output.open(options.tilemap, std::ios_base::out | std::ios_base::binary)) {
|
||||||
|
// LCOV_EXCL_START
|
||||||
fatal("Failed to create \"%s\": %s", output.c_str(options.tilemap), strerror(errno));
|
fatal("Failed to create \"%s\": %s", output.c_str(options.tilemap), strerror(errno));
|
||||||
|
// LCOV_EXCL_STOP
|
||||||
}
|
}
|
||||||
|
|
||||||
for (AttrmapEntry const &entry : attrmap) {
|
for (AttrmapEntry const &entry : attrmap) {
|
||||||
@@ -1048,7 +1064,9 @@ static void outputAttrmap(
|
|||||||
) {
|
) {
|
||||||
File output;
|
File output;
|
||||||
if (!output.open(options.attrmap, std::ios_base::out | std::ios_base::binary)) {
|
if (!output.open(options.attrmap, std::ios_base::out | std::ios_base::binary)) {
|
||||||
|
// LCOV_EXCL_START
|
||||||
fatal("Failed to create \"%s\": %s", output.c_str(options.attrmap), strerror(errno));
|
fatal("Failed to create \"%s\": %s", output.c_str(options.attrmap), strerror(errno));
|
||||||
|
// LCOV_EXCL_STOP
|
||||||
}
|
}
|
||||||
|
|
||||||
for (AttrmapEntry const &entry : attrmap) {
|
for (AttrmapEntry const &entry : attrmap) {
|
||||||
@@ -1064,7 +1082,9 @@ static void outputPalmap(
|
|||||||
) {
|
) {
|
||||||
File output;
|
File output;
|
||||||
if (!output.open(options.palmap, std::ios_base::out | std::ios_base::binary)) {
|
if (!output.open(options.palmap, std::ios_base::out | std::ios_base::binary)) {
|
||||||
|
// LCOV_EXCL_START
|
||||||
fatal("Failed to create \"%s\": %s", output.c_str(options.palmap), strerror(errno));
|
fatal("Failed to create \"%s\": %s", output.c_str(options.palmap), strerror(errno));
|
||||||
|
// LCOV_EXCL_STOP
|
||||||
}
|
}
|
||||||
|
|
||||||
for (AttrmapEntry const &entry : attrmap) {
|
for (AttrmapEntry const &entry : attrmap) {
|
||||||
@@ -1092,6 +1112,7 @@ void process() {
|
|||||||
// Now, we have all the image's colors in `colors`
|
// Now, we have all the image's colors in `colors`
|
||||||
// The next step is to order the palette
|
// The next step is to order the palette
|
||||||
|
|
||||||
|
// LCOV_EXCL_START
|
||||||
if (options.verbosity >= Options::VERB_INTERM) {
|
if (options.verbosity >= Options::VERB_INTERM) {
|
||||||
fputs("Image colors: [ ", stderr);
|
fputs("Image colors: [ ", stderr);
|
||||||
for (auto const &slot : colors) {
|
for (auto const &slot : colors) {
|
||||||
@@ -1102,6 +1123,7 @@ void process() {
|
|||||||
}
|
}
|
||||||
fputs("]\n", stderr);
|
fputs("]\n", stderr);
|
||||||
}
|
}
|
||||||
|
// LCOV_EXCL_STOP
|
||||||
|
|
||||||
// Now, iterate through the tiles, generating proto-palettes as we go
|
// Now, iterate through the tiles, generating proto-palettes as we go
|
||||||
// We do this unconditionally because this performs the image validation (which we want to
|
// We do this unconditionally because this performs the image validation (which we want to
|
||||||
@@ -1191,6 +1213,7 @@ continue_visiting_tiles:;
|
|||||||
protoPalettes.size(),
|
protoPalettes.size(),
|
||||||
protoPalettes.size() != 1 ? "s" : ""
|
protoPalettes.size() != 1 ? "s" : ""
|
||||||
);
|
);
|
||||||
|
// LCOV_EXCL_START
|
||||||
if (options.verbosity >= Options::VERB_INTERM) {
|
if (options.verbosity >= Options::VERB_INTERM) {
|
||||||
for (auto const &protoPal : protoPalettes) {
|
for (auto const &protoPal : protoPalettes) {
|
||||||
fputs("[ ", stderr);
|
fputs("[ ", stderr);
|
||||||
@@ -1200,6 +1223,7 @@ continue_visiting_tiles:;
|
|||||||
fputs("]\n", stderr);
|
fputs("]\n", stderr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// LCOV_EXCL_STOP
|
||||||
|
|
||||||
if (options.palSpecType == Options::EMBEDDED) {
|
if (options.palSpecType == Options::EMBEDDED) {
|
||||||
generatePalSpec(png);
|
generatePalSpec(png);
|
||||||
|
|||||||
@@ -401,7 +401,9 @@ void reverse() {
|
|||||||
options.verbosePrint(Options::VERB_LOG_ACT, "Writing image...\n");
|
options.verbosePrint(Options::VERB_LOG_ACT, "Writing image...\n");
|
||||||
File pngFile;
|
File pngFile;
|
||||||
if (!pngFile.open(options.input, std::ios::out | std::ios::binary)) {
|
if (!pngFile.open(options.input, std::ios::out | std::ios::binary)) {
|
||||||
|
// LCOV_EXCL_START
|
||||||
fatal("Failed to create \"%s\": %s", pngFile.c_str(options.input), strerror(errno));
|
fatal("Failed to create \"%s\": %s", pngFile.c_str(options.input), strerror(errno));
|
||||||
|
// LCOV_EXCL_STOP
|
||||||
}
|
}
|
||||||
png_structp png = png_create_write_struct(
|
png_structp png = png_create_write_struct(
|
||||||
PNG_LIBPNG_VER_STRING,
|
PNG_LIBPNG_VER_STRING,
|
||||||
@@ -410,11 +412,15 @@ void reverse() {
|
|||||||
pngWarning
|
pngWarning
|
||||||
);
|
);
|
||||||
if (!png) {
|
if (!png) {
|
||||||
|
// LCOV_EXCL_START
|
||||||
fatal("Failed to create PNG write struct: %s", strerror(errno));
|
fatal("Failed to create PNG write struct: %s", strerror(errno));
|
||||||
|
// LCOV_EXCL_STOP
|
||||||
}
|
}
|
||||||
png_infop pngInfo = png_create_info_struct(png);
|
png_infop pngInfo = png_create_info_struct(png);
|
||||||
if (!pngInfo) {
|
if (!pngInfo) {
|
||||||
fatal("Failed to create PNG info struct: %s", strerror(errno));
|
// LCOV_EXCL_START
|
||||||
|
fatal("Failed to create PNG info structure: %s", strerror(errno));
|
||||||
|
// LCOV_EXCL_STOP
|
||||||
}
|
}
|
||||||
png_set_write_fn(png, &pngFile, writePng, flushPng);
|
png_set_write_fn(png, &pngFile, writePng, flushPng);
|
||||||
|
|
||||||
|
|||||||
@@ -424,5 +424,5 @@ max_out:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unreachable_();
|
unreachable_(); // LCOV_EXCL_LINE
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -397,11 +397,15 @@ int main(int argc, char *argv[]) {
|
|||||||
is32kMode = true;
|
is32kMode = true;
|
||||||
break;
|
break;
|
||||||
case 'V':
|
case 'V':
|
||||||
|
// LCOV_EXCL_START
|
||||||
printf("rgblink %s\n", get_package_version_string());
|
printf("rgblink %s\n", get_package_version_string());
|
||||||
exit(0);
|
exit(0);
|
||||||
|
// LCOV_EXCL_STOP
|
||||||
case 'v':
|
case 'v':
|
||||||
|
// LCOV_EXCL_START
|
||||||
beVerbose = true;
|
beVerbose = true;
|
||||||
break;
|
break;
|
||||||
|
// LCOV_EXCL_STOP
|
||||||
case 'w':
|
case 'w':
|
||||||
isWRAM0Mode = true;
|
isWRAM0Mode = true;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -228,7 +228,7 @@ static uint8_t parseHexDigit(int c) {
|
|||||||
} else if (c >= 'a' && c <= 'f') {
|
} else if (c >= 'a' && c <= 'f') {
|
||||||
return c - 'a' + 10;
|
return c - 'a' + 10;
|
||||||
} else {
|
} else {
|
||||||
unreachable_();
|
unreachable_(); // LCOV_EXCL_LINE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -208,8 +208,10 @@ static void mergeSections(Section &target, std::unique_ptr<Section> &&other) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SECTION_NORMAL:
|
case SECTION_NORMAL:
|
||||||
|
// LCOV_EXCL_START
|
||||||
unreachable_();
|
unreachable_();
|
||||||
}
|
}
|
||||||
|
// LCOV_EXCL_STOP
|
||||||
|
|
||||||
// Note that the order in which fragments are stored in the `nextu` list does not
|
// Note that the order in which fragments are stored in the `nextu` list does not
|
||||||
// really matter, only that offsets were properly computed above
|
// really matter, only that offsets were properly computed above
|
||||||
|
|||||||
Reference in New Issue
Block a user