public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
* [PATCH] drm/amd/display: Fix a benign uninitialized variable warning
@ 2026-03-10 15:46 Calvin Owens
  2026-03-11  3:10 ` Claude review: " Claude Code Review Bot
  2026-03-11  3:10 ` Claude Code Review Bot
  0 siblings, 2 replies; 3+ messages in thread
From: Calvin Owens @ 2026-03-10 15:46 UTC (permalink / raw)
  To: linux-kernel
  Cc: dri-devel, amd-gfx, Harry Wentland, Leo Li, Rodrigo Siqueira,
	Alex Deucher, Christian Koenig, David Airlie, Simona Vetter

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


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

end of thread, other threads:[~2026-03-11  3:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-10 15:46 [PATCH] drm/amd/display: Fix a benign uninitialized variable warning Calvin Owens
2026-03-11  3:10 ` Claude review: " Claude Code Review Bot
2026-03-11  3:10 ` 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