Browse Source

Fix: enforce strict backward compatibility for older Perl and Lua runtimes

- Replaced newSVbool with boolSV inside modules/perl/bsdiskinfo.xs to support
  legacy Perl versions (below 5.36) and avoid execution undefined symbol traps.
- Rewrote bitwise operations and math.tointeger in examples/tree_view.lua
  using math.floor and modulo arithmetic for universal Lua 5.1/5.2/5.3/5.4
  compliance.
master
Sergey Kiselev 3 months ago
parent
commit
17fa6c2c04
  1. 2
      examples/tree_view.lua
  2. 4
      modules/perl/bsdiskinfo.xs

2
examples/tree_view.lua

@ -91,7 +91,7 @@ for _, disk in ipairs(disks) do
local temp = "N/A" local temp = "N/A"
for _, attr in ipairs(smart) do for _, attr in ipairs(smart) do
if attr.id == 194 or attr.id == 190 then if attr.id == 194 or attr.id == 190 then
temp = string.format("%d°C", math.tointeger(attr.raw_val & 0xFF) or attr.raw_val) temp = string.format("%d°C", math.floor(attr.raw_val % 256) or attr.raw_val)
break break
end end
end end

4
modules/perl/bsdiskinfo.xs

@ -51,8 +51,8 @@ get_properties(base_disk)
} }
if (props.smart_supported >= 0) { if (props.smart_supported >= 0) {
hv_store(hv, "smart_supported", 15, newSVbool(props.smart_supported == 1), 0); hv_store(hv, "smart_supported", 15, boolSV(props.smart_supported == 1), 0);
hv_store(hv, "smart_enabled", 13, newSVbool(props.smart_enabled == 1), 0); hv_store(hv, "smart_enabled", 13, boolSV(props.smart_enabled == 1), 0);
} }
/* Return as a reference to the hash */ /* Return as a reference to the hash */

Loading…
Cancel
Save