[PATCH] BUG: bootenv functions not available

7 views
Skip to first unread message

Stefano Babic

unread,
9:08 AM (11 hours ago) 9:08 AM
to swup...@googlegroups.com, Stefano Babic
commit f8153 introduced a regression bug. The bootenv functions are not
registered anymore and they cannot be called from scripts. They were
handled separately, but after switching to a Lua Session State, there is
no need for this and the function can be added together with the rest of
the interface.

Signed-off-by: Stefano Babic <stefan...@swupdate.org>
---
corelib/lua_interface.c | 6 ------
1 file changed, 6 deletions(-)

diff --git a/corelib/lua_interface.c b/corelib/lua_interface.c
index 74590ab6..86c2112d 100644
--- a/corelib/lua_interface.c
+++ b/corelib/lua_interface.c
@@ -1195,10 +1195,6 @@ static const luaL_Reg l_swupdate[] = {
{ "getversion", lua_get_swupdate_version },
{ "progress", lua_notify_progress },
{ "emmcbootpart", l_get_emmc_bootpart },
- { NULL, NULL }
-};
-
-static const luaL_Reg l_swupdate_bootenv[] = {
{ "get_bootenv", l_get_bootenv },
{ "set_bootenv", l_set_bootenv },
{ "get_selection", l_get_selection },
@@ -1319,7 +1315,6 @@ static int l_handler_wrapper(struct img_type *img, void *data,
}
struct dict **udbootenv = lua_newuserdata(L, sizeof(struct dict*));
*udbootenv = img->bootloader;
- luaL_setfuncs(L, l_swupdate_bootenv, 1);
lua_pop(L, 1);
}

@@ -1549,7 +1544,6 @@ lua_State *lua_session_init(struct dict *bootenv)
luaL_requiref(L, "swupdate", luaopen_swupdate, 1 );
struct dict **udbootenv = lua_newuserdata(L, sizeof(struct dict*));
*udbootenv = bootenv;
- luaL_setfuncs(L, l_swupdate_bootenv, 1);
lua_pop(L, 1); /* remove unused copy left on stack */

lua_handlers_init(L);
--
2.34.1

Storm, Christian

unread,
10:30 AM (10 hours ago) 10:30 AM
to swupdate
Hi Stefano,
This is a local and now unused variable since it's no longer used for upvalue storage by the following removed line:

> - luaL_setfuncs(L, l_swupdate_bootenv, 1);
> lua_pop(L, 1);

This does leave the lua_getglobal(L, "swupdate") result on the stack.

> }
>
> @@ -1549,7 +1544,6 @@ lua_State *lua_session_init(struct dict *bootenv)
> luaL_requiref(L, "swupdate", luaopen_swupdate, 1 );
> struct dict **udbootenv = lua_newuserdata(L, sizeof(struct dict*));
> *udbootenv = bootenv;

See above.

> - luaL_setfuncs(L, l_swupdate_bootenv, 1);
> lua_pop(L, 1); /* remove unused copy left on stack */

See above, this removes the pushed userdata but leaves the luaL_requiref(L, "swupdate", luaopen_swupdate, 1 ) return table on the stack.


With this and the other patch, I'm wondering where the upvalue used in l_set_bootenv() [https://github.com/sbabic/swupdate/blob/master/corelib/lua_interface.c#L886] is set? It's also removed for handlers in the follow-up patch but nowhere set? Am I missing something?



Kind regards,
Christian

--
Dr. Christian Storm
Siemens AG, Technology, T CED OES-DE
Friedrich-Ludwig-Bauer-Str. 3, 85748 Garching, Germany

Stefano Babic

unread,
2:29 PM (6 hours ago) 2:29 PM
to Storm, Christian, swupdate
Hi Christian,
No, you're absolutely right and this patch is *garbage*. I will create a
test first, and check in detail for next version. Both patches could be
discarded.

Thanks,
Stefano

>
>
>
> Kind regards,
> Christian
>
Reply all
Reply to author
Forward
0 new messages