diff --git a/src/error.cpp b/src/error.cpp index 8ddc9c268..2d05facb6 100644 --- a/src/error.cpp +++ b/src/error.cpp @@ -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); diff --git a/src/link/assign.cpp b/src/link/assign.cpp index c74859249..22daf95d5 100644 --- a/src/link/assign.cpp +++ b/src/link/assign.cpp @@ -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"); }