From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp54.i.mail.ru (smtp54.i.mail.ru [217.69.128.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 7502B4696C3 for ; Sat, 11 Apr 2020 19:54:42 +0300 (MSK) References: <2211143d95d0385682f79fb632bd7fd84c442c23.1586341316.git.sergeyb@tarantool.org> From: Vladislav Shpilevoy Message-ID: <70f13a2e-6c41-abfd-7108-05b6f1098c19@tarantool.org> Date: Sat, 11 Apr 2020 18:54:40 +0200 MIME-Version: 1.0 In-Reply-To: <2211143d95d0385682f79fb632bd7fd84c442c23.1586341316.git.sergeyb@tarantool.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [Tarantool-patches] [PATCH v2 1/6] Fix luacheck warnings in src/lua/ List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Sergey Bronnikov , tarantool-patches@dev.tarantool.org Cc: o.piskunov@tarantool.org Thanks for the patch! > diff --git a/src/lua/swim.lua b/src/lua/swim.lua > index 0859915c9..466e77ce4 100644 > --- a/src/lua/swim.lua > +++ b/src/lua/swim.lua > @@ -782,20 +782,20 @@ local swim_member_event_mt = { > -- > -- Create a closure function for preprocessing raw SWIM member > -- event trigger parameters. > --- @param s SWIM instance. > +-- @param instance SWIM instance. luacheck reported shadowing of 's' in the cycle below, so it is enough to fix the cycle. I fixed that in a separate commit. Squash it if you agree. > -- @param callback User functions to call. > -- @param ctx An optional parameter for @a callback passed as is. > -- @return A function to set as a trigger. > -- > -local function swim_on_member_event_new(s, callback, ctx) > +local function swim_on_member_event_new(instance, callback, ctx) > -- Do not keep a hard reference to a SWIM instance. Otherwise > -- it is a cyclic reference, and both the instance and the > -- trigger will never be GC-ed. > - s = setmetatable({s}, {__mode = 'v'}) > + instance = setmetatable({instance}, {__mode = 'v'}) > return function(member_ptr, event_mask) > - local s = s[1] > - if s then > - local m = swim_wrap_member(s, member_ptr) > + local i = instance[1] > + if i then > + local m = swim_wrap_member(i, member_ptr) > local event = setmetatable({event_mask}, swim_member_event_mt) > return callback(m, event, ctx) > end See diff below and in a separate commit on the branch. ==================== diff --git a/src/lua/swim.lua b/src/lua/swim.lua index 466e77ce4..8e3b0ab13 100644 --- a/src/lua/swim.lua +++ b/src/lua/swim.lua @@ -782,20 +782,20 @@ local swim_member_event_mt = { -- -- Create a closure function for preprocessing raw SWIM member -- event trigger parameters. --- @param instance SWIM instance. +-- @param s SWIM instance. -- @param callback User functions to call. -- @param ctx An optional parameter for @a callback passed as is. -- @return A function to set as a trigger. -- -local function swim_on_member_event_new(instance, callback, ctx) +local function swim_on_member_event_new(s, callback, ctx) -- Do not keep a hard reference to a SWIM instance. Otherwise -- it is a cyclic reference, and both the instance and the -- trigger will never be GC-ed. - instance = setmetatable({instance}, {__mode = 'v'}) + s = setmetatable({s}, {__mode = 'v'}) return function(member_ptr, event_mask) - local i = instance[1] - if i then - local m = swim_wrap_member(i, member_ptr) + local si = s[1] + if si then + local m = swim_wrap_member(si, member_ptr) local event = setmetatable({event_mask}, swim_member_event_mt) return callback(m, event, ctx) end diff --git a/src/lua/tap.lua b/src/lua/tap.lua index 04497386e..094eb883f 100644 --- a/src/lua/tap.lua +++ b/src/lua/tap.lua @@ -53,7 +53,6 @@ local function ok(test, cond, message, extra) io.write(string.format("not ok - %s\n", message)) extra = extra or {} if test.trace then - debug.getinfo(3, "Sl") extra.trace = traceback() extra.filename = extra.trace[#extra.trace].filename extra.line = extra.trace[#extra.trace].line