Inproper use of lua_pcall.
Posted: Wed Feb 20, 2013 1:06 am
In using a lua debugger I have picked up the following warning, which causes the debugger to stop:
Further examination of the function shows that the followin segment of code is unnecesary:
This is due to the fact that if PStatusEffect returns null, there is no further need to make the lua_pcall. Ideally the lua_pcall should be moved to the end of the else statement just above it.
Since lua_pushnil is called if PStatusEffect is null, the only other suitable place for this would be in the else statment.
As the else statement adds a second parameter, this will qualify the lua_pcall.
This originates from lua_baseentity.cpp: Line 3675 of getStatusEffect.Warning 1005: lua_call/lua_pcall called with too few arguments on the stack wrote: This warning indicates that the lua_call or lua_pcall Lua API function was called from C with fewer than the expected number of arguments on the Lua stack. These functions both expect there to be one plus the number of arguments the function accepts on the stack.
Further examination of the function shows that the followin segment of code is unnecesary:
Code: Select all
if( lua_pcall(L,2,1,0) )
{
return 0;
}
Since lua_pushnil is called if PStatusEffect is null, the only other suitable place for this would be in the else statment.
As the else statement adds a second parameter, this will qualify the lua_pcall.