If you are convinced that dropping the null tests is a good idea, then you can submit the patch that makes the change to the relevant maintainers and mailing lists.
Would you like to integrate the following proposal into your source code repository?
Regards, Markus
From 29e61d5ccc44cd5e5961acff61b6938e0705044d Mon Sep 17 00:00:00 2001
From: Markus Elfring elfring@users.sourceforge.net Date: Wed, 22 Oct 2014 15:45:22 +0200 Subject: [PATCH] GPU-DRM-nouveau: Deletion of unnecessary checks before two function calls
A semantic patch approach was proposed with the subject "[PATCH with Coccinelle?] Deletion of unnecessary checks before specific function calls" on 2014-03-05. https://lkml.org/lkml/2014/3/5/344 http://article.gmane.org/gmane.comp.version-control.coccinelle/3513/
This patch pattern application was repeated with the help of the software "Coccinelle 1.0.0-rc22" on the source files for Linux 3.17.1. An extract of the automatically generated update suggestions is shown here.
It was determined that the affected source code places call functions which perform input parameter validation already. It is therefore not needed that a similar safety check is repeated at the call site.
Signed-off-by: Markus Elfring elfring@users.sourceforge.net --- drivers/gpu/drm/nouveau/core/core/handle.c | 3 +-- drivers/gpu/drm/nouveau/nouveau_drm.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/nouveau/core/core/handle.c b/drivers/gpu/drm/nouveau/core/core/handle.c index a490b80..75d0c2c 100644 --- a/drivers/gpu/drm/nouveau/core/core/handle.c +++ b/drivers/gpu/drm/nouveau/core/core/handle.c @@ -219,8 +219,7 @@ nouveau_handle_get_cinst(struct nouveau_object *engctx, u32 cinst) void nouveau_handle_put(struct nouveau_handle *handle) { - if (handle) - nouveau_namedb_put(handle); + nouveau_namedb_put(handle); }
int diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c index 5723807..5c29079 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.c +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c @@ -512,8 +512,7 @@ nouveau_drm_unload(struct drm_device *dev) nouveau_vga_fini(drm);
nvif_device_fini(&drm->device); - if (drm->hdmi_device) - pci_dev_put(drm->hdmi_device); + pci_dev_put(drm->hdmi_device); nouveau_cli_destroy(&drm->client); return 0; }
From: Markus Elfring elfring@users.sourceforge.net Date: Sun, 5 Jul 2015 20:15:12 +0200
The functions nvkm_namedb_put() and pci_dev_put() test whether their argument is NULL and then return immediately. Thus the test around the calls is not needed.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring elfring@users.sourceforge.net --- drivers/gpu/drm/nouveau/nouveau_drm.c | 3 +-- drivers/gpu/drm/nouveau/nvkm/core/handle.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c index 36b40c9..8ca3d0c 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.c +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c @@ -515,8 +515,7 @@ nouveau_drm_unload(struct drm_device *dev) nouveau_vga_fini(drm);
nvif_device_fini(&drm->device); - if (drm->hdmi_device) - pci_dev_put(drm->hdmi_device); + pci_dev_put(drm->hdmi_device); nouveau_cli_destroy(&drm->client); return 0; } diff --git a/drivers/gpu/drm/nouveau/nvkm/core/handle.c b/drivers/gpu/drm/nouveau/nvkm/core/handle.c index dc7ff10..165f3ff 100644 --- a/drivers/gpu/drm/nouveau/nvkm/core/handle.c +++ b/drivers/gpu/drm/nouveau/nvkm/core/handle.c @@ -216,6 +216,5 @@ nvkm_handle_get_cinst(struct nvkm_object *engctx, u32 cinst) void nvkm_handle_put(struct nvkm_handle *handle) { - if (handle) - nvkm_namedb_put(handle); + nvkm_namedb_put(handle); }
From: Markus Elfring elfring@users.sourceforge.net Date: Wed, 20 Jul 2016 19:43:27 +0200
The pci_dev_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring elfring@users.sourceforge.net --- drivers/gpu/drm/nouveau/nouveau_drm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c index 66c1280..7b09841 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.c +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c @@ -525,8 +525,7 @@ nouveau_drm_unload(struct drm_device *dev) nouveau_vga_fini(drm);
nvif_device_fini(&drm->device); - if (drm->hdmi_device) - pci_dev_put(drm->hdmi_device); + pci_dev_put(drm->hdmi_device); nouveau_cli_destroy(&drm->client); return 0; }
dri-devel@lists.freedesktop.org