Re: [PATCH v8 1/1] rust: pci: add extended capability and SR-IOV support

[email protected]
Newsgroups org.kernel.vger.linux-pci
Message-ID <[email protected]>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The `ExtSriovVfBars` struct is constructed without an `// INVARIANT:` comment explaining why its invariants are satisfied.
--

--- Patch [1]: [PATCH v8 1/1] rust: pci: add extended capability and SR-IOV support ---
commit e0446bc8a9435cb9072472f040f7215e21d10ce1
Author: Zhi Wang <[email protected]>

rust: pci: add extended capability and SR-IOV support

This commit adds Rust PCI abstractions for locating and accessing PCIe
extended capabilities. It provides specific support for the SR-IOV
extended capability and a decoded VF BAR iterator.

Link: https://lore.kernel.org/rust-for-linux/[email protected]/

> diff --git a/rust/kernel/pci/cap.rs b/rust/kernel/pci/cap.rs
> new file mode 100644
> index 0000000000000..ddb3fd73e1955
> --- /dev/null
> +++ b/rust/kernel/pci/cap.rs

[ ... ]

> +struct ExtSriovVfBars {
> +    bars: [ExtSriovVfBar; NUM_VF_BARS],
> +    bar_count: usize,
> +    next_bar: usize,
> +}
> +
> +impl ExtSriovVfBars {
> +    fn new(slots: [u32; NUM_VF_BARS]) -> Result<Self> {

[ ... ]

> +            bars[bar_count] = ExtSriovVfBar { address, is_64bit };
> +            bar_count += 1;
> +        }
> +
> +        Ok(Self {
> +            bars,
> +            bar_count,
> +            next_bar: 0,
> +        })

[Severity: Low]
This isn't a bug, but the Rust subsystem guidelines require an // INVARIANT:
comment when constructing a struct that has documented invariants.
ExtSriovVfBars documents its invariants above, but is constructed here
without explaining how they are satisfied. Could an // INVARIANT: comment
be added here?

> +    }
> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.