mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-03-19 18:00:23 +08:00
Fix some format strings for nasm_error
Added a format attribute to nasm_error (only for GCC) and used the resulting warnings to fix some format strings.
This commit is contained in:
parent
5a49e7c578
commit
15bb233036
4
labels.c
4
labels.c
@ -224,7 +224,7 @@ void redefine_label(char *label, int32_t segment, int64_t offset, char *special,
|
||||
#if DEBUG<3
|
||||
if (!strncmp(label, "debugdump", 9))
|
||||
#endif
|
||||
nasm_error(ERR_DEBUG, "redefine_label (%s, %ld, %08lx, %s, %d, %d)",
|
||||
nasm_error(ERR_DEBUG, "redefine_label (%s, %"PRIx32", %"PRIx64", %s, %d, %d)",
|
||||
label, segment, offset, special, is_norm, isextrn);
|
||||
#endif
|
||||
|
||||
@ -288,7 +288,7 @@ void define_label(char *label, int32_t segment, int64_t offset, char *special,
|
||||
#if DEBUG<3
|
||||
if (!strncmp(label, "debugdump", 9))
|
||||
#endif
|
||||
nasm_error(ERR_DEBUG, "define_label (%s, %ld, %08lx, %s, %d, %d)",
|
||||
nasm_error(ERR_DEBUG, "define_label (%s, %"PRIx32", %"PRIx64", %s, %d, %d)",
|
||||
label, segment, offset, special, is_norm, isextrn);
|
||||
#endif
|
||||
lptr = find_label(label, 1);
|
||||
|
@ -84,7 +84,11 @@ extern unsigned char nasm_tolower_tab[256];
|
||||
*/
|
||||
typedef void (*efunc) (int severity, const char *fmt, ...);
|
||||
typedef void (*vefunc) (int severity, const char *fmt, va_list ap);
|
||||
#ifdef __GNUC__
|
||||
void nasm_error(int severity, const char *fmt, ...) __attribute__((format(printf, 2, 3)));
|
||||
#else
|
||||
void nasm_error(int severity, const char *fmt, ...);
|
||||
#endif
|
||||
void nasm_set_verror(vefunc);
|
||||
|
||||
/*
|
||||
|
@ -241,7 +241,7 @@ static void bin_cleanup(int debuginfo)
|
||||
(void)debuginfo; /* placate optimizers */
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stdout,
|
||||
nasm_error(ERR_DEBUG,
|
||||
"bin_cleanup: Sections were initially referenced in this order:\n");
|
||||
for (h = 0, s = sections; s; h++, s = s->next)
|
||||
fprintf(stdout, "%i. %s\n", h, s->name);
|
||||
@ -530,7 +530,7 @@ static void bin_cleanup(int debuginfo)
|
||||
nasm_error(ERR_FATAL|ERR_NOFILE, "circular vfollows path detected");
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stdout,
|
||||
nasm_error(ERR_DEBUG,
|
||||
"bin_cleanup: Confirm final section order for output file:\n");
|
||||
for (h = 0, s = sections; s && (s->flags & TYPE_PROGBITS);
|
||||
h++, s = s->next)
|
||||
|
@ -461,8 +461,8 @@ static void elf_deflabel(char *name, int32_t segment, int64_t offset,
|
||||
bool special_used = false;
|
||||
|
||||
#if defined(DEBUG) && DEBUG>2
|
||||
fprintf(stderr,
|
||||
" elf_deflabel: %s, seg=%ld, off=%ld, is_global=%d, %s\n",
|
||||
nasm_error(ERR_DEBUG,
|
||||
" elf_deflabel: %s, seg=%"PRIx32", off=%"PRIx64", is_global=%d, %s\n",
|
||||
name, segment, offset, is_global, special);
|
||||
#endif
|
||||
if (name[0] == '.' && name[1] == '.' && name[2] != '@') {
|
||||
|
@ -386,7 +386,7 @@ static int32_t elf_section_names(char *name, int pass, int *bits)
|
||||
if (align == 0)
|
||||
align = 1;
|
||||
if ((align - 1) & align) { /* means it's not a power of two */
|
||||
nasm_error(ERR_NONFATAL, "section alignment %d is not"
|
||||
nasm_error(ERR_NONFATAL, "section alignment %"PRId64" is not"
|
||||
" a power of two", align);
|
||||
align = 1;
|
||||
}
|
||||
@ -465,8 +465,8 @@ static void elf_deflabel(char *name, int32_t segment, int64_t offset,
|
||||
bool special_used = false;
|
||||
|
||||
#if defined(DEBUG) && DEBUG>2
|
||||
fprintf(stderr,
|
||||
" elf_deflabel: %s, seg=%x, off=%x, is_global=%d, %s\n",
|
||||
nasm_error(ERR_DEBUG,
|
||||
" elf_deflabel: %s, seg=%"PRIx32", off=%"PRIx64", is_global=%d, %s\n",
|
||||
name, segment, offset, is_global, special);
|
||||
#endif
|
||||
if (name[0] == '.' && name[1] == '.' && name[2] != '@') {
|
||||
@ -792,12 +792,14 @@ static void elf_out(int32_t segto, const void *data,
|
||||
zero = 0;
|
||||
|
||||
#if defined(DEBUG) && DEBUG>2
|
||||
if (data) fprintf(stderr,
|
||||
" elf_out line: %d type: %x seg: %d segto: %d bytes: %x data: %"PRIx64"\n",
|
||||
currentline, type, segment, segto, size, *(int64_t *)data);
|
||||
else fprintf(stderr,
|
||||
" elf_out line: %d type: %x seg: %d segto: %d bytes: %x\n",
|
||||
currentline, type, segment, segto, size);
|
||||
if (data)
|
||||
nasm_error(ERR_DEBUG,
|
||||
" elf_out line: %d type: %x seg: %"PRIx32" segto: %"PRIx32" bytes: %"PRIx64" data: %"PRIx64"\n",
|
||||
currentline, type, segment, segto, size, *(int64_t *)data);
|
||||
else
|
||||
nasm_error(ERR_DEBUG,
|
||||
" elf_out line: %d type: %x seg: %"PRIx32" segto: %"PRIx32" bytes: %"PRIx64"\n",
|
||||
currentline, type, segment, segto, size);
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -774,8 +774,8 @@ static void obj_deflabel(char *name, int32_t segment,
|
||||
bool used_special = false; /* have we used the special text? */
|
||||
|
||||
#if defined(DEBUG) && DEBUG>2
|
||||
fprintf(stderr,
|
||||
" obj_deflabel: %s, seg=%ld, off=%ld, is_global=%d, %s\n",
|
||||
nasm_error(ERR_DEBUG,
|
||||
" obj_deflabel: %s, seg=%"PRIx32", off=%"PRIx64", is_global=%d, %s\n",
|
||||
name, segment, offset, is_global, special);
|
||||
#endif
|
||||
|
||||
@ -1288,7 +1288,7 @@ static int32_t obj_segment(char *name, int pass, int *bits)
|
||||
* by sponging off the label manager.
|
||||
*/
|
||||
#if defined(DEBUG) && DEBUG>=3
|
||||
fprintf(stderr, " obj_segment: < %s >, pass=%d, *bits=%d\n",
|
||||
nasm_error(ERR_DEBUG, " obj_segment: < %s >, pass=%d, *bits=%d\n",
|
||||
name, pass, *bits);
|
||||
#endif
|
||||
if (!name) {
|
||||
|
6
parser.c
6
parser.c
@ -283,7 +283,7 @@ restart_parse:
|
||||
} else {
|
||||
result->times = value->value;
|
||||
if (value->value < 0 && pass0 == 2) {
|
||||
nasm_error(ERR_NONFATAL, "TIMES value %d is negative",
|
||||
nasm_error(ERR_NONFATAL, "TIMES value %"PRId64" is negative",
|
||||
value->value);
|
||||
result->times = 0;
|
||||
}
|
||||
@ -531,11 +531,11 @@ restart_parse:
|
||||
nasm_error(ERR_NONFATAL, "`incbin' expects a file name");
|
||||
else if (result->eops->next &&
|
||||
result->eops->next->type != EOT_DB_NUMBER)
|
||||
nasm_error(ERR_NONFATAL, "`incbin': second parameter is",
|
||||
nasm_error(ERR_NONFATAL, "`incbin': second parameter is"
|
||||
" non-numeric");
|
||||
else if (result->eops->next && result->eops->next->next &&
|
||||
result->eops->next->next->type != EOT_DB_NUMBER)
|
||||
nasm_error(ERR_NONFATAL, "`incbin': third parameter is",
|
||||
nasm_error(ERR_NONFATAL, "`incbin': third parameter is"
|
||||
" non-numeric");
|
||||
else if (result->eops->next && result->eops->next->next &&
|
||||
result->eops->next->next->next)
|
||||
|
Loading…
x
Reference in New Issue
Block a user