linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] [media] DVB-frontends: Deletion of a few unnecessary checks
       [not found]                               ` <5317A59D.4@users.sourceforge.net>
@ 2014-11-20  8:19                                 ` SF Markus Elfring
  2014-11-20  8:29                                   ` [PATCH 2/3] [media] m88ds3103: One function call less in m88ds3103_init() after error detection SF Markus Elfring
                                                     ` (2 more replies)
  2014-11-20  9:55                                 ` [PATCH 1/1] [media] firewire: Deletion of an unnecessary check before the function call "dvb_unregister_device" SF Markus Elfring
                                                   ` (22 subsequent siblings)
  23 siblings, 3 replies; 43+ messages in thread
From: SF Markus Elfring @ 2014-11-20  8:19 UTC (permalink / raw)
  To: Antti Palosaari, Mauro Carvalho Chehab, linux-media
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 23:30:37 +0100

Another update suggestion was taken into account after a patch was applied
from static source code analysis.

Markus Elfring (3):
  DVB-frontends: Deletion of unnecessary checks before the function
    call "release_firmware"
  m88ds3103: One function call less in m88ds3103_init() after error detection
  si2168: One function call less in si2168_init() after error detection

 drivers/media/dvb-frontends/drx39xyj/drxj.c |  3 +--
 drivers/media/dvb-frontends/drxk_hard.c     |  3 +--
 drivers/media/dvb-frontends/m88ds3103.c     | 12 ++++++------
 drivers/media/dvb-frontends/si2168.c        | 10 +++++-----
 4 files changed, 13 insertions(+), 15 deletions(-)

-- 
2.1.3


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

* [PATCH 2/3] [media] m88ds3103: One function call less in m88ds3103_init() after error detection
  2014-11-20  8:19                                 ` [PATCH 0/3] [media] DVB-frontends: Deletion of a few unnecessary checks SF Markus Elfring
@ 2014-11-20  8:29                                   ` SF Markus Elfring
  2014-11-20  8:33                                   ` [PATCH 1/3] [media] DVB-frontends: Deletion of unnecessary checks before the function call "release_firmware" SF Markus Elfring
  2014-11-20  8:39                                   ` [PATCH 3/3] [media] si2168: One function call less in si2168_init() after error detection SF Markus Elfring
  2 siblings, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2014-11-20  8:29 UTC (permalink / raw)
  To: Antti Palosaari, Mauro Carvalho Chehab, linux-media
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 23:20:51 +0100

The release_firmware() function was called in some cases by the
m88ds3103_init() function during error handling even if the passed variable
contained still a null pointer. This implementation detail could be improved
by the introduction of another jump label.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/dvb-frontends/m88ds3103.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/media/dvb-frontends/m88ds3103.c b/drivers/media/dvb-frontends/m88ds3103.c
index e88f0f6..82da715 100644
--- a/drivers/media/dvb-frontends/m88ds3103.c
+++ b/drivers/media/dvb-frontends/m88ds3103.c
@@ -590,7 +590,7 @@ static int m88ds3103_init(struct dvb_frontend *fe)
 
 	ret = m88ds3103_wr_reg(priv, 0xb2, 0x01);
 	if (ret)
-		goto err;
+		goto error_fw_release;
 
 	for (remaining = fw->size; remaining > 0;
 			remaining -= (priv->cfg->i2c_wr_max - 1)) {
@@ -604,13 +604,13 @@ static int m88ds3103_init(struct dvb_frontend *fe)
 			dev_err(&priv->i2c->dev,
 					"%s: firmware download failed=%d\n",
 					KBUILD_MODNAME, ret);
-			goto err;
+			goto error_fw_release;
 		}
 	}
 
 	ret = m88ds3103_wr_reg(priv, 0xb2, 0x00);
 	if (ret)
-		goto err;
+		goto error_fw_release;
 
 	release_firmware(fw);
 	fw = NULL;
@@ -636,9 +636,10 @@ skip_fw_download:
 	priv->warm = true;
 
 	return 0;
-err:
-	release_firmware(fw);
 
+error_fw_release:
+	release_firmware(fw);
+err:
 	dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret);
 	return ret;
 }
-- 
2.1.3


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

* [PATCH 1/3] [media] DVB-frontends: Deletion of unnecessary checks before the function call "release_firmware"
  2014-11-20  8:19                                 ` [PATCH 0/3] [media] DVB-frontends: Deletion of a few unnecessary checks SF Markus Elfring
  2014-11-20  8:29                                   ` [PATCH 2/3] [media] m88ds3103: One function call less in m88ds3103_init() after error detection SF Markus Elfring
@ 2014-11-20  8:33                                   ` SF Markus Elfring
  2014-11-20  8:39                                   ` [PATCH 3/3] [media] si2168: One function call less in si2168_init() after error detection SF Markus Elfring
  2 siblings, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2014-11-20  8:33 UTC (permalink / raw)
  To: Antti Palosaari, Mauro Carvalho Chehab, linux-media
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 22:27:24 +0100

The release_firmware() 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/media/dvb-frontends/drx39xyj/drxj.c | 3 +--
 drivers/media/dvb-frontends/drxk_hard.c     | 3 +--
 drivers/media/dvb-frontends/m88ds3103.c     | 3 +--
 drivers/media/dvb-frontends/si2168.c        | 3 +--
 4 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/media/dvb-frontends/drx39xyj/drxj.c b/drivers/media/dvb-frontends/drx39xyj/drxj.c
index 7ca7a21..08e6ca5 100644
--- a/drivers/media/dvb-frontends/drx39xyj/drxj.c
+++ b/drivers/media/dvb-frontends/drx39xyj/drxj.c
@@ -12255,8 +12255,7 @@ static void drx39xxj_release(struct dvb_frontend *fe)
 	kfree(demod->my_ext_attr);
 	kfree(demod->my_common_attr);
 	kfree(demod->my_i2c_dev_addr);
-	if (demod->firmware)
-		release_firmware(demod->firmware);
+	release_firmware(demod->firmware);
 	kfree(demod);
 	kfree(state);
 }
diff --git a/drivers/media/dvb-frontends/drxk_hard.c b/drivers/media/dvb-frontends/drxk_hard.c
index cce94a7..f871478 100644
--- a/drivers/media/dvb-frontends/drxk_hard.c
+++ b/drivers/media/dvb-frontends/drxk_hard.c
@@ -6309,8 +6309,7 @@ static void drxk_release(struct dvb_frontend *fe)
 	struct drxk_state *state = fe->demodulator_priv;
 
 	dprintk(1, "\n");
-	if (state->fw)
-		release_firmware(state->fw);
+	release_firmware(state->fw);
 
 	kfree(state);
 }
diff --git a/drivers/media/dvb-frontends/m88ds3103.c b/drivers/media/dvb-frontends/m88ds3103.c
index dfe0c2f..e88f0f6 100644
--- a/drivers/media/dvb-frontends/m88ds3103.c
+++ b/drivers/media/dvb-frontends/m88ds3103.c
@@ -637,8 +637,7 @@ skip_fw_download:
 
 	return 0;
 err:
-	if (fw)
-		release_firmware(fw);
+	release_firmware(fw);
 
 	dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret);
 	return ret;
diff --git a/drivers/media/dvb-frontends/si2168.c b/drivers/media/dvb-frontends/si2168.c
index 8f81d97..6a455f9 100644
--- a/drivers/media/dvb-frontends/si2168.c
+++ b/drivers/media/dvb-frontends/si2168.c
@@ -469,8 +469,7 @@ static int si2168_init(struct dvb_frontend *fe)
 
 	return 0;
 err:
-	if (fw)
-		release_firmware(fw);
+	release_firmware(fw);
 
 	dev_dbg(&s->client->dev, "%s: failed=%d\n", __func__, ret);
 	return ret;
-- 
2.1.3


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

* [PATCH 3/3] [media] si2168: One function call less in si2168_init() after error detection
  2014-11-20  8:19                                 ` [PATCH 0/3] [media] DVB-frontends: Deletion of a few unnecessary checks SF Markus Elfring
  2014-11-20  8:29                                   ` [PATCH 2/3] [media] m88ds3103: One function call less in m88ds3103_init() after error detection SF Markus Elfring
  2014-11-20  8:33                                   ` [PATCH 1/3] [media] DVB-frontends: Deletion of unnecessary checks before the function call "release_firmware" SF Markus Elfring
@ 2014-11-20  8:39                                   ` SF Markus Elfring
  2 siblings, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2014-11-20  8:39 UTC (permalink / raw)
  To: Antti Palosaari, Mauro Carvalho Chehab, linux-media
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 23:23:15 +0100

The release_firmware() function was called in some cases by the
si2168_init() function during error handling even if the passed variable
contained still a null pointer. This implementation detail could be improved
by the introduction of another jump label.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/dvb-frontends/si2168.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/media/dvb-frontends/si2168.c b/drivers/media/dvb-frontends/si2168.c
index 6a455f9..b8c6372 100644
--- a/drivers/media/dvb-frontends/si2168.c
+++ b/drivers/media/dvb-frontends/si2168.c
@@ -428,7 +428,7 @@ static int si2168_init(struct dvb_frontend *fe)
 			dev_err(&s->client->dev,
 					"%s: firmware file '%s' not found\n",
 					KBUILD_MODNAME, fw_file);
-			goto err;
+			goto error_fw_release;
 		}
 	}
 
@@ -448,7 +448,7 @@ static int si2168_init(struct dvb_frontend *fe)
 			dev_err(&s->client->dev,
 					"%s: firmware download failed=%d\n",
 					KBUILD_MODNAME, ret);
-			goto err;
+			goto error_fw_release;
 		}
 	}
 
@@ -468,9 +468,10 @@ static int si2168_init(struct dvb_frontend *fe)
 	s->active = true;
 
 	return 0;
-err:
-	release_firmware(fw);
 
+error_fw_release:
+	release_firmware(fw);
+err:
 	dev_dbg(&s->client->dev, "%s: failed=%d\n", __func__, ret);
 	return ret;
 }
-- 
2.1.3


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

* [PATCH 1/1] [media] firewire: Deletion of an unnecessary check before the function call "dvb_unregister_device"
       [not found]                               ` <5317A59D.4@users.sourceforge.net>
  2014-11-20  8:19                                 ` [PATCH 0/3] [media] DVB-frontends: Deletion of a few unnecessary checks SF Markus Elfring
@ 2014-11-20  9:55                                 ` SF Markus Elfring
  2014-11-20 14:41                                   ` Stefan Richter
  2014-11-20 10:20                                 ` [PATCH 1/1] [media] i2c: Deletion of an unnecessary check before the function call "rc_unregister_device" SF Markus Elfring
                                                   ` (21 subsequent siblings)
  23 siblings, 1 reply; 43+ messages in thread
From: SF Markus Elfring @ 2014-11-20  9:55 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Stefan Richter, linux-media, linux1394-devel
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 10:49:07 +0100

The dvb_unregister_device() 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/media/firewire/firedtv-ci.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/firewire/firedtv-ci.c b/drivers/media/firewire/firedtv-ci.c
index e5ebdbf..e63f582 100644
--- a/drivers/media/firewire/firedtv-ci.c
+++ b/drivers/media/firewire/firedtv-ci.c
@@ -253,6 +253,5 @@ int fdtv_ca_register(struct firedtv *fdtv)
 
 void fdtv_ca_release(struct firedtv *fdtv)
 {
-	if (fdtv->cadev)
-		dvb_unregister_device(fdtv->cadev);
+	dvb_unregister_device(fdtv->cadev);
 }
-- 
2.1.3


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

* [PATCH 1/1] [media] i2c: Deletion of an unnecessary check before the function call "rc_unregister_device"
       [not found]                               ` <5317A59D.4@users.sourceforge.net>
  2014-11-20  8:19                                 ` [PATCH 0/3] [media] DVB-frontends: Deletion of a few unnecessary checks SF Markus Elfring
  2014-11-20  9:55                                 ` [PATCH 1/1] [media] firewire: Deletion of an unnecessary check before the function call "dvb_unregister_device" SF Markus Elfring
@ 2014-11-20 10:20                                 ` SF Markus Elfring
  2014-11-20 10:50                                 ` [PATCH 1/1] [media] platform: Deletion of unnecessary checks before two function calls SF Markus Elfring
                                                   ` (20 subsequent siblings)
  23 siblings, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2014-11-20 10:20 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, linux-media; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 11:13:16 +0100

The rc_unregister_device() 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/media/i2c/ir-kbd-i2c.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/i2c/ir-kbd-i2c.c b/drivers/media/i2c/ir-kbd-i2c.c
index 8311f1a..175a761 100644
--- a/drivers/media/i2c/ir-kbd-i2c.c
+++ b/drivers/media/i2c/ir-kbd-i2c.c
@@ -464,8 +464,7 @@ static int ir_remove(struct i2c_client *client)
 	cancel_delayed_work_sync(&ir->work);
 
 	/* unregister device */
-	if (ir->rc)
-		rc_unregister_device(ir->rc);
+	rc_unregister_device(ir->rc);
 
 	/* free memory */
 	return 0;
-- 
2.1.3


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

* [PATCH 1/1] [media] platform: Deletion of unnecessary checks before two function calls
       [not found]                               ` <5317A59D.4@users.sourceforge.net>
                                                   ` (2 preceding siblings ...)
  2014-11-20 10:20                                 ` [PATCH 1/1] [media] i2c: Deletion of an unnecessary check before the function call "rc_unregister_device" SF Markus Elfring
@ 2014-11-20 10:50                                 ` SF Markus Elfring
  2014-11-20 12:08                                 ` [PATCH 1/1] [media] rc: " SF Markus Elfring
                                                   ` (19 subsequent siblings)
  23 siblings, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2014-11-20 10:50 UTC (permalink / raw)
  To: Kukjin Kim, Kyungmin Park, Mauro Carvalho Chehab,
	Sylwester Nawrocki, linux-media, linux-arm-kernel
  Cc: linux-samsung-soc, LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 11:44:20 +0100

The functions i2c_put_adapter() and release_firmware() test whether their
argument is NULL and then return 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/media/platform/exynos4-is/fimc-is.c   | 6 ++----
 drivers/media/platform/s3c-camif/camif-core.c | 3 +--
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/media/platform/exynos4-is/fimc-is.c b/drivers/media/platform/exynos4-is/fimc-is.c
index 5476dce..a1db27b 100644
--- a/drivers/media/platform/exynos4-is/fimc-is.c
+++ b/drivers/media/platform/exynos4-is/fimc-is.c
@@ -428,8 +428,7 @@ static void fimc_is_load_firmware(const struct firmware *fw, void *context)
 	 * needed around for copying to the IS working memory every
 	 * time before the Cortex-A5 is restarted.
 	 */
-	if (is->fw.f_w)
-		release_firmware(is->fw.f_w);
+	release_firmware(is->fw.f_w);
 	is->fw.f_w = fw;
 done:
 	mutex_unlock(&is->lock);
@@ -937,8 +936,7 @@ static int fimc_is_remove(struct platform_device *pdev)
 	vb2_dma_contig_cleanup_ctx(is->alloc_ctx);
 	fimc_is_put_clocks(is);
 	fimc_is_debugfs_remove(is);
-	if (is->fw.f_w)
-		release_firmware(is->fw.f_w);
+	release_firmware(is->fw.f_w);
 	fimc_is_free_cpu_memory(is);
 
 	return 0;
diff --git a/drivers/media/platform/s3c-camif/camif-core.c b/drivers/media/platform/s3c-camif/camif-core.c
index b385747..3b09b5b 100644
--- a/drivers/media/platform/s3c-camif/camif-core.c
+++ b/drivers/media/platform/s3c-camif/camif-core.c
@@ -256,8 +256,7 @@ static void camif_unregister_sensor(struct camif_dev *camif)
 	v4l2_device_unregister_subdev(sd);
 	camif->sensor.sd = NULL;
 	i2c_unregister_device(client);
-	if (adapter)
-		i2c_put_adapter(adapter);
+	i2c_put_adapter(adapter);
 }
 
 static int camif_create_media_links(struct camif_dev *camif)
-- 
2.1.3


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

* [PATCH 1/1] [media] rc: Deletion of unnecessary checks before two function calls
       [not found]                               ` <5317A59D.4@users.sourceforge.net>
                                                   ` (3 preceding siblings ...)
  2014-11-20 10:50                                 ` [PATCH 1/1] [media] platform: Deletion of unnecessary checks before two function calls SF Markus Elfring
@ 2014-11-20 12:08                                 ` SF Markus Elfring
  2014-11-20 12:33                                 ` [PATCH 1/1] [media] USB: Deletion of unnecessary checks before three " SF Markus Elfring
                                                   ` (18 subsequent siblings)
  23 siblings, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2014-11-20 12:08 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, linux-media; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 13:01:32 +0100

The functions input_free_device() and rc_close() test whether their argument
is NULL and then return 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/media/rc/lirc_dev.c | 3 +--
 drivers/media/rc/rc-main.c  | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/media/rc/lirc_dev.c b/drivers/media/rc/lirc_dev.c
index dc5cbff..5c232e6 100644
--- a/drivers/media/rc/lirc_dev.c
+++ b/drivers/media/rc/lirc_dev.c
@@ -518,8 +518,7 @@ int lirc_dev_fop_close(struct inode *inode, struct file *file)
 
 	WARN_ON(mutex_lock_killable(&lirc_dev_lock));
 
-	if (ir->d.rdev)
-		rc_close(ir->d.rdev);
+	rc_close(ir->d.rdev);
 
 	ir->open--;
 	if (ir->attached) {
diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
index 8d3b74c..66df9fb 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -1298,8 +1298,7 @@ void rc_free_device(struct rc_dev *dev)
 	if (!dev)
 		return;
 
-	if (dev->input_dev)
-		input_free_device(dev->input_dev);
+	input_free_device(dev->input_dev);
 
 	put_device(&dev->dev);
 
-- 
2.1.3


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

* [PATCH 1/1] [media] USB: Deletion of unnecessary checks before three function calls
       [not found]                               ` <5317A59D.4@users.sourceforge.net>
                                                   ` (4 preceding siblings ...)
  2014-11-20 12:08                                 ` [PATCH 1/1] [media] rc: " SF Markus Elfring
@ 2014-11-20 12:33                                 ` SF Markus Elfring
  2014-11-24 21:40                                 ` [PATCH 1/1] [media] Siano: Deletion of an unnecessary check before the function call "rc_unregister_device" SF Markus Elfring
                                                   ` (17 subsequent siblings)
  23 siblings, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2014-11-20 12:33 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Mike Isely, linux-media
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 13:26:36 +0100

The functions pvr2_hdw_destroy(), rc_unregister_device() and vfree() perform
also input parameter validation. 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/media/usb/au0828/au0828-input.c     | 3 +--
 drivers/media/usb/em28xx/em28xx-input.c     | 3 +--
 drivers/media/usb/pvrusb2/pvrusb2-context.c | 2 +-
 drivers/media/usb/s2255/s2255drv.c          | 3 +--
 4 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/media/usb/au0828/au0828-input.c b/drivers/media/usb/au0828/au0828-input.c
index fd0d3a90..3357141 100644
--- a/drivers/media/usb/au0828/au0828-input.c
+++ b/drivers/media/usb/au0828/au0828-input.c
@@ -353,8 +353,7 @@ void au0828_rc_unregister(struct au0828_dev *dev)
 	if (!ir)
 		return;
 
-	if (ir->rc)
-		rc_unregister_device(ir->rc);
+	rc_unregister_device(ir->rc);
 
 	/* done */
 	kfree(ir);
diff --git a/drivers/media/usb/em28xx/em28xx-input.c b/drivers/media/usb/em28xx/em28xx-input.c
index ed843bd..67a22f4 100644
--- a/drivers/media/usb/em28xx/em28xx-input.c
+++ b/drivers/media/usb/em28xx/em28xx-input.c
@@ -838,8 +838,7 @@ static int em28xx_ir_fini(struct em28xx *dev)
 	if (!ir)
 		goto ref_put;
 
-	if (ir->rc)
-		rc_unregister_device(ir->rc);
+	rc_unregister_device(ir->rc);
 
 	/* done */
 	kfree(ir);
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-context.c b/drivers/media/usb/pvrusb2/pvrusb2-context.c
index 7c19ff7..c8761c7 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-context.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-context.c
@@ -80,7 +80,7 @@ static void pvr2_context_set_notify(struct pvr2_context *mp, int fl)
 static void pvr2_context_destroy(struct pvr2_context *mp)
 {
 	pvr2_trace(PVR2_TRACE_CTXT,"pvr2_context %p (destroy)",mp);
-	if (mp->hdw) pvr2_hdw_destroy(mp->hdw);
+	pvr2_hdw_destroy(mp->hdw);
 	pvr2_context_set_notify(mp, 0);
 	mutex_lock(&pvr2_context_mutex);
 	if (mp->exist_next) {
diff --git a/drivers/media/usb/s2255/s2255drv.c b/drivers/media/usb/s2255/s2255drv.c
index 2c90186..3cab886 100644
--- a/drivers/media/usb/s2255/s2255drv.c
+++ b/drivers/media/usb/s2255/s2255drv.c
@@ -1976,8 +1976,7 @@ static int s2255_release_sys_buffers(struct s2255_vc *vc)
 {
 	unsigned long i;
 	for (i = 0; i < SYS_FRAMES; i++) {
-		if (vc->buffer.frame[i].lpvbits)
-			vfree(vc->buffer.frame[i].lpvbits);
+		vfree(vc->buffer.frame[i].lpvbits);
 		vc->buffer.frame[i].lpvbits = NULL;
 	}
 	return 0;
-- 
2.1.3


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

* Re: [PATCH 1/1] [media] firewire: Deletion of an unnecessary check before the function call "dvb_unregister_device"
  2014-11-20  9:55                                 ` [PATCH 1/1] [media] firewire: Deletion of an unnecessary check before the function call "dvb_unregister_device" SF Markus Elfring
@ 2014-11-20 14:41                                   ` Stefan Richter
  0 siblings, 0 replies; 43+ messages in thread
From: Stefan Richter @ 2014-11-20 14:41 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Mauro Carvalho Chehab, linux-media, linux1394-devel, LKML,
	kernel-janitors, Julia Lawall

On Nov 20 SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 20 Nov 2014 10:49:07 +0100
> 
> The dvb_unregister_device() 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>

Reviewed-by: Stefan Richter <stefanr@s5r6.in-berlin.de>

> ---
>  drivers/media/firewire/firedtv-ci.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/media/firewire/firedtv-ci.c b/drivers/media/firewire/firedtv-ci.c
> index e5ebdbf..e63f582 100644
> --- a/drivers/media/firewire/firedtv-ci.c
> +++ b/drivers/media/firewire/firedtv-ci.c
> @@ -253,6 +253,5 @@ int fdtv_ca_register(struct firedtv *fdtv)
>  
>  void fdtv_ca_release(struct firedtv *fdtv)
>  {
> -	if (fdtv->cadev)
> -		dvb_unregister_device(fdtv->cadev);
> +	dvb_unregister_device(fdtv->cadev);
>  }



-- 
Stefan Richter
-=====-====- =-== =-=--
http://arcgraph.de/sr/

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

* [PATCH 1/1] [media] Siano: Deletion of an unnecessary check before the function call "rc_unregister_device"
       [not found]                               ` <5317A59D.4@users.sourceforge.net>
                                                   ` (5 preceding siblings ...)
  2014-11-20 12:33                                 ` [PATCH 1/1] [media] USB: Deletion of unnecessary checks before three " SF Markus Elfring
@ 2014-11-24 21:40                                 ` SF Markus Elfring
  2014-11-30 20:21                                 ` [PATCH 0/2] [media] tuners: Deletion of two unnecessary checks SF Markus Elfring
                                                   ` (16 subsequent siblings)
  23 siblings, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2014-11-24 21:40 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, linux-media; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 24 Nov 2014 22:32:30 +0100

The rc_unregister_device() 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/media/common/siano/smsir.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/common/siano/smsir.c b/drivers/media/common/siano/smsir.c
index 273043e..35d0e88 100644
--- a/drivers/media/common/siano/smsir.c
+++ b/drivers/media/common/siano/smsir.c
@@ -107,8 +107,7 @@ int sms_ir_init(struct smscore_device_t *coredev)
 
 void sms_ir_exit(struct smscore_device_t *coredev)
 {
-	if (coredev->ir.dev)
-		rc_unregister_device(coredev->ir.dev);
+	rc_unregister_device(coredev->ir.dev);
 
 	sms_log("");
 }
-- 
2.1.3


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

* [PATCH 0/2] [media] tuners: Deletion of two unnecessary checks
       [not found]                               ` <5317A59D.4@users.sourceforge.net>
                                                   ` (6 preceding siblings ...)
  2014-11-24 21:40                                 ` [PATCH 1/1] [media] Siano: Deletion of an unnecessary check before the function call "rc_unregister_device" SF Markus Elfring
@ 2014-11-30 20:21                                 ` SF Markus Elfring
  2014-11-30 20:25                                   ` [PATCH 1/2] [media] tuners: Deletion of unnecessary checks before the function call "release_firmware" SF Markus Elfring
  2014-11-30 20:28                                   ` [PATCH 2/2] [media] tuners-si2157: One function call less in si2157_init() after error detection SF Markus Elfring
  2014-11-30 21:55                                 ` [PATCH 1/1] [media] ddbridge: Deletion of an unnecessary check before the function call "dvb_unregister_device" SF Markus Elfring
                                                   ` (15 subsequent siblings)
  23 siblings, 2 replies; 43+ messages in thread
From: SF Markus Elfring @ 2014-11-30 20:21 UTC (permalink / raw)
  To: Antti Palosaari, Mauro Carvalho Chehab, linux-media
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 30 Nov 2014 20:50:15 +0100

Another update suggestion was taken into account after a patch was applied
from static source code analysis.

Markus Elfring (2):
  Deletion of unnecessary checks before the function call "release_firmware"
  One function call less in si2157_init() after error detection

 drivers/media/tuners/si2157.c | 9 ++++-----
 drivers/media/tuners/xc5000.c | 3 +--
 2 files changed, 5 insertions(+), 7 deletions(-)

-- 
2.1.3


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

* [PATCH 1/2] [media] tuners: Deletion of unnecessary checks before the function call "release_firmware"
  2014-11-30 20:21                                 ` [PATCH 0/2] [media] tuners: Deletion of two unnecessary checks SF Markus Elfring
@ 2014-11-30 20:25                                   ` SF Markus Elfring
  2014-11-30 20:28                                   ` [PATCH 2/2] [media] tuners-si2157: One function call less in si2157_init() after error detection SF Markus Elfring
  1 sibling, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2014-11-30 20:25 UTC (permalink / raw)
  To: Antti Palosaari, Mauro Carvalho Chehab, linux-media
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 30 Nov 2014 19:05:48 +0100

The release_firmware() 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/media/tuners/si2157.c | 3 +--
 drivers/media/tuners/xc5000.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c
index 8e57696..e17ab1f 100644
--- a/drivers/media/tuners/si2157.c
+++ b/drivers/media/tuners/si2157.c
@@ -196,8 +196,7 @@ warm:
 	return 0;
 
 err:
-	if (fw)
-		release_firmware(fw);
+	release_firmware(fw);
 
 	dev_dbg(&s->client->dev, "failed=%d\n", ret);
 	return ret;
diff --git a/drivers/media/tuners/xc5000.c b/drivers/media/tuners/xc5000.c
index 705c258..2a039de 100644
--- a/drivers/media/tuners/xc5000.c
+++ b/drivers/media/tuners/xc5000.c
@@ -1336,8 +1336,7 @@ static int xc5000_release(struct dvb_frontend *fe)
 
 	if (priv) {
 		cancel_delayed_work(&priv->timer_sleep);
-		if (priv->firmware)
-			release_firmware(priv->firmware);
+		release_firmware(priv->firmware);
 		hybrid_tuner_release_state(priv);
 	}
 
-- 
2.1.3


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

* [PATCH 2/2] [media] tuners-si2157: One function call less in si2157_init() after error detection
  2014-11-30 20:21                                 ` [PATCH 0/2] [media] tuners: Deletion of two unnecessary checks SF Markus Elfring
  2014-11-30 20:25                                   ` [PATCH 1/2] [media] tuners: Deletion of unnecessary checks before the function call "release_firmware" SF Markus Elfring
@ 2014-11-30 20:28                                   ` SF Markus Elfring
  1 sibling, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2014-11-30 20:28 UTC (permalink / raw)
  To: Antti Palosaari, Mauro Carvalho Chehab, linux-media
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 30 Nov 2014 20:48:24 +0100

The release_firmware() function was called in some cases by the si2157_init()
function during error handling even if the passed variable contained still
a null pointer. This implementation detail could be improved
by the introduction of another jump label.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/tuners/si2157.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c
index e17ab1f..2180de9 100644
--- a/drivers/media/tuners/si2157.c
+++ b/drivers/media/tuners/si2157.c
@@ -157,7 +157,7 @@ static int si2157_init(struct dvb_frontend *fe)
 		dev_err(&s->client->dev, "firmware file '%s' is invalid\n",
 				fw_file);
 		ret = -EINVAL;
-		goto err;
+		goto fw_release_exit;
 	}
 
 	dev_info(&s->client->dev, "downloading firmware from file '%s'\n",
@@ -173,7 +173,7 @@ static int si2157_init(struct dvb_frontend *fe)
 			dev_err(&s->client->dev,
 					"firmware download failed=%d\n",
 					ret);
-			goto err;
+			goto fw_release_exit;
 		}
 	}
 
@@ -195,9 +195,9 @@ warm:
 	s->active = true;
 	return 0;
 
-err:
+fw_release_exit:
 	release_firmware(fw);
-
+err:
 	dev_dbg(&s->client->dev, "failed=%d\n", ret);
 	return ret;
 }
-- 
2.1.3


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

* [PATCH 1/1] [media] ddbridge: Deletion of an unnecessary check before the function call "dvb_unregister_device"
       [not found]                               ` <5317A59D.4@users.sourceforge.net>
                                                   ` (7 preceding siblings ...)
  2014-11-30 20:21                                 ` [PATCH 0/2] [media] tuners: Deletion of two unnecessary checks SF Markus Elfring
@ 2014-11-30 21:55                                 ` SF Markus Elfring
  2014-11-30 22:23                                 ` [PATCH 1/1] [media] V4L2: Deletion of an unnecessary check before the function call "vb2_put_vma" SF Markus Elfring
                                                   ` (14 subsequent siblings)
  23 siblings, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2014-11-30 21:55 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, linux-media; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 30 Nov 2014 22:50:20 +0100

The dvb_unregister_device() 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/media/pci/ddbridge/ddbridge-core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c b/drivers/media/pci/ddbridge/ddbridge-core.c
index c82e855..9e3492e 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -1118,8 +1118,7 @@ static void ddb_ports_detach(struct ddb *dev)
 			dvb_input_detach(port->input[1]);
 			break;
 		case DDB_PORT_CI:
-			if (port->output->dev)
-				dvb_unregister_device(port->output->dev);
+			dvb_unregister_device(port->output->dev);
 			if (port->en) {
 				ddb_input_stop(port->input[0]);
 				ddb_output_stop(port->output);
-- 
2.1.3


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

* [PATCH 1/1] [media] V4L2: Deletion of an unnecessary check before the function call "vb2_put_vma"
       [not found]                               ` <5317A59D.4@users.sourceforge.net>
                                                   ` (8 preceding siblings ...)
  2014-11-30 21:55                                 ` [PATCH 1/1] [media] ddbridge: Deletion of an unnecessary check before the function call "dvb_unregister_device" SF Markus Elfring
@ 2014-11-30 22:23                                 ` SF Markus Elfring
  2014-12-01  9:46                                   ` Marek Szyprowski
  2014-12-01 18:55                                 ` [PATCH 1/1] [media] lirc_zilog: Deletion of unnecessary checks before the function call "vfree" SF Markus Elfring
                                                   ` (13 subsequent siblings)
  23 siblings, 1 reply; 43+ messages in thread
From: SF Markus Elfring @ 2014-11-30 22:23 UTC (permalink / raw)
  To: Kyungmin Park, Marek Szyprowski, Mauro Carvalho Chehab,
	Pawel Osciak, linux-media
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 30 Nov 2014 23:10:51 +0100

The vb2_put_vma() 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/media/v4l2-core/videobuf2-vmalloc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/v4l2-core/videobuf2-vmalloc.c b/drivers/media/v4l2-core/videobuf2-vmalloc.c
index 3966b12..fba944e 100644
--- a/drivers/media/v4l2-core/videobuf2-vmalloc.c
+++ b/drivers/media/v4l2-core/videobuf2-vmalloc.c
@@ -154,8 +154,7 @@ static void vb2_vmalloc_put_userptr(void *buf_priv)
 		}
 		kfree(buf->pages);
 	} else {
-		if (buf->vma)
-			vb2_put_vma(buf->vma);
+		vb2_put_vma(buf->vma);
 		iounmap(buf->vaddr);
 	}
 	kfree(buf);
-- 
2.1.3


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

* Re: [PATCH 1/1] [media] V4L2: Deletion of an unnecessary check before the function call "vb2_put_vma"
  2014-11-30 22:23                                 ` [PATCH 1/1] [media] V4L2: Deletion of an unnecessary check before the function call "vb2_put_vma" SF Markus Elfring
@ 2014-12-01  9:46                                   ` Marek Szyprowski
  0 siblings, 0 replies; 43+ messages in thread
From: Marek Szyprowski @ 2014-12-01  9:46 UTC (permalink / raw)
  To: SF Markus Elfring, Kyungmin Park, Mauro Carvalho Chehab,
	Pawel Osciak, linux-media
  Cc: LKML, kernel-janitors, Julia Lawall

Hello,

On 2014-11-30 23:23, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 30 Nov 2014 23:10:51 +0100
>
> The vb2_put_vma() 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>

Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>

> ---
>   drivers/media/v4l2-core/videobuf2-vmalloc.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/media/v4l2-core/videobuf2-vmalloc.c b/drivers/media/v4l2-core/videobuf2-vmalloc.c
> index 3966b12..fba944e 100644
> --- a/drivers/media/v4l2-core/videobuf2-vmalloc.c
> +++ b/drivers/media/v4l2-core/videobuf2-vmalloc.c
> @@ -154,8 +154,7 @@ static void vb2_vmalloc_put_userptr(void *buf_priv)
>   		}
>   		kfree(buf->pages);
>   	} else {
> -		if (buf->vma)
> -			vb2_put_vma(buf->vma);
> +		vb2_put_vma(buf->vma);
>   		iounmap(buf->vaddr);
>   	}
>   	kfree(buf);

Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland


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

* [PATCH 1/1] [media] lirc_zilog: Deletion of unnecessary checks before the function call "vfree"
       [not found]                               ` <5317A59D.4@users.sourceforge.net>
                                                   ` (9 preceding siblings ...)
  2014-11-30 22:23                                 ` [PATCH 1/1] [media] V4L2: Deletion of an unnecessary check before the function call "vb2_put_vma" SF Markus Elfring
@ 2014-12-01 18:55                                 ` SF Markus Elfring
  2014-12-01 22:30                                 ` [PATCH 0/2] [media] mn88473: Delete an unnecessary check SF Markus Elfring
                                                   ` (12 subsequent siblings)
  23 siblings, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2014-12-01 18:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jarod Wilson, Mauro Carvalho Chehab,
	linux-media, devel
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 1 Dec 2014 19:49:39 +0100

The vfree() function performs also input parameter validation. 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/staging/media/lirc/lirc_zilog.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/media/lirc/lirc_zilog.c b/drivers/staging/media/lirc/lirc_zilog.c
index 3259aac..50b255a 100644
--- a/drivers/staging/media/lirc/lirc_zilog.c
+++ b/drivers/staging/media/lirc/lirc_zilog.c
@@ -729,11 +729,9 @@ static int send_boot_data(struct IR_tx *tx)
 static void fw_unload_locked(void)
 {
 	if (tx_data) {
-		if (tx_data->code_sets)
-			vfree(tx_data->code_sets);
+		vfree(tx_data->code_sets);
 
-		if (tx_data->datap)
-			vfree(tx_data->datap);
+		vfree(tx_data->datap);
 
 		vfree(tx_data);
 		tx_data = NULL;
-- 
2.1.3


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

* [PATCH 0/2] [media] mn88473: Delete an unnecessary check
       [not found]                               ` <5317A59D.4@users.sourceforge.net>
                                                   ` (10 preceding siblings ...)
  2014-12-01 18:55                                 ` [PATCH 1/1] [media] lirc_zilog: Deletion of unnecessary checks before the function call "vfree" SF Markus Elfring
@ 2014-12-01 22:30                                 ` SF Markus Elfring
  2014-12-01 22:33                                   ` [PATCH 1/2] [media] mn88473: Deletion of an unnecessary check before the function call "release_firmware" SF Markus Elfring
  2014-12-01 22:35                                   ` [PATCH 2/2] [media] mn88473: One function call less in mn88473_init() after error detection SF Markus Elfring
  2015-02-01 19:11                                 ` [PATCH 0/2] [media] mn88472: Delete an unnecessary check SF Markus Elfring
                                                   ` (11 subsequent siblings)
  23 siblings, 2 replies; 43+ messages in thread
From: SF Markus Elfring @ 2014-12-01 22:30 UTC (permalink / raw)
  To: Antti Palosaari, Greg Kroah-Hartman, Mauro Carvalho Chehab,
	devel, linux-media
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 1 Dec 2014 23:16:34 +0100

Another update suggestion was taken into account after a patch was applied
from static source code analysis.

Markus Elfring (2):
  Deletion of an unnecessary check before the function call "release_firmware"
  One function call less in mn88473_init() after error detection

 drivers/staging/media/mn88473/mn88473.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

-- 
2.1.3


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

* [PATCH 1/2] [media] mn88473: Deletion of an unnecessary check before the function call "release_firmware"
  2014-12-01 22:30                                 ` [PATCH 0/2] [media] mn88473: Delete an unnecessary check SF Markus Elfring
@ 2014-12-01 22:33                                   ` SF Markus Elfring
  2014-12-01 22:35                                   ` [PATCH 2/2] [media] mn88473: One function call less in mn88473_init() after error detection SF Markus Elfring
  1 sibling, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2014-12-01 22:33 UTC (permalink / raw)
  To: Antti Palosaari, Greg Kroah-Hartman, Mauro Carvalho Chehab,
	devel, linux-media
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 1 Dec 2014 22:55:29 +0100

The release_firmware() 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/staging/media/mn88473/mn88473.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/media/mn88473/mn88473.c b/drivers/staging/media/mn88473/mn88473.c
index 1659335..52180bb 100644
--- a/drivers/staging/media/mn88473/mn88473.c
+++ b/drivers/staging/media/mn88473/mn88473.c
@@ -262,8 +262,7 @@ static int mn88473_init(struct dvb_frontend *fe)
 
 	return 0;
 err:
-	if (fw)
-		release_firmware(fw);
+	release_firmware(fw);
 
 	dev_dbg(&client->dev, "failed=%d\n", ret);
 	return ret;
-- 
2.1.3


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

* [PATCH 2/2] [media] mn88473: One function call less in mn88473_init() after error detection
  2014-12-01 22:30                                 ` [PATCH 0/2] [media] mn88473: Delete an unnecessary check SF Markus Elfring
  2014-12-01 22:33                                   ` [PATCH 1/2] [media] mn88473: Deletion of an unnecessary check before the function call "release_firmware" SF Markus Elfring
@ 2014-12-01 22:35                                   ` SF Markus Elfring
  1 sibling, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2014-12-01 22:35 UTC (permalink / raw)
  To: Antti Palosaari, Greg Kroah-Hartman, Mauro Carvalho Chehab,
	devel, linux-media
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 1 Dec 2014 23:15:20 +0100

The release_firmware() function was called by the mn88473_init() function even
if a previous function call "request_firmware" failed.
This implementation detail could be improved by the introduction of another
jump label.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/staging/media/mn88473/mn88473.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/media/mn88473/mn88473.c b/drivers/staging/media/mn88473/mn88473.c
index 52180bb..a333744 100644
--- a/drivers/staging/media/mn88473/mn88473.c
+++ b/drivers/staging/media/mn88473/mn88473.c
@@ -225,7 +225,7 @@ static int mn88473_init(struct dvb_frontend *fe)
 	ret = request_firmware(&fw, fw_file, &client->dev);
 	if (ret) {
 		dev_err(&client->dev, "firmare file '%s' not found\n", fw_file);
-		goto err;
+		goto err_request_firmware;
 	}
 
 	dev_info(&client->dev, "downloading firmware from file '%s'\n",
@@ -261,9 +261,10 @@ static int mn88473_init(struct dvb_frontend *fe)
 	dev->warm = true;
 
 	return 0;
+
 err:
 	release_firmware(fw);
-
+err_request_firmware:
 	dev_dbg(&client->dev, "failed=%d\n", ret);
 	return ret;
 }
-- 
2.1.3


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

* [PATCH 0/2] [media] mn88472: Delete an unnecessary check
       [not found]                               ` <5317A59D.4@users.sourceforge.net>
                                                   ` (11 preceding siblings ...)
  2014-12-01 22:30                                 ` [PATCH 0/2] [media] mn88473: Delete an unnecessary check SF Markus Elfring
@ 2015-02-01 19:11                                 ` SF Markus Elfring
  2015-02-01 19:16                                   ` [PATCH 1/2] [media] mn88472: Deletion of an unnecessary check before the function call "release_firmware" SF Markus Elfring
  2015-02-01 19:18                                   ` [PATCH 2/2] [media] mn88472: One function call less in mn88472_init() after error detection SF Markus Elfring
  2015-02-02 12:44                                 ` [media] staging: bcm2048: Delete an unnecessary check before the function call "video_unregister_device" SF Markus Elfring
                                                   ` (10 subsequent siblings)
  23 siblings, 2 replies; 43+ messages in thread
From: SF Markus Elfring @ 2015-02-01 19:11 UTC (permalink / raw)
  To: Antti Palosaari, Greg Kroah-Hartman, Mauro Carvalho Chehab,
	devel, linux-media
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 1 Feb 2015 20:00:17 +0100

Another update suggestion was taken into account after a patch was applied
from static source code analysis.

Markus Elfring (2):
  Deletion of an unnecessary check before the function call "release_firmware"
  One function call less in mn88472_init() after error detection

 drivers/staging/media/mn88472/mn88472.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

-- 
2.2.2


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

* [PATCH 1/2] [media] mn88472: Deletion of an unnecessary check before the function call "release_firmware"
  2015-02-01 19:11                                 ` [PATCH 0/2] [media] mn88472: Delete an unnecessary check SF Markus Elfring
@ 2015-02-01 19:16                                   ` SF Markus Elfring
  2015-02-01 19:18                                   ` [PATCH 2/2] [media] mn88472: One function call less in mn88472_init() after error detection SF Markus Elfring
  1 sibling, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2015-02-01 19:16 UTC (permalink / raw)
  To: Antti Palosaari, Greg Kroah-Hartman, Mauro Carvalho Chehab,
	devel, linux-media
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 1 Feb 2015 19:12:56 +0100

The release_firmware() 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/staging/media/mn88472/mn88472.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/media/mn88472/mn88472.c b/drivers/staging/media/mn88472/mn88472.c
index 52de8f8..e7874ae 100644
--- a/drivers/staging/media/mn88472/mn88472.c
+++ b/drivers/staging/media/mn88472/mn88472.c
@@ -315,8 +315,7 @@ static int mn88472_init(struct dvb_frontend *fe)
 
 	return 0;
 err:
-	if (fw)
-		release_firmware(fw);
+	release_firmware(fw);
 
 	dev_dbg(&client->dev, "failed=%d\n", ret);
 	return ret;
-- 
2.2.2


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

* [PATCH 2/2] [media] mn88472: One function call less in mn88472_init() after error detection
  2015-02-01 19:11                                 ` [PATCH 0/2] [media] mn88472: Delete an unnecessary check SF Markus Elfring
  2015-02-01 19:16                                   ` [PATCH 1/2] [media] mn88472: Deletion of an unnecessary check before the function call "release_firmware" SF Markus Elfring
@ 2015-02-01 19:18                                   ` SF Markus Elfring
  1 sibling, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2015-02-01 19:18 UTC (permalink / raw)
  To: Antti Palosaari, Greg Kroah-Hartman, Mauro Carvalho Chehab,
	devel, linux-media
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 1 Feb 2015 19:34:37 +0100

The release_firmware() function was called in three cases by the mn88472_init()
function during error handling even if the passed variable "fw" contained still
a null pointer.

This implementation detail could be improved by the introduction of another
jump label.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/staging/media/mn88472/mn88472.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/media/mn88472/mn88472.c b/drivers/staging/media/mn88472/mn88472.c
index e7874ae..3975a57 100644
--- a/drivers/staging/media/mn88472/mn88472.c
+++ b/drivers/staging/media/mn88472/mn88472.c
@@ -286,7 +286,7 @@ static int mn88472_init(struct dvb_frontend *fe)
 
 	ret = regmap_write(dev->regmap[0], 0xf5, 0x03);
 	if (ret)
-		goto err;
+		goto firmware_release;
 
 	for (remaining = fw->size; remaining > 0;
 			remaining -= (dev->i2c_wr_max - 1)) {
@@ -299,13 +299,13 @@ static int mn88472_init(struct dvb_frontend *fe)
 		if (ret) {
 			dev_err(&client->dev,
 					"firmware download failed=%d\n", ret);
-			goto err;
+			goto firmware_release;
 		}
 	}
 
 	ret = regmap_write(dev->regmap[0], 0xf5, 0x00);
 	if (ret)
-		goto err;
+		goto firmware_release;
 
 	release_firmware(fw);
 	fw = NULL;
@@ -314,9 +314,9 @@ static int mn88472_init(struct dvb_frontend *fe)
 	dev->warm = true;
 
 	return 0;
-err:
+firmware_release:
 	release_firmware(fw);
-
+err:
 	dev_dbg(&client->dev, "failed=%d\n", ret);
 	return ret;
 }
-- 
2.2.2


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

* [media] staging: bcm2048: Delete an unnecessary check before the function call "video_unregister_device"
       [not found]                               ` <5317A59D.4@users.sourceforge.net>
                                                   ` (12 preceding siblings ...)
  2015-02-01 19:11                                 ` [PATCH 0/2] [media] mn88472: Delete an unnecessary check SF Markus Elfring
@ 2015-02-02 12:44                                 ` SF Markus Elfring
  2015-02-03 14:10                                 ` [PATCH] [media] sp2: Delete an unnecessary check before the function call "kfree" SF Markus Elfring
                                                   ` (9 subsequent siblings)
  23 siblings, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2015-02-02 12:44 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Mauro Carvalho Chehab, devel, linux-media
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 2 Feb 2015 13:20:23 +0100

The video_unregister_device() 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/staging/media/bcm2048/radio-bcm2048.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/media/bcm2048/radio-bcm2048.c b/drivers/staging/media/bcm2048/radio-bcm2048.c
index 60a57b2..f308078 100644
--- a/drivers/staging/media/bcm2048/radio-bcm2048.c
+++ b/drivers/staging/media/bcm2048/radio-bcm2048.c
@@ -2684,9 +2684,7 @@ static int __exit bcm2048_i2c_driver_remove(struct i2c_client *client)
 		vd = bdev->videodev;
 
 		bcm2048_sysfs_unregister_properties(bdev, ARRAY_SIZE(attrs));
-
-		if (vd)
-			video_unregister_device(vd);
+		video_unregister_device(vd);
 
 		if (bdev->power_state)
 			bcm2048_set_power_state(bdev, BCM2048_POWER_OFF);
-- 
2.2.2


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

* [PATCH] [media] sp2: Delete an unnecessary check before the function call "kfree"
       [not found]                               ` <5317A59D.4@users.sourceforge.net>
                                                   ` (13 preceding siblings ...)
  2015-02-02 12:44                                 ` [media] staging: bcm2048: Delete an unnecessary check before the function call "video_unregister_device" SF Markus Elfring
@ 2015-02-03 14:10                                 ` SF Markus Elfring
  2015-02-03 14:31                                 ` [PATCH] [media] V4L2: Delete an unnecessary check before the function call "media_entity_put" SF Markus Elfring
                                                   ` (8 subsequent siblings)
  23 siblings, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2015-02-03 14:10 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Olli Salonen, linux-media
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 3 Feb 2015 15:05:26 +0100

The kfree() 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/media/dvb-frontends/sp2.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/media/dvb-frontends/sp2.c b/drivers/media/dvb-frontends/sp2.c
index cc1ef96..8fd4276 100644
--- a/drivers/media/dvb-frontends/sp2.c
+++ b/drivers/media/dvb-frontends/sp2.c
@@ -413,11 +413,8 @@ static int sp2_remove(struct i2c_client *client)
 	struct sp2 *s = i2c_get_clientdata(client);
 
 	dev_dbg(&client->dev, "\n");
-
 	sp2_exit(client);
-	if (s != NULL)
-		kfree(s);
-
+	kfree(s);
 	return 0;
 }
 
-- 
2.2.2


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

* [PATCH] [media] V4L2: Delete an unnecessary check before the function call "media_entity_put"
       [not found]                               ` <5317A59D.4@users.sourceforge.net>
                                                   ` (14 preceding siblings ...)
  2015-02-03 14:10                                 ` [PATCH] [media] sp2: Delete an unnecessary check before the function call "kfree" SF Markus Elfring
@ 2015-02-03 14:31                                 ` SF Markus Elfring
  2015-02-03 16:18                                 ` [PATCH 0/2] DVB: Deletion of a few unnecessary checks SF Markus Elfring
                                                   ` (7 subsequent siblings)
  23 siblings, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2015-02-03 14:31 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, linux-media; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 3 Feb 2015 15:27:38 +0100

The media_entity_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/media/v4l2-core/v4l2-subdev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
index 543631c..b9ff7fd 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -93,8 +93,7 @@ static int subdev_open(struct file *file)
 
 err:
 #if defined(CONFIG_MEDIA_CONTROLLER)
-	if (entity)
-		media_entity_put(entity);
+	media_entity_put(entity);
 #endif
 	v4l2_fh_del(&subdev_fh->vfh);
 	v4l2_fh_exit(&subdev_fh->vfh);
-- 
2.2.2


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

* [PATCH 0/2] DVB: Deletion of a few unnecessary checks
       [not found]                               ` <5317A59D.4@users.sourceforge.net>
                                                   ` (15 preceding siblings ...)
  2015-02-03 14:31                                 ` [PATCH] [media] V4L2: Delete an unnecessary check before the function call "media_entity_put" SF Markus Elfring
@ 2015-02-03 16:18                                 ` SF Markus Elfring
  2015-02-03 16:22                                   ` [PATCH 1/2] [media] DVB: Delete an unnecessary check before the function call "dvb_unregister_device" SF Markus Elfring
  2015-02-03 16:23                                   ` [PATCH 2/2] [media] DVB: Less function calls in dvb_ca_en50221_init() after error detection SF Markus Elfring
  2015-02-03 17:45                                 ` [PATCH] [media] stk-webcam: Delete an unnecessary check before the function call "vfree" SF Markus Elfring
                                                   ` (6 subsequent siblings)
  23 siblings, 2 replies; 43+ messages in thread
From: SF Markus Elfring @ 2015-02-03 16:18 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, linux-media; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 3 Feb 2015 16:50:07 +0100

Another update suggestion was taken into account after a patch was applied
from static source code analysis.

Markus Elfring (2):
  Delete an unnecessary check before the function call "dvb_unregister_device"
  Less function calls in dvb_ca_en50221_init() after error detection

 drivers/media/dvb-core/dvb_ca_en50221.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

-- 
2.2.2


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

* [PATCH 1/2] [media] DVB: Delete an unnecessary check before the function call "dvb_unregister_device"
  2015-02-03 16:18                                 ` [PATCH 0/2] DVB: Deletion of a few unnecessary checks SF Markus Elfring
@ 2015-02-03 16:22                                   ` SF Markus Elfring
  2015-02-03 16:23                                   ` [PATCH 2/2] [media] DVB: Less function calls in dvb_ca_en50221_init() after error detection SF Markus Elfring
  1 sibling, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2015-02-03 16:22 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, linux-media; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 3 Feb 2015 16:01:40 +0100

The dvb_unregister_device() 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/media/dvb-core/dvb_ca_en50221.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb-core/dvb_ca_en50221.c
index 0aac309..b999689 100644
--- a/drivers/media/dvb-core/dvb_ca_en50221.c
+++ b/drivers/media/dvb-core/dvb_ca_en50221.c
@@ -1726,8 +1726,7 @@ int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter,
 
 error:
 	if (ca != NULL) {
-		if (ca->dvbdev != NULL)
-			dvb_unregister_device(ca->dvbdev);
+		dvb_unregister_device(ca->dvbdev);
 		kfree(ca->slot_info);
 		kfree(ca);
 	}
-- 
2.2.2


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

* [PATCH 2/2] [media] DVB: Less function calls in dvb_ca_en50221_init() after error detection
  2015-02-03 16:18                                 ` [PATCH 0/2] DVB: Deletion of a few unnecessary checks SF Markus Elfring
  2015-02-03 16:22                                   ` [PATCH 1/2] [media] DVB: Delete an unnecessary check before the function call "dvb_unregister_device" SF Markus Elfring
@ 2015-02-03 16:23                                   ` SF Markus Elfring
  1 sibling, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2015-02-03 16:23 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, linux-media; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 3 Feb 2015 16:47:48 +0100

The functions "dvb_unregister_device" and "kfree" could still be called
by the dvb_ca_en50221_init() function in the case that a previous resource
allocation failed.

* Corresponding details could be improved by adjustments for jump targets.

* Let us delete also an unnecessary check for the variable "ca" there.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/dvb-core/dvb_ca_en50221.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/drivers/media/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb-core/dvb_ca_en50221.c
index b999689..9842fd1 100644
--- a/drivers/media/dvb-core/dvb_ca_en50221.c
+++ b/drivers/media/dvb-core/dvb_ca_en50221.c
@@ -1676,14 +1676,14 @@ int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter,
 	/* initialise the system data */
 	if ((ca = kzalloc(sizeof(struct dvb_ca_private), GFP_KERNEL)) == NULL) {
 		ret = -ENOMEM;
-		goto error;
+		goto exit;
 	}
 	ca->pub = pubca;
 	ca->flags = flags;
 	ca->slot_count = slot_count;
 	if ((ca->slot_info = kcalloc(slot_count, sizeof(struct dvb_ca_slot), GFP_KERNEL)) == NULL) {
 		ret = -ENOMEM;
-		goto error;
+		goto free_ca;
 	}
 	init_waitqueue_head(&ca->wait_queue);
 	ca->open = 0;
@@ -1694,7 +1694,7 @@ int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter,
 	/* register the DVB device */
 	ret = dvb_register_device(dvb_adapter, &ca->dvbdev, &dvbdev_ca, ca, DVB_DEVICE_CA);
 	if (ret)
-		goto error;
+		goto free_slot_info;
 
 	/* now initialise each slot */
 	for (i = 0; i < slot_count; i++) {
@@ -1709,7 +1709,7 @@ int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter,
 
 	if (signal_pending(current)) {
 		ret = -EINTR;
-		goto error;
+		goto unregister_device;
 	}
 	mb();
 
@@ -1720,16 +1720,17 @@ int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter,
 		ret = PTR_ERR(ca->thread);
 		printk("dvb_ca_init: failed to start kernel_thread (%d)\n",
 			ret);
-		goto error;
+		goto unregister_device;
 	}
 	return 0;
 
-error:
-	if (ca != NULL) {
-		dvb_unregister_device(ca->dvbdev);
-		kfree(ca->slot_info);
-		kfree(ca);
-	}
+unregister_device:
+	dvb_unregister_device(ca->dvbdev);
+free_slot_info:
+	kfree(ca->slot_info);
+free_ca:
+	kfree(ca);
+exit:
 	pubca->private = NULL;
 	return ret;
 }
-- 
2.2.2


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

* [PATCH] [media] stk-webcam: Delete an unnecessary check before the function call "vfree"
       [not found]                               ` <5317A59D.4@users.sourceforge.net>
                                                   ` (16 preceding siblings ...)
  2015-02-03 16:18                                 ` [PATCH 0/2] DVB: Deletion of a few unnecessary checks SF Markus Elfring
@ 2015-02-03 17:45                                 ` SF Markus Elfring
  2015-02-03 18:03                                 ` [PATCH] [media] au0828: Delete unnecessary checks before the function call "video_unregister_device" SF Markus Elfring
                                                   ` (5 subsequent siblings)
  23 siblings, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2015-02-03 17:45 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, linux-media; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 3 Feb 2015 18:36:35 +0100

The vfree() function performs also input parameter validation.
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/media/usb/stkwebcam/stk-webcam.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/media/usb/stkwebcam/stk-webcam.c b/drivers/media/usb/stkwebcam/stk-webcam.c
index 3588dc3..3686c4e 100644
--- a/drivers/media/usb/stkwebcam/stk-webcam.c
+++ b/drivers/media/usb/stkwebcam/stk-webcam.c
@@ -556,10 +556,8 @@ static int stk_free_sio_buffers(struct stk_camera *dev)
 	nbufs = dev->n_sbufs;
 	dev->n_sbufs = 0;
 	spin_unlock_irqrestore(&dev->spinlock, flags);
-	for (i = 0; i < nbufs; i++) {
-		if (dev->sio_bufs[i].buffer != NULL)
-			vfree(dev->sio_bufs[i].buffer);
-	}
+	for (i = 0; i < nbufs; i++)
+		vfree(dev->sio_bufs[i].buffer);
 	kfree(dev->sio_bufs);
 	dev->sio_bufs = NULL;
 	return 0;
-- 
2.2.2


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

* [PATCH] [media] au0828: Delete unnecessary checks before the function call "video_unregister_device"
       [not found]                               ` <5317A59D.4@users.sourceforge.net>
                                                   ` (17 preceding siblings ...)
  2015-02-03 17:45                                 ` [PATCH] [media] stk-webcam: Delete an unnecessary check before the function call "vfree" SF Markus Elfring
@ 2015-02-03 18:03                                 ` SF Markus Elfring
  2015-11-05 18:45                                 ` [PATCH 0/2] [media] c8sectpfe: Deletion of a few unnecessary checks SF Markus Elfring
                                                   ` (4 subsequent siblings)
  23 siblings, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2015-02-03 18:03 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, linux-media; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 3 Feb 2015 19:00:25 +0100

The video_unregister_device() 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/media/usb/au0828/au0828-video.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c
index 5f337b1..e593fb5 100644
--- a/drivers/media/usb/au0828/au0828-video.c
+++ b/drivers/media/usb/au0828/au0828-video.c
@@ -870,12 +870,8 @@ void au0828_analog_unregister(struct au0828_dev *dev)
 {
 	dprintk(1, "au0828_release_resources called\n");
 	mutex_lock(&au0828_sysfs_lock);
-
-	if (dev->vdev)
-		video_unregister_device(dev->vdev);
-	if (dev->vbi_dev)
-		video_unregister_device(dev->vbi_dev);
-
+	video_unregister_device(dev->vdev);
+	video_unregister_device(dev->vbi_dev);
 	mutex_unlock(&au0828_sysfs_lock);
 }
 
-- 
2.2.2


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

* [PATCH 0/2] [media] c8sectpfe: Deletion of a few unnecessary checks
       [not found]                               ` <5317A59D.4@users.sourceforge.net>
                                                   ` (18 preceding siblings ...)
  2015-02-03 18:03                                 ` [PATCH] [media] au0828: Delete unnecessary checks before the function call "video_unregister_device" SF Markus Elfring
@ 2015-11-05 18:45                                 ` SF Markus Elfring
  2015-11-05 18:49                                   ` [PATCH 1/2] [media] c8sectpfe: Delete unnecessary checks before two function calls SF Markus Elfring
                                                     ` (2 more replies)
  2016-07-17 20:16                                 ` [PATCH] [media] tw686x-kh: Delete an unnecessary check before the function call "video_unregister_device" SF Markus Elfring
                                                   ` (3 subsequent siblings)
  23 siblings, 3 replies; 43+ messages in thread
From: SF Markus Elfring @ 2015-11-05 18:45 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Maxime Coquelin, Patrice Chotard,
	Srinivas Kandagatla, linux-arm-kernel, linux-media, kernel
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 5 Nov 2015 19:39:32 +0100

Another update suggestion was taken into account after a patch was applied
from static source code analysis.

Markus Elfring (2):
  Delete unnecessary checks before two function calls
  Combine three checks into a single if block

 drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

-- 
2.6.2


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

* [PATCH 1/2] [media] c8sectpfe: Delete unnecessary checks before two function calls
  2015-11-05 18:45                                 ` [PATCH 0/2] [media] c8sectpfe: Deletion of a few unnecessary checks SF Markus Elfring
@ 2015-11-05 18:49                                   ` SF Markus Elfring
  2015-11-05 18:50                                   ` [PATCH 2/2] [media] c8sectpfe: Combine three checks into a single if block SF Markus Elfring
  2015-11-06  7:50                                   ` [PATCH 0/2] [media] c8sectpfe: Deletion of a few unnecessary checks Maxime Coquelin
  2 siblings, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2015-11-05 18:49 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Maxime Coquelin, Patrice Chotard,
	Srinivas Kandagatla, linux-arm-kernel, linux-media, kernel
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 5 Nov 2015 18:55:19 +0100

The functions i2c_put_adapter() and module_put() test whether their
argument is NULL and then return immediately.
Thus the tests around their calls are not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c
index 95223ab..07fd6d9 100644
--- a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c
+++ b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c
@@ -214,12 +214,11 @@ void c8sectpfe_tuner_unregister_frontend(struct c8sectpfe *c8sectpfe,
 			dvb_frontend_detach(tsin->frontend);
 		}
 
-		if (tsin && tsin->i2c_adapter)
+		if (tsin)
 			i2c_put_adapter(tsin->i2c_adapter);
 
 		if (tsin && tsin->i2c_client) {
-			if (tsin->i2c_client->dev.driver->owner)
-				module_put(tsin->i2c_client->dev.driver->owner);
+			module_put(tsin->i2c_client->dev.driver->owner);
 			i2c_unregister_device(tsin->i2c_client);
 		}
 	}
-- 
2.6.2


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

* [PATCH 2/2] [media] c8sectpfe: Combine three checks into a single if block
  2015-11-05 18:45                                 ` [PATCH 0/2] [media] c8sectpfe: Deletion of a few unnecessary checks SF Markus Elfring
  2015-11-05 18:49                                   ` [PATCH 1/2] [media] c8sectpfe: Delete unnecessary checks before two function calls SF Markus Elfring
@ 2015-11-05 18:50                                   ` SF Markus Elfring
  2015-11-06 10:09                                     ` walter harms
  2015-11-06  7:50                                   ` [PATCH 0/2] [media] c8sectpfe: Deletion of a few unnecessary checks Maxime Coquelin
  2 siblings, 1 reply; 43+ messages in thread
From: SF Markus Elfring @ 2015-11-05 18:50 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Maxime Coquelin, Patrice Chotard,
	Srinivas Kandagatla, linux-arm-kernel, linux-media, kernel
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 5 Nov 2015 19:23:50 +0100

The variable "tsin" was checked three times in a loop iteration of the
c8sectpfe_tuner_unregister_frontend() function.
This implementation detail could be improved by the combination of the
involved statements into a single if block so that this variable will be
checked only once there.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c
index 07fd6d9..2dfbe8a 100644
--- a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c
+++ b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c
@@ -209,17 +209,18 @@ void c8sectpfe_tuner_unregister_frontend(struct c8sectpfe *c8sectpfe,
 
 		tsin = fei->channel_data[n];
 
-		if (tsin && tsin->frontend) {
-			dvb_unregister_frontend(tsin->frontend);
-			dvb_frontend_detach(tsin->frontend);
-		}
+		if (tsin) {
+			if (tsin->frontend) {
+				dvb_unregister_frontend(tsin->frontend);
+				dvb_frontend_detach(tsin->frontend);
+			}
 
-		if (tsin)
 			i2c_put_adapter(tsin->i2c_adapter);
 
-		if (tsin && tsin->i2c_client) {
-			module_put(tsin->i2c_client->dev.driver->owner);
-			i2c_unregister_device(tsin->i2c_client);
+			if (tsin->i2c_client) {
+				module_put(tsin->i2c_client->dev.driver->owner);
+				i2c_unregister_device(tsin->i2c_client);
+			}
 		}
 	}
 
-- 
2.6.2


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

* Re: [PATCH 0/2] [media] c8sectpfe: Deletion of a few unnecessary checks
  2015-11-05 18:45                                 ` [PATCH 0/2] [media] c8sectpfe: Deletion of a few unnecessary checks SF Markus Elfring
  2015-11-05 18:49                                   ` [PATCH 1/2] [media] c8sectpfe: Delete unnecessary checks before two function calls SF Markus Elfring
  2015-11-05 18:50                                   ` [PATCH 2/2] [media] c8sectpfe: Combine three checks into a single if block SF Markus Elfring
@ 2015-11-06  7:50                                   ` Maxime Coquelin
  2 siblings, 0 replies; 43+ messages in thread
From: Maxime Coquelin @ 2015-11-06  7:50 UTC (permalink / raw)
  To: SF Markus Elfring, Mauro Carvalho Chehab, Patrice Chotard,
	Srinivas Kandagatla, linux-arm-kernel, linux-media, kernel
  Cc: LKML, kernel-janitors, Julia Lawall

Hi Markus,

On 11/05/2015 07:45 PM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 5 Nov 2015 19:39:32 +0100
>
> Another update suggestion was taken into account after a patch was applied
> from static source code analysis.
>
> Markus Elfring (2):
>    Delete unnecessary checks before two function calls
>    Combine three checks into a single if block
>
>   drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c | 16 ++++++++--------
>   1 file changed, 8 insertions(+), 8 deletions(-)
>
For the series:
Acked-by: Maxime Coquelin <maxime.coquelin@st.com>

Thanks!
Maxime

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

* Re: [PATCH 2/2] [media] c8sectpfe: Combine three checks into a single if block
  2015-11-05 18:50                                   ` [PATCH 2/2] [media] c8sectpfe: Combine three checks into a single if block SF Markus Elfring
@ 2015-11-06 10:09                                     ` walter harms
  0 siblings, 0 replies; 43+ messages in thread
From: walter harms @ 2015-11-06 10:09 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Mauro Carvalho Chehab, Maxime Coquelin, Patrice Chotard,
	Srinivas Kandagatla, linux-arm-kernel, linux-media, kernel, LKML,
	kernel-janitors, Julia Lawall



Am 05.11.2015 19:50, schrieb SF Markus Elfring:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 5 Nov 2015 19:23:50 +0100
> 
> The variable "tsin" was checked three times in a loop iteration of the
> c8sectpfe_tuner_unregister_frontend() function.
> This implementation detail could be improved by the combination of the
> involved statements into a single if block so that this variable will be
> checked only once there.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c | 17 +++++++++--------
>  1 file changed, 9 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c
> index 07fd6d9..2dfbe8a 100644
> --- a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c
> +++ b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c
> @@ -209,17 +209,18 @@ void c8sectpfe_tuner_unregister_frontend(struct c8sectpfe *c8sectpfe,
>  
>  		tsin = fei->channel_data[n];


if you do "if (!tsin) continue ;"
you can save one indent level

re,
 wh

>  
> -		if (tsin && tsin->frontend) {
> -			dvb_unregister_frontend(tsin->frontend);
> -			dvb_frontend_detach(tsin->frontend);
> -		}
> +		if (tsin) {
> +			if (tsin->frontend) {
> +				dvb_unregister_frontend(tsin->frontend);
> +				dvb_frontend_detach(tsin->frontend);
> +			}
>  
> -		if (tsin)
>  			i2c_put_adapter(tsin->i2c_adapter);
>  
> -		if (tsin && tsin->i2c_client) {
> -			module_put(tsin->i2c_client->dev.driver->owner);
> -			i2c_unregister_device(tsin->i2c_client);
> +			if (tsin->i2c_client) {
> +				module_put(tsin->i2c_client->dev.driver->owner);
> +				i2c_unregister_device(tsin->i2c_client);
> +			}
>  		}
>  	}
>  

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

* [PATCH] [media] tw686x-kh: Delete an unnecessary check before the function call "video_unregister_device"
       [not found]                               ` <5317A59D.4@users.sourceforge.net>
                                                   ` (19 preceding siblings ...)
  2015-11-05 18:45                                 ` [PATCH 0/2] [media] c8sectpfe: Deletion of a few unnecessary checks SF Markus Elfring
@ 2016-07-17 20:16                                 ` SF Markus Elfring
  2016-07-22 10:16                                   ` Krzysztof Hałasa
  2016-07-17 21:00                                 ` [PATCH] [media] cec: Delete an unnecessary check before the function call "rc_free_device" SF Markus Elfring
                                                   ` (2 subsequent siblings)
  23 siblings, 1 reply; 43+ messages in thread
From: SF Markus Elfring @ 2016-07-17 20:16 UTC (permalink / raw)
  To: linux-media, devel, Mauro Carvalho Chehab, Krzysztof Hałasa,
	Hans Verkuil, Greg Kroah-Hartman
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 17 Jul 2016 22:00:35 +0200

The video_unregister_device() 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/staging/media/tw686x-kh/tw686x-kh-video.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/media/tw686x-kh/tw686x-kh-video.c b/drivers/staging/media/tw686x-kh/tw686x-kh-video.c
index 6ecb504..3f2830c 100644
--- a/drivers/staging/media/tw686x-kh/tw686x-kh-video.c
+++ b/drivers/staging/media/tw686x-kh/tw686x-kh-video.c
@@ -643,8 +643,7 @@ void tw686x_kh_video_free(struct tw686x_dev *dev)
 		struct tw686x_video_channel *vc = &dev->video_channels[ch];
 
 		v4l2_ctrl_handler_free(&vc->ctrl_handler);
-		if (vc->device)
-			video_unregister_device(vc->device);
+		video_unregister_device(vc->device);
 		vb2_dma_sg_cleanup_ctx(vc->alloc_ctx);
 		for (n = 0; n < 2; n++) {
 			struct dma_desc *descs = &vc->sg_tables[n];
-- 
2.9.1


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

* [PATCH] [media] cec: Delete an unnecessary check before the function call "rc_free_device"
       [not found]                               ` <5317A59D.4@users.sourceforge.net>
                                                   ` (20 preceding siblings ...)
  2016-07-17 20:16                                 ` [PATCH] [media] tw686x-kh: Delete an unnecessary check before the function call "video_unregister_device" SF Markus Elfring
@ 2016-07-17 21:00                                 ` SF Markus Elfring
  2016-07-19 18:02                                 ` [PATCH] [media] v4l2-common: Delete an unnecessary check before the function call "spi_unregister_device" SF Markus Elfring
  2016-07-19 19:35                                 ` [PATCH] [media] tw686x: Delete an unnecessary check before the function call "video_unregister_device" SF Markus Elfring
  23 siblings, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2016-07-17 21:00 UTC (permalink / raw)
  To: linux-media, devel, Mauro Carvalho Chehab, Hans Verkuil,
	Greg Kroah-Hartman
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 17 Jul 2016 22:52:49 +0200

The rc_free_device() 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/staging/media/cec/cec-core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/media/cec/cec-core.c b/drivers/staging/media/cec/cec-core.c
index 61a1e69..123e1bf 100644
--- a/drivers/staging/media/cec/cec-core.c
+++ b/drivers/staging/media/cec/cec-core.c
@@ -354,8 +354,7 @@ void cec_delete_adapter(struct cec_adapter *adap)
 	if (adap->kthread_config)
 		kthread_stop(adap->kthread_config);
 #if IS_ENABLED(CONFIG_RC_CORE)
-	if (adap->rc)
-		rc_free_device(adap->rc);
+	rc_free_device(adap->rc);
 #endif
 	kfree(adap);
 }
-- 
2.9.1


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

* [PATCH] [media] v4l2-common: Delete an unnecessary check before the function call "spi_unregister_device"
       [not found]                               ` <5317A59D.4@users.sourceforge.net>
                                                   ` (21 preceding siblings ...)
  2016-07-17 21:00                                 ` [PATCH] [media] cec: Delete an unnecessary check before the function call "rc_free_device" SF Markus Elfring
@ 2016-07-19 18:02                                 ` SF Markus Elfring
  2016-07-19 18:36                                   ` walter harms
  2016-07-19 19:35                                 ` [PATCH] [media] tw686x: Delete an unnecessary check before the function call "video_unregister_device" SF Markus Elfring
  23 siblings, 1 reply; 43+ messages in thread
From: SF Markus Elfring @ 2016-07-19 18:02 UTC (permalink / raw)
  To: linux-media, Hans Verkuil, Mauro Carvalho Chehab
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 19 Jul 2016 19:54:16 +0200

The spi_unregister_device() 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/media/v4l2-core/v4l2-common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c
index 5b80850..57cfe26a 100644
--- a/drivers/media/v4l2-core/v4l2-common.c
+++ b/drivers/media/v4l2-core/v4l2-common.c
@@ -291,7 +291,7 @@ struct v4l2_subdev *v4l2_spi_new_subdev(struct v4l2_device *v4l2_dev,
 error:
 	/* If we have a client but no subdev, then something went wrong and
 	   we must unregister the client. */
-	if (spi && sd == NULL)
+	if (!sd)
 		spi_unregister_device(spi);
 
 	return sd;
-- 
2.9.2


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

* Re: [PATCH] [media] v4l2-common: Delete an unnecessary check before the function call "spi_unregister_device"
  2016-07-19 18:02                                 ` [PATCH] [media] v4l2-common: Delete an unnecessary check before the function call "spi_unregister_device" SF Markus Elfring
@ 2016-07-19 18:36                                   ` walter harms
  0 siblings, 0 replies; 43+ messages in thread
From: walter harms @ 2016-07-19 18:36 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-media, Hans Verkuil, Mauro Carvalho Chehab, LKML,
	kernel-janitors, Julia Lawall



Am 19.07.2016 20:02, schrieb SF Markus Elfring:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 19 Jul 2016 19:54:16 +0200
> 
> The spi_unregister_device() 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/media/v4l2-core/v4l2-common.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c
> index 5b80850..57cfe26a 100644
> --- a/drivers/media/v4l2-core/v4l2-common.c
> +++ b/drivers/media/v4l2-core/v4l2-common.c
> @@ -291,7 +291,7 @@ struct v4l2_subdev *v4l2_spi_new_subdev(struct v4l2_device *v4l2_dev,
>  error:
>  	/* If we have a client but no subdev, then something went wrong and
>  	   we must unregister the client. */
> -	if (spi && sd == NULL)
> +	if (!sd)
>  		spi_unregister_device(spi);
>  
>  	return sd;


if i read the code correct sd is always NULL at this point.
so this was wrong in the first place and you must remove sd also.


re,
 wh





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

* [PATCH] [media] tw686x: Delete an unnecessary check before the function call "video_unregister_device"
       [not found]                               ` <5317A59D.4@users.sourceforge.net>
                                                   ` (22 preceding siblings ...)
  2016-07-19 18:02                                 ` [PATCH] [media] v4l2-common: Delete an unnecessary check before the function call "spi_unregister_device" SF Markus Elfring
@ 2016-07-19 19:35                                 ` SF Markus Elfring
  23 siblings, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2016-07-19 19:35 UTC (permalink / raw)
  To: linux-media, Ezequiel Garcia, Hans Verkuil, Mauro Carvalho Chehab
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 19 Jul 2016 21:24:26 +0200

The video_unregister_device() 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/media/pci/tw686x/tw686x-video.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/pci/tw686x/tw686x-video.c b/drivers/media/pci/tw686x/tw686x-video.c
index cdb16de..4475a9d9 100644
--- a/drivers/media/pci/tw686x/tw686x-video.c
+++ b/drivers/media/pci/tw686x/tw686x-video.c
@@ -1093,8 +1093,7 @@ void tw686x_video_free(struct tw686x_dev *dev)
 	for (ch = 0; ch < max_channels(dev); ch++) {
 		struct tw686x_video_channel *vc = &dev->video_channels[ch];
 
-		if (vc->device)
-			video_unregister_device(vc->device);
+		video_unregister_device(vc->device);
 
 		if (dev->dma_ops->free)
 			for (pb = 0; pb < 2; pb++)
-- 
2.9.2


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

* Re: [PATCH] [media] tw686x-kh: Delete an unnecessary check before the function call "video_unregister_device"
  2016-07-17 20:16                                 ` [PATCH] [media] tw686x-kh: Delete an unnecessary check before the function call "video_unregister_device" SF Markus Elfring
@ 2016-07-22 10:16                                   ` Krzysztof Hałasa
  0 siblings, 0 replies; 43+ messages in thread
From: Krzysztof Hałasa @ 2016-07-22 10:16 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-media, devel, Mauro Carvalho Chehab, Hans Verkuil,
	Greg Kroah-Hartman, LKML, kernel-janitors, Julia Lawall

SF Markus Elfring <elfring@users.sourceforge.net> writes:

> The video_unregister_device() 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/staging/media/tw686x-kh/tw686x-kh-video.c | 3 +--

Thanks.
-- 
Krzysztof Halasa

Industrial Research Institute for Automation and Measurements PIAP
Al. Jerozolimskie 202, 02-486 Warsaw, Poland

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

end of thread, other threads:[~2016-07-22 10:23 UTC | newest]

Thread overview: 43+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <5307CAA2.8060406@users.sourceforge.net>
     [not found] ` <alpine.DEB.2.02.1402212321410.2043@localhost6.localdomain6>
     [not found]   ` <530A086E.8010901@users.sourceforge.net>
     [not found]     ` <alpine.DEB.2.02.1402231635510.1985@localhost6.localdomain6>
     [not found]       ` <530A72AA.3000601@users.sourceforge.net>
     [not found]         ` <alpine.DEB.2.02.1402240658210.2090@localhost6.localdomain6>
     [not found]           ` <530B5FB6.6010207@users.sourceforge.net>
     [not found]             ` <alpine.DEB.2.10.1402241710370.2074@hadrien>
     [not found]               ` <530C5E18.1020800@users.sourceforge.net>
     [not found]                 ` <alpine.DEB.2.10.1402251014170.2080@hadrien>
     [not found]                   ` <530CD2C4.4050903@users.sourceforge.net>
     [not found]                     ` <alpine.DEB.2.10.1402251840450.7035@hadrien>
     [not found]                       ` <530CF8FF.8080600@users.sourceforge.net>
     [not found]                         ` <alpine.DEB.2.02.1402252117150.2047@localhost6.localdomain6>
     [not found]                           ` <530DD06F.4090703@users.sourceforge.net>
     [not found]                             ` <alpine.DEB.2.02.1402262129250.2221@localhost6.localdomain6>
     [not found]                               ` <5317A59D.4@users.sourceforge.net>
2014-11-20  8:19                                 ` [PATCH 0/3] [media] DVB-frontends: Deletion of a few unnecessary checks SF Markus Elfring
2014-11-20  8:29                                   ` [PATCH 2/3] [media] m88ds3103: One function call less in m88ds3103_init() after error detection SF Markus Elfring
2014-11-20  8:33                                   ` [PATCH 1/3] [media] DVB-frontends: Deletion of unnecessary checks before the function call "release_firmware" SF Markus Elfring
2014-11-20  8:39                                   ` [PATCH 3/3] [media] si2168: One function call less in si2168_init() after error detection SF Markus Elfring
2014-11-20  9:55                                 ` [PATCH 1/1] [media] firewire: Deletion of an unnecessary check before the function call "dvb_unregister_device" SF Markus Elfring
2014-11-20 14:41                                   ` Stefan Richter
2014-11-20 10:20                                 ` [PATCH 1/1] [media] i2c: Deletion of an unnecessary check before the function call "rc_unregister_device" SF Markus Elfring
2014-11-20 10:50                                 ` [PATCH 1/1] [media] platform: Deletion of unnecessary checks before two function calls SF Markus Elfring
2014-11-20 12:08                                 ` [PATCH 1/1] [media] rc: " SF Markus Elfring
2014-11-20 12:33                                 ` [PATCH 1/1] [media] USB: Deletion of unnecessary checks before three " SF Markus Elfring
2014-11-24 21:40                                 ` [PATCH 1/1] [media] Siano: Deletion of an unnecessary check before the function call "rc_unregister_device" SF Markus Elfring
2014-11-30 20:21                                 ` [PATCH 0/2] [media] tuners: Deletion of two unnecessary checks SF Markus Elfring
2014-11-30 20:25                                   ` [PATCH 1/2] [media] tuners: Deletion of unnecessary checks before the function call "release_firmware" SF Markus Elfring
2014-11-30 20:28                                   ` [PATCH 2/2] [media] tuners-si2157: One function call less in si2157_init() after error detection SF Markus Elfring
2014-11-30 21:55                                 ` [PATCH 1/1] [media] ddbridge: Deletion of an unnecessary check before the function call "dvb_unregister_device" SF Markus Elfring
2014-11-30 22:23                                 ` [PATCH 1/1] [media] V4L2: Deletion of an unnecessary check before the function call "vb2_put_vma" SF Markus Elfring
2014-12-01  9:46                                   ` Marek Szyprowski
2014-12-01 18:55                                 ` [PATCH 1/1] [media] lirc_zilog: Deletion of unnecessary checks before the function call "vfree" SF Markus Elfring
2014-12-01 22:30                                 ` [PATCH 0/2] [media] mn88473: Delete an unnecessary check SF Markus Elfring
2014-12-01 22:33                                   ` [PATCH 1/2] [media] mn88473: Deletion of an unnecessary check before the function call "release_firmware" SF Markus Elfring
2014-12-01 22:35                                   ` [PATCH 2/2] [media] mn88473: One function call less in mn88473_init() after error detection SF Markus Elfring
2015-02-01 19:11                                 ` [PATCH 0/2] [media] mn88472: Delete an unnecessary check SF Markus Elfring
2015-02-01 19:16                                   ` [PATCH 1/2] [media] mn88472: Deletion of an unnecessary check before the function call "release_firmware" SF Markus Elfring
2015-02-01 19:18                                   ` [PATCH 2/2] [media] mn88472: One function call less in mn88472_init() after error detection SF Markus Elfring
2015-02-02 12:44                                 ` [media] staging: bcm2048: Delete an unnecessary check before the function call "video_unregister_device" SF Markus Elfring
2015-02-03 14:10                                 ` [PATCH] [media] sp2: Delete an unnecessary check before the function call "kfree" SF Markus Elfring
2015-02-03 14:31                                 ` [PATCH] [media] V4L2: Delete an unnecessary check before the function call "media_entity_put" SF Markus Elfring
2015-02-03 16:18                                 ` [PATCH 0/2] DVB: Deletion of a few unnecessary checks SF Markus Elfring
2015-02-03 16:22                                   ` [PATCH 1/2] [media] DVB: Delete an unnecessary check before the function call "dvb_unregister_device" SF Markus Elfring
2015-02-03 16:23                                   ` [PATCH 2/2] [media] DVB: Less function calls in dvb_ca_en50221_init() after error detection SF Markus Elfring
2015-02-03 17:45                                 ` [PATCH] [media] stk-webcam: Delete an unnecessary check before the function call "vfree" SF Markus Elfring
2015-02-03 18:03                                 ` [PATCH] [media] au0828: Delete unnecessary checks before the function call "video_unregister_device" SF Markus Elfring
2015-11-05 18:45                                 ` [PATCH 0/2] [media] c8sectpfe: Deletion of a few unnecessary checks SF Markus Elfring
2015-11-05 18:49                                   ` [PATCH 1/2] [media] c8sectpfe: Delete unnecessary checks before two function calls SF Markus Elfring
2015-11-05 18:50                                   ` [PATCH 2/2] [media] c8sectpfe: Combine three checks into a single if block SF Markus Elfring
2015-11-06 10:09                                     ` walter harms
2015-11-06  7:50                                   ` [PATCH 0/2] [media] c8sectpfe: Deletion of a few unnecessary checks Maxime Coquelin
2016-07-17 20:16                                 ` [PATCH] [media] tw686x-kh: Delete an unnecessary check before the function call "video_unregister_device" SF Markus Elfring
2016-07-22 10:16                                   ` Krzysztof Hałasa
2016-07-17 21:00                                 ` [PATCH] [media] cec: Delete an unnecessary check before the function call "rc_free_device" SF Markus Elfring
2016-07-19 18:02                                 ` [PATCH] [media] v4l2-common: Delete an unnecessary check before the function call "spi_unregister_device" SF Markus Elfring
2016-07-19 18:36                                   ` walter harms
2016-07-19 19:35                                 ` [PATCH] [media] tw686x: Delete an unnecessary check before the function call "video_unregister_device" SF Markus Elfring

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