<HTML><BODY><div>Hi Sergey, thank you for the patch, LGTM.<br><br> <blockquote style="border-left:1px solid #0857A6; margin:10px; padding:0 0 0 10px;">Среда, 8 апреля 2020, 18:43 +03:00 от Sergey Bronnikov <estetus@gmail.com>:<br> <div id=""><div class="js-helper js-readmsg-msg"><style type="text/css"></style><div><div id="style_15863606060537973655_BODY">From: Sergey Bronnikov <<a href="/compose?To=sergeyb@tarantool.org">sergeyb@tarantool.org</a>><br><br>Many warnings fixed with help from Vladislav Shpilevoy.<br><br>Closes #4681<br>---<br> src/lua/argparse.lua | 6 ++--<br> src/lua/buffer.lua | 4 +--<br> src/lua/clock.lua | 2 +-<br> src/lua/crypto.lua | 4 +--<br> src/lua/csv.lua | 5 ++-<br> src/lua/digest.lua | 2 +-<br> src/lua/env.lua | 2 +-<br> src/lua/fio.lua | 25 +++++++-------<br> src/lua/httpc.lua | 3 --<br> src/lua/init.lua | 7 ++--<br> src/lua/msgpackffi.lua | 16 +++------<br> src/lua/socket.lua | 65 ++++++++++++++++++------------------<br> src/lua/string.lua | 1 -<br> src/lua/swim.lua | 16 ++++-----<br> src/lua/tap.lua | 75 ++++++++++++++++++++----------------------<br> src/lua/trigger.lua | 3 --<br> 16 files changed, 109 insertions(+), 127 deletions(-)<br><br>diff --git a/src/lua/argparse.lua b/src/lua/argparse.lua<br>index faa0ae130..f58985425 100644<br>--- a/src/lua/argparse.lua<br>+++ b/src/lua/argparse.lua<br>@@ -90,8 +90,8 @@ local function convert_parameter(name, convert_from, convert_to)<br> return convert_from<br> end<br> <br>-local function parameters_parse(t_in, options)<br>- local t_out, t_in = {}, t_in or {}<br>+local function parameters_parse(t__in, options)<br>+ local t_out, t_in = {}, t__in or {}<br> <br> -- Prepare a lookup table for options. An option name -> a<br> -- type name to convert a parameter into or true (which means<br>@@ -145,7 +145,7 @@ local function parameters_parse(t_in, options)<br> if parameter_has_value(lookup[command]) then<br> -- in case next argument is value of this key (not --arg)<br> local next_arg = t_in[i + 1]<br>- local is_long, is_short, is_dash = parse_param_prefix(next_arg)<br>+ is_long, is_short, is_dash = parse_param_prefix(next_arg)<br> if is_dash then<br> skip_param = true<br> elseif is_long == false and not is_short and not is_dash then<br>diff --git a/src/lua/buffer.lua b/src/lua/buffer.lua<br>index 9aac82b39..43c7e1170 100644<br>--- a/src/lua/buffer.lua<br>+++ b/src/lua/buffer.lua<br>@@ -182,7 +182,7 @@ local ibuf_methods = {<br> unused = ibuf_unused;<br> }<br> <br>-local function ibuf_tostring(ibuf)<br>+local function ibuf_tostring()<br> return '<ibuf>'<br> end<br> local ibuf_mt = {<br>@@ -193,7 +193,7 @@ local ibuf_mt = {<br> <br> ffi.metatype(ibuf_t, ibuf_mt);<br> <br>-local function ibuf_new(arg, arg2)<br>+local function ibuf_new(arg)<br> local buf = ffi.new(ibuf_t)<br> local slabc = builtin.tarantool_lua_slab_cache()<br> builtin.ibuf_create(buf, slabc, READAHEAD)<br>diff --git a/src/lua/clock.lua b/src/lua/clock.lua<br>index 60c78663c..fee43ccde 100644<br>--- a/src/lua/clock.lua<br>+++ b/src/lua/clock.lua<br>@@ -33,7 +33,7 @@ clock.bench = function(fun, ...)<br> overhead = clock.proc() - overhead<br> local start_time = clock.proc()<br> local res = {0, fun(...)}<br>- res[1] = clock.proc() - start_time - overhead, res<br>+ res[1] = clock.proc() - start_time - overhead<br> return res<br> end<br> <br>diff --git a/src/lua/crypto.lua b/src/lua/crypto.lua<br>index bf3064c70..c0eb0d303 100644<br>--- a/src/lua/crypto.lua<br>+++ b/src/lua/crypto.lua<br>@@ -75,7 +75,7 @@ local function openssl_err_str()<br> end<br> <br> local digests = {}<br>-for class, name in pairs({<br>+for class, _ in pairs({<br> md2 = 'MD2', md4 = 'MD4', md5 = 'MD5',<br> sha1 = 'SHA1', sha224 = 'SHA224',<br> sha256 = 'SHA256', sha384 = 'SHA384', sha512 = 'SHA512',<br>@@ -428,7 +428,7 @@ local public_methods = {<br> }<br> <br> local module_mt = {<br>- __serialize = function(s)<br>+ __serialize = function()<br> return public_methods<br> end,<br> __index = public_methods<br>diff --git a/src/lua/csv.lua b/src/lua/csv.lua<br>index 7dff2f213..de6726bb7 100644<br>--- a/src/lua/csv.lua<br>+++ b/src/lua/csv.lua<br>@@ -188,10 +188,10 @@ module.dump = function(t, opts, writable)<br> if type(writable) == 'nil' then<br> result_table = {}<br> end<br>- for k, line in pairs(t) do<br>+ for _, line in pairs(t) do<br> local first = true<br> local output_tuple = {}<br>- for k2, field in pairs(line) do<br>+ for _, field in pairs(line) do<br> local strf = tostring(field)<br> local buf_new_size = (strf:len() + 1) * 2<br> if buf_new_size > bufsz then<br>@@ -214,7 +214,6 @@ module.dump = function(t, opts, writable)<br> else<br> writable:write(table.concat(output_tuple))<br> end<br>- output_tuple = {}<br> end<br> ffi.C.csv_destroy(csv)<br> csv.realloc(buf, 0)<br>diff --git a/src/lua/digest.lua b/src/lua/digest.lua<br>index 6ed91cfa2..7f1aea8d0 100644<br>--- a/src/lua/digest.lua<br>+++ b/src/lua/digest.lua<br>@@ -246,7 +246,7 @@ local m = {<br> end<br> }<br> <br>-for digest, name in pairs(digest_shortcuts) do<br>+for digest, _ in pairs(digest_shortcuts) do<br> m[digest] = function (str)<br> return crypto.digest[digest](str)<br> end<br>diff --git a/src/lua/env.lua b/src/lua/env.lua<br>index dd1616a84..a31b7098f 100644<br>--- a/src/lua/env.lua<br>+++ b/src/lua/env.lua<br>@@ -28,7 +28,7 @@ os.environ = function()<br> end<br> <br> os.setenv = function(key, value)<br>- local rv = nil<br>+ local rv<br> if value ~= nil then<br> rv = ffi.C.setenv(key, value, 1)<br> else<br>diff --git a/src/lua/fio.lua b/src/lua/fio.lua<br>index 83fddaa0a..b2b4b4c77 100644<br>--- a/src/lua/fio.lua<br>+++ b/src/lua/fio.lua<br>@@ -329,7 +329,7 @@ fio.abspath = function(path)<br> error("Usage: fio.abspath(path)")<br> end<br> path = path<br>- local joined_path = ''<br>+ local joined_path<br> local path_tab = {}<br> if string.sub(path, 1, 1) == '/' then<br> joined_path = path<br>@@ -366,7 +366,7 @@ fio.listdir = function(path)<br> return t<br> end<br> local names = string.split(str, "\n")<br>- for i, name in ipairs(names) do<br>+ for _, name in ipairs(names) do<br> table.insert(t, name)<br> end<br> return t<br>@@ -378,15 +378,15 @@ fio.mktree = function(path, mode)<br> end<br> path = fio.abspath(path)<br> <br>- local path = string.gsub(path, '^/', '')<br>+ path = string.gsub(path, '^/', '')<br> local dirs = string.split(path, "/")<br> <br> local current_dir = "/"<br>- for i, dir in ipairs(dirs) do<br>+ for _, dir in ipairs(dirs) do<br> current_dir = fio.pathjoin(current_dir, dir)<br> local stat = fio.stat(current_dir)<br> if stat == nil then<br>- local st, err = fio.mkdir(current_dir, mode)<br>+ local _, err = fio.mkdir(current_dir, mode)<br> -- fio.stat() and fio.mkdir() above are separate calls<br> -- and a file system may be changed between them. So<br> -- if the error here is due to an existing directory,<br>@@ -407,20 +407,20 @@ fio.rmtree = function(path)<br> if type(path) ~= 'string' then<br> error("Usage: fio.rmtree(path)")<br> end<br>- local status, err<br>+ local status<br> path = fio.abspath(path)<br> local ls, err = fio.listdir(path)<br> if err ~= nil then<br> return nil, err<br> end<br>- for i, f in ipairs(ls) do<br>+ for _, f in ipairs(ls) do<br> local tmppath = fio.pathjoin(path, f)<br> local st = fio.lstat(tmppath)<br> if st then<br> if st:is_dir() then<br>- st, err = fio.rmtree(tmppath)<br>+ _, err = fio.rmtree(tmppath)<br> else<br>- st, err = fio.unlink(tmppath)<br>+ _, err = fio.unlink(tmppath)<br> end<br> if err ~= nil then<br> return nil, err<br>@@ -471,10 +471,10 @@ fio.copytree = function(from, to)<br> if reason ~= nil then<br> return false, reason<br> end<br>- for i, f in ipairs(ls) do<br>+ for _, f in ipairs(ls) do<br> local ffrom = fio.pathjoin(from, f)<br> local fto = fio.pathjoin(to, f)<br>- local st = fio.lstat(ffrom)<br>+ st = fio.lstat(ffrom)<br> if st and st:is_dir() then<br> status, reason = fio.copytree(ffrom, fto)<br> if reason ~= nil then<br>@@ -488,7 +488,8 @@ fio.copytree = function(from, to)<br> end<br> end<br> if st:is_link() then<br>- local link_to, reason = fio.readlink(ffrom)<br>+ local link_to<br>+ link_to, reason = fio.readlink(ffrom)<br> if reason ~= nil then<br> return false, reason<br> end<br>diff --git a/src/lua/httpc.lua b/src/lua/httpc.lua<br>index 6381c6a1a..9336dcee0 100644<br>--- a/src/lua/httpc.lua<br>+++ b/src/lua/httpc.lua<br>@@ -29,8 +29,6 @@<br> -- SUCH DAMAGE.<br> --<br> <br>-local fiber = require('fiber')<br>-<br> local driver = package.loaded.http.client<br> package.loaded.http = nil<br> <br>@@ -112,7 +110,6 @@ local special_characters = {<br> [']'] = true,<br> ['<'] = true,<br> ['>'] = true,<br>- ['>'] = true,<br> ['@'] = true,<br> [','] = true,<br> [';'] = true,<br>diff --git a/src/lua/init.lua b/src/lua/init.lua<br>index ff3e74c3c..a831549d1 100644<br>--- a/src/lua/init.lua<br>+++ b/src/lua/init.lua<br>@@ -144,9 +144,9 @@ local function gen_search_func(path_fn, templates, need_traverse)<br> <br> local searchpaths = {}<br> <br>- for _, path in ipairs(paths) do<br>+ for _, p in ipairs(paths) do<br> for _, template in pairs(templates) do<br>- table.insert(searchpaths, fio.pathjoin(path, template))<br>+ table.insert(searchpaths, fio.pathjoin(p, template))<br> end<br> end<br> <br>@@ -176,7 +176,8 @@ local function gen_loader_func(search_fn, load_fn)<br> if not file then<br> return err<br> end<br>- local loaded, err = load_fn(file, name)<br>+ local loaded<br>+ loaded, err = load_fn(file, name)<br> if err == nil then<br> return loaded<br> else<br>diff --git a/src/lua/msgpackffi.lua b/src/lua/msgpackffi.lua<br>index f775f2d41..eacf2d1d5 100644<br>--- a/src/lua/msgpackffi.lua<br>+++ b/src/lua/msgpackffi.lua<br>@@ -291,10 +291,6 @@ local function encode(obj)<br> return r<br> end<br> <br>-local function encode_ibuf(obj, ibuf)<br>- encode_r(ibuf, obj, 0)<br>-end<br>-<br> on_encode(ffi.typeof('uint8_t'), encode_int)<br> on_encode(ffi.typeof('uint16_t'), encode_int)<br> on_encode(ffi.typeof('uint32_t'), encode_int)<br>@@ -320,7 +316,6 @@ local decode_r<br> <br> -- See similar constants in utils.cc<br> local DBL_INT_MAX = 1e14 - 1<br>-local DBL_INT_MIN = -1e14 + 1<br> <br> local function decode_u8(data)<br> local num = ffi.cast(uint8_ptr_t, data[0])[0]<br>@@ -465,8 +460,7 @@ end<br> local function decode_array(data, size)<br> assert (type(size) == "number")<br> local arr = {}<br>- local i<br>- for i=1,size,1 do<br>+ for _ = 1, size do<br> table.insert(arr, decode_r(data))<br> end<br> if not msgpack.cfg.decode_save_metatables then<br>@@ -478,8 +472,7 @@ end<br> local function decode_map(data, size)<br> assert (type(size) == "number")<br> local map = {}<br>- local i<br>- for i=1,size,1 do<br>+ for _ = 1, size do<br> local key = decode_r(data);<br> local val = decode_r(data);<br> map[key] = val<br>@@ -492,7 +485,7 @@ end<br> <br> local ext_decoder = {<br> -- MP_UNKNOWN_EXTENSION<br>- [0] = function(data, len) error("unsupported extension type") end,<br>+ [0] = function() error("unsupported extension type") end,<br> -- MP_DECIMAL<br> [1] = function(data, len) local num = ffi.new("decimal_t") builtin.decimal_unpack(data, len, num) return num end,<br> }<br>@@ -502,7 +495,6 @@ local function decode_ext(data)<br> -- mp_decode_extl and mp_decode_decimal<br> -- need type code<br> data[0] = data[0] - 1<br>- local old_data = data[0]<br> local len = builtin.mp_decode_extl(data, t)<br> local fun = ext_decoder[t[0]]<br> if type(fun) == 'function' then<br>@@ -589,7 +581,7 @@ local function check_offset(offset, len)<br> if offset == nil then<br> return 1<br> end<br>- local offset = ffi.cast('ptrdiff_t', offset)<br>+ offset = ffi.cast('ptrdiff_t', offset)<br> if offset < 1 or offset > len then<br> error(string.format("offset = %d is out of bounds [1..%d]",<br> tonumber(offset), len))<br>diff --git a/src/lua/socket.lua b/src/lua/socket.lua<br>index a334ad45b..317acfe8e 100644<br>--- a/src/lua/socket.lua<br>+++ b/src/lua/socket.lua<br>@@ -172,7 +172,7 @@ local function get_iflags(table, flags)<br> if type(flags) ~= 'table' then<br> flags = { flags }<br> end<br>- for i, f in pairs(flags) do<br>+ for _, f in pairs(flags) do<br> if table[f] == nil then<br> return nil<br> end<br>@@ -660,7 +660,7 @@ local function check_delimiter(self, limit, eols)<br> end<br> <br> local shortest<br>- for i, eol in ipairs(eols) do<br>+ for _, eol in ipairs(eols) do<br> local data = ffi.C.memmem(rbuf.rpos, rbuf:size(), eol, #eol)<br> if data ~= nil then<br> local len = ffi.cast('char *', data) - rbuf.rpos + #eol<br>@@ -706,16 +706,16 @@ local function read(self, limit, timeout, check, ...)<br> local res = sysread(self, data, rbuf:unused())<br> if res == 0 then -- eof<br> self._errno = nil<br>- local len = rbuf:size()<br>- local data = ffi.string(rbuf.rpos, len)<br>+ len = rbuf:size()<br>+ data = ffi.string(rbuf.rpos, len)<br> rbuf.rpos = rbuf.rpos + len<br> return data<br> elseif res ~= nil then<br> rbuf.wpos = rbuf.wpos + res<br>- local len = check(self, limit, ...)<br>+ len = check(self, limit, ...)<br> if len ~= nil then<br> self._errno = nil<br>- local data = ffi.string(rbuf.rpos, len)<br>+ data = ffi.string(rbuf.rpos, len)<br> rbuf.rpos = rbuf.rpos + len<br> return data<br> end<br>@@ -1039,7 +1039,7 @@ local function tcp_connect(host, port, timeout)<br> boxerrno(0)<br> return s<br> end<br>- local timeout = timeout or TIMEOUT_INFINITY<br>+ timeout = timeout or TIMEOUT_INFINITY<br> local stop = fiber.clock() + timeout<br> local dns = getaddrinfo(host, port, timeout, { type = 'SOCK_STREAM',<br> protocol = 'tcp' })<br>@@ -1047,7 +1047,7 @@ local function tcp_connect(host, port, timeout)<br> boxerrno(boxerrno.EINVAL)<br> return nil<br> end<br>- for i, remote in pairs(dns) do<br>+ for _, remote in pairs(dns) do<br> timeout = stop - fiber.clock()<br> if timeout <= 0 then<br> boxerrno(boxerrno.ETIMEDOUT)<br>@@ -1078,8 +1078,8 @@ local function tcp_server_handler(server, sc, from)<br> end<br> end<br> <br>-local function tcp_server_loop(server, s, addr)<br>- fiber.name(format("%s/%s:%s", server.name, addr.host, addr.port), {truncate = true})<br>+local function tcp_server_loop(server, s, address)<br>+ fiber.name(format("%s/%s:%s", server.name, address.host, address.port), {truncate = true})<br> log.info("started")<br> while socket_readable(s) do<br> local sc, from = socket_accept(s)<br>@@ -1104,15 +1104,15 @@ local function tcp_server_usage()<br> error('Usage: socket.tcp_server(host, port, handler | opts)')<br> end<br> <br>-local function tcp_server_do_bind(s, addr)<br>- if socket_bind(s, addr.host, addr.port) then<br>- if addr.family == 'AF_UNIX' then<br>+local function tcp_server_do_bind(s, address)<br>+ if socket_bind(s, address.host, address.port) then<br>+ if address.family == 'AF_UNIX' then<br> -- Make close() remove the unix socket file created<br> -- by bind(). Note, this must be done before closing<br> -- the socket fd so that no other tcp server can<br> -- reuse the same path before we remove the file.<br> s.close = function(self)<br>- fio.unlink(addr.port)<br>+ fio.unlink(address.port)<br> return socket_close(self)<br> end<br> end<br>@@ -1121,12 +1121,12 @@ local function tcp_server_do_bind(s, addr)<br> return false<br> end<br> <br>-local function tcp_server_bind_addr(s, addr)<br>- if tcp_server_do_bind(s, addr) then<br>+local function tcp_server_bind_addr(s, address)<br>+ if tcp_server_do_bind(s, address) then<br> return true<br> end<br> <br>- if addr.family ~= 'AF_UNIX' then<br>+ if address.family ~= 'AF_UNIX' then<br> return false<br> end<br> <br>@@ -1136,7 +1136,7 @@ local function tcp_server_bind_addr(s, addr)<br> <br> local save_errno = boxerrno()<br> <br>- local sc = tcp_connect(addr.host, addr.port)<br>+ local sc = tcp_connect(address.host, address.port)<br> if sc ~= nil then<br> sc:close()<br> boxerrno(save_errno)<br>@@ -1148,13 +1148,13 @@ local function tcp_server_bind_addr(s, addr)<br> return false<br> end<br> <br>- log.info("tcp_server: remove dead UNIX socket: %s", addr.port)<br>- if not fio.unlink(addr.port) then<br>+ log.info("tcp_server: remove dead UNIX socket: %s", address.port)<br>+ if not fio.unlink(address.port) then<br> log.warn("tcp_server: %s", boxerrno.strerror())<br> boxerrno(save_errno)<br> return false<br> end<br>- return tcp_server_do_bind(s, addr)<br>+ return tcp_server_do_bind(s, address)<br> end<br> <br> <br>@@ -1172,8 +1172,8 @@ local function tcp_server_bind(host, port, prepare, timeout)<br> end<br> end<br> <br>- for _, addr in ipairs(dns) do<br>- local s = socket_new(addr.family, addr.type, addr.protocol)<br>+ for _, address in ipairs(dns) do<br>+ local s = socket_new(address.family, address.type, address.protocol)<br> if s ~= nil then<br> local backlog<br> if prepare then<br>@@ -1181,13 +1181,13 @@ local function tcp_server_bind(host, port, prepare, timeout)<br> else<br> socket_setsockopt(s, 'SOL_SOCKET', 'SO_REUSEADDR', 1) -- ignore error<br> end<br>- if not tcp_server_bind_addr(s, addr) or not s:listen(backlog) then<br>+ if not tcp_server_bind_addr(s, address) or not s:listen(backlog) then<br> local save_errno = boxerrno()<br> socket_close(s)<br> boxerrno(save_errno)<br> return nil<br> end<br>- return s, addr<br>+ return s, address<br> end<br> end<br> -- DNS resolved successfully, but addresss family is not supported<br>@@ -1211,12 +1211,12 @@ local function tcp_server(host, port, opts, timeout)<br> tcp_server_usage()<br> end<br> server.name = server.name or 'server'<br>- local s, addr = tcp_server_bind(host, port, server.prepare, timeout)<br>+ local s, address = tcp_server_bind(host, port, server.prepare, timeout)<br> if not s then<br> return nil<br> end<br>- fiber.create(tcp_server_loop, server, s, addr)<br>- return s, addr<br>+ fiber.create(tcp_server_loop, server, s, address)<br>+ return s, address<br> end<br> <br> socket_mt = {<br>@@ -1311,10 +1311,9 @@ local function lsocket_tcp_getpeername(self)<br> return peer.host, tostring(peer.port), peer.family:match("AF_(.*)"):lower()<br> end<br> <br>-local function lsocket_tcp_settimeout(self, value, mode)<br>+local function lsocket_tcp_settimeout(self, value)<br> check_socket(self)<br> self.timeout = value<br>- -- mode is effectively ignored<br> return 1<br> end<br> <br>@@ -1467,7 +1466,7 @@ local function lsocket_tcp_receive(self, pattern, prefix)<br> local result = { prefix }<br> local deadline = fiber.clock() + (self.timeout or TIMEOUT_INFINITY)<br> repeat<br>- local data = read(self, LIMIT_INFINITY, timeout, check_infinity)<br>+ data = read(self, LIMIT_INFINITY, timeout, check_infinity)<br> if data == nil then<br> if not errno_is_transient[self._errno] then<br> return nil, socket_error(self)<br>@@ -1535,7 +1534,7 @@ lsocket_tcp_mt.__index.send = lsocket_tcp_send;<br> -- TCP Constructor and Shortcuts<br> --<br> <br>-local function lsocket_tcp()<br>+local function lsocket_tcp(self)<br> local s = socket_new('AF_INET', 'SOCK_STREAM', 'tcp')<br> if not s then<br> return nil, socket_error(self)<br>@@ -1559,7 +1558,7 @@ local function lsocket_bind(host, port, backlog)<br> if host == nil or port == nil then<br> error("Usage: luasocket.bind(host, port [, backlog])")<br> end<br>- local function prepare(s) return backlog end<br>+ local function prepare() return backlog end<br> local s = tcp_server_bind(host, port, prepare)<br> if not s then<br> return nil, boxerrno.strerror()<br>diff --git a/src/lua/string.lua b/src/lua/string.lua<br>index 6e12c59ae..d3a846645 100644<br>--- a/src/lua/string.lua<br>+++ b/src/lua/string.lua<br>@@ -233,7 +233,6 @@ local function string_startswith(inp, head, _start, _end)<br> return false<br> end<br> _start = _start - 1<br>- _end = _start + head_len - 1<br> return memcmp(c_char_ptr(inp) + _start, c_char_ptr(head), head_len) == 0<br> end<br> <br>diff --git a/src/lua/swim.lua b/src/lua/swim.lua<br>index 0859915c9..466e77ce4 100644<br>--- a/src/lua/swim.lua<br>+++ b/src/lua/swim.lua<br>@@ -371,7 +371,7 @@ end<br> --<br> local function swim_member_payload_str(m)<br> local ptr = swim_check_member(m, 'member:payload_str()')<br>- local cdata, size = swim_member_payload_raw(ptr)<br>+ local _, size = swim_member_payload_raw(ptr)<br> if size > 0 then<br> return ffi.string(swim_member_payload_raw(ptr))<br> end<br>@@ -462,7 +462,7 @@ local swim_member_mt = {<br> is_dropped = swim_member_is_dropped,<br> },<br> __serialize = swim_member_serialize,<br>- __newindex = function(m)<br>+ __newindex = function()<br> return error('swim_member is a read-only object')<br> end<br> }<br>@@ -782,20 +782,20 @@ local swim_member_event_mt = {<br> --<br> -- Create a closure function for preprocessing raw SWIM member<br> -- event trigger parameters.<br>--- @param s SWIM instance.<br>+-- @param instance SWIM instance.<br> -- @param callback User functions to call.<br> -- @param ctx An optional parameter for @a callback passed as is.<br> -- @return A function to set as a trigger.<br> --<br>-local function swim_on_member_event_new(s, callback, ctx)<br>+local function swim_on_member_event_new(instance, callback, ctx)<br> -- Do not keep a hard reference to a SWIM instance. Otherwise<br> -- it is a cyclic reference, and both the instance and the<br> -- trigger will never be GC-ed.<br>- s = setmetatable({s}, {__mode = 'v'})<br>+ instance = setmetatable({instance}, {__mode = 'v'})<br> return function(member_ptr, event_mask)<br>- local s = s[1]<br>- if s then<br>- local m = swim_wrap_member(s, member_ptr)<br>+ local i = instance[1]<br>+ if i then<br>+ local m = swim_wrap_member(i, member_ptr)<br> local event = setmetatable({event_mask}, swim_member_event_mt)<br> return callback(m, event, ctx)<br> end<br>diff --git a/src/lua/tap.lua b/src/lua/tap.lua<br>index 94b080d5a..04497386e 100644<br>--- a/src/lua/tap.lua<br>+++ b/src/lua/tap.lua<br>@@ -53,7 +53,7 @@ local function ok(test, cond, message, extra)<br> io.write(string.format("not ok - %s\n", message))<br> extra = extra or {}<br> if test.trace then<br>- local frame = debug.getinfo(3, "Sl")<br>+ debug.getinfo(3, "Sl")<br> extra.trace = traceback()<br> extra.filename = extra.trace[#extra.trace].filename<br> extra.line = extra.trace[#extra.trace].line<br>@@ -76,9 +76,6 @@ local function skip(test, message, extra)<br> ok(test, true, message.." # skip", extra)<br> end<br> <br>-<br>-local nan = 0/0<br>-<br> local function cmpdeeply(got, expected, extra)<br> if type(expected) == "number" or type(got) == "number" then<br> extra.got = got<br>@@ -190,38 +187,38 @@ local function isboolean(test, v, message, extra)<br> return is(test, type(v), 'boolean', message, extra)<br> end<br> <br>-local function isfunction(test, v, message, extra)<br>- return is(test, type(v), 'function', message, extra)<br>+local function isfunction(testcase, v, message, extra)<br>+ return is(testcase, type(v), 'function', message, extra)<br> end<br> <br>-local function isudata(test, v, utype, message, extra)<br>+local function isudata(testcase, v, utype, message, extra)<br> extra = extra or {}<br> extra.expected = 'userdata<'..utype..'>'<br> if type(v) == 'userdata' then<br> extra.got = 'userdata<'..getmetatable(v)..'>'<br>- return ok(test, getmetatable(v) == utype, message, extra)<br>+ return ok(testcase, getmetatable(v) == utype, message, extra)<br> else<br> extra.got = type(v)<br>- return fail(test, message, extra)<br>+ return fail(testcase, message, extra)<br> end<br> end<br> <br>-local function iscdata(test, v, ctype, message, extra)<br>+local function iscdata(testcase, v, ctype, message, extra)<br> extra = extra or {}<br> extra.expected = ffi.typeof(ctype)<br> if type(v) == 'cdata' then<br> extra.got = ffi.typeof(v)<br>- return ok(test, ffi.istype(ctype, v), message, extra)<br>+ return ok(testcase, ffi.istype(ctype, v), message, extra)<br> else<br> extra.got = type(v)<br>- return fail(test, message, extra)<br>+ return fail(testcase, message, extra)<br> end<br> end<br> <br> local test_mt<br> local function test(parent, name, fun, ...)<br> local level = parent ~= nil and parent.level + 1 or 0<br>- local test = setmetatable({<br>+ local testcase = setmetatable({<br> parent = parent;<br> name = name;<br> level = level;<br>@@ -232,48 +229,48 @@ local function test(parent, name, fun, ...)<br> strict = false;<br> }, test_mt)<br> if fun ~= nil then<br>- test:diag('%s', test.name)<br>- fun(test, ...)<br>- test:diag('%s: end', test.name)<br>- return test:check()<br>+ testcase:diag('%s', testcase.name)<br>+ fun(testcase, ...)<br>+ testcase:diag('%s: end', testcase.name)<br>+ return testcase:check()<br> else<br>- return test<br>+ return testcase<br> end<br> end<br> <br>-local function plan(test, planned)<br>- test.planned = planned<br>- io.write(string.rep(' ', 4 * test.level), string.format("1..%d\n", planned))<br>+local function plan(testcase, planned)<br>+ testcase.planned = planned<br>+ io.write(string.rep(' ', 4 * testcase.level), string.format("1..%d\n", planned))<br> end<br> <br>-local function check(test)<br>- if test.checked then<br>+local function check(testcase)<br>+ if testcase.checked then<br> error('check called twice')<br> end<br>- test.checked = true<br>- if test.planned ~= test.total then<br>- if test.parent ~= nil then<br>- ok(test.parent, false, "bad plan", { planned = test.planned;<br>- run = test.total})<br>+ testcase.checked = true<br>+ if testcase.planned ~= testcase.total then<br>+ if testcase.parent ~= nil then<br>+ ok(testcase.parent, false, "bad plan", { planned = testcase.planned;<br>+ run = testcase.total})<br> else<br>- diag(test, string.format("bad plan: planned %d run %d",<br>- test.planned, test.total))<br>+ diag(testcase, string.format("bad plan: planned %d run %d",<br>+ testcase.planned, testcase.total))<br> end<br>- elseif test.failed > 0 then<br>- if test.parent ~= nil then<br>- ok(test.parent, false, "failed subtests", {<br>- failed = test.failed;<br>- planned = test.planned;<br>+ elseif testcase.failed > 0 then<br>+ if testcase.parent ~= nil then<br>+ ok(testcase.parent, false, "failed subtests", {<br>+ failed = testcase.failed;<br>+ planned = testcase.planned;<br> })<br> else<br>- diag(test, "failed subtest: %d", test.failed)<br>+ diag(testcase, "failed subtest: %d", testcase.failed)<br> end<br> else<br>- if test.parent ~= nil then<br>- ok(test.parent, true, test.name)<br>+ if testcase.parent ~= nil then<br>+ ok(testcase.parent, true, testcase.name)<br> end<br> end<br>- return test.planned == test.total and test.failed == 0<br>+ return testcase.planned == testcase.total and testcase.failed == 0<br> end<br> <br> test_mt = {<br>diff --git a/src/lua/trigger.lua b/src/lua/trigger.lua<br>index 76a582c47..1330ecdd4 100644<br>--- a/src/lua/trigger.lua<br>+++ b/src/lua/trigger.lua<br>@@ -1,7 +1,4 @@<br> local fun = require('fun')<br>-local log = require('log')<br>-<br>-local table_clear = require('table.clear')<br> <br> --<br> -- Checks that argument is a callable, i.e. a function or a table<br>--<br>2.23.0<br> </div></div></div></div></blockquote> <div> </div><div data-signature-widget="container"><div data-signature-widget="content"><div>--<br>Alexander Tikhonov</div></div></div><div> </div></div></BODY></HTML>