summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor van den Elzen <victor.vde@gmail.com>2009-08-11 02:10:16 +0200
committerVictor van den Elzen <victor.vde@gmail.com>2009-08-11 02:43:41 +0200
commit15bb2330368783724cf526dfec5c02d028bd5b98 (patch)
treefa653bd47ff1a50eb5e0264cadf158413e3b9ca0
parent5a49e7c578378308c4e866313ea08c65e6869a06 (diff)
downloadnasm-15bb2330368783724cf526dfec5c02d028bd5b98.tar.gz
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.
-rw-r--r--labels.c4
-rw-r--r--nasmlib.h4
-rw-r--r--output/outbin.c4
-rw-r--r--output/outelf32.c4
-rw-r--r--output/outelf64.c20
-rw-r--r--output/outobj.c6
-rw-r--r--parser.c6
7 files changed, 27 insertions, 21 deletions
diff --git a/labels.c b/labels.c
index 8c850c30..9152552e 100644
--- a/labels.c
+++ b/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);
diff --git a/nasmlib.h b/nasmlib.h
index 3cb15bae..c42c3fd2 100644
--- a/nasmlib.h
+++ b/nasmlib.h
@@ -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);
/*
diff --git a/output/outbin.c b/output/outbin.c
index 89c8ecf9..ba9947d9 100644
--- a/output/outbin.c
+++ b/output/outbin.c
@@ -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)
diff --git a/output/outelf32.c b/output/outelf32.c
index 7dce1658..6902beaf 100644
--- a/output/outelf32.c
+++ b/output/outelf32.c
@@ -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] != '@') {
diff --git a/output/outelf64.c b/output/outelf64.c
index 5ccdf51c..53bc4c5a 100644
--- a/output/outelf64.c
+++ b/output/outelf64.c
@@ -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
/*
diff --git a/output/outobj.c b/output/outobj.c
index b8499ab9..87846fbd 100644
--- a/output/outobj.c
+++ b/output/outobj.c
@@ -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) {
diff --git a/parser.c b/parser.c
index 2ff6e36e..88cb937c 100644
--- a/parser.c
+++ b/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)