drm/amd/amdkfd: Drop unnecessary NULL check after container_of
Subsystems (3)
PATCH 1/1 drm/amd/amdkfd: Drop unnecessary NULL check after container_of
The first parameter passed to container_of() is the pointer to the work structure passed to the worker and never NULL. The NULL check on the result of container_of() is therefore unnecessary and misleading. Remove it.
This change was made automatically with the following Coccinelle script.
@@
type t;
identifier v;
statement s;
@@
<+...
(
t v = container_of(...);
|
v = container_of(...);
)
...
when != v
- if (\( !v \| v == NULL \) ) s
...+>
--- drivers/gpu/drm/amd/amdkfd/kfd_process.c | 2 -- 1 file changed, 2 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_process.c +0 -2
@@ -110,8 +110,6 @@ static void kfd_sdma_activity_worker(struct work_struct *work) workarea = container_of(work, struct kfd_sdma_activity_handler_workarea, sdma_activity_work); -if (!workarea) -return ; pdd = workarea->pdd;if (!pdd)
Signature · 1 line
2.25.1
Alex Deucher
AppliedApplied. Thanks!
Alex
Quoted 46 lines · Guenter Roeck
The first parameter passed to
container_of()is the pointer to the work structure passed to the worker and never NULL. The NULL check on the result ofcontainer_of()is therefore unnecessary and misleading. Remove it.This change was made automatically with the following Coccinelle script.
@@
type t;
identifier v;
statement s;
@@<+...
(
t v =container_of(...);
|
v =container_of(...);
)
...
when != v
- if (\( !v \| v == NULL \) ) s
...+>Signed-off-by Guenter Roeck <[email protected]>--- drivers/gpu/drm/amd/amdkfd/kfd_process.c | 2 -- 1 file changed, 2 deletions(-)drivers/gpu/drm/amd/amdkfd/kfd_process.c +0
-3@@ -110,8 +110,6 @@ static void kfd_sdma_activity_worker(struct work_struct *work) workarea = container_of(work, struct kfd_sdma_activity_handler_workarea, sdma_activity_work); -if (!workarea) -return ; pdd = workarea->pdd;if (!pdd) --2.25.1
Am 2021-05-21 um 11:02 a.m. schrieb Guenter Roeck:
Quoted 24 lines
The first parameter passed to
container_of()is the pointer to the work structure passed to the worker and never NULL. The NULL check on the result ofcontainer_of()is therefore unnecessary and misleading. Remove it.This change was made automatically with the following Coccinelle script.
@@
type t;
identifier v;
statement s;
@@<+...
(
t v =container_of(...);
|
v =container_of(...);
)
...
when != v
- if (\( !v \| v == NULL \) ) s
...+>
Quoted 1 line
Signed-off-by Guenter Roeck <[email protected]>
Thank you. The patch looks good to me. I caught a few such pointless checks in code review but must have missed this one. I'll apply your patch to amd-staging-drm-next. The patch is
Quoted 17 lines
--- drivers/gpu/drm/amd/amdkfd/kfd_process.c | 2 -- 1 file changed, 2 deletions(-)drivers/gpu/drm/amd/amdkfd/kfd_process.c +0
-2@@ -110,8 +110,6 @@ static void kfd_sdma_activity_worker(struct work_struct *work) workarea = container_of(work, struct kfd_sdma_activity_handler_workarea, sdma_activity_work); -if (!workarea) -return ; pdd = workarea->pdd;if (!pdd)