From 41692dfb4bfb87f6f841f1124483d88a95d9df22 Mon Sep 17 00:00:00 2001 From: Stephan Gatzka Date: Sun, 21 Dec 2014 06:57:10 +0100 Subject: [PATCH 1/4] Make casts const correct. --- src/mime.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/mime.c b/src/mime.c index dd37dcf..a35a2c3 100644 --- a/src/mime.c +++ b/src/mime.c @@ -111,7 +111,7 @@ static int mime_global_wrp(lua_State *L) { size_t size = 0; int left = (int) luaL_checknumber(L, 1); - const UC *input = (UC *) luaL_optlstring(L, 2, NULL, &size); + const UC *input = (const UC *) luaL_optlstring(L, 2, NULL, &size); const UC *last = input + size; int length = (int) luaL_optnumber(L, 3, 76); luaL_Buffer buffer; @@ -259,7 +259,7 @@ static int mime_global_b64(lua_State *L) { UC atom[3]; size_t isize = 0, asize = 0; - const UC *input = (UC *) luaL_optlstring(L, 1, NULL, &isize); + const UC *input = (const UC *) luaL_optlstring(L, 1, NULL, &isize); const UC *last = input + isize; luaL_Buffer buffer; /* end-of-input blackhole */ @@ -274,7 +274,7 @@ static int mime_global_b64(lua_State *L) luaL_buffinit(L, &buffer); while (input < last) asize = b64encode(*input++, atom, asize, &buffer); - input = (UC *) luaL_optlstring(L, 2, NULL, &isize); + input = (const UC *) luaL_optlstring(L, 2, NULL, &isize); /* if second part is nil, we are done */ if (!input) { size_t osize = 0; @@ -305,7 +305,7 @@ static int mime_global_unb64(lua_State *L) { UC atom[4]; size_t isize = 0, asize = 0; - const UC *input = (UC *) luaL_optlstring(L, 1, NULL, &isize); + const UC *input = (const UC *) luaL_optlstring(L, 1, NULL, &isize); const UC *last = input + isize; luaL_Buffer buffer; /* end-of-input blackhole */ @@ -320,7 +320,7 @@ static int mime_global_unb64(lua_State *L) luaL_buffinit(L, &buffer); while (input < last) asize = b64decode(*input++, atom, asize, &buffer); - input = (UC *) luaL_optlstring(L, 2, NULL, &isize); + input = (const UC *) luaL_optlstring(L, 2, NULL, &isize); /* if second is nil, we are done */ if (!input) { size_t osize = 0; @@ -457,7 +457,7 @@ static int mime_global_qp(lua_State *L) size_t asize = 0, isize = 0; UC atom[3]; - const UC *input = (UC *) luaL_optlstring(L, 1, NULL, &isize); + const UC *input = (const UC *) luaL_optlstring(L, 1, NULL, &isize); const UC *last = input + isize; const char *marker = luaL_optstring(L, 3, CRLF); luaL_Buffer buffer; @@ -473,7 +473,7 @@ static int mime_global_qp(lua_State *L) luaL_buffinit(L, &buffer); while (input < last) asize = qpencode(*input++, atom, asize, marker, &buffer); - input = (UC *) luaL_optlstring(L, 2, NULL, &isize); + input = (const UC *) luaL_optlstring(L, 2, NULL, &isize); /* if second part is nil, we are done */ if (!input) { asize = qppad(atom, asize, &buffer); @@ -533,7 +533,7 @@ static int mime_global_unqp(lua_State *L) { size_t asize = 0, isize = 0; UC atom[3]; - const UC *input = (UC *) luaL_optlstring(L, 1, NULL, &isize); + const UC *input = (const UC *) luaL_optlstring(L, 1, NULL, &isize); const UC *last = input + isize; luaL_Buffer buffer; /* end-of-input blackhole */ @@ -548,7 +548,7 @@ static int mime_global_unqp(lua_State *L) luaL_buffinit(L, &buffer); while (input < last) asize = qpdecode(*input++, atom, asize, &buffer); - input = (UC *) luaL_optlstring(L, 2, NULL, &isize); + input = (const UC *) luaL_optlstring(L, 2, NULL, &isize); /* if second part is nil, we are done */ if (!input) { luaL_pushresult(&buffer); @@ -578,7 +578,7 @@ static int mime_global_qpwrp(lua_State *L) { size_t size = 0; int left = (int) luaL_checknumber(L, 1); - const UC *input = (UC *) luaL_optlstring(L, 2, NULL, &size); + const UC *input = (const UC *) luaL_optlstring(L, 2, NULL, &size); const UC *last = input + size; int length = (int) luaL_optnumber(L, 3, 76); luaL_Buffer buffer; From c6f136c7f51917b4803e5fa7934682286ab06255 Mon Sep 17 00:00:00 2001 From: Stephan Gatzka Date: Sun, 21 Dec 2014 07:44:11 +0100 Subject: [PATCH 2/4] Make local function udp_strerror() static. --- src/udp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/udp.c b/src/udp.c index a9f2393..12e320a 100644 --- a/src/udp.c +++ b/src/udp.c @@ -131,7 +131,7 @@ int udp_open(lua_State *L) /*=========================================================================*\ * Lua methods \*=========================================================================*/ -const char *udp_strerror(int err) { +static const char *udp_strerror(int err) { /* a 'closed' error on an unconnected means the target address was not * accepted by the transport layer */ if (err == IO_CLOSED) return "refused"; From 9178451ef9d97e99b31472ca287d203eca9a1a96 Mon Sep 17 00:00:00 2001 From: Stephan Gatzka Date: Sun, 21 Dec 2014 07:45:17 +0100 Subject: [PATCH 3/4] Add missing prototype for opt_get_reuseport(). --- src/options.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/options.h b/src/options.h index 5657a06..b75db37 100644 --- a/src/options.h +++ b/src/options.h @@ -51,7 +51,8 @@ int opt_get_error(lua_State *L, p_socket ps); int opt_get_ip6_multicast_loop(lua_State *L, p_socket ps); int opt_get_ip6_multicast_hops(lua_State *L, p_socket ps); int opt_get_ip6_unicast_hops(lua_State *L, p_socket ps); -int opt_get_ip6_v6only(lua_State *L, p_socket ps); +int opt_get_ip6_v6only(lua_State *L, p_socket ps); +int opt_get_reuseport(lua_State *L, p_socket ps); /* invokes the appropriate option handler */ int opt_meth_setoption(lua_State *L, p_opt opt, p_socket ps); From d8f77cca6456cbd5f0e34460aa9d379c0ac06740 Mon Sep 17 00:00:00 2001 From: Stephan Gatzka Date: Sun, 21 Dec 2014 07:45:36 +0100 Subject: [PATCH 4/4] Remove unused function luaL_typerror(). --- src/luasocket.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/luasocket.c b/src/luasocket.c index e6ee747..bce63a7 100644 --- a/src/luasocket.c +++ b/src/luasocket.c @@ -78,14 +78,6 @@ static int global_unload(lua_State *L) { return 0; } -#if LUA_VERSION_NUM > 501 -int luaL_typerror (lua_State *L, int narg, const char *tname) { - const char *msg = lua_pushfstring(L, "%s expected, got %s", - tname, luaL_typename(L, narg)); - return luaL_argerror(L, narg, msg); -} -#endif - /*-------------------------------------------------------------------------*\ * Setup basic stuff. \*-------------------------------------------------------------------------*/