]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: lua: silence a warning on systems where longjmp is not marked as noreturn
authorWilly Tarreau <w@1wt.eu>
Thu, 6 Feb 2020 14:55:41 +0000 (15:55 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 6 Feb 2020 15:01:04 +0000 (16:01 +0100)
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

index a1c0003c10c983e494b712000affed3d2c01c6f2..4c5598d8e2c5e5f4890b8c89d4dd053ea042c625 100644 (file)
 __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) \
        ({ \