From 2c2e88fd83a324969b5c4df397434a63895fd006 Mon Sep 17 00:00:00 2001 From: Sami Vaarala Date: Sun, 22 Dec 2013 20:50:09 +0200 Subject: [PATCH] more compile warning fixes for gcc-4.4.5 (on mips) --- src/duk_error_macros.c | 9 ++++++++- src/duk_heap.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/duk_error_macros.c b/src/duk_error_macros.c index 2bc4662f..c526a0ee 100644 --- a/src/duk_error_macros.c +++ b/src/duk_error_macros.c @@ -23,12 +23,19 @@ void duk_err_handle_panic(const char *filename, int line, int code, const char * va_list ap; char msg1[BUFSIZE]; char msg2[BUFSIZE]; + const char *tmp; va_start(ap, fmt); (void) DUK_VSNPRINTF(msg1, sizeof(msg1), fmt, ap); msg1[sizeof(msg1) - 1] = (char) 0; (void) DUK_SNPRINTF(msg2, sizeof(msg2), "(%s:%d): %s", filename ? filename : "null", line, msg1); msg2[sizeof(msg2) - 1] = (char) 0; - DUK_PANIC_HANDLER(code, msg2); + /* Intermediate variable used to avoid: "warning: the address of ‘msg2’ will always + * evaluate as ‘true’" when pragma suppression is not available. For some reason + * this variant does not trigger the warning (although the pointer is most certainly + * always non-NULL). + */ + tmp = (const char *) msg2; + DUK_PANIC_HANDLER(code, tmp); va_end(ap); /* dead code */ } #else /* DUK_USE_VARIADIC_MACROS */ diff --git a/src/duk_heap.h b/src/duk_heap.h index e1a55db7..11291009 100644 --- a/src/duk_heap.h +++ b/src/duk_heap.h @@ -299,6 +299,7 @@ struct duk_heap { /* fatal error handling, called e.g. when a longjmp() is needed but * lj.jmpbuf_ptr is NULL. fatal_func must never return. */ + /* FIXME: declaring a function typedef as noreturn? or this specific instance? */ duk_fatal_function fatal_func; /* longjmp state */