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/amd/display: Fix a benign uninitialized variable warning
Date: Wed, 11 Mar 2026 13:10:19 +1000	[thread overview]
Message-ID: <review-patch1-6aaf2cf4bd19363a85f35e649685d7bdae400253.1773157137.git.calvin@wbinvd.org> (raw)
In-Reply-To: <6aaf2cf4bd19363a85f35e649685d7bdae400253.1773157137.git.calvin@wbinvd.org>

Patch Review

**Status: Looks good**

The original code was:

```c
adev->dm.cached_state = drm_atomic_helper_suspend(adev_to_drm(adev));
if (IS_ERR(adev->dm.cached_state)) {
    r = PTR_ERR(adev->dm.cached_state);
    adev->dm.cached_state = NULL;
}

return adev->dm.cached_state ? 0 : r;
```

GCC correctly identifies that if `drm_atomic_helper_suspend()` returns a valid (non-NULL, non-ERR) pointer, the `IS_ERR` branch is not taken and `r` remains uninitialized — yet the final `return` expression `adev->dm.cached_state ? 0 : r` would use `r` if `cached_state` were NULL. In practice this path is unreachable (a valid pointer is not NULL), but the compiler can't prove that.

The fix replaces this with:

```c
r = PTR_ERR_OR_ZERO(adev->dm.cached_state);
if (r)
    adev->dm.cached_state = NULL;

return r;
```

This is logically equivalent and cleaner:
- `PTR_ERR_OR_ZERO()` returns 0 for valid pointers and the error code for `IS_ERR` pointers, so `r` is always initialized.
- The `if (r)` branch correctly NULLs out the cached state on error.
- `return r` returns 0 on success, the negative error code on failure — same behavior as before.

**Minor observations:**
- The commit message is well-written and honest about the cosmetic nature of the fix.
- The `int r` declaration could now be combined with initialization (`int r = PTR_ERR_OR_ZERO(...)`) to further simplify, but keeping the declaration separate is fine and matches kernel style in this file.
- No functional change, no risk of regression.

**Reviewed-by worthy.**

---
Generated by Claude Code Patch Reviewer

  reply	other threads:[~2026-03-11  3:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-10 15:46 [PATCH] drm/amd/display: Fix a benign uninitialized variable warning Calvin Owens
2026-03-11  3:10 ` Claude Code Review Bot [this message]
2026-03-11  3:10 ` Claude review: " Claude Code Review Bot

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-6aaf2cf4bd19363a85f35e649685d7bdae400253.1773157137.git.calvin@wbinvd.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