mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-11-28 22:31:06 +01:00
BUILD: lua: silence some compiler warnings about potential null derefs
These ones are on error paths that are properly handled by luaL_error() which does a longjmp() but the compiler cannot know it. By adding an __unreachable() statement in WILL_LJMP(), there is no ambiguity anymore. This may be backported to 1.8 but the previous patch (BUILD: compiler: add a new statement "__unreachable()") is needed for this.
This commit is contained in:
parent
8d26f02e69
commit
f1ffb39b61
10
src/hlua.c
10
src/hlua.c
@ -25,6 +25,7 @@
|
|||||||
#include <ebpttree.h>
|
#include <ebpttree.h>
|
||||||
|
|
||||||
#include <common/cfgparse.h>
|
#include <common/cfgparse.h>
|
||||||
|
#include <common/compiler.h>
|
||||||
#include <common/xref.h>
|
#include <common/xref.h>
|
||||||
#include <common/hathreads.h>
|
#include <common/hathreads.h>
|
||||||
|
|
||||||
@ -67,7 +68,7 @@
|
|||||||
* MAY_LJMP() marks an lua function that may use longjmp.
|
* MAY_LJMP() marks an lua function that may use longjmp.
|
||||||
*/
|
*/
|
||||||
#define __LJMP
|
#define __LJMP
|
||||||
#define WILL_LJMP(func) func
|
#define WILL_LJMP(func) do { func; __unreachable(); } while (0)
|
||||||
#define MAY_LJMP(func) func
|
#define MAY_LJMP(func) func
|
||||||
|
|
||||||
/* This couple of function executes securely some Lua calls outside of
|
/* This couple of function executes securely some Lua calls outside of
|
||||||
@ -2361,7 +2362,7 @@ __LJMP static int hlua_socket_connect_yield(struct lua_State *L, int status, lua
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
appctx = objt_appctx(s->si[0].end);
|
appctx = __objt_appctx(s->si[0].end);
|
||||||
|
|
||||||
/* Check for connection established. */
|
/* Check for connection established. */
|
||||||
if (appctx->ctx.hlua_cosocket.connected) {
|
if (appctx->ctx.hlua_cosocket.connected) {
|
||||||
@ -2473,7 +2474,7 @@ __LJMP static int hlua_socket_connect(struct lua_State *L)
|
|||||||
}
|
}
|
||||||
|
|
||||||
hlua = hlua_gethlua(L);
|
hlua = hlua_gethlua(L);
|
||||||
appctx = objt_appctx(s->si[0].end);
|
appctx = __objt_appctx(s->si[0].end);
|
||||||
|
|
||||||
/* inform the stream that we want to be notified whenever the
|
/* inform the stream that we want to be notified whenever the
|
||||||
* connection completes.
|
* connection completes.
|
||||||
@ -5723,6 +5724,9 @@ static int hlua_register_task(lua_State *L)
|
|||||||
WILL_LJMP(luaL_error(L, "Lua out of memory error."));
|
WILL_LJMP(luaL_error(L, "Lua out of memory error."));
|
||||||
|
|
||||||
task = task_new(MAX_THREADS_MASK);
|
task = task_new(MAX_THREADS_MASK);
|
||||||
|
if (!task)
|
||||||
|
WILL_LJMP(luaL_error(L, "Lua out of memory error."));
|
||||||
|
|
||||||
task->context = hlua;
|
task->context = hlua;
|
||||||
task->process = hlua_process_task;
|
task->process = hlua_process_task;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user