On Thu Dec 18, 2025 at 2:39 AM CET, Timur Tabi wrote:
> +    #[inline]
> +    pub fn name(&self) -> &CStr {
> +        // SAFETY: By its type invariant `self.as_raw` is always a valid 
> pointer to a
> +        // `struct pci_dev`, which contains a `struct device dev` member.
> +        unsafe {
> +            let pci_dev = self.as_raw();
> +            let dev = &raw const (*pci_dev).dev;
> +
> +            // If init_name is set, use it; otherwise use the kobject name
> +            let init_name = (*dev).init_name;
> +            let name_ptr = if !init_name.is_null() {
> +                init_name
> +            } else {
> +                (*dev).kobj.name
> +            };
> +
> +            CStr::from_char_ptr(name_ptr)
> +        }
> +    }
>  }

This does not belong into pci::Device, but device::Device.

Also, please do not open-code the init_name dance, please use dev_name() 
instead.

Reply via email to