clean up a warning and a bit of duplication

Now we have 2 probably-valid warnings caused by my edits, and 1
false-positive.
This commit is contained in:
Kartik K. Agaram 2021-11-22 19:25:05 -08:00
parent 76329c0206
commit 1bf2504a8b
4 changed files with 2 additions and 35 deletions

View File

@ -20,9 +20,6 @@
//------------------------------------------------------------------------------
#if (LUA_VERSION_NUM == 501)
#define luaL_testudata(L, ud, tname) lsec_testudata(L, ud, tname)
#define setfuncs(L, R) luaL_register(L, NULL, R)
#define lua_rawlen(L, i) lua_objlen(L, i)
@ -30,10 +27,6 @@
#define luaL_newlib(L, R) do { lua_newtable(L); luaL_register(L, NULL, R); } while(0)
#endif
#else
#define setfuncs(L, R) luaL_setfuncs(L, R, 0)
#endif
//------------------------------------------------------------------------------
#if (!defined(LIBRESSL_VERSION_NUMBER) && (OPENSSL_VERSION_NUMBER >= 0x1010000fL))

View File

@ -43,7 +43,7 @@ static p_context checkctx(lua_State *L, int idx)
static p_context testctx(lua_State *L, int idx)
{
return (p_context)luaL_testudata(L, idx, "SSL:Context");
return (p_context)luasocket_testudata(L, idx, "SSL:Context");
}
/**
@ -887,25 +887,6 @@ int lsec_getmode(lua_State *L, int idx)
return ctx->mode;
}
/*-- Compat - Lua 5.1 --*/
#if (LUA_VERSION_NUM == 501)
void *lsec_testudata (lua_State *L, int ud, const char *tname) {
void *p = lua_touserdata(L, ud);
if (p != NULL) { /* value is a userdata? */
if (lua_getmetatable(L, ud)) { /* does it have a metatable? */
luaL_getmetatable(L, tname); /* get correct metatable */
if (!lua_rawequal(L, -1, -2)) /* not the same? */
p = NULL; /* value is a userdata with wrong metatable */
lua_pop(L, 2); /* remove both metatables */
return p;
}
}
return NULL; /* value is not a userdata with a metatable */
}
#endif
/*------------------------------ Initialization ------------------------------*/
/**

View File

@ -39,9 +39,6 @@ int lsec_getmode(lua_State *L, int idx);
/* Registre the module. */
LSEC_API int luaopen_ssl_context(lua_State *L);
/* Compat - Lua 5.1 */
#if (LUA_VERSION_NUM == 501)
void *lsec_testudata (lua_State *L, int ud, const char *tname);
#endif
void *luasocket_testudata ( lua_State *L, int arg, const char *tname);
#endif

View File

@ -1,8 +1,6 @@
#ifndef COMPAT_H
#define COMPAT_H
#if LUA_VERSION_NUM==501
#ifndef _WIN32
#pragma GCC visibility push(hidden)
#endif
@ -18,5 +16,3 @@ void *luasocket_testudata ( lua_State *L, int arg, const char *tname);
#define luaL_testudata luasocket_testudata
#endif
#endif