Some refactoring

This commit is contained in:
Rangi42
2023-12-18 15:51:13 -05:00
parent fdd45ab1dc
commit 09dbc50447
2 changed files with 14 additions and 18 deletions

View File

@@ -11,34 +11,33 @@
static void vwarn(char const NONNULL(fmt), va_list ap) static void vwarn(char const NONNULL(fmt), va_list ap)
{ {
const char *error = strerror(errno);
fprintf(stderr, "warning: "); fprintf(stderr, "warning: ");
vfprintf(stderr, fmt, ap); vfprintf(stderr, fmt, ap);
fputs(": ", stderr); fprintf(stderr, ": %s\n", error);
perror(NULL);
} }
static void vwarnx(char const NONNULL(fmt), va_list ap) static void vwarnx(char const NONNULL(fmt), va_list ap)
{ {
fprintf(stderr, "warning"); fprintf(stderr, "warning: ");
fputs(": ", stderr);
vfprintf(stderr, fmt, ap); vfprintf(stderr, fmt, ap);
putc('\n', stderr); putc('\n', stderr);
} }
[[noreturn]] static void verr(char const NONNULL(fmt), va_list ap) [[noreturn]] static void verr(char const NONNULL(fmt), va_list ap)
{ {
const char *error = strerror(errno);
fprintf(stderr, "error: "); fprintf(stderr, "error: ");
vfprintf(stderr, fmt, ap); vfprintf(stderr, fmt, ap);
fputs(": ", stderr); fprintf(stderr, ": %s\n", error);
fputs(strerror(errno), stderr);
putc('\n', stderr);
exit(1); exit(1);
} }
[[noreturn]] static void verrx(char const NONNULL(fmt), va_list ap) [[noreturn]] static void verrx(char const NONNULL(fmt), va_list ap)
{ {
fprintf(stderr, "error"); fprintf(stderr, "error: ");
fputs(": ", stderr);
vfprintf(stderr, fmt, ap); vfprintf(stderr, fmt, ap);
putc('\n', stderr); putc('\n', stderr);
exit(1); exit(1);

View File

@@ -297,22 +297,19 @@ static void placeSection(struct Section *section)
if (section->isBankFixed && nbbanks(section->type) != 1) { if (section->isBankFixed && nbbanks(section->type) != 1) {
if (section->isAddressFixed) if (section->isAddressFixed)
snprintf(where, 64, "at $%02" PRIx32 ":%04" PRIx16, snprintf(where, sizeof(where), "at $%02" PRIx32 ":%04" PRIx16,
section->bank, section->org); section->bank, section->org);
else if (section->isAlignFixed) else if (section->isAlignFixed)
snprintf(where, 64, "in bank $%02" PRIx32 " with align mask %" PRIx16, snprintf(where, sizeof(where), "in bank $%02" PRIx32 " with align mask %" PRIx16,
section->bank, (uint16_t)~section->alignMask); section->bank, (uint16_t)~section->alignMask);
else else
snprintf(where, 64, "in bank $%02" PRIx32, snprintf(where, sizeof(where), "in bank $%02" PRIx32, section->bank);
section->bank);
} else { } else {
if (section->isAddressFixed) if (section->isAddressFixed)
snprintf(where, 64, "at address $%04" PRIx16, snprintf(where, sizeof(where), "at address $%04" PRIx16, section->org);
section->org);
else if (section->isAlignFixed) else if (section->isAlignFixed)
snprintf(where, 64, "with align mask %" PRIx16 " and offset %" PRIx16, snprintf(where, sizeof(where), "with align mask %" PRIx16 " and offset %" PRIx16,
(uint16_t)~section->alignMask, (uint16_t)~section->alignMask, section->alignOfs);
section->alignOfs);
else else
strcpy(where, "anywhere"); strcpy(where, "anywhere");
} }