From 50fe0b5904bce8b00eeb4f6ec7a9ac080e1a823c Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Mon, 8 Feb 2016 10:10:57 -0800 Subject: 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 --- nasmlib.c | 5 +++++ nasmlib.h | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/nasmlib.c b/nasmlib.c index 3c26546a..656350d5 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 f480c062..dfce1dd9 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 -- cgit v1.2.1