public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
* [PATCH] drm/radeon: avoid printing NULL strings
@ 2026-05-15  9:10 Arnd Bergmann
  2026-05-15 23:25 ` Claude review: " Claude Code Review Bot
  2026-05-15 23:25 ` Claude Code Review Bot
  0 siblings, 2 replies; 3+ messages in thread
From: Arnd Bergmann @ 2026-05-15  9:10 UTC (permalink / raw)
  To: Alex Deucher, Christian König, David Airlie, Simona Vetter,
	Dave Airlie, Jerome Glisse
  Cc: Arnd Bergmann, Chris Down, Borislav Petkov (AMD), amd-gfx,
	dri-devel, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>

gcc-10 warns about some printf format strings that are used to
unconditionally print a NULL string pointer from some call
sites:

In function 'evergreen_surface_check',
    inlined from 'evergreen_cs_track_validate_stencil' at drivers/gpu/drm/radeon/evergreen_cs.c:592:6,
    inlined from 'evergreen_cs_track_check' at drivers/gpu/drm/radeon/evergreen_cs.c:995:8:
include/linux/dev_printk.h:156:24: error: '%s' directive argument is null [-Werror=format-overflow=]
  156 |  dev_printk_index_wrap(_dev_warn, KERN_WARNING, dev, dev_fmt(fmt), ##__VA_ARGS__)

This is harmless here because the kernel prints them as "(null)", but
still breaks the build when compiling with -Werror.

Pass empty strings instead to avoid these warnings.

Fixes: 285484e2d55e ("drm/radeon: add support for evergreen/ni tiling informations v11")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/gpu/drm/radeon/evergreen_cs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/radeon/evergreen_cs.c b/drivers/gpu/drm/radeon/evergreen_cs.c
index daaeae6ba141..550e8f35c7d2 100644
--- a/drivers/gpu/drm/radeon/evergreen_cs.c
+++ b/drivers/gpu/drm/radeon/evergreen_cs.c
@@ -589,7 +589,7 @@ static int evergreen_cs_track_validate_stencil(struct radeon_cs_parser *p)
 		return r;
 	}
 
-	r = evergreen_surface_check(p, &surf, NULL);
+	r = evergreen_surface_check(p, &surf, "");
 	if (r) {
 		/* old userspace doesn't compute proper depth/stencil alignment
 		 * check that alignment against a bigger byte per elements and
@@ -818,7 +818,7 @@ static int evergreen_cs_track_validate_texture(struct radeon_cs_parser *p,
 	}
 
 	/* align height */
-	evergreen_surface_check(p, &surf, NULL);
+	evergreen_surface_check(p, &surf, "");
 	surf.nby = ALIGN(surf.nby, surf.halign);
 
 	r = evergreen_surface_check(p, &surf, "texture");
@@ -881,7 +881,7 @@ static int evergreen_cs_track_validate_texture(struct radeon_cs_parser *p,
 				surf.mode = ARRAY_1D_TILED_THIN1;
 			}
 			/* recompute alignment */
-			evergreen_surface_check(p, &surf, NULL);
+			evergreen_surface_check(p, &surf, "");
 			break;
 		case ARRAY_LINEAR_GENERAL:
 		case ARRAY_LINEAR_ALIGNED:
-- 
2.39.5


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

* Claude review: drm/radeon: avoid printing NULL strings
  2026-05-15  9:10 [PATCH] drm/radeon: avoid printing NULL strings Arnd Bergmann
@ 2026-05-15 23:25 ` Claude Code Review Bot
  2026-05-15 23:25 ` Claude Code Review Bot
  1 sibling, 0 replies; 3+ messages in thread
From: Claude Code Review Bot @ 2026-05-15 23:25 UTC (permalink / raw)
  To: dri-devel-reviews

Overall Series Review

Subject: drm/radeon: avoid printing NULL strings
Author: Arnd Bergmann <arnd@kernel.org>
Patches: 1
Reviewed: 2026-05-16T09:25:34.687919

---

This is a single-patch fix from Arnd Bergmann addressing a `-Wformat-overflow` warning from gcc-10. The compiler detects that `evergreen_surface_check()` is called with a `NULL` third argument (`prefix`), and that `prefix` is used in `dev_warn()` `%s` format strings, triggering a build failure with `-Werror`.

The fix is correct and minimal — it replaces `NULL` with `""` at the three call sites. However, there is a subtle **behavioral change** worth noting.

---
Generated by Claude Code Patch Reviewer

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

* Claude review: drm/radeon: avoid printing NULL strings
  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
  1 sibling, 0 replies; 3+ messages in thread
From: Claude Code Review Bot @ 2026-05-15 23:25 UTC (permalink / raw)
  To: dri-devel-reviews

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

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

end of thread, other threads:[~2026-05-15 23:25 UTC | newest]

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