azerothcore / mod-eluna-lua-engine

DEPRECATED

Home Page:https://www.azerothcore.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

warning: the use of `tmpnam' is dangerous, better use `mkstemp'

BarbzYHOOL opened this issue · comments

commented
../../../modules/mod-eluna-lua-engine/lualib/liblualib.a(loslib.c.o): In function `os_tmpname':
loslib.c:(.text+0x86c): warning: the use of `tmpnam' is dangerous, better use `mkstemp'

???

commented
#if defined(LUA_USE_MKSTEMP)
#include <unistd.h>
#define LUA_TMPNAMBUFSIZE	32
#define lua_tmpnam(b,e) { \
        strcpy(b, "/tmp/lua_XXXXXX"); \
        e = mkstemp(b); \
        if (e != -1) close(e); \
        e = (e == -1); }

#elif !defined(lua_tmpnam)

#define LUA_TMPNAMBUFSIZE	L_tmpnam
#define lua_tmpnam(b,e)		{ e = (tmpnam(b) == NULL); }

#endif

we can drop this defines and this part of code

#define LUA_TMPNAMBUFSIZE	L_tmpnam
#define lua_tmpnam(b,e)		{ e = (tmpnam(b) == NULL); }

to remove warning, or pass LUA_USE_MKSTEMP to lualib
us i understand in quick view its must be done here https://github.com/azerothcore/mod-eluna-lua-engine/blob/master/cmake/after_load_cmake_modules.cmake#L6

Can define use linux and mac instead.

#if defined(LUA_USE_LINUX)
#define LUA_USE_POSIX
#define LUA_USE_DLOPEN /* needs an extra library: -ldl */
#define LUA_USE_READLINE /* needs some extra libraries */
#define LUA_USE_STRTODHEX /* assume 'strtod' handles hex formats */
#define LUA_USE_AFORMAT /* assume 'printf' handles 'aA' specifiers */
#define LUA_USE_LONGLONG /* assume support for long long */
#endif
#if defined(LUA_USE_MACOSX)
#define LUA_USE_POSIX
#define LUA_USE_DLOPEN /* does not need -ldl */
#define LUA_USE_READLINE /* needs an extra library: -lreadline */
#define LUA_USE_STRTODHEX /* assume 'strtod' handles hex formats */
#define LUA_USE_AFORMAT /* assume 'printf' handles 'aA' specifiers */
#define LUA_USE_LONGLONG /* assume support for long long */
#endif

commented

i'd just copy that code rochet ? if so i'll try when i think about it

commented

@BarbzYHOOL no you just pass -DLUA_USE_LINUX for Eluna( https://github.com/azerothcore/mod-eluna-lua-engine/blob/master/cmake/after_load_cmake_modules.cmake#L6 ) and then when you build you get -DLUA_USE_LINUX(whats include) LUA_USE_POSIX whats include LUA_USE_MKSTEMP whats define usage mkstemp

commented

oh ok, thank you, when i try i'll update the readme then

commented

it was really not clear what to do, I tried to put the variables directly in the command, ofc didn't work

so I added add_definitions(-DLUA_USE_LINUX) here https://github.com/azerothcore/mod-eluna-lua-engine/blob/master/cmake/after_load_cmake_modules.cmake#L6 and the result is:

../../../modules/mod-eluna-lua-engine/lualib/liblualib.a(loslib.c.o): In function `os_tmpname':
loslib.c:(.text+0x86c): warning: the use of `tmpnam' is dangerous, better use `mkstemp'

Same exact message as previously

What to do? @Viste @Rochet2