[LEDE-DEV] uci-lua: error checking problems

Karl Palsson karlp at tweak.net.au
Tue May 24 05:17:27 PDT 2016


When using the lua binding for UCI, there's cases where failures
aren't properly propagating to the lua caller environment.

eg: (Starting from an empty file)

root at blah:/# lua
Lua 5.1.5 Copyright (C) 1994-2012 Lua.org, PUC-Rio (double int32)
> uci = require("uci")
> x = uci.cursor()
> =x:set("unknown", "unused", "someoption", "somevalue")
true   << lies!
> =x:save("unknown")
true  << more lies!
> =x:commit("unknown")
true  << redundant lies!
> 
root at blah:/# uci show unknown
root at blah:/# ^^ hah! 

In this particular case, the problem is that "err =
UCI_ERR_INVAL" should be "ctx->err = UCI_ERR_INVAL" however this
turns out to be a prevalent problem across the lua binding.

http://git.openwrt.org/?p=project/uci.git;a=blob;f=lua/uci.c;h=47d59c883ab9320b39304fdd46297576c3550fa1;hb=HEAD#l613

Options are some global replacing, or overhauling how the general
utility functions handle codes like this.

"Filed" as an email, as this is too big to fix in a few minutes
on IRC

Cheers,
Karl P
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP Digital Signature
URL: <http://lists.infradead.org/pipermail/lede-dev/attachments/20160524/bc073296/attachment.sig>


More information about the Lede-dev mailing list