From 90abbcb1fdc40ee97e0136cdf26d455daf9698eb Mon Sep 17 00:00:00 2001 From: utox39 Date: Fri, 11 Jul 2025 16:27:07 +0200 Subject: [PATCH] feat(linux-gpu): handle the return value of the pci_fill_info function --- src/linux/hardware.zig | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/linux/hardware.zig b/src/linux/hardware.zig index 75a247a..0e79a1d 100644 --- a/src/linux/hardware.zig +++ b/src/linux/hardware.zig @@ -100,8 +100,11 @@ pub fn getGpuInfo(allocator: std.mem.Allocator) !GpuInfo { var devices = pacc.*.devices; while (devices != null) : (devices = devices.*.next) { - // TODO: handle return value - _ = c_libpci.pci_fill_info(devices, c_libpci.PCI_FILL_IDENT | c_libpci.PCI_FILL_CLASS); + // NOTE: for references: https://github.com/pciutils/pciutils/blob/3ec74c71c01878f92e751f15bb8febe720c3ab40/lib/access.c#L194 + const known_fields = c_libpci.pci_fill_info(devices, c_libpci.PCI_FILL_IDENT | c_libpci.PCI_FILL_CLASS); + if (known_fields <= 0) { + return error.NoLibpciFieldsFound; + } if ((devices.*.device_class >> 8) == display_controller) { var name_buffer: [256]u8 = undefined;