From: nasm-bot f. H. P. A. <hp...@zy...> - 2016-02-11 22:45:22
|
Commit-ID: 50fe0b5904bce8b00eeb4f6ec7a9ac080e1a823c Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=50fe0b5904bce8b00eeb4f6ec7a9ac080e1a823c Author: H. Peter Anvin <hp...@zy...> AuthorDate: Mon, 8 Feb 2016 10:10:57 -0800 Committer: H. Peter Anvin <hp...@zy...> CommitDate: Mon, 8 Feb 2016 10:10:57 -0800 nasmlib: Factor out common code from the panic() macro There is no reason to pass a constant and a string from each call site. Move that into a separate out of line function. Signed-off-by: H. Peter Anvin <hp...@zy...> --- nasmlib.c | 5 +++++ nasmlib.h | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/nasmlib.c b/nasmlib.c index 3c26546..656350d 100644 --- a/nasmlib.c +++ b/nasmlib.c @@ -92,6 +92,11 @@ no_return nasm_panic(int flags, const char *fmt, ...) abort(); /* We should never get here */ } +no_return nasm_panic_from_macro(const char *file, int line) +{ + nasm_panic(ERR_NOFILE, "Internal error at %s:%d\n", file, line); +} + void *nasm_malloc(size_t size) { void *p = malloc(size); diff --git a/nasmlib.h b/nasmlib.h index f480c06..dfce1dd 100644 --- a/nasmlib.h +++ b/nasmlib.h @@ -78,7 +78,8 @@ typedef void (*vefunc) (int severity, const char *fmt, va_list ap); void printf_func(2, 3) nasm_error(int severity, const char *fmt, ...); void nasm_set_verror(vefunc); no_return printf_func(2, 3) nasm_panic(int flags, const char *fmt, ...); -#define panic() nasm_panic(ERR_NOFILE, "Internal error at %s:%d\n", __FILE__, __LINE__); +no_return nasm_panic_from_macro(const char *file, int line); +#define panic() nasm_panic_from_macro(__FILE__, __LINE__); /* * These are the error severity codes which get passed as the first |