From: Marek VavruĊĦa Date: Mon, 15 Jun 2015 16:43:22 +0000 (+0200) Subject: daemon/bindings: fixed Lua <=5.1 compat and bad cast X-Git-Tag: v1.0.0-beta1~116^2~11 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=449d3cc3ef0fa1820dcf17f0dace63e511267726;p=thirdparty%2Fknot-resolver.git daemon/bindings: fixed Lua <=5.1 compat and bad cast --- diff --git a/daemon/bindings/kres.c b/daemon/bindings/kres.c index 986d13b23..164a18f18 100644 --- a/daemon/bindings/kres.c +++ b/daemon/bindings/kres.c @@ -39,7 +39,7 @@ static lookup_table_t wire_flag_names[] = { static int pkt_flag(lua_State *L) { - knot_pkt_t *pkt = luaL_checkudata(L, 1, META_PKT); + knot_pkt_t *pkt = lua_touserdata(L, 1); if (lua_gettop(L) > 1 && lua_isnumber(L, 2)) { int flag_id = lua_tonumber(L, 2); switch(flag_id) { @@ -53,7 +53,7 @@ static int pkt_flag(lua_State *L) static int pkt_opcode(lua_State *L) { - knot_pkt_t *pkt = luaL_checkudata(L, 1, META_PKT); + knot_pkt_t *pkt = lua_touserdata(L, 1); if (lua_gettop(L) > 1 && lua_isnumber(L, 2)) { knot_wire_set_opcode(pkt->wire, lua_tonumber(L, 2)); } @@ -63,7 +63,7 @@ static int pkt_opcode(lua_State *L) static int pkt_rcode(lua_State *L) { - knot_pkt_t *pkt = luaL_checkudata(L, 1, META_PKT); + knot_pkt_t *pkt = lua_touserdata(L, 1); if (lua_gettop(L) > 1 && lua_isnumber(L, 2)) { knot_wire_set_rcode(pkt->wire, lua_tonumber(L, 2)); } @@ -73,21 +73,21 @@ static int pkt_rcode(lua_State *L) static int pkt_qtype(lua_State *L) { - knot_pkt_t *pkt = luaL_checkudata(L, 1, META_PKT); + knot_pkt_t *pkt = lua_touserdata(L, 1); lua_pushnumber(L, knot_pkt_qtype(pkt)); return 1; } static int pkt_qclass(lua_State *L) { - knot_pkt_t *pkt = luaL_checkudata(L, 1, META_PKT); + knot_pkt_t *pkt = lua_touserdata(L, 1); lua_pushnumber(L, knot_pkt_qclass(pkt)); return 1; } static int pkt_qname(lua_State *L) { - knot_pkt_t *pkt = luaL_checkudata(L, 1, META_PKT); + knot_pkt_t *pkt = lua_touserdata(L, 1); const knot_dname_t *dname = knot_pkt_qname(pkt); char dname_str[KNOT_DNAME_MAXLEN]; knot_dname_to_str(dname_str, dname, sizeof(dname_str)); diff --git a/daemon/ffimodule.c b/daemon/ffimodule.c index cd9d0aade..d1482b184 100644 --- a/daemon/ffimodule.c +++ b/daemon/ffimodule.c @@ -81,7 +81,7 @@ static inline int l_ffi_call(lua_State *L, int argc) if (lua_isthread(L, -1)) { /* Continuations */ status = l_ffi_defer(lua_tothread(L, -1)); } else if (lua_isnumber(L, -1)) { /* Return code */ - status = lua_tonumber(L, 1); + status = lua_tonumber(L, -1); } lua_pop(L, 1); } diff --git a/modules/block/block.lua b/modules/block/block.lua index 002ebc5b2..facd35f33 100644 --- a/modules/block/block.lua +++ b/modules/block/block.lua @@ -91,8 +91,6 @@ block.layer = { else return state end - - end }