Avoid using %# printf specifier

This commit is contained in:
Rangi42
2023-11-02 11:20:49 -04:00
committed by Eldred Habert
parent b4dbb5093a
commit a64f28de5c
7 changed files with 22 additions and 21 deletions

View File

@@ -335,8 +335,8 @@ static struct Section *getSection(char const *name, enum SectionType type, uint3
if (org != (uint32_t)-1) {
if (org < sectionTypeInfo[type].startAddr || org > endaddr(type))
error("Section \"%s\"'s fixed address %#" PRIx32
" is outside of range [%#" PRIx16 "; %#" PRIx16 "]\n",
error("Section \"%s\"'s fixed address $%04" PRIx32
" is outside of range [$%04" PRIx16 "; $%04" PRIx16 "]\n",
name, org, sectionTypeInfo[type].startAddr, endaddr(type));
}

View File

@@ -969,7 +969,7 @@ static void processFile(int input, int output, char const *name, off_t fileSize)
overwriteByte(rom0, 0x14B, oldLicensee, "old licensee code");
else if (sgb && rom0[0x14B] != 0x33)
fprintf(stderr,
"warning: SGB compatibility enabled, but old licensee was %#x, not 0x33\n",
"warning: SGB compatibility enabled, but old licensee was 0x%02x, not 0x33\n",
rom0[0x14B]);
if (romVersion != UNSPECIFIED)
@@ -1440,7 +1440,7 @@ do { \
if (sgb && oldLicensee != UNSPECIFIED && oldLicensee != 0x33)
fprintf(stderr,
"warning: SGB compatibility enabled, but old licensee is %#x, not 0x33\n",
"warning: SGB compatibility enabled, but old licensee is 0x%02x, not 0x33\n",
oldLicensee);
argv += musl_optind;

View File

@@ -525,7 +525,7 @@ static void applyFilePatches(struct Section *section, struct Section *dataSectio
if (!isError && (value < types[patch->type].min
|| value > types[patch->type].max))
error(patch->src, patch->lineNo,
"Value %#" PRIx32 "%s is not %u-bit",
"Value %" PRId32 "%s is not %u-bit",
value, value < 0 ? " (maybe negative?)" : "",
types[patch->type].size * 8U);
for (uint8_t i = 0; i < types[patch->type].size; i++) {

View File

@@ -274,8 +274,9 @@ static void doSanityChecks(struct Section *section, void *ptr)
// Check if section has a chance to be placed
if (section->size > sectionTypeInfo[section->type].size)
error(NULL, 0, "Section \"%s\" is bigger than the max size for that type: %#" PRIx16 " > %#" PRIx16,
section->name, section->size, sectionTypeInfo[section->type].size);
error(NULL, 0, "Section \"%s\" is bigger than the max size for that type: $%"
PRIx16 " > $%" PRIx16,
section->name, section->size, sectionTypeInfo[section->type].size);
// Translate loose constraints to strong ones when they're equivalent
@@ -296,14 +297,14 @@ static void doSanityChecks(struct Section *section, void *ptr)
// Ensure the target address is valid
if (section->org < sectionTypeInfo[section->type].startAddr
|| section->org > endaddr(section->type))
error(NULL, 0, "Section \"%s\"'s fixed address %#" PRIx16 " is outside of range [%#"
PRIx16 "; %#" PRIx16 "]", section->name, section->org,
error(NULL, 0, "Section \"%s\"'s fixed address $%04" PRIx16 " is outside of range [$%04"
PRIx16 "; $%04" PRIx16 "]", section->name, section->org,
sectionTypeInfo[section->type].startAddr, endaddr(section->type));
if (section->org + section->size > endaddr(section->type) + 1)
error(NULL, 0, "Section \"%s\"'s end address %#x is greater than last address %#x",
section->name, section->org + section->size,
endaddr(section->type) + 1);
error(NULL, 0, "Section \"%s\"'s end address $%04x is greater than last address $%04x",
section->name, section->org + section->size,
endaddr(section->type) + 1);
}
#undef fail