Make the scripting code compatible with LUA 5.4

There's no unsigned anymore, just integers.
This commit is contained in:
Jean-Michel Picod 2024-09-20 17:12:59 +02:00
commit 22658097a7

View file

@ -320,7 +320,7 @@ static int l_GetFromFlashMemSpiffs(lua_State *L) {
}
lua_pushlstring(L, (const char *)data, len);
lua_pushunsigned(L, len);
lua_pushinteger(L, len);
free(data);
return 2;
}
@ -344,11 +344,11 @@ static int l_WaitForResponseTimeout(lua_State *L) {
// extract first param. cmd byte to look for
if (n >= 1)
cmd = luaL_checkunsigned(L, 1);
cmd = (uint32_t)luaL_checkinteger(L, 1);
// extract second param. timeout value
if (n >= 2)
ms_timeout = luaL_checkunsigned(L, 2);
ms_timeout = luaL_checkinteger(L, 2);
PacketResponseNG resp;
if (WaitForResponseTimeout(cmd, &resp, ms_timeout) == false) {
@ -643,7 +643,7 @@ static int l_crc8legic(lua_State *L) {
size_t size;
const char *p_hexstr = luaL_checklstring(L, 1, &size);
uint16_t retval = CRC8Legic((uint8_t *)p_hexstr, size);
lua_pushunsigned(L, retval);
lua_pushinteger(L, retval);
return 1;
}
@ -659,7 +659,7 @@ static int l_crc16legic(lua_State *L) {
init_table(CRC_LEGIC_16);
uint16_t retval = crc16_legic((uint8_t *)p_hexstr, hexsize, uidcrc);
lua_pushunsigned(L, retval);
lua_pushinteger(L, retval);
return 1;
}
@ -669,7 +669,7 @@ static int l_crc16(lua_State *L) {
const char *p_str = luaL_checklstring(L, 1, &size);
uint16_t checksum = Crc16ex(CRC_CCITT, (uint8_t *) p_str, size);
lua_pushunsigned(L, checksum);
lua_pushinteger(L, checksum);
return 1;
}
@ -735,7 +735,7 @@ static int l_reveng_models(lua_State *L) {
#define NMODELS 106
int count = 0;
uint8_t in_width = luaL_checkunsigned(L, 1);
uint8_t in_width = (uint8_t)luaL_checkinteger(L, 1);
if (in_width > 89)
return returnToLuaWithError(L, "Width cannot exceed 89, got %d", in_width);
@ -916,8 +916,8 @@ static int l_keygen_algoB(lua_State *L) {
uint32_t pwd = ul_ev1_pwdgenB(uid);
uint16_t pack = ul_ev1_packgenB(uid);
lua_pushunsigned(L, pwd);
lua_pushunsigned(L, pack);
lua_pushinteger(L, pwd);
lua_pushinteger(L, pack);
return 2;
}
@ -949,8 +949,8 @@ static int l_keygen_algoD(lua_State *L) {
uint32_t pwd = ul_ev1_pwdgenD(uid);
uint16_t pack = ul_ev1_packgenD(uid);
lua_pushunsigned(L, pwd);
lua_pushunsigned(L, pack);
lua_pushinteger(L, pwd);
lua_pushinteger(L, pack);
return 2;
}
@ -1037,7 +1037,7 @@ static int l_T55xx_readblock(lua_State *L) {
return returnToLuaWithError(L, "Failed to get actual data");
}
lua_pushunsigned(L, blockData);
lua_pushinteger(L, blockData);
return 1;
}
@ -1436,16 +1436,9 @@ int set_pm3_libraries(lua_State *L) {
};
lua_pushglobaltable(L);
// Core library is in this table. Contains '
// this is 'pm3' table
lua_newtable(L);
// put the function into the hash table.
for (int i = 0; libs[i].name; i++) {
lua_pushcfunction(L, libs[i].func);
lua_setfield(L, -2, libs[i].name); // set the name, pop stack
}
// Name of 'core'
// Core module
luaL_newlib(L, libs);
lua_setfield(L, -2, "core");
// remove the global environment table from the stack