drm/amdgpu: remove the redundant null check

Submitted by zhong jiang on Sept. 3, 2019, 6:15 a.m.

Details

Message ID 1567491305-18320-1-git-send-email-zhongjiang@huawei.com
State Accepted
Commit 2032324682c1ca563e33c56e51d9ae17a2b38105
Headers show
Series "drm/amdgpu: remove the redundant null check" ( rev: 1 ) in AMD X.Org drivers

Not browsing as part of any series.

Commit Message

zhong jiang Sept. 3, 2019, 6:15 a.m.
debugfs_remove and kfree has taken the null check in account.
hence it is unnecessary to check it. Just remove the condition.
No functional change.

Signed-off-by: zhong jiang <zhongjiang@huawei.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
index 5652cc7..cb94627 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
@@ -1077,8 +1077,7 @@  static int amdgpu_debugfs_ib_preempt(void *data, u64 val)
 
 	ttm_bo_unlock_delayed_workqueue(&adev->mman.bdev, resched);
 
-	if (fences)
-		kfree(fences);
+	kfree(fences);
 
 	return 0;
 }
@@ -1103,8 +1102,7 @@  int amdgpu_debugfs_init(struct amdgpu_device *adev)
 
 void amdgpu_debugfs_preempt_cleanup(struct amdgpu_device *adev)
 {
-	if (adev->debugfs_preempt)
-		debugfs_remove(adev->debugfs_preempt);
+	debugfs_remove(adev->debugfs_preempt);
 }
 
 #else

Comments

> debugfs_remove and kfree has taken the null check in account.
> hence it is unnecessary to check it. Just remove the condition.

How do you think about a wording like the following?

  The functions “debugfs_remove” and “kfree” tolerate the passing
  of null pointers. Hence it is unnecessary to check such arguments
  around the calls. Thus remove the extra condition check at two places.


> No functional change.

I find this information questionable while it is partly reasonable
according to the shown software refactoring.

Can a subject like “[PATCH] drm/amdgpu: Remove two redundant
null pointer checks” be nicer here?


Were any source code analysis tools involved for finding
these update candidates?

Regards,
Markus
>> Were any source code analysis tools involved for finding
>> these update candidates?
> With the help of Coccinelle. You can find out some example in scripts/coccinelle/.

Thanks for such background information.
Was the script “ifnullfree.cocci” applied here?

Will it be helpful to add attribution for such tools
to any more descriptions in your patches?

Regards,
Markus
On 2019/9/5 16:38, Markus Elfring wrote:
>>> Were any source code analysis tools involved for finding
>>> these update candidates?
>> With the help of Coccinelle. You can find out some example in scripts/coccinelle/.
> Thanks for such background information.
> Was the script “ifnullfree.cocci” applied here?
Yep
> Will it be helpful to add attribution for such tools
> to any more descriptions in your patches?
Sometimes, I will add the description in my patches. Not always.

Thanks,
zhong jiang
> Regards,
> Markus
>
> .
>
On Fri, Sep 6, 2019 at 3:01 AM zhong jiang <zhongjiang@huawei.com> wrote:
>
> On 2019/9/5 16:38, Markus Elfring wrote:
> >>> Were any source code analysis tools involved for finding
> >>> these update candidates?
> >> With the help of Coccinelle. You can find out some example in scripts/coccinelle/.
> > Thanks for such background information.
> > Was the script “ifnullfree.cocci” applied here?
> Yep
> > Will it be helpful to add attribution for such tools
> > to any more descriptions in your patches?
> Sometimes, I will add the description in my patches. Not always.

Applied with some minor tweaks to the commit message.

Thanks!

Alex

>
> Thanks,
> zhong jiang
> > Regards,
> > Markus
> >
> > .
> >
>
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel