public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
* [PATCH] drm/nouveau: fix misleading indentation
@ 2026-03-13  6:32 Joey Pabalinas
  2026-03-13 21:24 ` Claude review: " Claude Code Review Bot
  2026-03-13 21:24 ` Claude Code Review Bot
  0 siblings, 2 replies; 3+ messages in thread
From: Joey Pabalinas @ 2026-03-13  6:32 UTC (permalink / raw)
  To: nouveau
  Cc: linux-kernel, dri-devel, Lyude Paul, Danilo Krummrich,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, Joey Pabalinas

[-- Attachment #1: Type: text/plain, Size: 3359 bytes --]

Fix misleading indentation in if/else statements.

Signed-off-by: Joey Pabalinas <joeypabalinas@gmail.com>
---
 drivers/gpu/drm/nouveau/nouveau_abi16.c | 49 ++++++++++++-------------
 1 file changed, 24 insertions(+), 25 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_abi16.c b/drivers/gpu/drm/nouveau/nouveau_abi16.c
index f9201f2e73a339a10b..3da75aa136d04faf3b 100644
--- a/drivers/gpu/drm/nouveau/nouveau_abi16.c
+++ b/drivers/gpu/drm/nouveau/nouveau_abi16.c
@@ -425,14 +425,14 @@ nouveau_abi16_ioctl_channel_alloc(ABI16_IOCTL_ARGS)
 
 	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;
 
 	if (device->info.family < NV_DEVICE_INFO_V0_CELSIUS) {
 		init->subchan[0].handle = 0x00000000;
 		init->subchan[0].grclass = 0x0000;
 		init->subchan[1].handle = chan->chan->nvsw.handle;
@@ -579,21 +579,20 @@ nouveau_abi16_ioctl_grobj_alloc(ABI16_IOCTL_ARGS)
 				oclass = sclass[i].oclass;
 				break;
 			}
 		}
 	} else
-	if ((init->class & 0x00ff) == 0x00b3) { /* msppp */
-		/* msppp: compatibility with incorrect version exposure */
-		for (i = 0; i < ret; i++) {
-			if ((sclass[i].oclass & 0x00ff) == 0x00b3) {
-				oclass = sclass[i].oclass;
-				break;
+		if ((init->class & 0x00ff) == 0x00b3) { /* msppp */
+			/* msppp: compatibility with incorrect version exposure */
+			for (i = 0; i < ret; i++) {
+				if ((sclass[i].oclass & 0x00ff) == 0x00b3) {
+					oclass = sclass[i].oclass;
+					break;
+				}
 			}
-		}
-	} else {
-		oclass = init->class;
-	}
+		} else
+			oclass = init->class;
 
 	nvif_object_sclass_put(&sclass);
 	if (!oclass)
 		return nouveau_abi16_put(abi16, -EINVAL);
 
@@ -652,21 +651,21 @@ nouveau_abi16_ioctl_notifierobj_alloc(ABI16_IOCTL_ARGS)
 		args.target = NV_DMA_V0_TARGET_VM;
 		args.access = NV_DMA_V0_ACCESS_VM;
 		args.start += chan->ntfy_vma->addr;
 		args.limit += chan->ntfy_vma->addr;
 	} else
-	if (drm->agp.bridge) {
-		args.target = NV_DMA_V0_TARGET_AGP;
-		args.access = NV_DMA_V0_ACCESS_RDWR;
-		args.start += drm->agp.base + chan->ntfy->offset;
-		args.limit += drm->agp.base + chan->ntfy->offset;
-	} else {
-		args.target = NV_DMA_V0_TARGET_VM;
-		args.access = NV_DMA_V0_ACCESS_RDWR;
-		args.start += chan->ntfy->offset;
-		args.limit += chan->ntfy->offset;
-	}
+		if (drm->agp.bridge) {
+			args.target = NV_DMA_V0_TARGET_AGP;
+			args.access = NV_DMA_V0_ACCESS_RDWR;
+			args.start += drm->agp.base + chan->ntfy->offset;
+			args.limit += drm->agp.base + chan->ntfy->offset;
+		} else {
+			args.target = NV_DMA_V0_TARGET_VM;
+			args.access = NV_DMA_V0_ACCESS_RDWR;
+			args.start += chan->ntfy->offset;
+			args.limit += chan->ntfy->offset;
+		}
 
 	ret = nvif_object_ctor(&chan->chan->user, "abi16Ntfy", info->handle,
 			       NV_DMA_IN_MEMORY, &args, sizeof(args),
 			       &ntfy->object);
 	if (ret)
-- 
Cheers,
Joey Pabalinas


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 870 bytes --]

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

* Claude review: drm/nouveau: fix misleading indentation
  2026-03-13  6:32 [PATCH] drm/nouveau: fix misleading indentation Joey Pabalinas
@ 2026-03-13 21:24 ` Claude Code Review Bot
  2026-03-13 21:24 ` Claude Code Review Bot
  1 sibling, 0 replies; 3+ messages in thread
From: Claude Code Review Bot @ 2026-03-13 21:24 UTC (permalink / raw)
  To: dri-devel-reviews

Overall Series Review

Subject: drm/nouveau: fix misleading indentation
Author: Joey Pabalinas <joeypabalinas@gmail.com>
Patches: 1
Reviewed: 2026-03-14T07:24:31.945133

---

**NAK — This patch introduces functional regressions by changing code semantics.**

The patch claims to "fix misleading indentation" but the original indentation was **intentional and correct**. The existing code uses a well-known (if unusual) kernel coding pattern: `else\nif (...)` as a continuation of an if/else-if chain at the same logical nesting level. The patch misinterprets this as "misleading indentation" and re-indents the `else` branches to be nested inside the preceding `else`, which **changes the logical structure of the code** in at least one case.

---
Generated by Claude Code Patch Reviewer

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

* Claude review: drm/nouveau: fix misleading indentation
  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
  1 sibling, 0 replies; 3+ messages in thread
From: Claude Code Review Bot @ 2026-03-13 21:24 UTC (permalink / raw)
  To: dri-devel-reviews

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

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

end of thread, other threads:[~2026-03-13 21:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox