public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
From: Calvin Owens <calvin@wbinvd.org>
To: linux-kernel@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org,
	Harry Wentland <harry.wentland@amd.com>,
	Leo Li <sunpeng.li@amd.com>,
	Rodrigo Siqueira <siqueira@igalia.com>,
	Alex Deucher <alexander.deucher@amd.com>,
	Christian Koenig <christian.koenig@amd.com>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>
Subject: [PATCH] drm/amd/display: Fix a benign uninitialized variable warning
Date: Tue, 10 Mar 2026 08:46:06 -0700	[thread overview]
Message-ID: <6aaf2cf4bd19363a85f35e649685d7bdae400253.1773157137.git.calvin@wbinvd.org> (raw)

This warning shows up with GCC at W=2:

    drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:3229:32: warning: ‘r’ may be used uninitialized [-Wmaybe-uninitialized]
     3229 |                         return r;
          |                                ^
    drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:3133:13: note: ‘r’ was declared here
     3133 |         int r;
          |             ^

The compiler can't know drm_atomic_helper_suspend() doesn't return NULL,
so GCC is technically correct, that case would return `r` uninitialized.

Fix the warning by using PTR_ERR_OR_ZERO() on the return value from
drm_atomic_helper_suspend() like i915 does.

Signed-off-by: Calvin Owens <calvin@wbinvd.org>
---
This is pretty nitpicky and obviously benign IMO, I just happened to
spot it while debugging [1]. No argument from me if you don't want it :)

[1] https://lore.kernel.org/lkml/ef7266eb7802ce6d68ebd9356477e9671f0c94e0.1773116305.git.calvin@wbinvd.org/#t

 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index b3d6f2cd8ab6..9c5dce8d38b6 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -3133,12 +3133,11 @@ static int dm_cache_state(struct amdgpu_device *adev)
 	int r;
 
 	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);
+	r = PTR_ERR_OR_ZERO(adev->dm.cached_state);
+	if (r)
 		adev->dm.cached_state = NULL;
-	}
 
-	return adev->dm.cached_state ? 0 : r;
+	return r;
 }
 
 static void dm_destroy_cached_state(struct amdgpu_device *adev)
-- 
2.47.3


             reply	other threads:[~2026-03-10 15:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-10 15:46 Calvin Owens [this message]
2026-03-11  3:10 ` Claude review: drm/amd/display: Fix a benign uninitialized variable warning Claude Code Review Bot
2026-03-11  3:10 ` 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=6aaf2cf4bd19363a85f35e649685d7bdae400253.1773157137.git.calvin@wbinvd.org \
    --to=calvin@wbinvd.org \
    --cc=airlied@gmail.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=harry.wentland@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=simona@ffwll.ch \
    --cc=siqueira@igalia.com \
    --cc=sunpeng.li@amd.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