Skip to content

Commit

Permalink
Some refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Rangi42 committed Dec 18, 2023
1 parent fdd45ab commit 09dbc50
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
17 changes: 8 additions & 9 deletions src/error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,33 @@

static void vwarn(char const NONNULL(fmt), va_list ap)
{
const char *error = strerror(errno);

fprintf(stderr, "warning: ");
vfprintf(stderr, fmt, ap);
fputs(": ", stderr);
perror(NULL);
fprintf(stderr, ": %s\n", error);
}

static void vwarnx(char const NONNULL(fmt), va_list ap)
{
fprintf(stderr, "warning");
fputs(": ", stderr);
fprintf(stderr, "warning: ");
vfprintf(stderr, fmt, ap);
putc('\n', stderr);
}

[[noreturn]] static void verr(char const NONNULL(fmt), va_list ap)
{
const char *error = strerror(errno);

fprintf(stderr, "error: ");
vfprintf(stderr, fmt, ap);
fputs(": ", stderr);
fputs(strerror(errno), stderr);
putc('\n', stderr);
fprintf(stderr, ": %s\n", error);
exit(1);
}

[[noreturn]] static void verrx(char const NONNULL(fmt), va_list ap)
{
fprintf(stderr, "error");
fputs(": ", stderr);
fprintf(stderr, "error: ");
vfprintf(stderr, fmt, ap);
putc('\n', stderr);
exit(1);
Expand Down
15 changes: 6 additions & 9 deletions src/link/assign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,22 +297,19 @@ static void placeSection(struct Section *section)

if (section->isBankFixed && nbbanks(section->type) != 1) {
if (section->isAddressFixed)
snprintf(where, 64, "at $%02" PRIx32 ":%04" PRIx16,
snprintf(where, sizeof(where), "at $%02" PRIx32 ":%04" PRIx16,
section->bank, section->org);
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);
else
snprintf(where, 64, "in bank $%02" PRIx32,
section->bank);
snprintf(where, sizeof(where), "in bank $%02" PRIx32, section->bank);
} else {
if (section->isAddressFixed)
snprintf(where, 64, "at address $%04" PRIx16,
section->org);
snprintf(where, sizeof(where), "at address $%04" PRIx16, section->org);
else if (section->isAlignFixed)
snprintf(where, 64, "with align mask %" PRIx16 " and offset %" PRIx16,
(uint16_t)~section->alignMask,
section->alignOfs);
snprintf(where, sizeof(where), "with align mask %" PRIx16 " and offset %" PRIx16,
(uint16_t)~section->alignMask, section->alignOfs);
else
strcpy(where, "anywhere");
}
Expand Down

0 comments on commit 09dbc50

Please sign in to comment.