Skip to content

Commit

Permalink
gluon-core: util: avoid unintended second return value from gsub()
Browse files Browse the repository at this point in the history
gsub() returns the number of matches as its second return value. This
was unintendedly passed through by the util functions trim() and
node_id(). It can be presumed that this had no effect in practice, but
it can lead to surprising output when passing values to print() for
debugging.
  • Loading branch information
neocturne committed May 4, 2020
1 parent daf8a6c commit 0e681d5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions package/gluon-core/luasrc/usr/lib/lua/gluon/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ local function do_filter_prefix(input, output, prefix)
end

function M.trim(str)
return str:gsub("^%s*(.-)%s*$", "%1")
return (str:gsub("^%s*(.-)%s*$", "%1"))
end

function M.contains(table, value)
Expand Down Expand Up @@ -96,7 +96,7 @@ function M.exec(command)
end

function M.node_id()
return string.gsub(sysconfig.primary_mac, ':', '')
return (string.gsub(sysconfig.primary_mac, ':', ''))
end

function M.default_hostname()
Expand Down

0 comments on commit 0e681d5

Please sign in to comment.