summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin (Intel) <hpa@zytor.com>2018-12-13 19:39:41 -0800
committerH. Peter Anvin (Intel) <hpa@zytor.com>2018-12-13 19:42:38 -0800
commit6bde2ed8806b3e53657d46b61ee79d7afe5c2e13 (patch)
tree116b747e03890c86b964ce3f50c9cc1e74aba912
parent9f89eb38fc0e7566b8a35408b36d7c900ab5d046 (diff)
downloadnasm-6bde2ed8806b3e53657d46b61ee79d7afe5c2e13.tar.gz
errors: change the severity parameter from "int" to "errflags"
Change the severity parameter to the error function from "int" to an unsigned typedef, currently uint32_t. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
-rw-r--r--asm/error.c4
-rw-r--r--asm/listing.c2
-rw-r--r--asm/listing.h2
-rw-r--r--asm/nasm.c18
-rw-r--r--asm/preproc-nop.c2
-rw-r--r--asm/preproc.c10
-rw-r--r--disasm/ndisasm.c2
-rw-r--r--include/error.h25
-rw-r--r--include/nasm.h3
-rw-r--r--rdoff/rdoff.c2
10 files changed, 38 insertions, 32 deletions
diff --git a/asm/error.c b/asm/error.c
index fa8d2d62..2a0b34ad 100644
--- a/asm/error.c
+++ b/asm/error.c
@@ -95,13 +95,13 @@ vefunc nasm_verror;
nasm_verror((s), fmt, ap); \
va_end(ap);
-void nasm_error(int severity, const char *fmt, ...)
+void nasm_error(errflags severity, const char *fmt, ...)
{
nasm_do_error(severity);
}
#define nasm_err_helpers(_type, _name, _sev) \
-_type nasm_ ## _name ## f (int flags, const char *fmt, ...) \
+_type nasm_ ## _name ## f (errflags flags, const char *fmt, ...) \
{ \
nasm_do_error((_sev)|flags); \
if (_sev >= ERR_FATAL) \
diff --git a/asm/listing.c b/asm/listing.c
index 440cc177..099ce8d1 100644
--- a/asm/listing.c
+++ b/asm/listing.c
@@ -330,7 +330,7 @@ static void list_downlevel(int type)
}
}
-static void list_error(int severity, const char *fmt, ...)
+static void list_error(errflags severity, const char *fmt, ...)
{
struct list_error *le;
va_list ap;
diff --git a/asm/listing.h b/asm/listing.h
index f3ddb0e0..1751c7f7 100644
--- a/asm/listing.h
+++ b/asm/listing.h
@@ -96,7 +96,7 @@ struct lfmt {
/*
* Called on a warning or error, with the error message.
*/
- void printf_func(2, 3) (*error)(int severity, const char *fmt, ...);
+ void printf_func(2, 3) (*error)(errflags severity, const char *fmt, ...);
/*
* Update the current offset. Used to give the listing generator
diff --git a/asm/nasm.c b/asm/nasm.c
index 149e1042..2a95f6a1 100644
--- a/asm/nasm.c
+++ b/asm/nasm.c
@@ -76,8 +76,8 @@ struct forwrefinfo { /* info held on forward refs. */
static void parse_cmdline(int, char **, int);
static void assemble_file(const char *, struct strlist *);
-static bool skip_this_pass(int severity);
-static void nasm_verror_asm(int severity, const char *fmt, va_list args);
+static bool skip_this_pass(errflags severity);
+static void nasm_verror_asm(errflags severity, const char *fmt, va_list args);
static void usage(void);
static void help(char xopt);
@@ -1700,7 +1700,7 @@ static void assemble_file(const char *fname, struct strlist *depend_list)
/**
* get warning index; 0 if this is non-suppressible.
*/
-static size_t warn_index(int severity)
+static size_t warn_index(errflags severity)
{
size_t index;
@@ -1717,7 +1717,7 @@ static size_t warn_index(int severity)
return index;
}
-static bool skip_this_pass(int severity)
+static bool skip_this_pass(errflags severity)
{
/*
* See if it's a pass-specific error or warning which should be skipped.
@@ -1742,7 +1742,7 @@ static bool skip_this_pass(int severity)
* @param severity the severity of the warning or error
* @return true if we should abort error/warning printing
*/
-static bool is_suppressed(int severity)
+static bool is_suppressed(errflags severity)
{
if ((severity & ERR_MASK) >= ERR_FATAL)
return false; /* Fatal errors can never be suppressed */
@@ -1758,7 +1758,7 @@ static bool is_suppressed(int severity)
* @param severity the severity of the warning or error
* @return true if we should error out
*/
-static int true_error_type(int severity)
+static errflags true_error_type(errflags severity)
{
const uint8_t warn_is_err = WARN_ST_ENABLED|WARN_ST_ERROR;
int type;
@@ -1785,14 +1785,14 @@ static int true_error_type(int severity)
* @param severity the severity of the warning or error
* @param fmt the printf style format string
*/
-static void nasm_verror_asm(int severity, const char *fmt, va_list args)
+static void nasm_verror_asm(errflags severity, const char *fmt, va_list args)
{
char msg[1024];
char warnsuf[64];
char linestr[64];
const char *pfx;
- int spec_type = severity & ERR_MASK; /* type originally specified */
- int true_type = true_error_type(severity);
+ errflags spec_type = severity & ERR_MASK; /* type originally specified */
+ errflags true_type = true_error_type(severity);
const char *currentfile = NULL;
int32_t lineno = 0;
static const char * const pfx_table[ERR_MASK+1] = {
diff --git a/asm/preproc-nop.c b/asm/preproc-nop.c
index 43c0fbe2..f885f72e 100644
--- a/asm/preproc-nop.c
+++ b/asm/preproc-nop.c
@@ -175,7 +175,7 @@ static void nop_include_path(struct strlist *list)
(void)list;
}
-static void nop_error_list_macros(int severity)
+static void nop_error_list_macros(errflags severity)
{
(void)severity;
}
diff --git a/asm/preproc.c b/asm/preproc.c
index af990e13..741430f2 100644
--- a/asm/preproc.c
+++ b/asm/preproc.c
@@ -451,7 +451,7 @@ static Token *expand_smacro(Token * tline);
static Token *expand_id(Token * tline);
static Context *get_ctx(const char *name, const char **namep);
static void make_tok_num(Token * tok, int64_t val);
-static void pp_verror(int severity, const char *fmt, va_list ap);
+static void pp_verror(errflags severity, const char *fmt, va_list ap);
static vefunc real_verror;
static void *new_Block(size_t size);
static void delete_Blocks(void);
@@ -2203,7 +2203,7 @@ static int do_directive(Token *tline, char **output)
MMacro *tmp_defining; /* Used when manipulating rep_nest */
int64_t count;
size_t len;
- int severity;
+ errflags severity;
*output = NULL; /* No output generated */
origline = tline;
@@ -4828,7 +4828,7 @@ static int expand_mmacro(Token * tline)
* This function adds macro names to error messages, and suppresses
* them if necessary.
*/
-static void pp_verror(int severity, const char *fmt, va_list arg)
+static void pp_verror(errflags severity, const char *fmt, va_list arg)
{
char buff[BUFSIZ];
MMacro *mmac = NULL;
@@ -5315,7 +5315,7 @@ static void make_tok_num(Token * tok, int64_t val)
tok->type = TOK_NUMBER;
}
-static void pp_list_one_macro(MMacro *m, int severity)
+static void pp_list_one_macro(MMacro *m, errflags severity)
{
if (!m)
return;
@@ -5329,7 +5329,7 @@ static void pp_list_one_macro(MMacro *m, int severity)
}
}
-static void pp_error_list_macros(int severity)
+static void pp_error_list_macros(errflags severity)
{
struct src_location saved;
diff --git a/disasm/ndisasm.c b/disasm/ndisasm.c
index f2067a31..0863309f 100644
--- a/disasm/ndisasm.c
+++ b/disasm/ndisasm.c
@@ -69,7 +69,7 @@ static const char *help =
static void output_ins(uint64_t, uint8_t *, int, char *);
static void skip(uint32_t dist, FILE * fp);
-static void ndisasm_verror(int severity, const char *fmt, va_list va)
+static void ndisasm_verror(errflags severity, const char *fmt, va_list va)
{
vfprintf(stderr, fmt, va);
diff --git a/include/error.h b/include/error.h
index d5b4f852..34e7d50f 100644
--- a/include/error.h
+++ b/include/error.h
@@ -46,25 +46,30 @@
extern FILE *error_file; /* Error file descriptor */
/*
+ * Typedef for the severity field
+ */
+typedef uint32_t errflags;
+
+/*
* An error reporting function should look like this.
*/
-void printf_func(2, 3) nasm_error(int severity, const char *fmt, ...);
+void printf_func(2, 3) nasm_error(errflags severity, const char *fmt, ...);
void printf_func(1, 2) nasm_debug(const char *fmt, ...);
-void printf_func(2, 3) nasm_debugf(int flags, const char *fmt, ...);
+void printf_func(2, 3) nasm_debugf(errflags flags, const char *fmt, ...);
void printf_func(1, 2) nasm_note(const char *fmt, ...);
-void printf_func(2, 3) nasm_notef(int flags, const char *fmt, ...);
+void printf_func(2, 3) nasm_notef(errflags flags, const char *fmt, ...);
void printf_func(1, 2) nasm_warn(const char *fmt, ...);
-void printf_func(2, 3) nasm_warnf(int flags, const char *fmt, ...);
+void printf_func(2, 3) nasm_warnf(errflags flags, const char *fmt, ...);
void printf_func(1, 2) nasm_nonfatal(const char *fmt, ...);
-void printf_func(2, 3) nasm_nonfatalf(int flags, const char *fmt, ...);
+void printf_func(2, 3) nasm_nonfatalf(errflags flags, const char *fmt, ...);
fatal_func printf_func(1, 2) nasm_fatal(const char *fmt, ...);
-fatal_func printf_func(2, 3) nasm_fatalf(int flags, const char *fmt, ...);
+fatal_func printf_func(2, 3) nasm_fatalf(errflags flags, const char *fmt, ...);
fatal_func printf_func(1, 2) nasm_panic(const char *fmt, ...);
-fatal_func printf_func(2, 3) nasm_panicf(int flags, const char *fmt, ...);
+fatal_func printf_func(2, 3) nasm_panicf(errflags flags, const char *fmt, ...);
fatal_func nasm_panic_from_macro(const char *file, int line);
#define panic() nasm_panic_from_macro(__FILE__, __LINE__);
-typedef void (*vefunc) (int severity, const char *fmt, va_list ap);
+typedef void (*vefunc) (errflags severity, const char *fmt, va_list ap);
extern vefunc nasm_verror;
static inline vefunc nasm_set_verror(vefunc ve)
@@ -104,9 +109,9 @@ static inline vefunc nasm_set_verror(vefunc ve)
*/
#define WARN_SHR 12 /* how far to shift right */
-#define WARN(x) ((x) << WARN_SHR)
+#define WARN(x) (((errflags)(x)) << WARN_SHR)
#define WARN_MASK WARN(~0)
-#define WARN_IDX(x) ((x) >> WARN_SHR)
+#define WARN_IDX(x) (((errflags)(x)) >> WARN_SHR)
#define WARN_MACRO_PARAMS WARN( 1) /* macro-num-parameters warning */
#define WARN_MACRO_SELFREF WARN( 2) /* macro self-reference */
diff --git a/include/nasm.h b/include/nasm.h
index f259d063..08474135 100644
--- a/include/nasm.h
+++ b/include/nasm.h
@@ -53,6 +53,7 @@
#include "opflags.h"
#include "regs.h"
#include "srcfile.h"
+#include "error.h"
/* Time stamp for the official start of compilation */
struct compile_time {
@@ -368,7 +369,7 @@ struct preproc_ops {
void (*include_path)(struct strlist *ipath);
/* Unwind the macro stack when printing an error message */
- void (*error_list_macros)(int severity);
+ void (*error_list_macros)(errflags severity);
};
extern const struct preproc_ops nasmpp;
diff --git a/rdoff/rdoff.c b/rdoff/rdoff.c
index 77fec399..e77c88ef 100644
--- a/rdoff/rdoff.c
+++ b/rdoff/rdoff.c
@@ -229,7 +229,7 @@ int rdf_errno = 0;
/* ========================================================================
* Hook for nasm_error() to work
* ======================================================================== */
-static void rdoff_verror(int severity, const char *fmt, va_list val)
+static void rdoff_verror(errflags severity, const char *fmt, va_list val)
{
vfprintf(stderr, fmt, val);