]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
table_print: simplification
authorPetr Špaček <petr.spacek@nic.cz>
Thu, 11 Apr 2019 13:57:06 +0000 (15:57 +0200)
committerPetr Špaček <petr.spacek@nic.cz>
Thu, 11 Apr 2019 14:01:28 +0000 (16:01 +0200)
As far as I understand the debug.sethook('call') descrption we are not
going to have any locals except function parameters so we can simplify
the code.

daemon/lua/sandbox.lua.in

index b09c87f87088690413bd25e85ef5868d26667157..59b9fcb04fe0ffc06cf90de76a4d83a79ddcfbf4 100644 (file)
@@ -377,16 +377,12 @@ local function funcsign(f)
                local function hook()
                        delay = delay - 1
                        if delay == 0 then  -- call this only for the introspected function
-                               for i = 1, math.huge do
-                                       -- stack depth 2 is the introspected function
+                               -- stack depth 2 is the introspected function
+                               local debuginfo = debug.getinfo(2)
+                               for i = 1, debuginfo.nparams do
                                        local k = debug.getlocal(2, i)
-                                       if (k or '('):sub(1, 1) == '(' then
-                                               break  -- internal variable, skip
-                                       else
-                                               table.insert(func_args, k)
-                                       end
+                                       table.insert(func_args, k)
                                end
-                               local debuginfo = debug.getinfo(2)
                                if debuginfo.what == 'C' then  -- names N/A
                                        table.insert(func_args, '?')
                                elseif debuginfo.isvararg then