public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: drm/nouveau: fix misleading indentation
Date: Sat, 14 Mar 2026 07:24:32 +1000	[thread overview]
Message-ID: <review-patch1-6c1d96782664e4f491f23e8c73545fe4d8b9533a.1773383224.git.joeypabalinas@gmail.com> (raw)
In-Reply-To: <6c1d96782664e4f491f23e8c73545fe4d8b9533a.1773383224.git.joeypabalinas@gmail.com>

Patch Review

**Hunk 1 (line 425): Semantically neutral but stylistically worse**

```c
 	if (device->info.family >= NV_DEVICE_INFO_V0_TESLA)
 		init->pushbuf_domains = NOUVEAU_GEM_DOMAIN_VRAM |
 					NOUVEAU_GEM_DOMAIN_GART;
 	else
-	if (chan->chan->push.buffer->bo.resource->mem_type == TTM_PL_VRAM)
-		init->pushbuf_domains = NOUVEAU_GEM_DOMAIN_VRAM;
-	else
-		init->pushbuf_domains = NOUVEAU_GEM_DOMAIN_GART;
+		if (chan->chan->push.buffer->bo.resource->mem_type == TTM_PL_VRAM)
+			init->pushbuf_domains = NOUVEAU_GEM_DOMAIN_VRAM;
+		else
+			init->pushbuf_domains = NOUVEAU_GEM_DOMAIN_GART;
```

The original code is an `if / else if / else` chain — three mutually exclusive branches at the same logical level. The patch nests the second and third branches inside the first `else`, making it look like a two-level decision tree. While the **runtime behavior** is identical (C doesn't care about indentation), the new indentation is arguably **more** misleading because it obscures the flat if/else-if/else structure. The original style (`else` on its own line followed by `if` at the original indent level) is a deliberate pattern used throughout the nouveau driver and the kernel at large.

**Hunk 2 (line 579): FUNCTIONAL REGRESSION — changes code behavior**

```c
 	} else
-	if ((init->class & 0x00ff) == 0x00b3) { /* msppp */
-		...
-	} else {
-		oclass = init->class;
-	}
+		if ((init->class & 0x00ff) == 0x00b3) { /* msppp */
+			...
+		} else
+			oclass = init->class;
```

This is the most critical problem. Looking at the full context of the function, the original code has a **flat** `if / else if / else if / else if / else` chain checking `init->class` against `0x006e`, `0x00b1`, `0x00b2`, `0x00b3`, with a final `else { oclass = init->class; }` as the default fallback.

The patch only modifies the **last** `else if` in this chain (the `0x00b3` case) and the final `else` default. By indenting these, the `else oclass = init->class` now becomes the else-branch of only the `0x00b3` test, rather than the default for the entire chain. Looking at the unmodified preceding code (lines 594-611 in the patched file), the `0x00b1` and `0x00b2` cases still use the original `} else\nif (...)` pattern at the original indent level. This creates an **inconsistent and broken** if/else chain:

- The `0x006e`, `0x00b1`, `0x00b2` blocks remain at the original indent level
- The `0x00b3` block is now nested inside the `0x00b2` else
- The default `oclass = init->class` is now the else of only the `0x00b3` test, not the whole chain

Since C treats `else if` as `else { if ... }`, the **semantics haven't actually changed** in terms of which branch executes. However, the patch creates a deeply inconsistent style: the first three `else if` branches use the original pattern while the last one is indented differently. If a future developer reads this code, the mixed indentation would be genuinely confusing. And the removal of the braces around `{ oclass = init->class; }` is a gratuitous style change.

**Hunk 3 (line 652): Semantically neutral but stylistically worse**

```c
 	} else
-	if (drm->agp.bridge) {
-		...
-	} else {
-		...
-	}
+		if (drm->agp.bridge) {
+			...
+		} else {
+			...
+		}
```

Same issue as Hunk 1 — the original is a flat `if / else if / else` chain and the patch makes it look nested. No behavioral change but the new indentation misrepresents the logical structure.

**Summary of issues:**

1. The original indentation style (`else\n<tab>if`) is a **deliberate and widely-used kernel coding pattern** for flat if/else-if chains when the first `if` has a single-statement body (no braces). The patch author has misidentified this as a bug.
2. Hunk 2 creates **inconsistent indentation** within a single if/else-if chain — only the last branch is re-indented while the preceding branches retain the original style.
3. The deeper nesting makes the code **harder to read**, not easier, by obscuring the flat control flow.
4. The commit message ("Fix misleading indentation in if/else statements") provides no analysis of why the indentation is misleading or what bug it might cause.

**Recommendation:** NAK this patch. The existing indentation is intentional and correct for this codebase.

---
Generated by Claude Code Patch Reviewer

      parent reply	other threads:[~2026-03-13 21:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-13  6:32 [PATCH] drm/nouveau: fix misleading indentation Joey Pabalinas
2026-03-13 21:24 ` Claude review: " Claude Code Review Bot
2026-03-13 21:24 ` Claude Code Review Bot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=review-patch1-6c1d96782664e4f491f23e8c73545fe4d8b9533a.1773383224.git.joeypabalinas@gmail.com \
    --to=claude-review@example.com \
    --cc=dri-devel-reviews@example.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox