From 9d6bb5a5468e07525ae21269776f38f5737aebcf Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Thu, 6 Feb 2020 15:55:41 +0100 Subject: [PATCH] BUILD: lua: silence a warning on systems where longjmp is not marked as noreturn If the longjmp() call is not flagged as "noreturn", for example, because the operating system doesn't target a gcc-compatible compiler, we may get this warning when building Lua : src/hlua.c: In function 'hlua_panic_ljmp': src/hlua.c:128:1: warning: no return statement in function returning non-void [-Wreturn-type] static int hlua_panic_ljmp(lua_State *L) { longjmp(safe_ljmp_env, 1); } ^~~~~~ The function's prototype cannot be changed because it must be compatible with Lua's callbacks. Let's simply enclose the call inside WILL_LJMP() which we created exactly to signal a call to longjmp(). It lets the compiler know we won't get back into the function and that the return statement is not needed. --- src/hlua.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hlua.c b/src/hlua.c index a1c0003c1..4c5598d8e 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -125,7 +125,7 @@ __decl_spinlock(hlua_global_lock); THREAD_LOCAL jmp_buf safe_ljmp_env; static int hlua_panic_safe(lua_State *L) { return 0; } -static int hlua_panic_ljmp(lua_State *L) { longjmp(safe_ljmp_env, 1); } +static int hlua_panic_ljmp(lua_State *L) { WILL_LJMP(longjmp(safe_ljmp_env, 1)); } #define SET_SAFE_LJMP(__L) \ ({ \