Skip to content

Commit

Permalink
scripts/nvidia-pci-ids-dumper: Rename err to die function
Browse files Browse the repository at this point in the history
Signed-off-by: Vasiliy Stelmachenok <ventureo@cachyos.org>
  • Loading branch information
ventureoo committed Oct 4, 2024
1 parent d60a454 commit 636549a
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions scripts/nvidia-pci-ids-dumper/nvidia-pci-ids-dumper
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ with this program; if not, write to the Free Software Foundation, Inc.,
--]]
local found, json = pcall(require, 'dkjson')

local function err(msg, ...)
local function die(msg, ...)
print(msg:format(...))
os.exit(1)
end

if not found then
err("lua-dkjson dependency is missing, please install it from repositories")
die("lua-dkjson dependency is missing, please install it from repositories")
end

local function write(generations)
Expand All @@ -44,7 +44,7 @@ local function write(generations)
hwdb:write(content .. "\n")
hwdb:close()
else
err("Failed to write PCI ids: %s", errmsg)
die("Failed to write PCI ids: %s", errmsg)
end
end
end
Expand Down Expand Up @@ -89,29 +89,28 @@ end

local function main()
if #arg < 1 then
err("Specify path to the supported-gpu.json file")
os.exit(0)
die("Specify path to the supported-gpu.json file")
end

local path = arg[1]
local file, errmsg = io.open(path, "r")

if not file then
err("Failed to open %s file: %s", path, errmsg)
die("Failed to open %s file: %s", path, errmsg)
return
end

local raw = file:read()
file:close()

if not raw then
err("Failed to read file %s", path)
die("Failed to read file %s", path)
end

local supported_gpus = json.decode(raw)

if not supported_gpus.chips then
err("Failed to parse supported_gpus.json")
die("Failed to parse supported_gpus.json")
end

local generations = parse(supported_gpus.chips)
Expand Down

0 comments on commit 636549a

Please sign in to comment.