* [PATCH] drm/amd/amdkfd: Drop unnecessary NULL check after container_of
@ 2021-05-21 15:02 Guenter Roeck
2021-05-21 21:00 ` Alex Deucher
2021-05-21 22:08 ` Felix Kuehling
0 siblings, 2 replies; 3+ messages in thread
From: Guenter Roeck @ 2021-05-21 15:02 UTC (permalink / raw)
To: Felix Kuehling
Cc: David Airlie, linux-kernel, dri-devel, amd-gfx, Alex Deucher,
Christian König, 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 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
...+>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
drivers/gpu/drm/amd/amdkfd/kfd_process.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
index 5b6c5669c03d..2f8d352e0069 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
@@ -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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/amd/amdkfd: Drop unnecessary NULL check after container_of
2021-05-21 15:02 [PATCH] drm/amd/amdkfd: Drop unnecessary NULL check after container_of Guenter Roeck
@ 2021-05-21 21:00 ` Alex Deucher
2021-05-21 22:08 ` Felix Kuehling
1 sibling, 0 replies; 3+ messages in thread
From: Alex Deucher @ 2021-05-21 21:00 UTC (permalink / raw)
To: Guenter Roeck
Cc: David Airlie, Felix Kuehling, LKML, amd-gfx list,
Maling list - DRI developers, Alex Deucher, Christian König
Applied. Thanks!
Alex
On Fri, May 21, 2021 at 11:02 AM Guenter Roeck <linux@roeck-us.net> wrote:
>
> 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
> ...+>
>
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> ---
> drivers/gpu/drm/amd/amdkfd/kfd_process.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
> index 5b6c5669c03d..2f8d352e0069 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
> @@ -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
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/amd/amdkfd: Drop unnecessary NULL check after container_of
2021-05-21 15:02 [PATCH] drm/amd/amdkfd: Drop unnecessary NULL check after container_of Guenter Roeck
2021-05-21 21:00 ` Alex Deucher
@ 2021-05-21 22:08 ` Felix Kuehling
1 sibling, 0 replies; 3+ messages in thread
From: Felix Kuehling @ 2021-05-21 22:08 UTC (permalink / raw)
To: Guenter Roeck
Cc: David Airlie, linux-kernel, dri-devel, amd-gfx, Alex Deucher,
Christian König
Am 2021-05-21 um 11:02 a.m. schrieb 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 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
> ...+>
>
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
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
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
> ---
> drivers/gpu/drm/amd/amdkfd/kfd_process.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
> index 5b6c5669c03d..2f8d352e0069 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
> @@ -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)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-05-21 22:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-21 15:02 [PATCH] drm/amd/amdkfd: Drop unnecessary NULL check after container_of Guenter Roeck
2021-05-21 21:00 ` Alex Deucher
2021-05-21 22:08 ` Felix Kuehling
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).