public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
* [PATCH] gpu: nova-core: vbios: Fix clippy error in Vbios::new()
@ 2026-05-27 17:15 Lyude Paul
  2026-05-28  1:12 ` Alexandre Courbot
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Lyude Paul @ 2026-05-27 17:15 UTC (permalink / raw)
  To: dri-devel, nova-gpu
  Cc: Alexandre Courbot, linux-kernel, Simona Vetter, Alice Ryhl,
	David Airlie, Danilo Krummrich, Lyude Paul

>From clippy:

  error: this `if` can be collapsed into the outer `match`
     --> drivers/gpu/nova-core/vbios.rs:328:21
      |
  328 | /                     if pci_at_image.is_none() {
  329 | |                         pci_at_image = Some(PciAtBiosImage::try_from(image)?);
  330 | |                     }
      | |_____________________^
      |

There should be no functional changes in this patch.

Signed-off-by: Lyude Paul <lyude@redhat.com>
---
 drivers/gpu/nova-core/vbios.rs | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/nova-core/vbios.rs b/drivers/gpu/nova-core/vbios.rs
index c0bc1008ed752..d38d7f138b49d 100644
--- a/drivers/gpu/nova-core/vbios.rs
+++ b/drivers/gpu/nova-core/vbios.rs
@@ -323,11 +323,9 @@ pub(crate) fn new(dev: &device::Device, bar0: &Bar0) -> Result<Vbios> {
 
             // Convert to a specific image type
             match BiosImageType::try_from(image.pcir.code_type) {
-                Ok(BiosImageType::PciAt) => {
+                Ok(BiosImageType::PciAt) if pci_at_image.is_none() => {
                     // Silently ignore any extra PCI-AT images.
-                    if pci_at_image.is_none() {
-                        pci_at_image = Some(PciAtBiosImage::try_from(image)?);
-                    }
+                    pci_at_image = Some(PciAtBiosImage::try_from(image)?);
                 }
                 Ok(BiosImageType::FwSec) => fwsec_section = Some(image.data),
                 _ => {

base-commit: 2cf1840b0fa7637b6731fd554529f8d57ea34c04
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] gpu: nova-core: vbios: Fix clippy error in Vbios::new()
  2026-05-27 17:15 [PATCH] gpu: nova-core: vbios: Fix clippy error in Vbios::new() Lyude Paul
@ 2026-05-28  1:12 ` Alexandre Courbot
  2026-05-28  2:09 ` Claude review: " Claude Code Review Bot
  2026-05-28  2:09 ` Claude Code Review Bot
  2 siblings, 0 replies; 4+ messages in thread
From: Alexandre Courbot @ 2026-05-28  1:12 UTC (permalink / raw)
  To: Lyude Paul
  Cc: dri-devel, nova-gpu, linux-kernel, Simona Vetter, Alice Ryhl,
	David Airlie, Danilo Krummrich

Hi Lyude,

On Thu May 28, 2026 at 2:15 AM JST, Lyude Paul wrote:
> From clippy:
>
>   error: this `if` can be collapsed into the outer `match`
>      --> drivers/gpu/nova-core/vbios.rs:328:21
>       |
>   328 | /                     if pci_at_image.is_none() {
>   329 | |                         pci_at_image = Some(PciAtBiosImage::try_from(image)?);
>   330 | |                     }
>       | |_____________________^
>       |
>
> There should be no functional changes in this patch.
>
> Signed-off-by: Lyude Paul <lyude@redhat.com>
> ---
>  drivers/gpu/nova-core/vbios.rs | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/nova-core/vbios.rs b/drivers/gpu/nova-core/vbios.rs
> index c0bc1008ed752..d38d7f138b49d 100644
> --- a/drivers/gpu/nova-core/vbios.rs
> +++ b/drivers/gpu/nova-core/vbios.rs
> @@ -323,11 +323,9 @@ pub(crate) fn new(dev: &device::Device, bar0: &Bar0) -> Result<Vbios> {
>  
>              // Convert to a specific image type
>              match BiosImageType::try_from(image.pcir.code_type) {
> -                Ok(BiosImageType::PciAt) => {
> +                Ok(BiosImageType::PciAt) if pci_at_image.is_none() => {
>                      // Silently ignore any extra PCI-AT images.
> -                    if pci_at_image.is_none() {
> -                        pci_at_image = Some(PciAtBiosImage::try_from(image)?);
> -                    }
> +                    pci_at_image = Some(PciAtBiosImage::try_from(image)?);
>                  }
>                  Ok(BiosImageType::FwSec) => fwsec_section = Some(image.data),
>                  _ => {

This lint should disappear once -rc3 reaches `drm-rust-next` per [1].

[1] https://lore.kernel.org/all/CANiq72kR0raSG33DgSxMuc-2uMa626dT=-5=ko_HBgmeOrCFZA@mail.gmail.com/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Claude review: gpu: nova-core: vbios: Fix clippy error in Vbios::new()
  2026-05-27 17:15 [PATCH] gpu: nova-core: vbios: Fix clippy error in Vbios::new() Lyude Paul
  2026-05-28  1:12 ` Alexandre Courbot
@ 2026-05-28  2:09 ` Claude Code Review Bot
  2026-05-28  2:09 ` Claude Code Review Bot
  2 siblings, 0 replies; 4+ messages in thread
From: Claude Code Review Bot @ 2026-05-28  2:09 UTC (permalink / raw)
  To: dri-devel-reviews

Overall Series Review

Subject: gpu: nova-core: vbios: Fix clippy error in Vbios::new()
Author: Lyude Paul <lyude@redhat.com>
Patches: 2
Reviewed: 2026-05-28T12:09:53.398378

---

This is a single-patch series from Lyude Paul fixing a clippy lint (`collapsible_match`) in the nova-core VBIOS parser. The fix moves a guard condition from an `if` inside a match arm body into a match guard on the arm itself. The change is straightforward and correct — the behavior is preserved because a failed match guard in Rust falls through to subsequent arms, and the catch-all `_ =>` arm is a no-op that simply ignores unrecognized image types.

**Verdict: Looks good.** Minor nit on comment placement below.

---
Generated by Claude Code Patch Reviewer

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Claude review: gpu: nova-core: vbios: Fix clippy error in Vbios::new()
  2026-05-27 17:15 [PATCH] gpu: nova-core: vbios: Fix clippy error in Vbios::new() Lyude Paul
  2026-05-28  1:12 ` Alexandre Courbot
  2026-05-28  2:09 ` Claude review: " Claude Code Review Bot
@ 2026-05-28  2:09 ` Claude Code Review Bot
  2 siblings, 0 replies; 4+ messages in thread
From: Claude Code Review Bot @ 2026-05-28  2:09 UTC (permalink / raw)
  To: dri-devel-reviews

Patch Review

**Correctness: OK**

The transformation is sound. Before the patch:

```rust
Ok(BiosImageType::PciAt) => {
    if pci_at_image.is_none() {
        pci_at_image = Some(PciAtBiosImage::try_from(image)?);
    }
}
```

When `pci_at_image.is_some()`, the arm body runs but skips the assignment — effectively a no-op.

After the patch:

```rust
Ok(BiosImageType::PciAt) if pci_at_image.is_none() => {
    pci_at_image = Some(PciAtBiosImage::try_from(image)?);
}
```

When `pci_at_image.is_some()`, the match guard fails, Rust continues pattern matching, `Ok(BiosImageType::FwSec)` doesn't match (the code_type is PciAt), and execution falls through to `_ =>` which is a no-op. Behavior is identical.

**Minor nit — comment placement:**

```rust
Ok(BiosImageType::PciAt) if pci_at_image.is_none() => {
    // Silently ignore any extra PCI-AT images.
    pci_at_image = Some(PciAtBiosImage::try_from(image)?);
}
```

The comment "Silently ignore any extra PCI-AT images" now sits inside the arm that only fires for the *first* PCI-AT image (where we actually *process* it, not ignore it). The ignoring now happens implicitly via fall-through to `_ =>`. The comment still makes sense as explaining *why* the guard exists, but it could be slightly misleading to a reader who interprets it as describing what this arm body does. Consider moving it above the match arm:

```rust
// Silently ignore any extra PCI-AT images.
Ok(BiosImageType::PciAt) if pci_at_image.is_none() => {
    pci_at_image = Some(PciAtBiosImage::try_from(image)?);
}
```

This is a very minor style nit and not worth blocking the patch over.

**No other issues.** The patch does what it says — no functional change, just collapsing the `if` into a match guard to satisfy clippy.

---
Generated by Claude Code Patch Reviewer

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-05-28  2:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-27 17:15 [PATCH] gpu: nova-core: vbios: Fix clippy error in Vbios::new() Lyude Paul
2026-05-28  1:12 ` Alexandre Courbot
2026-05-28  2:09 ` Claude review: " Claude Code Review Bot
2026-05-28  2:09 ` Claude Code Review Bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox