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/radeon: avoid printing NULL strings
Date: Sat, 16 May 2026 09:25:35 +1000	[thread overview]
Message-ID: <review-patch1-20260515091054.529610-1-arnd@kernel.org> (raw)
In-Reply-To: <20260515091054.529610-1-arnd@kernel.org>

Patch Review

**Correctness: The fix works but changes behavior.**

The sub-functions (`evergreen_surface_check_1d`, `evergreen_surface_check_2d`, `evergreen_surface_check_linear_aligned`) all use `prefix` in two ways:

1. As a **gate** for printing: `if (prefix) { dev_warn(...); }` — when `prefix` is NULL, the warning message is suppressed entirely.
2. As a **string** in the format: `%s ... prefix`.

By changing `NULL` to `""`, the patch silences the compiler warning but also changes the runtime semantics: previously, these call sites would **silently return -EINVAL** on validation failure (since `if (prefix)` is false for NULL). Now, `if (prefix)` evaluates to true for `""` (it's a non-NULL pointer), so the `dev_warn()` messages **will fire** on validation errors.

```c
// In evergreen_surface_check_1d (line 238):
if ((surf->nbx & (palign - 1))) {
    if (prefix) {   // <-- was skipped when NULL, now enters with ""
        dev_warn(p->dev, "%s:%d %s pitch %d invalid ...",
                 __func__, __LINE__, prefix, ...);
    }
    return -EINVAL;
}
```

The three affected call sites are at:
- **Line 597** (`evergreen_cs_track_validate_stencil`): This is followed by a retry path with `"stencil"` prefix, so emitting an extra warning before the retry is mildly noisy but not harmful.
- **Line 826** (`evergreen_cs_track_validate_texture`): This call is used only to compute alignment (`surf.halign`), and the return value is ignored — so the warning path is never reached in practice. No behavioral change.
- **Line 889** (`evergreen_cs_track_validate_texture`, mipmap path): Similar to line 597 — the return value is discarded (`evergreen_surface_check(p, &surf, "")` with no `r =`), so warnings would fire but the error is silently swallowed. No functional change, but new log noise is possible.

Additionally, `evergreen_surface_check` itself has a `default` case at **line 315** that uses `prefix` in a `dev_warn` **without** the `if (prefix)` guard:

```c
default:
    dev_warn(p->dev, "%s:%d %s invalid array mode %d\n",
             __func__, __LINE__, prefix, surf->mode);
```

This is the actual path gcc is warning about — and the fix correctly addresses it since `""` is safe to print via `%s`.

**Verdict:** The patch is **correct for the stated purpose** (fixing the build warning) and is practically harmless in the radeon driver (this is legacy command-submission validation code for old userspace). The behavioral nuance of enabling previously-suppressed `dev_warn` messages is unlikely to matter in practice, but it's worth the author/maintainer being aware of it. An alternative would be to add `if (prefix)` guards to the `default` case in `evergreen_surface_check()` (line 315) so that the NULL-means-silent convention is preserved. That said, the current approach is simpler and this is frozen legacy code, so the pragmatic fix is reasonable.

**Reviewed-by assessment:** Acceptable for merge as-is. The Fixes tag correctly references the commit that introduced these call sites.

---
Generated by Claude Code Patch Reviewer

      parent reply	other threads:[~2026-05-15 23:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-15  9:10 [PATCH] drm/radeon: avoid printing NULL strings Arnd Bergmann
2026-05-15 23:25 ` Claude review: " Claude Code Review Bot
2026-05-15 23:25 ` 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-20260515091054.529610-1-arnd@kernel.org \
    --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