Skip to contentSkip to conversation

drm/amd/display: Remove pointless NULL checks in dmub_psr_copy_settings

PATCH Applied Nathan Chancellor 3 participants 3 messages Mar 2, 2020 – Mar 4, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amd/display: Remove pointless NULL checks in dmub_psr_copy_settings

Clang warns:

drivers/gpu/drm/amd/amdgpu/../display/dc/dce/dmub_psr.c:147:31: warning:
address of 'pipe_ctx->plane_res' will always evaluate to 'true' [-Wpointer-bool-conversion]

        if (!pipe_ctx || !&pipe_ctx->plane_res || !&pipe_ctx->stream_res)
                         ~ ~~~~~~~~~~^~~~~~~~~
drivers/gpu/drm/amd/amdgpu/../display/dc/dce/dmub_psr.c:147:56: warning:
address of 'pipe_ctx->stream_res' will always evaluate to 'true'
[-Wpointer-bool-conversion]
        if (!pipe_ctx || !&pipe_ctx->plane_res || !&pipe_ctx->stream_res)
                                                  ~ ~~~~~~~~~~^~~~~~~~~~

2 warnings generated.

As long as pipe_ctx is not NULL, the address of members in this struct cannot be NULL, which means these checks will always evaluate to false.

Fixes 4c1a1335dfe0 ("drm/amd/display: Driverside changes to support PSR in DMCUB")
---
 drivers/gpu/drm/amd/display/dc/dce/dmub_psr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/dce/dmub_psr.c +1 -1
index 2c932c29f1f9..a9e1c01e9d9b 100644
@@ -144,7 +144,7 @@ static bool dmub_psr_copy_settings(struct dmub_psr *dmub,
 		}
 	}
 
-	if (!pipe_ctx || !&pipe_ctx->plane_res || !&pipe_ctx->stream_res)
+	if (!pipe_ctx)
 		return false;
 
 	// First, set the psr version
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 13 lines · Nathan Chancellor

Clang warns:

drivers/gpu/drm/amd/amdgpu/../display/dc/dce/dmub_psr.c:147:31: warning:
address of 'pipe_ctx->plane_res' will always evaluate to 'true' [-Wpointer-bool-conversion]

        if (!pipe_ctx || !&pipe_ctx->plane_res || !&pipe_ctx->stream_res)
                         ~ ~~~~~~~~~~^~~~~~~~~
drivers/gpu/drm/amd/amdgpu/../display/dc/dce/dmub_psr.c:147:56: warning:
address of 'pipe_ctx->stream_res' will always evaluate to 'true'
[-Wpointer-bool-conversion]
        if (!pipe_ctx || !&pipe_ctx->plane_res || !&pipe_ctx->stream_res)
                                                  ~ ~~~~~~~~~~^~~~~~~~~~
Quoted 8 lines

2 warnings generated.

As long as pipe_ctx is not NULL, the address of members in this struct cannot be NULL, which means these checks will always evaluate to false.

Fixes 4c1a1335dfe0 ("drm/amd/display: Driverside changes to support PSR in DMCUB")

Indeed, they are not pointers, and no members within struct plane_resource or struct stream_resource seem to indicate that they are somehow invalid. Good job sleuthing out the correct fixes by tag.

Quoted 20 lines
---
 drivers/gpu/drm/amd/display/dc/dce/dmub_psr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/dce/dmub_psr.c +1 -2
index 2c932c29f1f9..a9e1c01e9d9b 100644
@@ -144,7 +144,7 @@ static bool dmub_psr_copy_settings(struct dmub_psr *dmub,
                }
        }
 
-       if (!pipe_ctx || !&pipe_ctx->plane_res || !&pipe_ctx->stream_res)
+       if (!pipe_ctx)
                return false;
 
        // First, set the psr version
--

2.25.1

Signature · 2 lines
Thanks,
~Nick Desaulniers
Applied
#2 lore raw
In reply to Nathan Chancellor
Quoted 13 lines · Nathan Chancellor

Clang warns:

drivers/gpu/drm/amd/amdgpu/../display/dc/dce/dmub_psr.c:147:31: warning:
address of 'pipe_ctx->plane_res' will always evaluate to 'true' [-Wpointer-bool-conversion]

        if (!pipe_ctx || !&pipe_ctx->plane_res || !&pipe_ctx->stream_res)
                         ~ ~~~~~~~~~~^~~~~~~~~
drivers/gpu/drm/amd/amdgpu/../display/dc/dce/dmub_psr.c:147:56: warning:
address of 'pipe_ctx->stream_res' will always evaluate to 'true'
[-Wpointer-bool-conversion]
        if (!pipe_ctx || !&pipe_ctx->plane_res || !&pipe_ctx->stream_res)
                                                  ~ ~~~~~~~~~~^~~~~~~~~~
Quoted 8 lines

2 warnings generated.

As long as pipe_ctx is not NULL, the address of members in this struct cannot be NULL, which means these checks will always evaluate to false.

Fixes 4c1a1335dfe0 ("drm/amd/display: Driverside changes to support PSR in DMCUB")

Applied. Thanks!

Alex

Quoted 20 lines
---
 drivers/gpu/drm/amd/display/dc/dce/dmub_psr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/dce/dmub_psr.c +1 -2
index 2c932c29f1f9..a9e1c01e9d9b 100644
@@ -144,7 +144,7 @@ static bool dmub_psr_copy_settings(struct dmub_psr *dmub,
                }
        }
 
-       if (!pipe_ctx || !&pipe_ctx->plane_res || !&pipe_ctx->stream_res)
+       if (!pipe_ctx)
                return false;
 
        // First, set the psr version
--

2.25.1

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx