linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] Remove redundant NULL checks.
@ 2013-02-12  4:01 Cyril Roelandt
  2013-02-12  4:01 ` [PATCH 1/5] radeon: Remove redundant NULL check before radeon_i2c_destroy() Cyril Roelandt
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Cyril Roelandt @ 2013-02-12  4:01 UTC (permalink / raw)
  To: linux-kernel, kernel-janitors; +Cc: Cyril Roelandt

Remove redundant NULL checks before calls to functions that are equivalent to a
no-op when run on a NULL pointer.

These patches were generated by the following semantic patch, and manually
reviewed:

<smpl>
@r@
identifier noop_func;
identifier param;
type T;
@@
noop_func (T *param) {
	...
	if (!param) return;
	...
}

@@
identifier r.noop_func;
expression E;
statement S;
@@
(
- if (E) noop_func(E);
+ noop_func(E);
|
- if (E) { noop_func(E); E = NULL; }
+ noop_func(E);
+ E = NULL;
)
</smpl>

Regards,
Cyril Roelandt
---

Cyril Roelandt (5):
  radeon: Remove redundant NULL check before radeon_i2c_destroy().
  iommu: remove redundant NULL check before dma_ops_domain_free().
  staging: dgrp: remove redundant NULL check before
    unregister_dgrp_device().
  staging: tidspbridge: remove redundant NULL check before
    delete_msg_mgr().
  xen: remove redundant NULL check before unregister_and_remove_pcpu().

 drivers/gpu/drm/radeon/radeon_i2c.c       |    6 ++----
 drivers/iommu/amd_iommu.c                 |    3 +--
 drivers/staging/dgrp/dgrp_specproc.c      |    9 +++------
 drivers/staging/tidspbridge/core/msg_sm.c |    3 +--
 drivers/xen/pcpu.c                        |    3 +--
 5 files changed, 8 insertions(+), 16 deletions(-)

-- 
1.7.10.4


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/5] radeon: Remove redundant NULL check before radeon_i2c_destroy().
  2013-02-12  4:01 [PATCH 0/5] Remove redundant NULL checks Cyril Roelandt
@ 2013-02-12  4:01 ` Cyril Roelandt
  2013-02-12  4:01 ` [PATCH 2/5] iommu: remove redundant NULL check before dma_ops_domain_free() Cyril Roelandt
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Cyril Roelandt @ 2013-02-12  4:01 UTC (permalink / raw)
  To: linux-kernel, kernel-janitors
  Cc: Cyril Roelandt, airlied, alexander.deucher, paulmck, dhowells,
	mattst88, dri-devel

radeon_i2c_destroy on a NULL pointer is a no-op.

Signed-off-by: Cyril Roelandt <tipecaml@gmail.com>
---
 drivers/gpu/drm/radeon/radeon_i2c.c |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_i2c.c b/drivers/gpu/drm/radeon/radeon_i2c.c
index fc60b74..850df44 100644
--- a/drivers/gpu/drm/radeon/radeon_i2c.c
+++ b/drivers/gpu/drm/radeon/radeon_i2c.c
@@ -1032,10 +1032,8 @@ void radeon_i2c_fini(struct radeon_device *rdev)
 	int i;
 
 	for (i = 0; i < RADEON_MAX_I2C_BUS; i++) {
-		if (rdev->i2c_bus[i]) {
-			radeon_i2c_destroy(rdev->i2c_bus[i]);
-			rdev->i2c_bus[i] = NULL;
-		}
+		radeon_i2c_destroy(rdev->i2c_bus[i]);
+		rdev->i2c_bus[i] = NULL;
 	}
 }
 
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/5] iommu: remove redundant NULL check before dma_ops_domain_free().
  2013-02-12  4:01 [PATCH 0/5] Remove redundant NULL checks Cyril Roelandt
  2013-02-12  4:01 ` [PATCH 1/5] radeon: Remove redundant NULL check before radeon_i2c_destroy() Cyril Roelandt
@ 2013-02-12  4:01 ` Cyril Roelandt
  2013-02-13 11:13   ` Joerg Roedel
  2013-02-12  4:01 ` [PATCH 3/5] staging: dgrp: remove redundant NULL check before unregister_dgrp_device() Cyril Roelandt
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 7+ messages in thread
From: Cyril Roelandt @ 2013-02-12  4:01 UTC (permalink / raw)
  To: linux-kernel, kernel-janitors; +Cc: Cyril Roelandt, joro, iommu

dma_ops_domain_free on a NULL pointer is a no-op, so the NULL check in
amd_iommu_init_dma_ops() can be removed.

Signed-off-by: Cyril Roelandt <tipecaml@gmail.com>
---
 drivers/iommu/amd_iommu.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index d33eaaf..98f555d 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -3187,8 +3187,7 @@ int __init amd_iommu_init_dma_ops(void)
 free_domains:
 
 	for_each_iommu(iommu) {
-		if (iommu->default_dom)
-			dma_ops_domain_free(iommu->default_dom);
+		dma_ops_domain_free(iommu->default_dom);
 	}
 
 	return ret;
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/5] staging: dgrp: remove redundant NULL check before unregister_dgrp_device().
  2013-02-12  4:01 [PATCH 0/5] Remove redundant NULL checks Cyril Roelandt
  2013-02-12  4:01 ` [PATCH 1/5] radeon: Remove redundant NULL check before radeon_i2c_destroy() Cyril Roelandt
  2013-02-12  4:01 ` [PATCH 2/5] iommu: remove redundant NULL check before dma_ops_domain_free() Cyril Roelandt
@ 2013-02-12  4:01 ` Cyril Roelandt
  2013-02-12  4:01 ` [PATCH 4/5] staging: tidspbridge: remove redundant NULL check before delete_msg_mgr() Cyril Roelandt
  2013-02-12  4:01 ` [PATCH 5/5] xen: remove redundant NULL check before unregister_and_remove_pcpu() Cyril Roelandt
  4 siblings, 0 replies; 7+ messages in thread
From: Cyril Roelandt @ 2013-02-12  4:01 UTC (permalink / raw)
  To: linux-kernel, kernel-janitors
  Cc: Cyril Roelandt, gregkh, wfp5p, tt.rantala, jslaby, sfr, devel


unregister_dgrp_device on a NULL pointer is a no-op, so the NULL checks in
dgrp_remove_nd() can be removed.

Signed-off-by: Cyril Roelandt <tipecaml@gmail.com>
---
 drivers/staging/dgrp/dgrp_specproc.c |    9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/dgrp/dgrp_specproc.c b/drivers/staging/dgrp/dgrp_specproc.c
index dfdaede..13c7ccf 100644
--- a/drivers/staging/dgrp/dgrp_specproc.c
+++ b/drivers/staging/dgrp/dgrp_specproc.c
@@ -777,14 +777,11 @@ static int dgrp_remove_nd(struct nd_struct *nd)
 		dgrp_remove_node_class_sysfs_files(nd);
 	}
 
-	if (nd->nd_mon_de)
-		unregister_dgrp_device(nd->nd_mon_de);
+	unregister_dgrp_device(nd->nd_mon_de);
 
-	if (nd->nd_ports_de)
-		unregister_dgrp_device(nd->nd_ports_de);
+	unregister_dgrp_device(nd->nd_ports_de);
 
-	if (nd->nd_dpa_de)
-		unregister_dgrp_device(nd->nd_dpa_de);
+	unregister_dgrp_device(nd->nd_dpa_de);
 
 	dgrp_tty_uninit(nd);
 
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 4/5] staging: tidspbridge: remove redundant NULL check before delete_msg_mgr().
  2013-02-12  4:01 [PATCH 0/5] Remove redundant NULL checks Cyril Roelandt
                   ` (2 preceding siblings ...)
  2013-02-12  4:01 ` [PATCH 3/5] staging: dgrp: remove redundant NULL check before unregister_dgrp_device() Cyril Roelandt
@ 2013-02-12  4:01 ` Cyril Roelandt
  2013-02-12  4:01 ` [PATCH 5/5] xen: remove redundant NULL check before unregister_and_remove_pcpu() Cyril Roelandt
  4 siblings, 0 replies; 7+ messages in thread
From: Cyril Roelandt @ 2013-02-12  4:01 UTC (permalink / raw)
  To: linux-kernel, kernel-janitors; +Cc: Cyril Roelandt, omar.ramirez, gregkh, devel


delete_msg_mgr on a NULL pointer is a no-op, so the NULL check in
bridge_msg_delete can be removed.

Signed-off-by: Cyril Roelandt <tipecaml@gmail.com>
---
 drivers/staging/tidspbridge/core/msg_sm.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/tidspbridge/core/msg_sm.c b/drivers/staging/tidspbridge/core/msg_sm.c
index ce9557e..7b517eb 100644
--- a/drivers/staging/tidspbridge/core/msg_sm.c
+++ b/drivers/staging/tidspbridge/core/msg_sm.c
@@ -198,8 +198,7 @@ out_err:
  */
 void bridge_msg_delete(struct msg_mgr *hmsg_mgr)
 {
-	if (hmsg_mgr)
-		delete_msg_mgr(hmsg_mgr);
+	delete_msg_mgr(hmsg_mgr);
 }
 
 /*
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 5/5] xen: remove redundant NULL check before unregister_and_remove_pcpu().
  2013-02-12  4:01 [PATCH 0/5] Remove redundant NULL checks Cyril Roelandt
                   ` (3 preceding siblings ...)
  2013-02-12  4:01 ` [PATCH 4/5] staging: tidspbridge: remove redundant NULL check before delete_msg_mgr() Cyril Roelandt
@ 2013-02-12  4:01 ` Cyril Roelandt
  4 siblings, 0 replies; 7+ messages in thread
From: Cyril Roelandt @ 2013-02-12  4:01 UTC (permalink / raw)
  To: linux-kernel, kernel-janitors
  Cc: Cyril Roelandt, konrad.wilk, jeremy, xen-devel, virtualization

unregister_and_remove_pcpu on a NULL pointer is a no-op, so the NULL check in
sync_pcpu can be removed.

Signed-off-by: Cyril Roelandt <tipecaml@gmail.com>
---
 drivers/xen/pcpu.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/xen/pcpu.c b/drivers/xen/pcpu.c
index 067fcfa..5a27a45 100644
--- a/drivers/xen/pcpu.c
+++ b/drivers/xen/pcpu.c
@@ -278,8 +278,7 @@ static int sync_pcpu(uint32_t cpu, uint32_t *max_cpu)
 	 * Only those at cpu present map has its sys interface.
 	 */
 	if (info->flags & XEN_PCPU_FLAGS_INVALID) {
-		if (pcpu)
-			unregister_and_remove_pcpu(pcpu);
+		unregister_and_remove_pcpu(pcpu);
 		return 0;
 	}
 
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/5] iommu: remove redundant NULL check before dma_ops_domain_free().
  2013-02-12  4:01 ` [PATCH 2/5] iommu: remove redundant NULL check before dma_ops_domain_free() Cyril Roelandt
@ 2013-02-13 11:13   ` Joerg Roedel
  0 siblings, 0 replies; 7+ messages in thread
From: Joerg Roedel @ 2013-02-13 11:13 UTC (permalink / raw)
  To: Cyril Roelandt; +Cc: linux-kernel, kernel-janitors, iommu

On Tue, Feb 12, 2013 at 05:01:50AM +0100, Cyril Roelandt wrote:
> dma_ops_domain_free on a NULL pointer is a no-op, so the NULL check in
> amd_iommu_init_dma_ops() can be removed.
> 
> Signed-off-by: Cyril Roelandt <tipecaml@gmail.com>
> ---
>  drivers/iommu/amd_iommu.c |    3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)

Applied to x86/amd, Thanks.



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-02-13 11:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-12  4:01 [PATCH 0/5] Remove redundant NULL checks Cyril Roelandt
2013-02-12  4:01 ` [PATCH 1/5] radeon: Remove redundant NULL check before radeon_i2c_destroy() Cyril Roelandt
2013-02-12  4:01 ` [PATCH 2/5] iommu: remove redundant NULL check before dma_ops_domain_free() Cyril Roelandt
2013-02-13 11:13   ` Joerg Roedel
2013-02-12  4:01 ` [PATCH 3/5] staging: dgrp: remove redundant NULL check before unregister_dgrp_device() Cyril Roelandt
2013-02-12  4:01 ` [PATCH 4/5] staging: tidspbridge: remove redundant NULL check before delete_msg_mgr() Cyril Roelandt
2013-02-12  4:01 ` [PATCH 5/5] xen: remove redundant NULL check before unregister_and_remove_pcpu() Cyril Roelandt

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).