mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Fix -Wformat build warnings on macOS
C arithmetic promotes certain expressions to `int`, so formatting has to use "%d" or "%x", not inttypes.h. Fixes #883
This commit is contained in:
3
Makefile
3
Makefile
@@ -216,7 +216,8 @@ develop:
|
|||||||
-fsanitize=unreachable -fsanitize=vla-bound \
|
-fsanitize=unreachable -fsanitize=vla-bound \
|
||||||
-fsanitize=signed-integer-overflow -fsanitize=bounds \
|
-fsanitize=signed-integer-overflow -fsanitize=bounds \
|
||||||
-fsanitize=object-size -fsanitize=bool -fsanitize=enum \
|
-fsanitize=object-size -fsanitize=bool -fsanitize=enum \
|
||||||
-fsanitize=alignment -fsanitize=null -fsanitize=address" CFLAGS="-ggdb3 -O0"
|
-fsanitize=alignment -fsanitize=null -fsanitize=address" \
|
||||||
|
CFLAGS="-ggdb3 -O0"
|
||||||
|
|
||||||
# Targets for the project maintainer to easily create Windows exes.
|
# Targets for the project maintainer to easily create Windows exes.
|
||||||
# This is not for Windows users!
|
# This is not for Windows users!
|
||||||
|
|||||||
@@ -337,7 +337,7 @@ static void placeSection(struct Section *section)
|
|||||||
section->name, typeNames[section->type], where);
|
section->name, typeNames[section->type], where);
|
||||||
/* If the section just can't fit the bank, report that */
|
/* If the section just can't fit the bank, report that */
|
||||||
else if (section->org + section->size > endaddr(section->type) + 1)
|
else if (section->org + section->size > endaddr(section->type) + 1)
|
||||||
errx(1, "Unable to place \"%s\" (%s section) %s: section runs past end of region ($%04" PRIx16 " > $%04" PRIx16 ")",
|
errx(1, "Unable to place \"%s\" (%s section) %s: section runs past end of region ($%04x > $%04x)",
|
||||||
section->name, typeNames[section->type], where,
|
section->name, typeNames[section->type], where,
|
||||||
section->org + section->size, endaddr(section->type) + 1);
|
section->org + section->size, endaddr(section->type) + 1);
|
||||||
/* Otherwise there is overlap with another section */
|
/* Otherwise there is overlap with another section */
|
||||||
|
|||||||
@@ -384,7 +384,8 @@ static uint16_t writeMapBank(struct SortedSections const *sectList,
|
|||||||
used += sect->size;
|
used += sect->size;
|
||||||
|
|
||||||
if (sect->size != 0)
|
if (sect->size != 0)
|
||||||
fprintf(mapFile, " SECTION: $%04" PRIx16 "-$%04" PRIx16 " ($%04" PRIx16 " byte%s) [\"%s\"]\n",
|
fprintf(mapFile, " SECTION: $%04" PRIx16 "-$%04x ($%04" PRIx16
|
||||||
|
" byte%s) [\"%s\"]\n",
|
||||||
sect->org, sect->org + sect->size - 1,
|
sect->org, sect->org + sect->size - 1,
|
||||||
sect->size, sect->size == 1 ? "" : "s",
|
sect->size, sect->size == 1 ? "" : "s",
|
||||||
sect->name);
|
sect->name);
|
||||||
|
|||||||
@@ -49,8 +49,8 @@ static void checkSectUnionCompat(struct Section *target, struct Section *other)
|
|||||||
other->name, target->org, other->org);
|
other->name, target->org, other->org);
|
||||||
} else if (target->isAlignFixed) {
|
} else if (target->isAlignFixed) {
|
||||||
if ((other->org - target->alignOfs) & target->alignMask)
|
if ((other->org - target->alignOfs) & target->alignMask)
|
||||||
errx(1, "Section \"%s\" is defined with conflicting %" PRIu16
|
errx(1, "Section \"%s\" is defined with conflicting %d-byte alignment (offset %"
|
||||||
"-byte alignment (offset %" PRIu16 ") and address $%04" PRIx16,
|
PRIu16 ") and address $%04" PRIx16,
|
||||||
other->name, target->alignMask + 1,
|
other->name, target->alignMask + 1,
|
||||||
target->alignOfs, other->org);
|
target->alignOfs, other->org);
|
||||||
}
|
}
|
||||||
@@ -61,15 +61,14 @@ static void checkSectUnionCompat(struct Section *target, struct Section *other)
|
|||||||
if (target->isAddressFixed) {
|
if (target->isAddressFixed) {
|
||||||
if ((target->org - other->alignOfs) & other->alignMask)
|
if ((target->org - other->alignOfs) & other->alignMask)
|
||||||
errx(1, "Section \"%s\" is defined with conflicting address $%04"
|
errx(1, "Section \"%s\" is defined with conflicting address $%04"
|
||||||
PRIx16 " and %" PRIu16 "-byte alignment (offset %" PRIu16 ")",
|
PRIx16 " and %d-byte alignment (offset %" PRIu16 ")",
|
||||||
other->name, target->org,
|
other->name, target->org,
|
||||||
other->alignMask + 1, other->alignOfs);
|
other->alignMask + 1, other->alignOfs);
|
||||||
} else if (target->isAlignFixed
|
} else if (target->isAlignFixed
|
||||||
&& (other->alignMask & target->alignOfs)
|
&& (other->alignMask & target->alignOfs)
|
||||||
!= (target->alignMask & other->alignOfs)) {
|
!= (target->alignMask & other->alignOfs)) {
|
||||||
errx(1, "Section \"%s\" is defined with conflicting %" PRIu16
|
errx(1, "Section \"%s\" is defined with conflicting %d-byte alignment (offset %"
|
||||||
"-byte alignment (offset %" PRIu16 ") and %" PRIu16
|
PRIu16 ") and %d-byte alignment (offset %" PRIu16 ")",
|
||||||
"-byte alignment (offset %" PRIu16 ")",
|
|
||||||
other->name, target->alignMask + 1, target->alignOfs,
|
other->name, target->alignMask + 1, target->alignOfs,
|
||||||
other->alignMask + 1, other->alignOfs);
|
other->alignMask + 1, other->alignOfs);
|
||||||
} else if (!target->isAlignFixed || (other->alignMask > target->alignMask)) {
|
} else if (!target->isAlignFixed || (other->alignMask > target->alignMask)) {
|
||||||
@@ -92,8 +91,8 @@ static void checkFragmentCompat(struct Section *target, struct Section *other)
|
|||||||
|
|
||||||
} else if (target->isAlignFixed) {
|
} else if (target->isAlignFixed) {
|
||||||
if ((org - target->alignOfs) & target->alignMask)
|
if ((org - target->alignOfs) & target->alignMask)
|
||||||
errx(1, "Section \"%s\" is defined with conflicting %" PRIu16
|
errx(1, "Section \"%s\" is defined with conflicting %d-byte alignment (offset %"
|
||||||
"-byte alignment (offset %" PRIu16 ") and address $%04" PRIx16,
|
PRIu16 ") and address $%04" PRIx16,
|
||||||
other->name, target->alignMask + 1,
|
other->name, target->alignMask + 1,
|
||||||
target->alignOfs, other->org);
|
target->alignOfs, other->org);
|
||||||
}
|
}
|
||||||
@@ -109,15 +108,14 @@ static void checkFragmentCompat(struct Section *target, struct Section *other)
|
|||||||
if (target->isAddressFixed) {
|
if (target->isAddressFixed) {
|
||||||
if ((target->org - ofs) & other->alignMask)
|
if ((target->org - ofs) & other->alignMask)
|
||||||
errx(1, "Section \"%s\" is defined with conflicting address $%04"
|
errx(1, "Section \"%s\" is defined with conflicting address $%04"
|
||||||
PRIx16 " and %" PRIu16 "-byte alignment (offset %" PRIu16 ")",
|
PRIx16 " and %d-byte alignment (offset %" PRIu16 ")",
|
||||||
other->name, target->org,
|
other->name, target->org,
|
||||||
other->alignMask + 1, other->alignOfs);
|
other->alignMask + 1, other->alignOfs);
|
||||||
|
|
||||||
} else if (target->isAlignFixed
|
} else if (target->isAlignFixed
|
||||||
&& (other->alignMask & target->alignOfs) != (target->alignMask & ofs)) {
|
&& (other->alignMask & target->alignOfs) != (target->alignMask & ofs)) {
|
||||||
errx(1, "Section \"%s\" is defined with conflicting %" PRIu16
|
errx(1, "Section \"%s\" is defined with conflicting %d-byte alignment (offset %"
|
||||||
"-byte alignment (offset %" PRIu16 ") and %" PRIu16
|
PRIu16 ") and %d-byte alignment (offset %" PRIu16 ")",
|
||||||
"-byte alignment (offset %" PRIu16 ")",
|
|
||||||
other->name, target->alignMask + 1, target->alignOfs,
|
other->name, target->alignMask + 1, target->alignOfs,
|
||||||
other->alignMask + 1, other->alignOfs);
|
other->alignMask + 1, other->alignOfs);
|
||||||
|
|
||||||
@@ -252,7 +250,7 @@ static void doSanityChecks(struct Section *section, void *ptr)
|
|||||||
|
|
||||||
/* Too large an alignment may not be satisfiable */
|
/* Too large an alignment may not be satisfiable */
|
||||||
if (section->isAlignFixed && (section->alignMask & startaddr[section->type]))
|
if (section->isAlignFixed && (section->alignMask & startaddr[section->type]))
|
||||||
fail("%s: %s sections cannot be aligned to $%04" PRIx16 " bytes",
|
fail("%s: %s sections cannot be aligned to $%04x bytes",
|
||||||
section->name, typeNames[section->type], section->alignMask + 1);
|
section->name, typeNames[section->type], section->alignMask + 1);
|
||||||
|
|
||||||
uint32_t minbank = bankranges[section->type][0], maxbank = bankranges[section->type][1];
|
uint32_t minbank = bankranges[section->type][0], maxbank = bankranges[section->type][1];
|
||||||
@@ -292,9 +290,9 @@ static void doSanityChecks(struct Section *section, void *ptr)
|
|||||||
startaddr[section->type], endaddr(section->type));
|
startaddr[section->type], endaddr(section->type));
|
||||||
|
|
||||||
if (section->org + section->size > endaddr(section->type) + 1)
|
if (section->org + section->size > endaddr(section->type) + 1)
|
||||||
fail("Section \"%s\"'s end address %#" PRIx16
|
fail("Section \"%s\"'s end address %#x is greater than last address %#x",
|
||||||
" is greater than last address %#" PRIx16, section->name,
|
section->name, section->org + section->size,
|
||||||
section->org + section->size, endaddr(section->type) + 1);
|
endaddr(section->type) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef fail
|
#undef fail
|
||||||
|
|||||||
Reference in New Issue
Block a user