diff --git a/util/os/linux.zig b/util/os/linux.zig index 95b48a5..bf3f5a1 100644 --- a/util/os/linux.zig +++ b/util/os/linux.zig @@ -17,7 +17,7 @@ pub fn getCpuName() ![]const u8 { _ = try file.read(&cpu_name_buffer); const needle = "model name"; - const start = if (mem.indexOf(u8, &buf, needle)) |pos| + const start = if (mem.indexOf(u8, &cpu_name_buffer, needle)) |pos| pos + needle.len else return error.CouldNotFindCpuName; diff --git a/util/platform.zig b/util/platform.zig index 2a2ab74..058d6e5 100644 --- a/util/platform.zig +++ b/util/platform.zig @@ -34,17 +34,17 @@ const platform = @tagName(builtin.os.tag) ++ " " ++ @tagName(builtin.cpu.arch); pub fn getSystemInfo(allocator: std.mem.Allocator) !OsInfo { return switch (builtin.os.tag) { - .linux => try linux(allocator), + .linux => try linux(), .macos => try macos(allocator), .windows => try windows(allocator), else => error.UnsupportedOs, }; } -pub fn linux(allocator: std.mem.Allocator) !OsInfo { +pub fn linux() !OsInfo { return OsInfo{ .platform = platform, - .cpu = try lnx.getCpuName(allocator), + .cpu = try lnx.getCpuName(), .cpu_cores = try lnx.getCpuCores(), .memory_total = try lnx.getTotalMemory(), }; @@ -69,7 +69,7 @@ pub fn windows(allocator: std.mem.Allocator) !OsInfo { } test "OsInfo" { - const sysinfo = getSystemInfo(std.testing.allocator); + const sysinfo = try getSystemInfo(std.testing.allocator); try std.testing.expect(sysinfo.platform.len != 0); try std.testing.expect(sysinfo.cpu.len != 0); try std.testing.expect(0 < sysinfo.cpu_cores);