summaryrefslogtreecommitdiff
path: root/lua
Commit message (Collapse)AuthorAgeFilesLines
* lua: add optional path filter to objects() methodEtienne Champetier2022-05-301-1/+2
| | | | | | | 'ubus list [<path>]' passes the path to ubusd, this commit fix the lua bindings to do the same Signed-off-by: Etienne Champetier <champetier.etienne@gmail.com>
* lua: avoid truncation of large numeric valuesAlin Nastac2020-03-151-1/+4
| | | | | | | | | | If the Lua number exceeds the maximum value representable by an unsigned 32bit integer, store it in an unsigned 64bit integer field instead. Signed-off-by: Alin Nastac <alin.nastac@gmail.com> [align code style, reword commit message] Signed-off-by: Jo-Philipp Wich <jo@mein.io>
* lua: ubus_lua_do_subscribe: fix copy&paste errorPetr Štetiar2019-12-161-2/+2
| | | | | | | Fix copy&paste error in Lua ubus subscriber removal callback. Addresses-Coverity-ID: 1412311 ("Copy-paste error") Signed-off-by: Petr Štetiar <ynezz@true.cz>
* lua: workaround false positive dereference of null pointerPetr Štetiar2019-12-161-9/+10
| | | | | | | | | | | | | | | | | scan-build from clang-9 has reported following: ubus.c:837:16: warning: Access to field 'rnotify' results in a dereference of a null pointer (loaded from variable 'sub') sub->rnotify = luaL_ref(L, -2); Which is false positive as the lua_error() does a long jump and therefore never returns and this long jump probably confuses the static analyzer. So this patch workarounds this false positive by helping static analyzer by using common Lua idiom which is to return lua_error()'s return value. Ref: https://www.lua.org/manual/5.1/manual.html#lua_error Addresses-Coverity-ID: 1412355 ("Dereference after null check") Signed-off-by: Petr Štetiar <ynezz@true.cz>
* iron out all extra compiler warningsPetr Štetiar2019-12-161-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | clang-9 on x86/64 has reported following warnings/errors: libubus-acl.c:123:2: error: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare] libubus-io.c:108:18: error: comparison of integers of different signs: 'int' and 'size_t' (aka 'unsigned long') [-Werror,-Wsign-compare] libubus-io.c:395:56: error: comparison of integers of different signs: 'ssize_t' (aka 'long') and 'size_t' (aka 'unsigned long') [-Werror,-Wsign-compare] libubus-req.c:441:4: error: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare] ubusd_acl.c:119:18: error: comparison of integers of different signs: 'int' and 'unsigned long' [-Werror,-Wsign-compare] ubusd_acl.c:152:5: error: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare] ubusd_acl.c:348:3: error: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare] ubusd_acl.c:352:3: error: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare] ubusd_acl.c:357:3: error: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare] ubusd_acl.c:362:3: error: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare] ubusd_acl.c:367:3: error: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare] ubusd_acl.c:447:16: error: comparison of integers of different signs: 'int' and '__size_t' (aka 'unsigned long') [-Werror,-Wsign-compare] ubusd_acl.c:502:18: error: comparison of integers of different signs: 'int' and 'unsigned long' [-Werror,-Wsign-compare] ubusd.c:123:13: error: comparison of integers of different signs: 'int' and 'unsigned long' [-Werror,-Wsign-compare] ubusd.c:170:15: error: comparison of integers of different signs: 'int' and 'unsigned long' [-Werror,-Wsign-compare] ubusd.c:262:43: error: comparison of integers of different signs: 'int' and 'unsigned long' [-Werror,-Wsign-compare] ubusd.c:287:30: error: comparison of integers of different signs: 'int' and 'unsigned long' [-Werror,-Wsign-compare] ubusd_event.c:170:18: error: comparison of integers of different signs: 'int' and 'unsigned long' [-Werror,-Wsign-compare] ubusd_obj.c:71:2: error: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare] Signed-off-by: Petr Štetiar <ynezz@true.cz>
* ubus/lua: add support for BLOBMSG_TYPE_DOUBLEMarcus Comstedt2018-09-101-0/+13
| | | | Signed-off-by: Marcus Comstedt <marcus@mc.pp.se>
* ubus/lua: pass notification name to callbackDirk Feytons2018-01-172-4/+6
| | | | | | | | | | | The callback function registered to be invoked when subscribing to a notification was only passed the notification data (if any) but not the name of the notification. This name is now passed as second argument to remain backwards compatible. The example subscriber.lua has also be updated. Signed-off-by: Dirk Feytons <dirk.feytons@gmail.com>
* ubus: Remove unnecessary memset calls.Rosen Penev2017-11-131-12/+6
| | | | | | | Replace malloc+memset with calloc. Signed-off-by: Rosen Penev <rosenp@gmail.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* lua: add 'defer_request' and 'complete_deferred_request' functionsVasily Goldobin2016-11-212-0/+34
| | | | | | Add Lua bindings for 'ubus_defer_request' and 'ubus_complete_deferred_request' functions with sample code. Signed-off-by: Vasily Goldobin <vasily@lynxtech.ru>
* Implemented publish/subscribe lua bindings to libubus-lua with example lua ↵Iain Fraser2016-06-063-1/+314
| | | | files.
* lua: fix stack leak in ubus method handlingFelix Fietkau2016-01-201-2/+3
| | | | | Signed-off-by: Chen Bin <ewolfok@126.com> Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* lua: Fix stack imbalance in ubus_event_handlerHans Dedecker2015-11-021-0/+3
| | | | | | | | The value from getglobal wasn't being removed from the stack, resulting in an ever growing stack in the ubus event handler. Signed-off-by: Karl Vogel <karl.vogel@gmail.com> Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
* lua: fix memory leak problem陈斌2015-05-251-0/+1
| | | | Signed-off-by: Chen Bin <ewolfok@126.com>
* ubus: Fix issues reported by static code analysis tool KlocworkHans Dedecker2015-04-201-2/+17
| | | | Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
* lua: forward return codes from lua to ubusSteven Barth2014-05-051-2/+5
| | | | | Signed-off-by: Steven Barth <cyrus@openwrt.org> Tested-by: Luka Perkov <luka@openwrt.org>
* ubus: Fix imbalance in lua stack push/pop of values.Karl Vogel2014-02-231-1/+5
| | | | | | | | | | | The lua getglobal and rawgeti both push a value onto the lua stack, but they weren't being removed by the ubus_method_handler function, thus corrupting the lua stack. In case the specified method wasn't a function, the stack was also corrupted as the method name remained on the stack. Signed-off-by: Karl Vogel <karl.vogel@gmail.com>
* lua: allow methods with no argumentsLuka Perkov2014-01-281-4/+12
| | | | | | | | | | | In C it is possible to have methods without arguments (UBUS_METHOD_NOARG). Enable support for the same calls in Lua too. This commit also fixes segfault which can be caused by passing non-table type where table is expected. The lua_gettablelen() function is called after we have made sure we are dealing with a table in the first place. Signed-off-by: Luka Perkov <luka@openwrt.org>
* lua: fix whitespaces and typoLuka Perkov2014-01-281-3/+3
| | | | Signed-off-by: Luka Perkov <luka@openwrt.org>
* add Lua bindings for ubus eventsJohn Crispin2013-11-073-1/+109
| | | | | | | | | | It mostly mimick the style of the existing code. With it and the ubox Lua bindings, you can now send ubus events through Lua or listen for events (you can register for multiple events at the same time). Signed-off-by: Jeff Remy <jeff.remy@gmail.com>
* add INCLUDE_DIRECTORIES to subdirectoriesThomas Gstädtner2013-03-031-0/+1
|
* lua: pass u64 blob type as double to LuaJo-Philipp Wich2013-01-131-4/+1
|
* lua: remove a superfluous lua_pop() when checking table styleJo-Philipp Wich2012-10-171-1/+0
|
* lua: fix ubus_lua_format_blob_is_array() to not leave garbage on the stackJo-Philipp Wich2012-10-161-2/+3
|
* lua: propagate incoming message to method callback inside the lua contextJohn Crispin2012-09-292-2/+9
| | | | Signed-off-by: John Crispin <blogic@openwrt.org>
* add lua binding test scriptsJohn Crispin2012-09-272-0/+78
| | | | Signed-off-by: John Crispin <blogic@openwrt.org>
* lua: add support for registering methodsFelix Fietkau2012-09-271-2/+230
| | | | Signed-off-by: John Crispin <blogic@openwrt.org>
* lua: add uloop supportFelix Fietkau2012-09-271-0/+1
|
* lua: allow building the lua binding with vanilla luaJohn Crispin2012-09-271-0/+6
| | | | Signed-off-by: John Crispin <blogic@openwrt.org>
* lua: add a prototype for luaopen_ubus so that -Wmissing-declarations can be ↵Felix Fietkau2012-05-291-0/+2
| | | | enabled
* lua: put LUAPATH in quotes to prevent weird error messages when it is unsetFelix Fietkau2012-05-061-1/+1
|
* implement Lua bindingJo-Philipp Wich2012-05-052-0/+446