Skip to content

Commit

Permalink
remove redundant parameters and fix typos
Browse files Browse the repository at this point in the history
  • Loading branch information
findstr committed Jan 13, 2024
1 parent 04765cb commit 229f505
Show file tree
Hide file tree
Showing 14 changed files with 36 additions and 39 deletions.
4 changes: 2 additions & 2 deletions examples/patch.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ console {
foo = function()
run.foo()
local a, b = run.dump()
return string.format("a:%s,b:%s,step:%s", a, b, tostring(step))
return string.format("a:%s,b:%s,step:%s", a, b, tostring(STEP))
end,
bar = function()
run.bar()
local a, b = run.dump()
return string.format("a:%s,b:%s,step:%s", a, b, tostring(step))
return string.format("a:%s,b:%s,step:%s", a, b, tostring(STEP))
end
}
}
Expand Down
8 changes: 4 additions & 4 deletions examples/patch/fix.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
local M = {}
step = 3
STEP = 3
local a, b = 1, 1

function M.foo()
step = 4
a = a + step
b = b + step
STEP = 4
a = a + STEP
b = b + STEP
end

function M.bar()
Expand Down
2 changes: 1 addition & 1 deletion lualib/cluster/rpc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ local function wakeup_all_calling(self)
local ackcmd = self.ackcmd
for session, co in pairs(waitpool) do
waitpool[session] = nil
logger.info("[rpc.client] wakeupall session", v)
logger.info("[rpc.client] wakeupall session", session)
ackcmd[co] = "closed"
core.wakeup(co)
end
Expand Down
2 changes: 1 addition & 1 deletion lualib/http/stream.lua
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ local function recv_request(sock)
local first = sock:readline()
local header = readheader(sock)
if not header then
return
return nil, nil
end
local typ = header["content-type"]
if typ and typ:find("multipart/form-data", 1, true) then
Expand Down
20 changes: 10 additions & 10 deletions lualib/http2/stream.lua
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ local function try_wakeup_connect(ch)
for i = 1, m do
local co = wait[i]
wait[i] = nil
wakeup(co, true, "ok")
wakeup(co, "ok")
end
ch.stream_count = ch.stream_count + m
if m < n then
Expand Down Expand Up @@ -262,15 +262,15 @@ local function frame_rst(ch, id, flag, dat)
end
local co = s.co
if co then
core.wakeup(co, nil, "rst")
core.wakeup(co, "rst")
end
end
end

local function frame_goaway(ch, _, flag, dat)
local wait = ch.wait_for_conn
for i = 1, #wait do
wakeup(wait[i], false, "goaway")
wakeup(wait[i], "goaway")
end
tls_close(ch.fd)
ch.fd = nil
Expand All @@ -283,7 +283,7 @@ local function frame_goaway(ch, _, flag, dat)
streams[k] = nil
local co = s.co
if co then
wakeup(co, nil, "goaway")
wakeup(co, "goaway")
end
end
end
Expand Down Expand Up @@ -339,7 +339,7 @@ local function common_dispatch(ch, frame_process)
for _, v in pairs(t) do
local co = v.co
if co then
wakeup(co, nil, "channel closed")
wakeup(co, "channel closed")
end
v.channel = nil
v.localclose = true
Expand All @@ -356,7 +356,7 @@ local function client_dispatch(ch)
end
local wait = ch.wait_for_conn
for i = 1, #wait do
wakeup(wait[i], false, "channel closed")
wakeup(wait[i], "channel closed")
end
end
end
Expand Down Expand Up @@ -487,16 +487,16 @@ function M.connect(host, port)
else
client_channel[tag] = nil
for i = 1, #wait do
wakeup(wait[i], false, reason)
wakeup(wait[i], reason)
end
return ok, reason
end
elseif not ch.fd or ch.stream_count >= ch.stream_max then
local t = ch.wait_for_conn
t[#t + 1] = core.running()
local ok, reason = core.wait()
if not ok then
return ok, reason
local reason = core.wait()
if reason ~= "ok" then
return false, reason
end
end
local id = ch.stream_idx
Expand Down
7 changes: 4 additions & 3 deletions lualib/sys/console.lua
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,11 @@ function console.inject(_, filepath)
if not filepath then
return "ERR lost the filepath"
end
local ok
local ENV = setmetatable({}, envmt)
local ok, err = pcall(loadfile, filepath, "bt", ENV)
if ok then
ok, err = pcall(err)
local chunk, err = loadfile(filepath, "bt", ENV)
if chunk then
ok, err = pcall(chunk)
end
local fmt = "Inject file:%s %s"
if ok then
Expand Down
6 changes: 3 additions & 3 deletions lualib/sys/core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ local traceback = debug.traceback
local weakmt = {__mode="kv"}

--misc
local log_info = logger.info
local log_error = logger.error
local log_info = assert(logger.info)
local log_error = assert(logger.error)
local readctrl = assert(c.readctrl)
local trace_new = assert(c.trace_new)
local trace_set = assert(c.trace_set)
Expand All @@ -42,7 +42,7 @@ end
--state migrate(RUN (WAIT->READY)/SLEEP RUN)
local task_status = setmetatable({}, weakmt)
local task_traceid = setmetatable({}, weakmt)
local task_running = nil
local task_running = "NIL"
local cocreate = coroutine.create
local corunning = coroutine.running
local coyield = coroutine.yield
Expand Down
4 changes: 2 additions & 2 deletions lualib/sys/db/mysql.lua
Original file line number Diff line number Diff line change
Expand Up @@ -798,9 +798,9 @@ local function read_prepare_result(self, sock)
return true, resp
end

local function _prepare_resp(self, sql)
local function _prepare_resp(self)
return function(sock)
return read_prepare_result(self, sock, sql)
return read_prepare_result(self, sock)
end
end

Expand Down
2 changes: 1 addition & 1 deletion lualib/sys/metrics/prometheus.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function M.unsample(fn)
R:unsample(fn)
end

function M:registry()
function M.registry()
return R
end

Expand Down
2 changes: 1 addition & 1 deletion lualib/sys/net/tcp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ local function suspend(s)
assert(not s.co)
local co = core.running()
s.co = co
return core.wait(co)
return core.wait()
end

local function wakeup(s, dat)
Expand Down
6 changes: 2 additions & 4 deletions test/testmutex.lua
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,12 @@ local function testcase5()
wg:fork(function()
local lock1 = mutex:lock(key)
local lock = mutex:lock(key)
local n = x
local flag = false
lock:unlock()
local parent = core.running()
core.fork(function()
core.wakeup(parent)
local key = mutex:lock(key)
local x = mutex:lock(key)
flag = true
end)
core.wait()
Expand All @@ -139,14 +138,13 @@ local function testcase6()
wg:fork(function()
local lock1 = mutex:lock(key)
local lock = mutex:lock(key)
local n = x
local flag = false
lock:unlock()
lock1:unlock()
local parent = core.running()
core.fork(function()
core.wakeup(parent)
local key = mutex:lock(key)
local k = mutex:lock(key)
flag = true
end)
core.wait()
Expand Down
4 changes: 2 additions & 2 deletions test/testpatch.lua
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,9 @@ local function case5(P)
]], nil, "t", ENV)()

fix(P, ENV, M1, M2, "$.foo._ENV")
testaux.asserteq(bar, 3, "global variable")
testaux.asserteq(_ENV.bar, 3, "global variable")
M1.foo()
testaux.asserteq(bar, 4, "global variable")
testaux.asserteq(_ENV.bar, 4, "global variable")
end

return function()
Expand Down
5 changes: 2 additions & 3 deletions test/testtcp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,7 @@ local function test_read(port)
core.sleep(0)
end
end
WAIT = core.running()
core.wait(WAIT)
core.wait()
testaux.asserteq(recv_nr, send_nr, "tcp send type count")
testaux.asserteq(recv_sum, send_sum, "tcp send checksum")
IO.close(fd)
Expand Down Expand Up @@ -456,7 +455,7 @@ return function()

IO = tls
testaux.module("tls")
IO.limit = function() end
IO.limit = function(fd, limit) end
test_read(":10002")
test_close(":10002")
core.sleep(100)
Expand Down
3 changes: 1 addition & 2 deletions test/testtimer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ local function test_timer()
local s = core.timeout(100 + n, f)
context[s] = n
end
WAIT = core.running()
core.wait(WAIT)
core.wait()
end

local function test_userdata()
Expand Down

0 comments on commit 229f505

Please sign in to comment.