Skip to contentSkip to conversation

Remove unnecessary null pointer checks?

Cocci Applied SF Markus Elfring 178 participants 1,551 messages Feb 21, 2014 – Apr 12, 2017 3 messages not in the archive Page 4 of 7

Subsystems (270)
lore
Share & tools
lore
maintainer Applied
#833 lore raw

Re: [PATCH] NetCP: Deletion of unnecessary checks before two function calls

In reply to SF Markus Elfring

From: SF Markus Elfring <[email protected]>
Date: Tue, 03 Feb 2015 20:22:23 +0100

Quoted 10 lines

From: Markus Elfring <[email protected]>
Date: Tue, 3 Feb 2015 20:12:25 +0100

The functions cpsw_ale_destroy() and of_dev_put() 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.

Applied.

maintainer Applied
#837 lore raw

Re: [PATCH] cxgb4: Delete an unnecessary check before the function call "release_firmware"

In reply to SF Markus Elfring

From: SF Markus Elfring <[email protected]>
Date: Wed, 04 Feb 2015 11:38:39 +0100

Quoted 9 lines

From: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 11:28:43 +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.

Applied.

maintainer Applied
#839 lore raw

Re: [PATCH] myri10ge: Delete an unnecessary check before the function call "kfree"

In reply to SF Markus Elfring

From: SF Markus Elfring <[email protected]>
Date: Wed, 04 Feb 2015 12:36:02 +0100

Quoted 9 lines

From: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 12:32:14 +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.

Applied.

maintainer Applied
#841 lore raw

Re: [PATCH] net: fec: Delete unnecessary checks before the function call "kfree"

In reply to SF Markus Elfring

From: SF Markus Elfring <[email protected]>
Date: Wed, 04 Feb 2015 13:00:46 +0100

Quoted 9 lines

From: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 12:56:42 +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.

Applied.

maintainer Applied
#843 lore raw

Re: [PATCH] netxen: Delete an unnecessary check before the function call "kfree"

In reply to SF Markus Elfring

From: SF Markus Elfring <[email protected]>
Date: Wed, 04 Feb 2015 13:21:29 +0100

Quoted 9 lines

From: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 13:17:48 +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.

Applied.

Acked-by on v1 1/1
#872 lore raw

Re: [PATCH] GPU-DRM-Exynos: Delete unnecessary checks before two function calls

In reply to SF Markus Elfring

Hi,

Quoted 41 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 21:54:45 +0100

The functions phy_power_on() and vunmap() perform also input parameter validation. Thus the test around their calls is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/gpu/drm/exynos/exynos_dp_core.c   | 6 ++----
 drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 2 +-
 2 files changed, 3 insertions(+), 5 deletions(-)
drivers/gpu/drm/exynos/exynos_dp_core.c +2 -4
index 34d46aa..306cf1d 100644
@@ -1057,14 +1057,12 @@ static int exynos_dp_create_connector(struct exynos_drm_display *display,
 
 static void exynos_dp_phy_init(struct exynos_dp_device *dp)
 {
-	if (dp->phy)
-		phy_power_on(dp->phy);
+	phy_power_on(dp->phy);
 }
 
 static void exynos_dp_phy_exit(struct exynos_dp_device *dp)
 {
-	if (dp->phy)
-		phy_power_off(dp->phy);
+	phy_power_off(dp->phy);
 }
 
 static void exynos_dp_poweron(struct exynos_drm_display *display)
drivers/gpu/drm/exynos/exynos_drm_fbdev.c +0 -0
index e12ea90..0dd448a 100644

drivers/gpu/drm/exynos/exynos_drm_fbdev.c static void exynos_drm_fbdev_destroy(struct drm_device *dev, · line 319

Quoted 8 lines
drivers/gpu/drm/exynos/exynos_drm_fbdev.c +1 -1
@@ -313,7 +313,7 @@ static void exynos_drm_fbdev_destroy(struct drm_device *dev,
 	struct exynos_drm_gem_obj *exynos_gem_obj = exynos_fbd->exynos_gem_obj;
 	struct drm_framebuffer *fb;
 
-	if (is_drm_iommu_supported(dev) && exynos_gem_obj->buffer->kvaddr)
+	if (is_drm_iommu_supported(dev))
 		vunmap(exynos_gem_obj->buffer->kvaddr);
 
 	/* release drm framebuffer and real buffer */

Thanks.
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

maintainer Applied
#845 lore raw

Re: [PATCH] qlogic: Deletion of unnecessary checks before two function calls

In reply to SF Markus Elfring

From: SF Markus Elfring <[email protected]>
Date: Wed, 04 Feb 2015 14:13:37 +0100

Quoted 9 lines

From: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 14:07:56 +0100

The functions kfree() and vfree() perform also input parameter validation. Thus the test around their calls is not needed.

This issue was detected by using the Coccinelle software.

Applied.

maintainer
#848 lore raw

Re: [PATCH] net: Mellanox: Delete unnecessary checks before the function call "vunmap"

In reply to SF Markus Elfring

From: SF Markus Elfring <[email protected]>
Date: Wed, 04 Feb 2015 15:22:33 +0100

Quoted 9 lines

From: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 15:17:00 +0100

The vunmap() function performs also input parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

This does not apply cleanly to the net-next tree, please respin.

maintainer Applied
#853 lore raw

Re: [PATCH] net: ep93xx_eth: Delete unnecessary checks before the function call "kfree"

In reply to SF Markus Elfring

From: SF Markus Elfring <[email protected]>
Date: Wed, 04 Feb 2015 16:00:37 +0100

Quoted 9 lines

From: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 15:56:58 +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.

Applied.

#878 lore raw

PATCH 1/1 GPU-DRM-Tegra: Delete an unnecessary check before the function call "vunmap"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 5 Feb 2015 10:12:51 +0100

The vunmap() function performs also input parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/gpu/drm/tegra/fb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/tegra/fb.c +1 -1
index e9c715d..803598e 100644
@@ -66,7 +66,7 @@ static void tegra_fb_destroy(struct drm_framebuffer *framebuffer)
 		struct tegra_bo *bo = fb->planes[i];
 
 		if (bo) {
-			if (bo->pages && bo->vaddr)
+			if (bo->pages)
 				vunmap(bo->vaddr);
 
 			drm_gem_object_unreference_unlocked(&bo->gem);
Signature · 1 line
2.2.2
#882 lore raw

PATCH 1/1 driver core: Delete an unnecessary check before the function call "put_device"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 5 Feb 2015 11:48:26 +0100

The put_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.

---
 drivers/base/core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/base/core.c +1 -2
index 97e2baf..9c6536f 100644
@@ -1095,8 +1095,7 @@ done:
 	kobject_del(&dev->kobj);
  Error:
 	cleanup_device_parent(dev);
-	if (parent)
-		put_device(parent);
+	put_device(parent);
 name_error:
 	kfree(dev->p);
 	dev->p = NULL;
Signature · 1 line
2.2.2
#834 lore raw

Re: [PATCH] NetCP: Deletion of unnecessary checks before two function calls

In reply to SF Markus Elfring

Hi Wingman,

There are some bugs in this error handling.

Quoted 6 lines · SF Markus Elfring
drivers/net/ethernet/ti/netcp_ethss.c +0 -0
index fa1041a..cbd6dde 100644
@@ -2010,12 +2010,10 @@ static int gbe_probe(struct netcp_device *netcp_device, struct device *dev,
 quit:

drivers/net/ethernet/ti/netcp_ethss.c static int gbe_probe(struct netcp_device *netcp_device, struct device *dev, · line 2016

Quoted 10 lines
drivers/net/ethernet/ti/netcp_ethss.c +2 -4
 	if (gbe_dev->hw_stats)
 		devm_kfree(dev, gbe_dev->hw_stats);
-	if (gbe_dev->ale)
-		cpsw_ale_destroy(gbe_dev->ale);
+	cpsw_ale_destroy(gbe_dev->ale);
 	if (gbe_dev->ss_regs)
 		devm_iounmap(dev, gbe_dev->ss_regs);
-	if (interfaces)
-		of_node_put(interfaces);
+	of_node_put(interfaces);
                    ^^^^^^^^^^

"interfaces" is sometimes unintialized in this code. I don't know why GCC doesn't catch this... :(

This is a "one rrr bug", which is caused because you just have one error label "quit" which handles all the error handling. Please read my Google+ comment on error handling.

https://plus.google.com/106378716002406849458/posts/dnanfhQ4mHQ

drivers/net/ethernet/ti/netcp_ethss.c static int gbe_probe(struct netcp_device *netcp_device, struct device *dev, · line 2017

Quoted 1 line
drivers/net/ethernet/ti/netcp_ethss.c +0 -0
 	devm_kfree(dev, gbe_dev);
        ^^^^^^^^^^^^^^^^^^^^^^^^

This is not the right way to use the devm_ interface. These things are freed automatically on error or when we are done with them. This driver is double freeing pretty much everything. Grep for devm_kfree() and fix everything.

I don't know why kbuild didn't catch this...

regards
dan carpenter

#883 lore raw

PATCH 1/1 InfiniBand: Delete unnecessary checks before the function, call "srp_destroy_fr_pool"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 5 Feb 2015 13:20:42 +0100

The srp_destroy_fr_pool() 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.

---
 drivers/infiniband/ulp/srp/ib_srp.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/infiniband/ulp/srp/ib_srp.c +5 -7
index 0747c05..6f5dfa1 100644
@@ -549,8 +549,7 @@ static int srp_create_ch_ib(struct srp_rdma_ch *ch)
 				     "FR pool allocation failed (%d)\n", ret);
 			goto err_qp;
 		}
-		if (ch->fr_pool)
-			srp_destroy_fr_pool(ch->fr_pool);
+		srp_destroy_fr_pool(ch->fr_pool);
 		ch->fr_pool = fr_pool;
 	} else if (!dev->use_fast_reg && dev->has_fmr) {
 		fmr_pool = srp_alloc_fmr_pool(target);
@@ -615,13 +614,12 @@ static void srp_free_ch_ib(struct srp_target_port *target,
 	if (!ch->qp)
 		return;
 
-	if (dev->use_fast_reg) {
-		if (ch->fr_pool)
-			srp_destroy_fr_pool(ch->fr_pool);
-	} else {
+	if (dev->use_fast_reg)
+		srp_destroy_fr_pool(ch->fr_pool);
+	else
 		if (ch->fmr_pool)
 			ib_destroy_fmr_pool(ch->fmr_pool);
-	}
+
 	srp_destroy_qp(ch);
 	ib_destroy_cq(ch->send_cq);
 	ib_destroy_cq(ch->recv_cq);
Signature · 1 line
2.2.2
#885 lore raw

PATCH 1/1 au1100fb: Delete unnecessary checks before two function calls

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 5 Feb 2015 14:10:21 +0100

The functions clk_enable() and clk_disable() test whether their argument is NULL and then return immediately. Thus the test around the calls is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/video/fbdev/au1100fb.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/video/fbdev/au1100fb.c +2 -8
index 5956018..47ee023 100644
@@ -605,11 +605,8 @@ int au1100fb_drv_suspend(struct platform_device *dev, pm_message_t state)
 	/* Blank the LCD */
 	au1100fb_fb_blank(VESA_POWERDOWN, &fbdev->info);
 
-	if (fbdev->lcdclk)
-		clk_disable(fbdev->lcdclk);
-
+	clk_disable(fbdev->lcdclk);
 	memcpy(&fbregs, fbdev->regs, sizeof(struct au1100fb_regs));
-
 	return 0;
 }
 
@@ -621,13 +618,10 @@ int au1100fb_drv_resume(struct platform_device *dev)
 		return 0;
 
 	memcpy(fbdev->regs, &fbregs, sizeof(struct au1100fb_regs));
-
-	if (fbdev->lcdclk)
-		clk_enable(fbdev->lcdclk);
+	clk_enable(fbdev->lcdclk);
 
 	/* Unblank the LCD */
 	au1100fb_fb_blank(VESA_NO_BLANKING, &fbdev->info);
-
 	return 0;
 }
 #else
Signature · 1 line
2.2.2
#886 lore raw

Re: [PATCH] au1100fb: Delete unnecessary checks before two function calls

Quoted 5 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 5 Feb 2015 14:10:21 +0100

The functions clk_enable() and clk_disable() test whether their argument is NULL and then return immediately.

This isn't true for clk_enable().

"I find it acceptable that some of my update suggestions do not fit to your quality expectations at the moment." --
https://lkml.org/lkml/2015/1/22/446

It's frustrating that you make the same mistake over and over and you are fine with doing that. If you make a mistake and you are fixing a bug, then hopefully you fix more bugs than you introduce. If you make a mistake and you are doing a cleanup then you are really just introducing bugs and that's not helpful. I wish you would find something useful to do instead of sending these patches. :(

regards,
dan carpenter

#887 lore raw

Re: [PATCH] au1100fb: Delete unnecessary checks before two function calls

Quoted 4 lines
Quoted 2 lines

The functions clk_enable() and clk_disable() test whether their argument is NULL and then return immediately.

This isn't true for clk_enable().

I stumble on an interesting name space issue once more.

Quoted 2 lines

It's frustrating that you make the same mistake over and over and you are fine with doing that.

I admit that there can be also risks with my update suggestions in similar ways to contributions from other software developers.

A specific function implementation exists which performs also input parameter validation.
http://lxr.free-electrons.com/source/drivers/sh/clk/core.c#L291

Such variants might not fit to the functions au1100fb_drv_suspend() and au1100fb_drv_resume().

Do you want that I send a reduced patch?

Regards,
Markus

#884 lore raw

Re: [PATCH] InfiniBand: Delete unnecessary checks before the function, call "srp_destroy_fr_pool"

In reply to SF Markus Elfring
Quoted 35 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 5 Feb 2015 13:20:42 +0100

The srp_destroy_fr_pool() 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.

---
 drivers/infiniband/ulp/srp/ib_srp.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/infiniband/ulp/srp/ib_srp.c +1 -6
index 0747c05..6f5dfa1 100644
@@ -549,8 +549,7 @@ static int srp_create_ch_ib(struct srp_rdma_ch *ch)
 				     "FR pool allocation failed (%d)\n", ret);
 			goto err_qp;
 		}
-		if (ch->fr_pool)
-			srp_destroy_fr_pool(ch->fr_pool);
+		srp_destroy_fr_pool(ch->fr_pool);
 		ch->fr_pool = fr_pool;
 	} else if (!dev->use_fast_reg && dev->has_fmr) {
 		fmr_pool = srp_alloc_fmr_pool(target);
@@ -615,13 +614,12 @@ static void srp_free_ch_ib(struct srp_target_port *target,
 	if (!ch->qp)
 		return;
 
-	if (dev->use_fast_reg) {
-		if (ch->fr_pool)
-			srp_destroy_fr_pool(ch->fr_pool);
-	} else {

drivers/infiniband/ulp/srp/ib_srp.c static void srp_free_ch_ib(struct srp_target_port *target, · line 625

Quoted 10 lines
drivers/infiniband/ulp/srp/ib_srp.c +4 -1
+	if (dev->use_fast_reg)
+		srp_destroy_fr_pool(ch->fr_pool);
+	else
 		if (ch->fmr_pool)
 			ib_destroy_fmr_pool(ch->fmr_pool);
-	}
+
 	srp_destroy_qp(ch);
 	ib_destroy_cq(ch->send_cq);
 	ib_destroy_cq(ch->recv_cq);

This patch makes the code in srp_free_ch_ib() asymmetric which is unfortunate. Please add a test in ib_destroy_fmr_pool() such that the check before ib_destroy_fmr_pool() can also be eliminated.

Bart.

#890 lore raw

PATCH 1/1 USB: appledisplay: Deletion of a check before backlight_device_unregister()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 5 Feb 2015 16:07:43 +0100

The backlight_device_unregister() 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.

---
 drivers/usb/misc/appledisplay.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/misc/appledisplay.c +1 -1
index b3d245e..a0a3827 100644
@@ -329,7 +329,7 @@ error:
 					pdata->urbdata, pdata->urb->transfer_dma);
 			usb_free_urb(pdata->urb);
 		}
-		if (pdata->bd && !IS_ERR(pdata->bd))
+		if (!IS_ERR(pdata->bd))
 			backlight_device_unregister(pdata->bd);
 		kfree(pdata->msgdata);
 	}
Signature · 1 line
2.2.2
#891 lore raw

PATCH 1/1 ueagle-atm: Delete unnecessary checks before the function call "release_firmware"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 5 Feb 2015 16:33:09 +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.

---
 drivers/usb/atm/ueagle-atm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/atm/ueagle-atm.c +2 -2
index 5a45937..888998a 100644
@@ -952,7 +952,7 @@ static void uea_load_page_e1(struct work_struct *work)
 	int i;
 
 	/* reload firmware when reboot start and it's loaded already */
-	if (ovl = 0 && pageno = 0 && sc->dsp_firm) {
+	if (ovl = 0 && pageno = 0) {
 		release_firmware(sc->dsp_firm);
 		sc->dsp_firm = NULL;
 	}
@@ -1074,7 +1074,7 @@ static void uea_load_page_e4(struct work_struct *work)
 	uea_dbg(INS_TO_USBDEV(sc), "sending DSP page %u\n", pageno);
 
 	/* reload firmware when reboot start and it's loaded already */
-	if (pageno = 0 && sc->dsp_firm) {
+	if (pageno = 0) {
 		release_firmware(sc->dsp_firm);
 		sc->dsp_firm = NULL;
 	}
Signature · 1 line
2.2.2
#835 lore raw

RE: [PATCH] NetCP: Deletion of unnecessary checks before two function calls

In reply to Dan Carpenter

RGFuLA0KDQpUaGFua3MuICBXZSdsbCBsb29rIGludG8gaXQgYW5kIHNlbmQgYSBwYXRjaCBzb29u Lg0KDQpSZWdhcmRzLA0KV2luZ01hbg0KDQo+IC0tLS0tT3JpZ2luYWwgTWVzc2FnZS0tLS0tDQo+ IEZyb206IERhbiBDYXJwZW50ZXIgW21haWx0bzpkYW4uY2FycGVudGVyQG9yYWNsZS5jb21dDQo+ IFNlbnQ6IFRodXJzZGF5LCBGZWJydWFyeSAwNSwgMjAxNSA3OjAyIEFNDQo+IFRvOiBLd29rLCBX aW5nTWFuDQo+IENjOiBTRiBNYXJrdXMgRWxmcmluZzsgS2FyaWNoZXJpLCBNdXJhbGlkaGFyYW47 IEt3b2ssIFdpbmdNYW47DQo+IG5ldGRldkB2Z2VyLmtlcm5lbC5vcmc7IExLTUw7IGtlcm5lbC1q YW5pdG9yc0B2Z2VyLmtlcm5lbC5vcmc7IEp1bGlhIExhd2FsbA0KPiBTdWJqZWN0OiBSZTogW1BB VENIXSBOZXRDUDogRGVsZXRpb24gb2YgdW5uZWNlc3NhcnkgY2hlY2tzIGJlZm9yZSB0d28NCj4g ZnVuY3Rpb24gY2FsbHMNCj4gDQo+IEhpIFdpbmdtYW4sDQo+IA0KPiBUaGVyZSBhcmUgc29tZSBi dWdzIGluIHRoaXMgZXJyb3IgaGFuZGxpbmcuDQo+IA0KPiBPbiBUdWUsIEZlYiAwMywgMjAxNSBh dCAwODoyMjoyM1BNICswMTAwLCBTRiBNYXJrdXMgRWxmcmluZyB3cm90ZToNCj4gPiBkaWZmIC0t Z2l0IGEvZHJpdmVycy9uZXQvZXRoZXJuZXQvdGkvbmV0Y3BfZXRoc3MuYw0KPiBiL2RyaXZlcnMv bmV0L2V0aGVybmV0L3RpL25ldGNwX2V0aHNzLmMNCj4gPiBpbmRleCBmYTEwNDFhLi5jYmQ2ZGRl IDEwMDY0NA0KPiA+IC0tLSBhL2RyaXZlcnMvbmV0L2V0aGVybmV0L3RpL25ldGNwX2V0aHNzLmMN Cj4gPiArKysgYi9kcml2ZXJzL25ldC9ldGhlcm5ldC90aS9uZXRjcF9ldGhzcy5jDQo+ID4gQEAg LTIwMTAsMTIgKzIwMTAsMTAgQEAgc3RhdGljIGludCBnYmVfcHJvYmUoc3RydWN0IG5ldGNwX2Rl dmljZQ0KPiAqbmV0Y3BfZGV2aWNlLCBzdHJ1Y3QgZGV2aWNlICpkZXYsDQo+ID4gIHF1aXQ6DQo+ ID4gIAlpZiAoZ2JlX2Rldi0+aHdfc3RhdHMpDQo+ID4gIAkJZGV2bV9rZnJlZShkZXYsIGdiZV9k ZXYtPmh3X3N0YXRzKTsNCj4gPiAtCWlmIChnYmVfZGV2LT5hbGUpDQo+ID4gLQkJY3Bzd19hbGVf ZGVzdHJveShnYmVfZGV2LT5hbGUpOw0KPiA+ICsJY3Bzd19hbGVfZGVzdHJveShnYmVfZGV2LT5h bGUpOw0KPiA+ICAJaWYgKGdiZV9kZXYtPnNzX3JlZ3MpDQo+ID4gIAkJZGV2bV9pb3VubWFwKGRl diwgZ2JlX2Rldi0+c3NfcmVncyk7DQo+ID4gLQlpZiAoaW50ZXJmYWNlcykNCj4gPiAtCQlvZl9u b2RlX3B1dChpbnRlcmZhY2VzKTsNCj4gPiArCW9mX25vZGVfcHV0KGludGVyZmFjZXMpOw0KPiAg ICAgICAgICAgICAgICAgICAgIF5eXl5eXl5eXl4NCj4gImludGVyZmFjZXMiIGlzIHNvbWV0aW1l cyB1bmludGlhbGl6ZWQgaW4gdGhpcyBjb2RlLiAgSSBkb24ndCBrbm93IHdoeQ0KPiBHQ0MgZG9l c24ndCBjYXRjaCB0aGlzLi4uICA6KA0KPiANCj4gVGhpcyBpcyBhICJvbmUgcnJyIGJ1ZyIsIHdo aWNoIGlzIGNhdXNlZCBiZWNhdXNlIHlvdSBqdXN0IGhhdmUgb25lIGVycm9yDQo+IGxhYmVsICJx dWl0IiB3aGljaCBoYW5kbGVzIGFsbCB0aGUgZXJyb3IgaGFuZGxpbmcuICBQbGVhc2UgcmVhZCBt eQ0KPiBHb29nbGUrIGNvbW1lbnQgb24gZXJyb3IgaGFuZGxpbmcuDQo+IA0KPiBodHRwczovL3Bs dXMuZ29vZ2xlLmNvbS8xMDYzNzg3MTYwMDI0MDY4NDk0NTgvcG9zdHMvZG5hbmZoUTRtSFENCj4g DQo+ID4gIAlkZXZtX2tmcmVlKGRldiwgZ2JlX2Rldik7DQo+ICAgICAgICAgXl5eXl5eXl5eXl5e Xl5eXl5eXl5eXl5eDQo+IFRoaXMgaXMgbm90IHRoZSByaWdodCB3YXkgdG8gdXNlIHRoZSBkZXZt XyBpbnRlcmZhY2UuICBUaGVzZSB0aGluZ3MgYXJlDQo+IGZyZWVkIGF1dG9tYXRpY2FsbHkgb24g ZXJyb3Igb3Igd2hlbiB3ZSBhcmUgZG9uZSB3aXRoIHRoZW0uICBUaGlzIGRyaXZlcg0KPiBpcyBk b3VibGUgZnJlZWluZyBwcmV0dHkgbXVjaCBldmVyeXRoaW5nLiAgR3JlcCBmb3IgZGV2bV9rZnJl ZSgpIGFuZA0KPiBmaXggZXZlcnl0aGluZy4NCj4gDQo+IEkgZG9uJ3Qga25vdyB3aHkga2J1aWxk IGRpZG4ndCBjYXRjaCB0aGlzLi4uDQo+IA0KPiByZWdhcmRzDQo+IGRhbiBjYXJwZW50ZXINCg0K

#892 lore raw

PATCH 1/1 USB: whci-hcd: Delete an unnecessary check before the function call "usb_put_hcd"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 5 Feb 2015 16:54:12 +0100

The usb_put_hcd() 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.

---
 drivers/usb/host/whci/hcd.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/usb/host/whci/hcd.c +1 -2
index d7b363a..43626c4 100644
@@ -313,8 +313,7 @@ error_wusbhc_create:
 	uwb_rc_put(wusbhc->uwb_rc);
 error:
 	whc_clean_up(whc);
-	if (usb_hcd)
-		usb_put_hcd(usb_hcd);
+	usb_put_hcd(usb_hcd);
 	return ret;
 }
 
Signature · 1 line
2.2.2
#893 lore raw

PATCH 1/1 Input: Delete an unnecessary check before the function call "input_free_device"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 5 Feb 2015 17:35:35 +0100

The input_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.

---
 drivers/input/joystick/adi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/input/joystick/adi.c +1 -2
index b784257..d09cefa 100644
@@ -535,8 +535,7 @@ static int adi_connect(struct gameport *gameport, struct gameport_driver *drv)
 		}
 	}
  fail2:	for (i = 0; i < 2; i++)
-		if (port->adi[i].dev)
-			input_free_device(port->adi[i].dev);
+		input_free_device(port->adi[i].dev);
 	gameport_close(gameport);
  fail1:	gameport_set_drvdata(gameport, NULL);
 	kfree(port);
Signature · 1 line
2.2.2
#722 lore raw

PATCH 1/1 IOMMU-Tegra: gart: Delete an unnecessary check before the function call "vfree"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 5 Feb 2015 17:54:16 +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.

---
 drivers/iommu/tegra-gart.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/iommu/tegra-gart.c +1 -2
index f722a0c..07a795a 100644
@@ -404,8 +404,7 @@ static int tegra_gart_remove(struct platform_device *pdev)
 	struct gart_device *gart = platform_get_drvdata(pdev);
 
 	writel(0, gart->regs + GART_CONFIG);
-	if (gart->savedata)
-		vfree(gart->savedata);
+	vfree(gart->savedata);
 	gart_handle = NULL;
 	return 0;
 }
Signature · 1 line
2.2.2
#888 lore raw

Re: [PATCH] au1100fb: Delete unnecessary checks before two function calls

In reply to SF Markus Elfring
Quoted 7 lines · SF Markus Elfring
Quoted 4 lines
Quoted 2 lines

The functions clk_enable() and clk_disable() test whether their argument is NULL and then return immediately.

This isn't true for clk_enable().

I stumble on an interesting name space issue once more.

The "once more" is the problem in this statement. Other people would have stopped making the mistake by now. I am able to see your bugs so you should be able to see your bugs as well.

Quoted 7 lines
Quoted 3 lines

It's frustrating that you make the same mistake over and over and you are fine with doing that.

I admit that there can be also risks with my update suggestions in similar ways to contributions from other software developers.

At times, I have told other people to stop sending cleanups until they can at least fix a bugs to balance out the bugs they have introduced. It's unacceptable to only introduce bugs and never fix any.

regards,
dan carpenter

#889 lore raw

Re: [PATCH] au1100fb: Delete unnecessary checks before two function calls

Quoted 1 line

It's unacceptable to only introduce bugs

Such a view is generally fine.

Would you like to point any more update candidates out from my suggestion collection?

Quoted 1 line

and never fix any.

Would you like to clarify any statistics around my update suggestions?

Regards,
Markus

#895 lore raw

PATCH 1/1 uwb/whci: Delete an unnecessary check before the function call "umc_device_unregister"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 5 Feb 2015 21:40:29 +0100

The umc_device_unregister() 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.

---
 drivers/uwb/whci.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/uwb/whci.c +1 -2
index 46b7cfc..c3ee39a 100644
@@ -133,8 +133,7 @@ static void whci_del_cap(struct whci_card *card, int n)
 {
 	struct umc_dev *umc = card->devs[n];
 
-	if (umc != NULL)
-		umc_device_unregister(umc);
+	umc_device_unregister(umc);
 }
 
 static int whci_n_caps(struct pci_dev *pci)
Signature · 1 line
2.2.2
#896 lore raw

PATCH 1/1 SCSI-bfa: Delete more unnecessary checks before the function call "vfree"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 5 Feb 2015 22:02:16 +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.

---
 drivers/scsi/bfa/bfad.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/scsi/bfa/bfad.c +3 -3
index e90a374..05c8ca0 100644
@@ -1810,11 +1810,11 @@ bfad_load_fwimg(struct pci_dev *pdev)
 static void
 bfad_free_fwimg(void)
 {
-	if (bfi_image_ct2_size && bfi_image_ct2)
+	if (bfi_image_ct2_size)
 		vfree(bfi_image_ct2);
-	if (bfi_image_ct_size && bfi_image_ct)
+	if (bfi_image_ct_size)
 		vfree(bfi_image_ct);
-	if (bfi_image_cb_size && bfi_image_cb)
+	if (bfi_image_cb_size)
 		vfree(bfi_image_cb);
 }
 
Signature · 1 line
2.2.2
#897 lore raw

PATCH 1/1 SCSI-aic7...: Delete unnecessary checks before the function call "kfree"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 5 Feb 2015 22:23:48 +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.

---
 drivers/scsi/aic7xxx/aic7xxx_core.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)
drivers/scsi/aic7xxx/aic7xxx_core.c +5 -10
index 10172a3..98a5ed1 100644
@@ -2200,8 +2200,7 @@ ahc_free_tstate(struct ahc_softc *ahc, u_int scsi_id, char channel, int force)
 	if (channel = 'B')
 		scsi_id += 8;
 	tstate = ahc->enabled_targets[scsi_id];
-	if (tstate != NULL)
-		kfree(tstate);
+	kfree(tstate);
 	ahc->enabled_targets[scsi_id] = NULL;
 }
 #endif
@@ -4482,8 +4481,7 @@ ahc_set_unit(struct ahc_softc *ahc, int unit)
 void
 ahc_set_name(struct ahc_softc *ahc, char *name)
 {
-	if (ahc->name != NULL)
-		kfree(ahc->name);
+	kfree(ahc->name);
 	ahc->name = name;
 }
 
@@ -4550,10 +4548,8 @@ ahc_free(struct ahc_softc *ahc)
 		kfree(ahc->black_hole);
 	}
 #endif
-	if (ahc->name != NULL)
-		kfree(ahc->name);
-	if (ahc->seep_config != NULL)
-		kfree(ahc->seep_config);
+	kfree(ahc->name);
+	kfree(ahc->seep_config);
 #ifndef __FreeBSD__
 	kfree(ahc);
 #endif
@@ -4958,8 +4954,7 @@ ahc_fini_scbdata(struct ahc_softc *ahc)
 	case 0:
 		break;
 	}
-	if (scb_data->scbarray != NULL)
-		kfree(scb_data->scbarray);
+	kfree(scb_data->scbarray);
 }
 
 static void
Signature · 1 line
2.2.2
#899 lore raw

cover SCSI-lpfc: Deletion of an unnecessary check

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 5 Feb 2015 23:17:52 +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 "kfree" One function call less in lpfc_bsg_hba_set_event() after error detection

 drivers/scsi/lpfc/lpfc_bsg.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
Signature · 1 line
2.2.2
#900 lore raw

PATCH 1/2 SCSI-lpfc: Delete an unnecessary check before the function call "kfree"

From: Markus Elfring <[email protected]>
Date: Thu, 5 Feb 2015 22:45:02 +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.

---
 drivers/scsi/lpfc/lpfc_bsg.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/scsi/lpfc/lpfc_bsg.c +1 -3
index a7bf359..1af783a 100644
@@ -1261,9 +1261,7 @@ lpfc_bsg_hba_set_event(struct fc_bsg_job *job)
 	return 0; /* call job done later */
 
 job_error:
-	if (dd_data != NULL)
-		kfree(dd_data);
-
+	kfree(dd_data);
 	job->dd_data = NULL;
 	return rc;
 }
Signature · 1 line
2.2.2
#901 lore raw

PATCH 2/2 SCSI-lpfc: One function call less in lpfc_bsg_hba_set_event() after error detection

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 5 Feb 2015 23:03:52 +0100

The kfree() function was called in two cases by the lpfc_bsg_hba_set_event() function during error handling even if the passed variable "dd_data" contained still a null pointer.

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

---
 drivers/scsi/lpfc/lpfc_bsg.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/scsi/lpfc/lpfc_bsg.c +3 -2
index 1af783a..b8074cf 100644
@@ -1240,7 +1240,7 @@ lpfc_bsg_hba_set_event(struct fc_bsg_job *job)
 					"2617 Failed allocation of event "
 					"waiter\n");
 			rc = -ENOMEM;
-			goto job_error;
+			goto free_data;
 		}
 		dd_data->type = TYPE_EVT;
 		dd_data->set_job = NULL;
@@ -1260,8 +1260,9 @@ lpfc_bsg_hba_set_event(struct fc_bsg_job *job)
 	spin_unlock_irqrestore(&phba->ct_ev_lock, flags);
 	return 0; /* call job done later */
 
-job_error:
+free_data:
 	kfree(dd_data);
+job_error:
 	job->dd_data = NULL;
 	return rc;
 }
Signature · 1 line
2.2.2
#856 lore raw

Re: [1/2] cw1200: Delete an unnecessary check before the function call "release_firmware"

In reply to SF Markus Elfring
Quoted 10 lines

From: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 16:32:15 +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.

Thanks, 2 patches applied to wireless-drivers-next.git:

df970d39b90e cw1200: Delete an unnecessary check before the function call "release_firmware" ee4ddad82356 cw1200: Less function calls in cw1200_load_firmware_cw1200() after error detection

Kalle Valo

Applied
#859 lore raw

Re: ath9k: Delete an unnecessary check before the function call"relay_close"

In reply to SF Markus Elfring
Quoted 10 lines

From: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 18:48:28 +0100

The relay_close() 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.

Thanks, applied to wireless-drivers-next.git.

Kalle Valo

Applied
#863 lore raw

Re: orinoco: Delete an unnecessary check before the function call "kfree"

In reply to SF Markus Elfring
Quoted 10 lines

From: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 19:53:11 +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.

Thanks, applied to wireless-drivers-next.git.

Kalle Valo

Applied
#865 lore raw

Re: hostap: Delete an unnecessary check before the function call "kfree"

In reply to SF Markus Elfring
Quoted 10 lines

From: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 20:06:39 +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.

Thanks, applied to wireless-drivers-next.git.

Kalle Valo

Applied
#867 lore raw

Re: brcm80211: Delete unnecessary checks before two function calls

In reply to SF Markus Elfring
Quoted 9 lines

From: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 20:28:49 +0100

The functions brcmu_pkt_buf_free_skb() and usb_free_urb() test whether their argument is NULL and then return immediately. Thus the test around the call is not needed.

Thanks, applied to wireless-drivers-next.git.

Kalle Valo

#903 lore raw

cover SCSI-debug: Deletion of a few unnecessary checks

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 6 Feb 2015 18:08:53 +0100

Further update suggestions were taken into account after a patch was applied from static source code analysis.

Markus Elfring (3):
Deletion of unnecessary checks before the function call "vfree" Less function calls in scsi_debug_init() after error detection Fix exception handling for an alignment/granularity mismatch
in scsi_debug_init()

 drivers/scsi/scsi_debug.c | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)
Signature · 1 line
2.2.2
#904 lore raw

PATCH 1/3 SCSI-debug: Deletion of unnecessary checks before the function call "vfree"

From: Markus Elfring <[email protected]>
Date: Fri, 6 Feb 2015 16:56:57 +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.

---
 drivers/scsi/scsi_debug.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/scsi/scsi_debug.c +3 -9
index 1132321..9e4add7 100644
@@ -4969,12 +4969,9 @@ bus_unreg:
 dev_unreg:
 	root_device_unregister(pseudo_primary);
 free_vm:
-	if (map_storep)
-		vfree(map_storep);
-	if (dif_storep)
-		vfree(dif_storep);
+	vfree(map_storep);
+	vfree(dif_storep);
 	vfree(fake_storep);
-
 	return ret;
 }
 
@@ -4989,10 +4986,7 @@ static void __exit scsi_debug_exit(void)
 	driver_unregister(&sdebug_driverfs_driver);
 	bus_unregister(&pseudo_lld_bus);
 	root_device_unregister(pseudo_primary);
-
-	if (dif_storep)
-		vfree(dif_storep);
-
+	vfree(dif_storep);
 	vfree(fake_storep);
 }
 
Signature · 1 line
2.2.2
#906 lore raw

PATCH 2/3 SCSI-debug: Less function calls in scsi_debug_init() after error detection

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 6 Feb 2015 17:48:34 +0100

The vfree() function was called in two cases by the scsi_debug_init() function during error handling even if the passed variables "dif_storep" and "map_storep" contained null pointers eventually.

This implementation detail could be improved by the introduction of two jump labels.

---
 drivers/scsi/scsi_debug.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/scsi/scsi_debug.c +6 -4
index 9e4add7..756b7be 100644
@@ -4887,7 +4887,7 @@ static int __init scsi_debug_init(void)
 		if (dif_storep = NULL) {
 			pr_err("%s: out of mem. (DIX)\n", __func__);
 			ret = -ENOMEM;
-			goto free_vm;
+			goto free_fake;
 		}
 
 		memset(dif_storep, 0xff, dif_size);
@@ -4920,7 +4920,7 @@ static int __init scsi_debug_init(void)
 		if (map_storep = NULL) {
 			pr_err("%s: out of mem. (MAP)\n", __func__);
 			ret = -ENOMEM;
-			goto free_vm;
+			goto free_dif;
 		}
 
 		bitmap_zero(map_storep, map_size);
@@ -4934,7 +4934,7 @@ static int __init scsi_debug_init(void)
 	if (IS_ERR(pseudo_primary)) {
 		pr_warn("%s: root_device_register() error\n", __func__);
 		ret = PTR_ERR(pseudo_primary);
-		goto free_vm;
+		goto free_map;
 	}
 	ret = bus_register(&pseudo_lld_bus);
 	if (ret < 0) {
@@ -4968,9 +4968,11 @@ bus_unreg:
 	bus_unregister(&pseudo_lld_bus);
 dev_unreg:
 	root_device_unregister(pseudo_primary);
-free_vm:
+free_map:
 	vfree(map_storep);
+free_dif:
 	vfree(dif_storep);
+free_fake:
 	vfree(fake_storep);
 	return ret;
 }
Signature · 1 line
2.2.2
#908 lore raw

PATCH 3/3 SCSI-debug: Fix exception handling for an alignment/granularity mismatch in scsi_debug_init()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 6 Feb 2015 17:57:32 +0100

The scsi_debug_init() function returned directly if the data items "alignment" and "granularity" did not fit together.

Let us improve the affected exception handling by replacing the return statement by a goto statement so that previously allocated resources will also be appropriately released.

---
 drivers/scsi/scsi_debug.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/scsi/scsi_debug.c +2 -1
index 756b7be..2c78663 100644
@@ -4909,7 +4909,8 @@ static int __init scsi_debug_init(void)
 		    scsi_debug_unmap_alignment) {
 			pr_err("%s: ERR: unmap_granularity <= unmap_alignment\n",
 			       __func__);
-			return -EINVAL;
+			ret = -EINVAL;
+			goto free_dif;
 		}
 
 		map_size = lba_to_map_index(sdebug_store_sectors - 1) + 1;
Signature · 1 line
2.2.2
#910 lore raw

PATCH 1/1 SCSI-csiostor: Delete an unnecessary check before the function call "release_firmware"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 6 Feb 2015 19:10:25 +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.

---
 drivers/scsi/csiostor/csio_hw.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/scsi/csiostor/csio_hw.c +1 -2
index 35c5f83..37fa8bf 100644
@@ -2117,8 +2117,7 @@ csio_hw_flash_fw(struct csio_hw *hw, int *reset)
 			 hw->fw_state, reset);
 
 	/* Cleaning up */
-	if (fw != NULL)
-		release_firmware(fw);
+	release_firmware(fw);
 	kfree(card_fw);
 	return ret;
 }
Signature · 1 line
2.2.2
#798 lore raw

Re: [PATCH 3/3] dm ioctl: Delete an unnecessary check before the function call "dm_table_destroy"

In reply to SF Markus Elfring
Quoted 7 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Mon, 2 Feb 2015 15:30:37 +0100

The dm_table_destroy() 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.

Your proposed patch (while technically correct) hurts code clarity.

Nack.

#911 lore raw

cover SCSI-QLA4...: Deletion of some unnecessary checks

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 6 Feb 2015 23:03:41 +0100

Further update suggestions were taken into account after a patch was applied from static source code analysis.

Markus Elfring (4):
Deletion of unnecessary checks before three function calls Less function calls in qla4xxx_is_session_exists() after error detection Less function calls in qla4xxx_is_flash_ddb_exists() after error detection Less function calls in qla4xxx_sysfs_ddb_logout() after error detection

 drivers/scsi/qla4xxx/ql4_mbx.c |  2 +-
 drivers/scsi/qla4xxx/ql4_os.c  | 96 ++++++++++++++++++------------------------
 2 files changed, 42 insertions(+), 56 deletions(-)
Signature · 1 line
2.2.2
#912 lore raw

PATCH 1/4 SCSI-QLA4...: Deletion of unnecessary checks before three function calls

From: Markus Elfring <[email protected]>
Date: Fri, 6 Feb 2015 20:38:23 +0100

The following functions perform also input parameter validation.
* iscsi_boot_destroy_kset
* kfree
* vfree

Thus the test around their calls is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/scsi/qla4xxx/ql4_mbx.c |  2 +-
 drivers/scsi/qla4xxx/ql4_os.c  | 31 ++++++++++---------------------
 2 files changed, 11 insertions(+), 22 deletions(-)
drivers/scsi/qla4xxx/ql4_mbx.c +1 -1
index c291fdf..2343c0f 100644
@@ -2410,7 +2410,7 @@ exit_free_acb:
 	dma_free_coherent(&ha->pdev->dev, sizeof(struct addr_ctrl_blk), acb,
 			  acb_dma);
 exit_config_acb:
-	if ((acb_config = ACB_CONFIG_SET) && ha->saved_acb) {
+	if (acb_config = ACB_CONFIG_SET) {
 		kfree(ha->saved_acb);
 		ha->saved_acb = NULL;
 	}
drivers/scsi/qla4xxx/ql4_os.c +10 -21
index 6d25879..2a00fd3 100644
@@ -4131,9 +4131,7 @@ static void qla4xxx_mem_free(struct scsi_qla_host *ha)
 		dma_free_coherent(&ha->pdev->dev, ha->queues_len, ha->queues,
 				  ha->queues_dma);
 
-	 if (ha->fw_dump)
-		vfree(ha->fw_dump);
-
+	vfree(ha->fw_dump);
 	ha->queues_len = 0;
 	ha->queues = NULL;
 	ha->queues_dma = 0;
@@ -4155,8 +4153,7 @@ static void qla4xxx_mem_free(struct scsi_qla_host *ha)
 	if (ha->chap_dma_pool)
 		dma_pool_destroy(ha->chap_dma_pool);
 
-	if (ha->chap_list)
-		vfree(ha->chap_list);
+	vfree(ha->chap_list);
 	ha->chap_list = NULL;
 
 	if (ha->fw_ddb_dma_pool)
@@ -4175,9 +4172,7 @@ static void qla4xxx_mem_free(struct scsi_qla_host *ha)
 		iounmap(ha->reg);
 	}
 
-	if (ha->reset_tmplt.buff)
-		vfree(ha->reset_tmplt.buff);
-
+	vfree(ha->reset_tmplt.buff);
 	pci_release_regions(ha->pdev);
 }
 
@@ -6370,10 +6365,8 @@ static int qla4xxx_is_session_exists(struct scsi_qla_host *ha,
 	}
 
 exit_check:
-	if (fw_tddb)
-		vfree(fw_tddb);
-	if (tmp_tddb)
-		vfree(tmp_tddb);
+	vfree(fw_tddb);
+	vfree(tmp_tddb);
 	return ret;
 }
 
@@ -6525,10 +6518,8 @@ static int qla4xxx_is_flash_ddb_exists(struct scsi_qla_host *ha,
 	}
 
 exit_check:
-	if (fw_tddb)
-		vfree(fw_tddb);
-	if (tmp_tddb)
-		vfree(tmp_tddb);
+	vfree(fw_tddb);
+	vfree(tmp_tddb);
 	return ret;
 }
 
@@ -7806,10 +7797,8 @@ static int qla4xxx_sysfs_ddb_logout(struct iscsi_bus_flash_session *fnode_sess,
 		ret = -ESRCH;
 
 exit_ddb_logout:
-	if (flash_tddb)
-		vfree(flash_tddb);
-	if (tmp_tddb)
-		vfree(tmp_tddb);
+	vfree(flash_tddb);
+	vfree(tmp_tddb);
 	if (fw_ddb_entry)
 		dma_pool_free(ha->fw_ddb_dma_pool, fw_ddb_entry, fw_ddb_dma);
 
@@ -9002,7 +8991,7 @@ static void qla4xxx_remove_adapter(struct pci_dev *pdev)
 	/* destroy iface from sysfs */
 	qla4xxx_destroy_ifaces(ha);
 
-	if ((!ql4xdisablesysfsboot) && ha->boot_kset)
+	if (!ql4xdisablesysfsboot)
 		iscsi_boot_destroy_kset(ha->boot_kset);
 
 	qla4xxx_destroy_fw_ddb_session(ha);
Signature · 1 line
2.2.2
#913 lore raw

PATCH 2/4 SCSI-QLA4...: Less function calls in qla4xxx_is_session_exists() after error detection

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 6 Feb 2015 21:14:40 +0100

The vfree() function was called in two cases by the qla4xxx_is_session_exists() function during error handling even if the passed variables "fw_tddb" and "tmp_tddb" contained still a null pointer.

* This implementation detail could be improved by adjustments for jump labels.

* Let us return immediately after the first failed function call according to the current Linux coding style convention.

---
 drivers/scsi/qla4xxx/ql4_os.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)
drivers/scsi/qla4xxx/ql4_os.c +8 -9
index 2a00fd3..a7ca479 100644
@@ -6327,17 +6327,15 @@ static int qla4xxx_is_session_exists(struct scsi_qla_host *ha,
 				     uint32_t *index)
 {
 	struct ddb_entry *ddb_entry;
-	struct ql4_tuple_ddb *fw_tddb = NULL;
-	struct ql4_tuple_ddb *tmp_tddb = NULL;
 	int idx;
 	int ret = QLA_ERROR;
+	struct ql4_tuple_ddb *tmp_tddb;
+	struct ql4_tuple_ddb *fw_tddb = vzalloc(sizeof(*fw_tddb));
 
-	fw_tddb = vzalloc(sizeof(*fw_tddb));
 	if (!fw_tddb) {
 		DEBUG2(ql4_printk(KERN_WARNING, ha,
 				  "Memory Allocation failed.\n"));
-		ret = QLA_SUCCESS;
-		goto exit_check;
+		return QLA_SUCCESS;
 	}
 
 	tmp_tddb = vzalloc(sizeof(*tmp_tddb));
@@ -6345,7 +6343,7 @@ static int qla4xxx_is_session_exists(struct scsi_qla_host *ha,
 		DEBUG2(ql4_printk(KERN_WARNING, ha,
 				  "Memory Allocation failed.\n"));
 		ret = QLA_SUCCESS;
-		goto exit_check;
+		goto free_fw;
 	}
 
 	qla4xxx_convert_param_ddb(fw_ddb_entry, fw_tddb, NULL);
@@ -6360,13 +6358,14 @@ static int qla4xxx_is_session_exists(struct scsi_qla_host *ha,
 			ret = QLA_SUCCESS; /* found */
 			if (index != NULL)
 				*index = idx;
-			goto exit_check;
+			goto free_tmp;
 		}
 	}
 
-exit_check:
-	vfree(fw_tddb);
+free_tmp:
 	vfree(tmp_tddb);
+free_fw:
+	vfree(fw_tddb);
 	return ret;
 }
 
Signature · 1 line
2.2.2
#918 lore raw

PATCH 3/4 SCSI-QLA4...: Less function calls in qla4xxx_is_flash_ddb_exists() after error detection

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 6 Feb 2015 21:55:55 +0100

The vfree() function was called in two cases by the qla4xxx_is_flash_ddb_exists() function during error handling even if the passed variables "fw_tddb" and "tmp_tddb" contained still a null pointer.

* This implementation detail could be improved by adjustments for jump labels.

* Let us return immediately after the first failed function call according to the current Linux coding style convention.

---
 drivers/scsi/qla4xxx/ql4_os.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)
drivers/scsi/qla4xxx/ql4_os.c +9 -10
index a7ca479..e508bc9 100644
@@ -6470,16 +6470,14 @@ static int qla4xxx_is_flash_ddb_exists(struct scsi_qla_host *ha,
 				       struct dev_db_entry *fw_ddb_entry)
 {
 	struct qla_ddb_index  *nt_ddb_idx, *nt_ddb_idx_tmp;
-	struct ql4_tuple_ddb *fw_tddb = NULL;
-	struct ql4_tuple_ddb *tmp_tddb = NULL;
 	int rval, ret = QLA_ERROR;
+	struct ql4_tuple_ddb *tmp_tddb;
+	struct ql4_tuple_ddb *fw_tddb = vzalloc(sizeof(*fw_tddb));
 
-	fw_tddb = vzalloc(sizeof(*fw_tddb));
 	if (!fw_tddb) {
 		DEBUG2(ql4_printk(KERN_WARNING, ha,
 				  "Memory Allocation failed.\n"));
-		ret = QLA_SUCCESS;
-		goto exit_check;
+		return QLA_SUCCESS;
 	}
 
 	tmp_tddb = vzalloc(sizeof(*tmp_tddb));
@@ -6487,7 +6485,7 @@ static int qla4xxx_is_flash_ddb_exists(struct scsi_qla_host *ha,
 		DEBUG2(ql4_printk(KERN_WARNING, ha,
 				  "Memory Allocation failed.\n"));
 		ret = QLA_SUCCESS;
-		goto exit_check;
+		goto vfree_fw;
 	}
 
 	qla4xxx_convert_param_ddb(fw_ddb_entry, fw_tddb, NULL);
@@ -6498,7 +6496,7 @@ static int qla4xxx_is_flash_ddb_exists(struct scsi_qla_host *ha,
 		ret = qla4xxx_compare_tuple_ddb(ha, fw_tddb, tmp_tddb, true);
 		/* found duplicate ddb */
 		if (ret = QLA_SUCCESS)
-			goto exit_check;
+			goto vfree_tmp;
 	}
 
 	list_for_each_entry_safe(nt_ddb_idx, nt_ddb_idx_tmp, list_nt, list) {
@@ -6512,13 +6510,14 @@ static int qla4xxx_is_flash_ddb_exists(struct scsi_qla_host *ha,
 			else
 				ret = QLA_SUCCESS;
 
-			goto exit_check;
+			goto vfree_tmp;
 		}
 	}
 
-exit_check:
-	vfree(fw_tddb);
+vfree_tmp:
 	vfree(tmp_tddb);
+vfree_fw:
+	vfree(fw_tddb);
 	return ret;
 }
 
Signature · 1 line
2.2.2
#919 lore raw

PATCH 4/4 SCSI-QLA4...: Less function calls in qla4xxx_sysfs_ddb_logout() after error detection

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 6 Feb 2015 22:44:23 +0100

The vfree() function was called in three cases by the qla4xxx_sysfs_ddb_logout() function during error handling even if the passed variables "flash_tddb" and "tmp_tddb" contained still a null pointer.

* This implementation detail could be improved by adjustments for jump labels.

* Let us return immediately after the first failed function call according to the current Linux coding style convention.

* Delete also an unnecessary check for the variable "fw_ddb_entry" there.

---
 drivers/scsi/qla4xxx/ql4_os.c | 35 +++++++++++++++++------------------
 1 file changed, 17 insertions(+), 18 deletions(-)
drivers/scsi/qla4xxx/ql4_os.c +17 -18
index e508bc9..802390b 100644
@@ -7699,23 +7699,22 @@ static int qla4xxx_sysfs_ddb_logout(struct iscsi_bus_flash_session *fnode_sess,
 {
 	struct Scsi_Host *shost = iscsi_flash_session_to_shost(fnode_sess);
 	struct scsi_qla_host *ha = to_qla_host(shost);
-	struct ql4_tuple_ddb *flash_tddb = NULL;
-	struct ql4_tuple_ddb *tmp_tddb = NULL;
-	struct dev_db_entry *fw_ddb_entry = NULL;
-	struct ddb_entry *ddb_entry = NULL;
 	dma_addr_t fw_ddb_dma;
 	uint32_t next_idx = 0;
 	uint32_t state = 0, conn_err = 0;
 	uint16_t conn_id = 0;
 	int idx, index;
 	int status, ret = 0;
+	struct ql4_tuple_ddb *flash_tddb;
+	struct ql4_tuple_ddb *tmp_tddb;
+	struct ddb_entry *ddb_entry;
+	struct dev_db_entry *fw_ddb_entry = dma_pool_alloc(ha->fw_ddb_dma_pool,
+								GFP_KERNEL,
+								&fw_ddb_dma);
 
-	fw_ddb_entry = dma_pool_alloc(ha->fw_ddb_dma_pool, GFP_KERNEL,
-				      &fw_ddb_dma);
-	if (fw_ddb_entry = NULL) {
+	if (!fw_ddb_entry) {
 		ql4_printk(KERN_ERR, ha, "%s:Out of memory\n", __func__);
-		ret = -ENOMEM;
-		goto exit_ddb_logout;
+		return -ENOMEM;
 	}
 
 	flash_tddb = vzalloc(sizeof(*flash_tddb));
@@ -7723,7 +7722,7 @@ static int qla4xxx_sysfs_ddb_logout(struct iscsi_bus_flash_session *fnode_sess,
 		ql4_printk(KERN_WARNING, ha,
 			   "%s:Memory Allocation failed.\n", __func__);
 		ret = -ENOMEM;
-		goto exit_ddb_logout;
+		goto free_pool;
 	}
 
 	tmp_tddb = vzalloc(sizeof(*tmp_tddb));
@@ -7731,7 +7730,7 @@ static int qla4xxx_sysfs_ddb_logout(struct iscsi_bus_flash_session *fnode_sess,
 		ql4_printk(KERN_WARNING, ha,
 			   "%s:Memory Allocation failed.\n", __func__);
 		ret = -ENOMEM;
-		goto exit_ddb_logout;
+		goto free_flash;
 	}
 
 	if (!fnode_sess->targetname) {
@@ -7739,7 +7738,7 @@ static int qla4xxx_sysfs_ddb_logout(struct iscsi_bus_flash_session *fnode_sess,
 			   "%s:Cannot logout from SendTarget entry\n",
 			   __func__);
 		ret = -EPERM;
-		goto exit_ddb_logout;
+		goto free_tmp;
 	}
 
 	if (fnode_sess->is_boot_target) {
@@ -7747,7 +7746,7 @@ static int qla4xxx_sysfs_ddb_logout(struct iscsi_bus_flash_session *fnode_sess,
 			   "%s: Logout from boot target entry is not permitted.\n",
 			   __func__);
 		ret = -EPERM;
-		goto exit_ddb_logout;
+		goto free_tmp;
 	}
 
 	strlcpy(flash_tddb->iscsi_name, fnode_sess->targetname,
@@ -7794,12 +7793,12 @@ static int qla4xxx_sysfs_ddb_logout(struct iscsi_bus_flash_session *fnode_sess,
 	if (idx = MAX_DDB_ENTRIES)
 		ret = -ESRCH;
 
-exit_ddb_logout:
-	vfree(flash_tddb);
+free_tmp:
 	vfree(tmp_tddb);
-	if (fw_ddb_entry)
-		dma_pool_free(ha->fw_ddb_dma_pool, fw_ddb_entry, fw_ddb_dma);
-
+free_flash:
+	vfree(flash_tddb);
+free_pool:
+	dma_pool_free(ha->fw_ddb_dma_pool, fw_ddb_entry, fw_ddb_dma);
 	return ret;
 }
 
Signature · 1 line
2.2.2
#914 lore raw

Re: [PATCH 2/4] SCSI-QLA4...: Less function calls in qla4xxx_is_session_exists() after error detection

In reply to SF Markus Elfring
Quoted 5 lines · SF Markus Elfring
drivers/scsi/qla4xxx/ql4_os.c +0 -0
index 2a00fd3..a7ca479 100644

drivers/scsi/qla4xxx/ql4_os.c static int qla4xxx_is_session_exists(struct scsi_qla_host *ha, · line 6334

Quoted 10 lines
drivers/scsi/qla4xxx/ql4_os.c +2 -2
@@ -6327,17 +6327,15 @@ static int qla4xxx_is_session_exists(struct scsi_qla_host *ha,
 				     uint32_t *index)
 {
 	struct ddb_entry *ddb_entry;
-	struct ql4_tuple_ddb *fw_tddb = NULL;
-	struct ql4_tuple_ddb *tmp_tddb = NULL;
 	int idx;
 	int ret = QLA_ERROR;
+	struct ql4_tuple_ddb *tmp_tddb;
+	struct ql4_tuple_ddb *fw_tddb = vzalloc(sizeof(*fw_tddb));
 

Don't do allocations in the initializers. Same for patches 3 and 4 as well.

regards,
dan carpenter

#915 lore raw

Re: [PATCH 2/4] SCSI-QLA4...: Less function calls in qla4xxx_is_session_exists() after error detection

Quoted 11 lines · Dan Carpenter
Quoted 10 lines · SF Markus Elfring
drivers/scsi/qla4xxx/ql4_os.c +0 -2
index 2a00fd3..a7ca479 100644
@@ -6327,17 +6327,15 @@ static int qla4xxx_is_session_exists(struct scsi_qla_host *ha,
 				     uint32_t *index)
 {
 	struct ddb_entry *ddb_entry;
-	struct ql4_tuple_ddb *fw_tddb = NULL;
-	struct ql4_tuple_ddb *tmp_tddb = NULL;
Quoted 8 lines

drivers/scsi/qla4xxx/ql4_os.c static int qla4xxx_is_session_exists(struct scsi_qla_host *ha, · line 6334

Quoted 5 lines
drivers/scsi/qla4xxx/ql4_os.c +2 -0
 	int idx;
 	int ret = QLA_ERROR;
+	struct ql4_tuple_ddb *tmp_tddb;
+	struct ql4_tuple_ddb *fw_tddb = vzalloc(sizeof(*fw_tddb));
 

Don't do allocations in the initializers. Same for patches 3 and 4 as well.

Why not? I can think of some reasons, but I am wondering what is the precise one.

thanks,
julia

#916 lore raw

Re: [PATCH 2/4] SCSI-QLA4...: Less function calls in qla4xxx_is_session_exists() after error detection

Quoted 22 lines · Julia Lawall
Quoted 11 lines · Dan Carpenter
Quoted 10 lines · SF Markus Elfring
drivers/scsi/qla4xxx/ql4_os.c +0 -2
index 2a00fd3..a7ca479 100644
@@ -6327,17 +6327,15 @@ static int qla4xxx_is_session_exists(struct scsi_qla_host *ha,
 				     uint32_t *index)
 {
 	struct ddb_entry *ddb_entry;
-	struct ql4_tuple_ddb *fw_tddb = NULL;
-	struct ql4_tuple_ddb *tmp_tddb = NULL;
Quoted 8 lines

drivers/scsi/qla4xxx/ql4_os.c static int qla4xxx_is_session_exists(struct scsi_qla_host *ha, · line 6334

Quoted 5 lines
drivers/scsi/qla4xxx/ql4_os.c +2 -0
 	int idx;
 	int ret = QLA_ERROR;
+	struct ql4_tuple_ddb *tmp_tddb;
+	struct ql4_tuple_ddb *fw_tddb = vzalloc(sizeof(*fw_tddb));
 

Don't do allocations in the initializers. Same for patches 3 and 4 as well.

Quoted 2 lines

Why not? I can think of some reasons, but I am wondering what is the precise one.

1) People gloss over initializers without reading them. You shouldn't put complicated code in initializers. Sarah Sharp is more strict on this than I am. http://www.spinics.net/lists/linux-usb/msg44389.html

2) It means you have to put a line of separation between the allocation and the NULL check, but they should be next to each other.

regards,
dan carpenter

#917 lore raw

Re: [PATCH 2/4] SCSI-QLA4...: Less function calls in qla4xxx_is_session_exists() after error detection

Quoted 1 line

1) People gloss over initializers without reading them.

I would find such a habit strange.

Quoted 1 line

You shouldn't put complicated code in initializers.

Does the affected memory allocation fall into such a category?

Quoted 2 lines

2) It means you have to put a line of separation between the allocation and the NULL check, but they should be next to each other.

Would you like to extend the Linux coding style documentation?

Regards,
Markus

#799 lore raw

Re: [PATCH 3/3] dm ioctl: Delete an unnecessary check before the function call "dm_table_destroy"

In reply to Mike Snitzer
Quoted 1 line

Your proposed patch (while technically correct) hurts code clarity.

How many source code readability and understanding challenges does each additional condition check cause?

Can the affected place become also a bit more efficient?

Regards,
Markus

#439 lore raw

Re: thunderbolt: Deletion of unnecessary checks before the function call "ring_free"

In reply to Andreas Noever
Quoted 1 line

Do symbols which are not exported (no EXPORT_SYMBOL_(GPL)) cause conflicts?

How do you think about to mark more functions from your software module as static?

Quoted 2 lines

I was under the impression that those are module private. If they are indeed private then I would prefer to not rename them.

Would you like to help in avoiding difficulties around name space issues?

Will specific prefixes make understanding a bit easier?

Regards,
Markus

#800 lore raw

Re: [PATCH 3/3] dm ioctl: Delete an unnecessary check before the function call "dm_table_destroy"

In reply to SF Markus Elfring
Quoted 4 lines · SF Markus Elfring
Quoted 1 line

Your proposed patch (while technically correct) hurts code clarity.

How many source code readability and understanding challenges does each additional condition check cause?

Please don't make a mountain out of a mole hill in an attempt to defend your robotic patch (I'm quite tired of some of these static analyzer patch submissions).

FYI, I did stage your other patch for 3.20, see:
https://git.kernel.org/cgit/linux/kernel/git/device-mapper/linux-dm.git/commit/?h=dm-for-3.20&id=d0ce7e911c97c7c6df1081dcedfefced82a0c6bf

Quoted 1 line

Can the affected place become also a bit more efficient?

Efficiency isn't a concern in this instance (it isn't a hot IO path). And even if it were, a branch (with current code) is more efficient vs a a jump + branch (your proposed patch) -- in the case that no active table exists. Now if it likely that old_map does exist then yes your patch is always a very slight win.

But given the duality of the calling function (deals with loading a new map and destroying the old map if it exists) I prefer to keep the code as is. Sorry.

#801 lore raw

Re: [PATCH 3/3] dm ioctl: Delete an unnecessary check before the function call "dm_table_destroy"

Quoted 2 lines

FYI, I did stage your other patch for 3.20, see:
https://git.kernel.org/cgit/linux/kernel/git/device-mapper/linux-dm.git/commit/?h=dm-for-3.20&id=d0ce7e911c97c7c6df1081dcedfefced82a0c6bf

Thanks for your acceptance of the suggested clean-up around vfree() function calls at least.
Additional source code places can also be reconsidered at other times, can't they?

Regards,
Markus

#849 lore raw

PATCH v2 1/1 net: Mellanox: Delete unnecessary checks before the function call "vunmap"

In reply to David Miller

From: Markus Elfring <[email protected]>
Date: Mon, 9 Feb 2015 11:10:41 +0100

The vunmap() function performs also input parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/net/ethernet/mellanox/mlx4/alloc.c      | 2 +-
 drivers/net/ethernet/mellanox/mlx5/core/alloc.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx4/alloc.c +1 -1
index a716c26..0c51c69 100644
@@ -662,7 +662,7 @@ void mlx4_buf_free(struct mlx4_dev *dev, int size, struct mlx4_buf *buf)
 				  buf->direct.buf,
 				  buf->direct.map);
 	else {
-		if (BITS_PER_LONG = 64 && buf->direct.buf)
+		if (BITS_PER_LONG = 64)
 			vunmap(buf->direct.buf);
 
 		for (i = 0; i < buf->nbufs; ++i)
drivers/net/ethernet/mellanox/mlx5/core/alloc.c +1 -1
index 56779c1..201ca6d 100644
@@ -121,7 +121,7 @@ void mlx5_buf_free(struct mlx5_core_dev *dev, struct mlx5_buf *buf)
 		dma_free_coherent(&dev->pdev->dev, buf->size, buf->direct.buf,
 				  buf->direct.map);
 	else {
-		if (BITS_PER_LONG = 64 && buf->direct.buf)
+		if (BITS_PER_LONG = 64)
 			vunmap(buf->direct.buf);
 
 		for (i = 0; i < buf->nbufs; i++)
Signature · 1 line
2.2.2
Applied
#850 lore raw

Re: [PATCH v2] net: Mellanox: Delete unnecessary checks before the function call "vunmap"

From: SF Markus Elfring <[email protected]>
Date: Mon, 09 Feb 2015 11:21:26 +0100

Quoted 10 lines

From: Markus Elfring <[email protected]>
Date: Mon, 9 Feb 2015 11:10:41 +0100

The vunmap() function performs also input parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Applied.

maintainer Applied
#894 lore raw

Re: [PATCH] Input: Delete an unnecessary check before the function call "input_free_device"

In reply to SF Markus Elfring
Quoted 9 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 5 Feb 2015 17:35:35 +0100

The input_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.

Applied, thank you.

Quoted 21 lines
---
 drivers/input/joystick/adi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/input/joystick/adi.c +1 -2
index b784257..d09cefa 100644
@@ -535,8 +535,7 @@ static int adi_connect(struct gameport *gameport, struct gameport_driver *drv)
 		}
 	}
  fail2:	for (i = 0; i < 2; i++)
-		if (port->adi[i].dev)
-			input_free_device(port->adi[i].dev);
+		input_free_device(port->adi[i].dev);
 	gameport_close(gameport);
  fail1:	gameport_set_drvdata(gameport, NULL);
 	kfree(port);
Signature · 1 line
2.2.2
Signature · 1 line
Dmitry
Acked-by on the v1 series
#902 lore raw

Re: [PATCH 0/2] SCSI-lpfc: Deletion of an unnecessary check

In reply to SF Markus Elfring

Markus,

Suggestions noted. If not merged, I'll pull them into the next patch set.

-- james

Quoted 13 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 5 Feb 2015 23:17:52 +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 "kfree" One function call less in lpfc_bsg_hba_set_event() after error detection

  drivers/scsi/lpfc/lpfc_bsg.c | 7 +++----
  1 file changed, 3 insertions(+), 4 deletions(-)
#818 lore raw

[tip:perf/core] perf/x86/intel/uncore: Delete an unnecessary check before pci_dev_put() call

In reply to SF Markus Elfring
perf/x86/intel/uncore: Delete an unnecessary check before pci_dev_put() call
Commit-ID:  8e57c586c6a8333c266a6cf76d50e110f2954558
Gitweb:     http://git.kernel.org/tip/8e57c586c6a8333c266a6cf76d50e110f2954558
Author:     Markus Elfring <[email protected]>
AuthorDate: Tue, 3 Feb 2015 12:40:54 +0100
Committer:  Ingo Molnar <[email protected]>
CommitDate: Wed, 18 Feb 2015 17:01:42 +0100

perf/x86/intel/uncore: Delete an unnecessary check before pci_dev_put() call

The pci_dev_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 arch/x86/kernel/cpu/perf_event_intel_uncore_snbep.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/x86/kernel/cpu/perf_event_intel_uncore_snbep.c +1 -2
index 21af6149e..12d9548 100644
@@ -1132,8 +1132,7 @@ static int snbep_pci2phy_map_init(int devid)
 		}
 	}
 
-	if (ubox_dev)
-		pci_dev_put(ubox_dev);
+	pci_dev_put(ubox_dev);
 
 	return err ? pcibios_err_to_errno(err) : 0;
 }
#920 lore raw

PATCH 1/1 video: fbdev-SIS: Deletion of unnecessary checks before three function calls

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 21 Feb 2015 14:14:56 +0100

The functions sisfb_search_crt2type(), sisfb_search_specialtiming() and sisfb_search_tvstd() test whether their argument is NULL and then return immediately. Thus the test around their calls is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/video/fbdev/sis/sis_main.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
drivers/video/fbdev/sis/sis_main.c +3 -8
index fcf610e..20ca80f 100644
@@ -6605,12 +6605,9 @@ static int __init sisfb_init_module(void)
 		sisfb_scalelcd = scalelcd ^ 1;
 
 	/* Need to check crt2 type first for fstn/dstn */
+	sisfb_search_crt2type(forcecrt2type);
 
-	if(forcecrt2type)
-		sisfb_search_crt2type(forcecrt2type);
-
-	if(tvstandard)
-		sisfb_search_tvstd(tvstandard);
+	sisfb_search_tvstd(tvstandard);
 
 	if(mode)
 		sisfb_search_mode(mode, false);
@@ -6656,9 +6653,7 @@ static int __init sisfb_init_module(void)
 		sisfb_pdca = (pdc1 & 0x1f);
 
 	sisfb_nocrt2rate = nocrt2rate;
-
-	if(specialtiming)
-		sisfb_search_specialtiming(specialtiming);
+	sisfb_search_specialtiming(specialtiming);
 
 	if((lvdshl >= 0) && (lvdshl <= 3))
 		sisfb_lvdshl = lvdshl;
Signature · 1 line
2.3.0
#111 lore raw

cover ocfs2: Deletion of some unnecessary checks

In reply to Julia Lawall

From: Markus Elfring <[email protected]>
Date: Sat, 21 Feb 2015 20:15:16 +0100

Further update suggestions were taken into account after a patch was applied from static source code analysis.

Markus Elfring (7):
Deletion of unnecessary checks before three function calls Less function calls in ocfs2_convert_inline_data_to_extents()
after error detection
Less function calls in ocfs2_figure_merge_contig_type()
after error detection
One function call less in ocfs2_merge_rec_left()
after error detection
One function call less in ocfs2_merge_rec_right()
after error detection
One function call less in ocfs2_init_slot_info()
after error detection
One function call less in user_cluster_connect()
after error detection

 fs/ocfs2/alloc.c      | 48 ++++++++++++++++++++++--------------------------
 fs/ocfs2/slot_map.c   |  4 ++--
 fs/ocfs2/stack_user.c |  8 +++-----
 3 files changed, 27 insertions(+), 33 deletions(-)
Signature · 1 line
2.3.0
#112 lore raw

PATCH 1/7 ocfs2: Deletion of unnecessary checks before three function calls

From: Markus Elfring <[email protected]>
Date: Sat, 21 Feb 2015 17:40:57 +0100

The functions kfree(), ocfs2_free_path() and __ocfs2_free_slot_info() test whether their argument is NULL and then return immediately. Thus the test around their calls is not needed.

This issue was detected by using the Coccinelle software.

---
 fs/ocfs2/alloc.c      | 17 +++++------------
 fs/ocfs2/slot_map.c   |  2 +-
 fs/ocfs2/stack_user.c |  2 +-
 3 files changed, 7 insertions(+), 14 deletions(-)
fs/ocfs2/alloc.c +5 -12
index 044158b..fdab27c 100644
@@ -3453,8 +3453,7 @@ static int ocfs2_merge_rec_right(struct ocfs2_path *left_path,
 					   subtree_index);
 	}
 out:
-	if (right_path)
-		ocfs2_free_path(right_path);
+	ocfs2_free_path(right_path);
 	return ret;
 }
 
@@ -3647,8 +3646,7 @@ static int ocfs2_merge_rec_left(struct ocfs2_path *right_path,
 						   right_path, subtree_index);
 	}
 out:
-	if (left_path)
-		ocfs2_free_path(left_path);
+	ocfs2_free_path(left_path);
 	return ret;
 }
 
@@ -4431,11 +4429,8 @@ ocfs2_figure_merge_contig_type(struct ocfs2_extent_tree *et,
 	}
 
 out:
-	if (left_path)
-		ocfs2_free_path(left_path);
-	if (right_path)
-		ocfs2_free_path(right_path);
-
+	ocfs2_free_path(left_path);
+	ocfs2_free_path(right_path);
 	return ret;
 }
 
@@ -6996,9 +6991,7 @@ out_commit:
 out:
 	if (data_ac)
 		ocfs2_free_alloc_context(data_ac);
-	if (pages)
-		kfree(pages);
-
+	kfree(pages);
 	return ret;
 }
 
fs/ocfs2/slot_map.c +1 -1
index d5493e3..c5e530a 100644
@@ -452,7 +452,7 @@ int ocfs2_init_slot_info(struct ocfs2_super *osb)
 
 	osb->slot_info = (struct ocfs2_slot_info *)si;
 bail:
-	if (status < 0 && si)
+	if (status < 0)
 		__ocfs2_free_slot_info(si);
 
 	return status;
fs/ocfs2/stack_user.c +1 -1
index 720aa38..c3b7807 100644
@@ -1063,7 +1063,7 @@ static int user_cluster_connect(struct ocfs2_cluster_connection *conn)
 	}
 
 out:
-	if (rc && lc)
+	if (rc)
 		kfree(lc);
 	return rc;
 }
Signature · 1 line
2.3.0
#113 lore raw

PATCH 2/7 ocfs2: Less function calls in ocfs2_convert_inline_data_to_extents() after error detection

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 21 Feb 2015 18:19:04 +0100

The kfree() function was called in a few cases by the ocfs2_convert_inline_data_to_extents() function during error handling even if the passed variable "pages" contained a null pointer.

* Return from this implementation directly after failure detection for the function call "kcalloc".

* Corresponding details could be improved by the introduction of another jump label.

---
 fs/ocfs2/alloc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
fs/ocfs2/alloc.c +3 -2
index fdab27c..bf806e5 100644
@@ -6853,13 +6853,13 @@ int ocfs2_convert_inline_data_to_extents(struct inode *inode,
 		if (pages = NULL) {
 			ret = -ENOMEM;
 			mlog_errno(ret);
-			goto out;
+			return ret;
 		}
 
 		ret = ocfs2_reserve_clusters(osb, 1, &data_ac);
 		if (ret) {
 			mlog_errno(ret);
-			goto out;
+			goto free_pages;
 		}
 	}
 
@@ -6991,6 +6991,7 @@ out_commit:
 out:
 	if (data_ac)
 		ocfs2_free_alloc_context(data_ac);
+free_pages:
 	kfree(pages);
 	return ret;
 }
Signature · 1 line
2.3.0
#114 lore raw

PATCH 3/7 ocfs2: Less function calls in ocfs2_figure_merge_contig_type() after error detection

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 21 Feb 2015 18:54:25 +0100

The ocfs2_free_path() function was called in some cases by the ocfs2_figure_merge_contig_type() function during error handling even if the passed variables "left_path" and "right_path" contained still a null pointer.

Corresponding implementation details could be improved by adjustments for jump labels according to the current Linux coding style convention.

---
 fs/ocfs2/alloc.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)
fs/ocfs2/alloc.c +13 -11
index bf806e5..370b4ea 100644
@@ -4332,17 +4332,17 @@ ocfs2_figure_merge_contig_type(struct ocfs2_extent_tree *et,
 	} else if (path->p_tree_depth > 0) {
 		status = ocfs2_find_cpos_for_left_leaf(sb, path, &left_cpos);
 		if (status)
-			goto out;
+			goto exit;
 
 		if (left_cpos != 0) {
 			left_path = ocfs2_new_path_from_path(path);
 			if (!left_path)
-				goto out;
+				goto exit;
 
 			status = ocfs2_find_path(et->et_ci, left_path,
 						 left_cpos);
 			if (status)
-				goto out;
+				goto free_left_path;
 
 			new_el = path_leaf_el(left_path);
 
@@ -4359,7 +4359,7 @@ ocfs2_figure_merge_contig_type(struct ocfs2_extent_tree *et,
 					    le16_to_cpu(new_el->l_next_free_rec),
 					    le16_to_cpu(new_el->l_count));
 				status = -EINVAL;
-				goto out;
+				goto free_left_path;
 			}
 			rec = &new_el->l_recs[
 				le16_to_cpu(new_el->l_next_free_rec) - 1];
@@ -4386,18 +4386,18 @@ ocfs2_figure_merge_contig_type(struct ocfs2_extent_tree *et,
 		 path->p_tree_depth > 0) {
 		status = ocfs2_find_cpos_for_right_leaf(sb, path, &right_cpos);
 		if (status)
-			goto out;
+			goto free_left_path;
 
 		if (right_cpos = 0)
-			goto out;
+			goto free_left_path;
 
 		right_path = ocfs2_new_path_from_path(path);
 		if (!right_path)
-			goto out;
+			goto free_left_path;
 
 		status = ocfs2_find_path(et->et_ci, right_path, right_cpos);
 		if (status)
-			goto out;
+			goto free_right_path;
 
 		new_el = path_leaf_el(right_path);
 		rec = &new_el->l_recs[0];
@@ -4411,7 +4411,7 @@ ocfs2_figure_merge_contig_type(struct ocfs2_extent_tree *et,
 					    (unsigned long long)le64_to_cpu(eb->h_blkno),
 					    le16_to_cpu(new_el->l_next_free_rec));
 				status = -EINVAL;
-				goto out;
+				goto free_right_path;
 			}
 			rec = &new_el->l_recs[1];
 		}
@@ -4428,9 +4428,11 @@ ocfs2_figure_merge_contig_type(struct ocfs2_extent_tree *et,
 			ret = contig_type;
 	}
 
-out:
-	ocfs2_free_path(left_path);
+free_right_path:
 	ocfs2_free_path(right_path);
+free_left_path:
+	ocfs2_free_path(left_path);
+exit:
 	return ret;
 }
 
Signature · 1 line
2.3.0
#115 lore raw

PATCH 4/7 ocfs2: One function call less in ocfs2_merge_rec_left() after error detection

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 21 Feb 2015 19:16:33 +0100

The ocfs2_free_path() function was called by the ocfs2_merge_rec_left() function even if a call of the ocfs2_get_left_path() function failed.

Return from this implementation directly after corresponding exception handling.

---
 fs/ocfs2/alloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ocfs2/alloc.c +1 -1
index 370b4ea..4bdc19f 100644
@@ -3535,7 +3535,7 @@ static int ocfs2_merge_rec_left(struct ocfs2_path *right_path,
 		ret = ocfs2_get_left_path(et, right_path, &left_path);
 		if (ret) {
 			mlog_errno(ret);
-			goto out;
+			return ret;
 		}
 
 		left_el = path_leaf_el(left_path);
Signature · 1 line
2.3.0
#116 lore raw

PATCH 5/7 ocfs2: One function call less in ocfs2_merge_rec_right() after error detection

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 21 Feb 2015 19:23:55 +0100

The ocfs2_free_path() function was called by the ocfs2_merge_rec_right() function even if a call of the ocfs2_get_right_path() function failed.

Return from this implementation directly after corresponding exception handling.

---
 fs/ocfs2/alloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ocfs2/alloc.c +1 -1
index 4bdc19f..2d7f76e 100644
@@ -3370,7 +3370,7 @@ static int ocfs2_merge_rec_right(struct ocfs2_path *left_path,
 		ret = ocfs2_get_right_path(et, left_path, &right_path);
 		if (ret) {
 			mlog_errno(ret);
-			goto out;
+			return ret;
 		}
 
 		right_el = path_leaf_el(right_path);
Signature · 1 line
2.3.0
#117 lore raw

PATCH 6/7 ocfs2: One function call less in ocfs2_init_slot_info() after error detection

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 21 Feb 2015 19:49:50 +0100

The __ocfs2_free_slot_info() function was called by the ocfs2_init_slot_info() function even if a call of the kzalloc() function failed.

Return from this implementation directly after corresponding exception handling.

---
 fs/ocfs2/slot_map.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ocfs2/slot_map.c +1 -1
index c5e530a..e78a203 100644
@@ -427,7 +427,7 @@ int ocfs2_init_slot_info(struct ocfs2_super *osb)
 	if (!si) {
 		status = -ENOMEM;
 		mlog_errno(status);
-		goto bail;
+		return status;
 	}
 
 	si->si_extended = ocfs2_uses_extended_slot_map(osb);
Signature · 1 line
2.3.0
#118 lore raw

PATCH 7/7 ocfs2: One function call less in user_cluster_connect() after error detection

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 21 Feb 2015 20:09:00 +0100

The kfree() function was called by the user_cluster_connect() function even if a previous call of the kzalloc() function failed.

Return from this implementation directly after failure detection.

---
 fs/ocfs2/stack_user.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
fs/ocfs2/stack_user.c +2 -4
index c3b7807..2768eb1 100644
@@ -1004,10 +1004,8 @@ static int user_cluster_connect(struct ocfs2_cluster_connection *conn)
 	BUG_ON(conn = NULL);
 
 	lc = kzalloc(sizeof(struct ocfs2_live_connection), GFP_KERNEL);
-	if (!lc) {
-		rc = -ENOMEM;
-		goto out;
-	}
+	if (!lc)
+		return -ENOMEM;
 
 	init_waitqueue_head(&lc->oc_wait);
 	init_completion(&lc->oc_sync_wait);
Signature · 1 line
2.3.0
Acked-by on v1 1/3
#905 lore raw

Re: [PATCH 1/3] SCSI-debug: Deletion of unnecessary checks before the function call "vfree"

In reply to SF Markus Elfring
Quoted 9 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 6 Feb 2015 16:56:57 +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.

Quoted 36 lines
---
  drivers/scsi/scsi_debug.c | 12 +++---------
  1 file changed, 3 insertions(+), 9 deletions(-)
drivers/scsi/scsi_debug.c +3 -9
index 1132321..9e4add7 100644
@@ -4969,12 +4969,9 @@ bus_unreg:
  dev_unreg:
  	root_device_unregister(pseudo_primary);
  free_vm:
-	if (map_storep)
-		vfree(map_storep);
-	if (dif_storep)
-		vfree(dif_storep);
+	vfree(map_storep);
+	vfree(dif_storep);
  	vfree(fake_storep);
-
  	return ret;
  }
 
@@ -4989,10 +4986,7 @@ static void __exit scsi_debug_exit(void)
  	driver_unregister(&sdebug_driverfs_driver);
  	bus_unregister(&pseudo_lld_bus);
  	root_device_unregister(pseudo_primary);
-
-	if (dif_storep)
-		vfree(dif_storep);
-
+	vfree(dif_storep);
  	vfree(fake_storep);
  }
 
Acked-by on v1 2/3
#907 lore raw

Re: [PATCH 2/3] SCSI-debug: Less function calls in scsi_debug_init() after error detection

In reply to SF Markus Elfring
Quoted 11 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 6 Feb 2015 17:48:34 +0100

The vfree() function was called in two cases by the scsi_debug_init() function during error handling even if the passed variables "dif_storep" and "map_storep" contained null pointers eventually.

This implementation detail could be improved by the introduction of two jump labels.

Quoted 49 lines
---
  drivers/scsi/scsi_debug.c | 10 ++++++----
  1 file changed, 6 insertions(+), 4 deletions(-)
drivers/scsi/scsi_debug.c +6 -4
index 9e4add7..756b7be 100644
@@ -4887,7 +4887,7 @@ static int __init scsi_debug_init(void)
  		if (dif_storep = NULL) {
  			pr_err("%s: out of mem. (DIX)\n", __func__);
  			ret = -ENOMEM;
-			goto free_vm;
+			goto free_fake;
  		}
 
  		memset(dif_storep, 0xff, dif_size);
@@ -4920,7 +4920,7 @@ static int __init scsi_debug_init(void)
  		if (map_storep = NULL) {
  			pr_err("%s: out of mem. (MAP)\n", __func__);
  			ret = -ENOMEM;
-			goto free_vm;
+			goto free_dif;
  		}
 
  		bitmap_zero(map_storep, map_size);
@@ -4934,7 +4934,7 @@ static int __init scsi_debug_init(void)
  	if (IS_ERR(pseudo_primary)) {
  		pr_warn("%s: root_device_register() error\n", __func__);
  		ret = PTR_ERR(pseudo_primary);
-		goto free_vm;
+		goto free_map;
  	}
  	ret = bus_register(&pseudo_lld_bus);
  	if (ret < 0) {
@@ -4968,9 +4968,11 @@ bus_unreg:
  	bus_unregister(&pseudo_lld_bus);
  dev_unreg:
  	root_device_unregister(pseudo_primary);
-free_vm:
+free_map:
  	vfree(map_storep);
+free_dif:
  	vfree(dif_storep);
+free_fake:
  	vfree(fake_storep);
  	return ret;
  }
Acked-by on v1 3/3
#909 lore raw

Re: [PATCH 3/3] SCSI-debug: Fix exception handling for an alignment/granularity mismatch in scsi_debug_init()

In reply to SF Markus Elfring
Quoted 11 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 6 Feb 2015 17:57:32 +0100

The scsi_debug_init() function returned directly if the data items "alignment" and "granularity" did not fit together.

Let us improve the affected exception handling by replacing the return statement by a goto statement so that previously allocated resources will also be appropriately released.

Quoted 19 lines
---
  drivers/scsi/scsi_debug.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/scsi/scsi_debug.c +2 -1
index 756b7be..2c78663 100644
@@ -4909,7 +4909,8 @@ static int __init scsi_debug_init(void)
  		    scsi_debug_unmap_alignment) {
  			pr_err("%s: ERR: unmap_granularity <= unmap_alignment\n",
  			       __func__);
-			return -EINVAL;
+			ret = -EINVAL;
+			goto free_dif;
  		}
 
  		map_size = lba_to_map_index(sdebug_store_sectors - 1) + 1;
Applied
#861 lore raw

Re: [PATCH] ath10k: Delete unnecessary checks before the function call "release_firmware"

In reply to SF Markus Elfring
Quoted 9 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 19:30:23 +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.

Thanks, applied to ath.git.

Signature · 1 line
Kalle Valo
#921 lore raw

PATCH 1/1 crypto-jitterentropy: Delete unnecessary checks before the function call "kzfree"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 23 Jun 2015 22:30:21 +0200

The kzfree() 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.

---
 crypto/jitterentropy.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
crypto/jitterentropy.c +2 -4
index d3c3045..22ded3e 100644
@@ -698,11 +698,9 @@ static struct rand_data *jent_entropy_collector_alloc(unsigned int osr,
 
 static void jent_entropy_collector_free(struct rand_data *entropy_collector)
 {
-	if (entropy_collector->mem)
-		kzfree(entropy_collector->mem);
+	kzfree(entropy_collector->mem);
 	entropy_collector->mem = NULL;
-	if (entropy_collector)
-		kzfree(entropy_collector);
+	kzfree(entropy_collector);
 	entropy_collector = NULL;
 }
 
Signature · 1 line
2.4.4
#922 lore raw

Re: [PATCH] crypto-jitterentropy: Delete unnecessary checks before the function call "kzfree"

Am Dienstag, 23. Juni 2015, 23:20:21 schrieb SF Markus Elfring:

Hi Markus,

Quoted 7 lines

From: Markus Elfring <[email protected]>
Date: Tue, 23 Jun 2015 22:30:21 +0200

The kzfree() 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.

Ack: the patch is correct and I was overzealous.

Nack: I just proposed a patch earlier today to avoid compiler warnings [1]. That patch clashes with yours. May I ask you to wait briefly to see whether that patch will be accepted? If yes, it would be great if you could repost the patch that applies to the changed code.

PS: when you are at it, maybe even the last line in the function can be
removed: setting the entropy_collector to NULL at that the end of the function is moot as well.

Thanks.

[1] http://lkml.iu.edu/hypermail/linux/kernel/1506.2/05196.html

Quoted 24 lines
---
 crypto/jitterentropy.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
crypto/jitterentropy.c +2 -4
index d3c3045..22ded3e 100644
@@ -698,11 +698,9 @@ static struct rand_data
 *jent_entropy_collector_alloc(unsigned int osr,
 
 static void jent_entropy_collector_free(struct rand_data
 *entropy_collector) {
-	if (entropy_collector->mem)
-		kzfree(entropy_collector->mem);
+	kzfree(entropy_collector->mem);
 	entropy_collector->mem = NULL;
-	if (entropy_collector)
-		kzfree(entropy_collector);
+	kzfree(entropy_collector);
 	entropy_collector = NULL;
 }
Signature · 2 lines
Ciao
Stephan
#923 lore raw

Re: [PATCH] crypto-jitterentropy: Delete unnecessary checks before the function call "kzfree"

The other NULL assignment isn't useful either. Also If "entropy_collector" is NULL then we would oops calling

kzfree(entropy_collector->mem);
       ^^^^^^^^^^^^^^^^^^^^^^

Dereference.

I don't understand the patch that you sent. We shouldn't be introducing jent_zalloc() or jent_zfree(). Why are you adding abstractions there? Quite bad ones as well.

regards,
dan carpenter

#924 lore raw

Re: [PATCH] crypto-jitterentropy: Delete unnecessary checks before the function call "kzfree"

Am Mittwoch, 24. Juni 2015, 10:48:19 schrieb Dan Carpenter:

Hi Dan,

Quoted 8 lines

The other NULL assignment isn't useful either. Also If "entropy_collector" is NULL then we would oops calling

kzfree(entropy_collector->mem);
      ^^^^^^^^^^^^^^^^^^^^^^

Dereference.

I don't understand the patch that you sent. We shouldn't be introducing jent_zalloc() or jent_zfree(). Why are you adding abstractions there?

The one C file should have no dependencies on any kernel header files. Thus, all links to kernel functions are wrapped.

Quoted 1 line

Quite bad ones as well.

What would you suggest to change?

Thanks.

Ciao
Stephan

#925 lore raw

Re: [PATCH] crypto-jitterentropy: Delete unnecessary checks before the function call "kzfree"

Ah. I should have read the whole thread. I sort of assumed we were just adding abstractions for the fun of it (because I have worked in staging for too long).

regards,
dan carpenter

#927 lore raw

ACPI-APEI: Make exception handling a bit more efficient in __einj_error_trigger()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 24 Jun 2015 11:41:46 +0200

Return from the __einj_error_trigger() function directly after a failed call for the request_mem_region() function according to the current Linux coding style convention.

Drop an unnecessary initialisation for the variable "trigger_tab" then.

---
 drivers/acpi/apei/einj.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/acpi/apei/einj.c +3 -3
index a095d4f..c3a2c06 100644
@@ -299,7 +299,7 @@ static struct acpi_generic_address *einj_get_trigger_parameter_region(
 static int __einj_error_trigger(u64 trigger_paddr, u32 type,
 				u64 param1, u64 param2)
 {
-	struct acpi_einj_trigger *trigger_tab = NULL;
+	struct acpi_einj_trigger *trigger_tab;
 	struct apei_exec_context trigger_ctx;
 	struct apei_resources trigger_resources;
 	struct acpi_whea_header *trigger_entry;
@@ -316,7 +316,7 @@ static int __einj_error_trigger(u64 trigger_paddr, u32 type,
 		       (unsigned long long)trigger_paddr,
 		       (unsigned long long)trigger_paddr +
 			    sizeof(*trigger_tab) - 1);
-		goto out;
+		return rc;
 	}
 	trigger_tab = ioremap_cache(trigger_paddr, sizeof(*trigger_tab));
 	if (!trigger_tab) {
@@ -407,7 +407,7 @@ out_rel_entry:
 			   table_size - sizeof(*trigger_tab));
 out_rel_header:
 	release_mem_region(trigger_paddr, sizeof(*trigger_tab));
-out:
+
 	if (trigger_tab)
 		iounmap(trigger_tab);
 
Signature · 1 line
2.4.4
#928 lore raw

PATCH 1/1 ACPICA: Delete an unnecessary check before the function call "acpi_ds_delete_walk_state"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 24 Jun 2015 13:33:47 +0200

The acpi_ds_delete_walk_state() 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.

---
 drivers/acpi/acpica/dsmethod.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/acpi/acpica/dsmethod.c +1 -4
index 85bb951..188b254 100644
@@ -574,10 +574,7 @@ cleanup:
 	/* On error, we must terminate the method properly */
 
 	acpi_ds_terminate_control_method(obj_desc, next_walk_state);
-	if (next_walk_state) {
-		acpi_ds_delete_walk_state(next_walk_state);
-	}
-
+	acpi_ds_delete_walk_state(next_walk_state);
 	return_ACPI_STATUS(status);
 }
 
Signature · 1 line
2.4.4
#930 lore raw

PATCH 1/1 kdbus: Delete an unnecessary check before the function call "kdbus_domain_unref"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 24 Jun 2015 14:30:17 +0200

The kdbus_domain_unref() 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.

---
 ipc/kdbus/fs.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
ipc/kdbus/fs.c +1 -3
index d01f33b..205a3ad 100644
@@ -325,9 +325,7 @@ static void fs_super_kill(struct super_block *sb)
 	}
 
 	kill_anon_super(sb);
-
-	if (domain)
-		kdbus_domain_unref(domain);
+	kdbus_domain_unref(domain);
 }
 
 static int fs_super_set(struct super_block *sb, void *data)
Signature · 1 line
2.4.4
Reviewed-by on v1 1/1
#931 lore raw

Re: [PATCH] kdbus: Delete an unnecessary check before the function call "kdbus_domain_unref"

Hi

Quoted 18 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 24 Jun 2015 14:30:17 +0200

The kdbus_domain_unref() 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.

---
 ipc/kdbus/fs.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
ipc/kdbus/fs.c +0 -0
index d01f33b..205a3ad 100644

ipc/kdbus/fs.c static void fs_super_kill(struct super_block *sb) · line 328

Quoted 7 lines
ipc/kdbus/fs.c +1 -3
@@ -325,9 +325,7 @@ static void fs_super_kill(struct super_block *sb)
        }
 
        kill_anon_super(sb);
-
-       if (domain)
-               kdbus_domain_unref(domain);
+       kdbus_domain_unref(domain);

Yeah, your patch is correct. The condition was kinda nice as it shows the connection to the tear-down before the call to kill_anon_super(). But the function is simple enough for a reader to figure out themselves.

Thanks
David

Quoted 6 lines
ipc/kdbus/fs.c +0 -1
 }
 
 static int fs_super_set(struct super_block *sb, void *data)
--

2.4.4

Reviewed-by on v1 1/1
#932 lore raw

Re: [PATCH] kdbus: Delete an unnecessary check before the function call "kdbus_domain_unref"

In reply to SF Markus Elfring
Quoted 31 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 24 Jun 2015 14:30:17 +0200

The kdbus_domain_unref() 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.

---
 ipc/kdbus/fs.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
ipc/kdbus/fs.c +1 -3
index d01f33b..205a3ad 100644
@@ -325,9 +325,7 @@ static void fs_super_kill(struct super_block *sb)
 	}
 
 	kill_anon_super(sb);
-
-	if (domain)
-		kdbus_domain_unref(domain);
+	kdbus_domain_unref(domain);
 }
 
 static int fs_super_set(struct super_block *sb, void *data)
Signature · 1 line
2.4.4
Signature · 2 lines
Djalal Harouni
http://opendz.org
#303 lore raw

PATCH 1/1 keys: Delete an unnecessary check before the function call "key_put"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 24 Jun 2015 15:16:35 +0200

The key_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.

---
 security/keys/process_keys.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
security/keys/process_keys.c +1 -3
index bd536cb..225dd08 100644
@@ -242,9 +242,7 @@ int install_session_keyring_to_cred(struct cred *cred, struct key *keyring)
 	old = cred->session_keyring;
 	rcu_assign_pointer(cred->session_keyring, keyring);
 
-	if (old)
-		key_put(old);
-
+	key_put(old);
 	return 0;
 }
 
Signature · 1 line
2.4.4
#402 lore raw

PATCH 1/1 SCSI-OSD: Delete an unnecessary check before the function call "put_disk"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 24 Jun 2015 16:06:21 +0200

The put_disk() 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.

---
 drivers/scsi/osd/osd_uld.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/scsi/osd/osd_uld.c +1 -3
index 243eab3..e2075522 100644
@@ -407,9 +407,7 @@ static void __remove(struct device *dev)
 
 	OSD_INFO("osd_remove %s\n",
 		 oud->disk ? oud->disk->disk_name : NULL);
-
-	if (oud->disk)
-		put_disk(oud->disk);
+	put_disk(oud->disk);
 	ida_remove(&osd_minor_ida, oud->minor);
 
 	kfree(oud);
Signature · 1 line
2.4.4
Reviewed-by on v1 1/1
#403 lore raw

Re: [PATCH] SCSI-OSD: Delete an unnecessary check before the function call "put_disk"

Quoted 35 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 24 Jun 2015 16:06:21 +0200

The put_disk() 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.

---
 drivers/scsi/osd/osd_uld.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/scsi/osd/osd_uld.c +1 -3
index 243eab3..e2075522 100644
@@ -407,9 +407,7 @@ static void __remove(struct device *dev)
 
 	OSD_INFO("osd_remove %s\n",
 		 oud->disk ? oud->disk->disk_name : NULL);
-
-	if (oud->disk)
-		put_disk(oud->disk);
+	put_disk(oud->disk);
 	ida_remove(&osd_minor_ida, oud->minor);
 
 	kfree(oud);
Signature · 6 lines
2.4.4

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Signature · 9 lines
Johannes Thumshirn                                       Storage
[email protected]                             +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#929 lore raw

RE: [PATCH] ACPICA: Delete an unnecessary check before the function call "acpi_ds_delete_walk_state"

In reply to SF Markus Elfring

Got it, thanks.

Quoted 41 lines

-----Original Message-----
From: SF Markus Elfring [mailto:elfring(a)users.sourceforge.net]
Sent: Wednesday, June 24, 2015 4:46 AM
To: Len Brown; Zheng, Lv; Wysocki, Rafael J; Moore, Robert; linux- acpi(a)vger.kernel.org; devel(a)acpica.org
Cc: LKML; kernel-janitors(a)vger.kernel.org; Julia Lawall
Subject: [PATCH] ACPICA: Delete an unnecessary check before the function call "acpi_ds_delete_walk_state"

From: Markus Elfring <elfring(a)users.sourceforge.net>
Date: Wed, 24 Jun 2015 13:33:47 +0200

The acpi_ds_delete_walk_state() 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(a)users.sourceforge.net>
---
 drivers/acpi/acpica/dsmethod.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
(quoted diff) +0 -0

b/drivers/acpi/acpica/dsmethod.c index 85bb951..188b254 100644

drivers/acpi/acpica/dsmethod.c +1 -5
@@ -574,10 +574,7 @@ cleanup:
 	/* On error, we must terminate the method properly */
 
 	acpi_ds_terminate_control_method(obj_desc, next_walk_state);
-	if (next_walk_state) {
-		acpi_ds_delete_walk_state(next_walk_state);
-	}
-
+	acpi_ds_delete_walk_state(next_walk_state);
 	return_ACPI_STATUS(status);
 }
 
--

2.4.4

#934 lore raw

PATCH 1/1 SCSI-wd33c93: Deletion of a check before the function call "wd33c93_setup"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 24 Jun 2015 17:15:17 +0200

The wd33c93_setup() function performs also input parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/scsi/wd33c93.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/wd33c93.c +1 -1
index 9e09da4..e5ed956 100644
@@ -1939,7 +1939,7 @@ wd33c93_init(struct Scsi_Host *instance, const wd33c93_regs regs,
 	int val;
 	char buf[32];
 
-	if (!done_setup && setup_strings)
+	if (!done_setup)
 		wd33c93_setup(setup_strings);
 
 	hostdata = (struct WD33C93_hostdata *) instance->hostdata;
Signature · 1 line
2.4.4
#408 lore raw

PATCH 1/1 SCSI-libfc: Delete an unnecessary check before the function call "fc_fcp_ddp_done"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 24 Jun 2015 17:50:32 +0200

The fc_fcp_ddp_done() 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.

---
 drivers/scsi/libfc/fc_exch.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/scsi/libfc/fc_exch.c +1 -2
index 1b3a094..aad6f48 100644
@@ -2120,8 +2120,7 @@ static struct fc_seq *fc_exch_seq_send(struct fc_lport *lport,
 	spin_unlock_bh(&ep->ex_lock);
 	return sp;
 err:
-	if (fsp)
-		fc_fcp_ddp_done(fsp);
+	fc_fcp_ddp_done(fsp);
 	rc = fc_exch_done_locked(ep);
 	spin_unlock_bh(&ep->ex_lock);
 	if (!rc)
Signature · 1 line
2.4.4
#406 lore raw

PATCH 1/1 SCSI: Delete unnecessary checks before the function call "put_device"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 24 Jun 2015 19:24:01 +0200

The put_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.

---
 drivers/scsi/hosts.c      | 4 +---
 drivers/scsi/scsi_sysfs.c | 4 +---
 2 files changed, 2 insertions(+), 6 deletions(-)
drivers/scsi/hosts.c +1 -3
index 8bb173e..84c8565 100644
@@ -336,9 +336,7 @@ static void scsi_host_dev_release(struct device *dev)
 	}
 
 	kfree(shost->shost_data);
-
-	if (parent)
-		put_device(parent);
+	put_device(parent);
 	kfree(shost);
 }
 
drivers/scsi/scsi_sysfs.c +1 -3
index 1ac38e7..9ed5391 100644
@@ -425,9 +425,7 @@ static void scsi_device_dev_release_usercontext(struct work_struct *work)
 	kfree(sdev->vpd_pg80);
 	kfree(sdev->inquiry);
 	kfree(sdev);
-
-	if (parent)
-		put_device(parent);
+	put_device(parent);
 }
 
 static void scsi_device_dev_release(struct device *dev)
Signature · 1 line
2.4.4
#420 lore raw

PATCH 1/1 SCSI-fnic: Delete an unnecessary check before the function call "vfree"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 24 Jun 2015 20:40:35 +0200

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.

---
 drivers/scsi/fnic/fnic_debugfs.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/scsi/fnic/fnic_debugfs.c +1 -3
index d6498fa..855d382 100644
@@ -102,9 +102,7 @@ void fnic_debugfs_terminate(void)
 
 	debugfs_remove(fnic_trace_debugfs_root);
 	fnic_trace_debugfs_root = NULL;
-
-	if (fc_trc_flag)
-		vfree(fc_trc_flag);
+	vfree(fc_trc_flag);
 }
 
 /*
Signature · 1 line
2.4.4
#936 lore raw

PATCH 1/1 s390/process: Delete an unnecessary check before the function call "kfree"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 24 Jun 2015 22:40:30 +0200

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.

---
 arch/s390/kernel/process.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/s390/kernel/process.c +1 -2
index dc5edc2..22e6448 100644
@@ -81,8 +81,7 @@ void release_thread(struct task_struct *dead_task)
 
 void arch_release_task_struct(struct task_struct *tsk)
 {
-	if (tsk->thread.vxrs)
-		kfree(tsk->thread.vxrs);
+	kfree(tsk->thread.vxrs);
 }
 
 int copy_thread(unsigned long clone_flags, unsigned long new_stackp,
Signature · 1 line
2.4.4
#935 lore raw

Re: [PATCH] SCSI-wd33c93: Deletion of a check before the function call "wd33c93_setup"

In reply to SF Markus Elfring
Quoted 6 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 24 Jun 2015 17:15:17 +0200

The wd33c93_setup() function performs also input parameter validation. Thus the test around the call is not needed.

Guys, you should be aware that Markus auto generates his patches and he doesn't even do a cursory review.

"I find it acceptable that some of my update suggestions do not fit to your quality expectations at the moment." -- Markus Elfring
(https://lkml.org/lkml/2015/1/22/446)

regards,
dan carpenter

#937 lore raw

Re: [PATCH] s390/process: Delete an unnecessary check before the function call "kfree"

In reply to SF Markus Elfring

Am 24.06.2015 22:48, schrieb SF Markus Elfring:

Quoted 18 lines

From: Markus Elfring <[email protected]>
Date: Wed, 24 Jun 2015 22:40:30 +0200

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.

---
 arch/s390/kernel/process.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/s390/kernel/process.c +0 -0
index dc5edc2..22e6448 100644

arch/s390/kernel/process.c void release_thread(struct task_struct *dead_task) · line 87

Quoted 9 lines
arch/s390/kernel/process.c +1 -2
@@ -81,8 +81,7 @@ void release_thread(struct task_struct *dead_task)
 
 void arch_release_task_struct(struct task_struct *tsk)
 {
-	if (tsk->thread.vxrs)
-		kfree(tsk->thread.vxrs);
+	kfree(tsk->thread.vxrs);
 }
 
 int copy_thread(unsigned long clone_flags, unsigned long new_stackp,

maybe the intention was to check tsk != NULL ?

re,
wh

#939 lore raw

cover ARM-OMAP2+: Deletion of unnecessary checks before two function calls

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 25 Jun 2015 13:24:35 +0200

Some functions which release a system resource tolerate the passing of a null pointer. I do not see a need because of this fact that a function caller repeats a corresponding check.

Markus Elfring (2):
Delete a check before the function call "omap_device_delete" Delete a check before the function call "of_node_put"

 arch/arm/mach-omap2/omap_device.c | 3 +--
 arch/arm/mach-omap2/timer.c       | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)
Signature · 1 line
2.4.4
#938 lore raw

Re: [PATCH] s390/process: Delete an unnecessary check before the function call "kfree"

In reply to walter harms
Quoted 21 lines · walter harms

Am 24.06.2015 22:48, schrieb SF Markus Elfring:

Quoted 19 lines

From: Markus Elfring <[email protected]>
Date: Wed, 24 Jun 2015 22:40:30 +0200

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.

---
 arch/s390/kernel/process.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/s390/kernel/process.c +0 -0
index dc5edc2..22e6448 100644
@@ -81,8 +81,7 @@ void release_thread(struct task_struct *dead_task)
 
Quoted 6 lines

arch/s390/kernel/process.c void release_thread(struct task_struct *dead_task) · line 85

Quoted 6 lines
arch/s390/kernel/process.c +1 -2
 void arch_release_task_struct(struct task_struct *tsk)
 {
-	if (tsk->thread.vxrs)
-		kfree(tsk->thread.vxrs);
+	kfree(tsk->thread.vxrs);
 }

This code will be changed soon anyway. So it would be rather pointless to apply your patch now. Thanks anyway!

Quoted 2 lines

arch/s390/kernel/process.c void release_thread(struct task_struct *dead_task) · line 87

Quoted 1 line
arch/s390/kernel/process.c +0 -0
 int copy_thread(unsigned long clone_flags, unsigned long new_stackp,

maybe the intention was to check tsk != NULL ?

No.

#940 lore raw

PATCH 1/2 ARM-OMAP2+: Delete an unnecessary check before the function call "omap_device_delete"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 25 Jun 2015 13:00:11 +0200

The omap_device_delete() 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.

---
 arch/arm/mach-omap2/omap_device.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm/mach-omap2/omap_device.c +1 -2
index 4cb8fd9..196366e 100644
@@ -193,8 +193,7 @@ static int _omap_device_notifier_call(struct notifier_block *nb,
 
 	switch (event) {
 	case BUS_NOTIFY_DEL_DEVICE:
-		if (pdev->archdata.od)
-			omap_device_delete(pdev->archdata.od);
+		omap_device_delete(pdev->archdata.od);
 		break;
 	case BUS_NOTIFY_ADD_DEVICE:
 		if (pdev->dev.of_node)
Signature · 1 line
2.4.4
#941 lore raw

PATCH 2/2 ARM-OMAP2+: Delete an unnecessary check before the function call "of_node_put"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 25 Jun 2015 13:05:28 +0200

The of_node_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.

---
 arch/arm/mach-omap2/timer.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm/mach-omap2/timer.c +1 -2
index cac46d8..15448221 100644
@@ -208,8 +208,7 @@ static void __init omap_dmtimer_init(void)
 	/* If we are a secure device, remove any secure timer nodes */
 	if ((omap_type() != OMAP2_DEVICE_TYPE_GP)) {
 		np = omap_get_timer_dt(omap_timer_match, "ti,timer-secure");
-		if (np)
-			of_node_put(np);
+		of_node_put(np);
 	}
 }
 
Signature · 1 line
2.4.4
maintainer Acked-by Serge Hallyn on v1 1/1
#304 lore raw

Re: [PATCH] keys: Delete an unnecessary check before the function call "key_put"

In reply to SF Markus Elfring
Quoted 9 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 24 Jun 2015 15:16:35 +0200

The key_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.

Quoted 21 lines
---
 security/keys/process_keys.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
security/keys/process_keys.c +1 -3
index bd536cb..225dd08 100644
@@ -242,9 +242,7 @@ int install_session_keyring_to_cred(struct cred *cred, struct key *keyring)
 	old = cred->session_keyring;
 	rcu_assign_pointer(cred->session_keyring, keyring);
 
-	if (old)
-		key_put(old);
-
+	key_put(old);
 	return 0;
 }
 
Signature · 1 line
2.4.4
#943 lore raw

cover ARM-kernel: Deletion of unnecessary checks before two function calls

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>

Some functions tolerate the passing of a null pointer. I do not see a need because of this fact that a function caller repeats a corresponding check.

Markus Elfring (2):
Delete a check before the function call "smp_set_ops" Delete a check before the function call "unwind_table_del"

 arch/arm/kernel/module.c | 3 +--
 arch/arm/kernel/setup.c  | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)
Signature · 1 line
2.4.4
#944 lore raw

PATCH 1/2 ARM-kernel: Delete an unnecessary check before the function call "smp_set_ops"

From: Markus Elfring <[email protected]>
Date: Thu, 25 Jun 2015 15:00:17 +0200

The smp_set_ops() 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.

---
 arch/arm/kernel/setup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/kernel/setup.c +1 -1
index e6d8c76..9ac786d 100644
@@ -977,7 +977,7 @@ void __init setup_arch(char **cmdline_p)
 		if (!mdesc->smp_init || !mdesc->smp_init()) {
 			if (psci_smp_available())
 				smp_set_ops(&psci_smp_ops);
-			else if (mdesc->smp)
+			else
 				smp_set_ops(mdesc->smp);
 		}
 		smp_init_cpus();
Signature · 1 line
2.4.4
#945 lore raw

PATCH 2/2 ARM-kernel: Delete an unnecessary check before the function call "unwind_table_del"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 25 Jun 2015 15:05:21 +0200

The unwind_table_del() 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.

---
 arch/arm/kernel/module.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm/kernel/module.c +1 -2
index efdddcb..0cc1afa 100644
@@ -390,7 +390,6 @@ module_arch_cleanup(struct module *mod)
 	int i;
 
 	for (i = 0; i < ARM_SEC_MAX; i++)
-		if (mod->arch.unwind[i])
-			unwind_table_del(mod->arch.unwind[i]);
+		unwind_table_del(mod->arch.unwind[i]);
 #endif
 }
Signature · 1 line
2.4.4
#245 lore raw

PATCH 1/1 tools lib traceevent: Delete an unnecessary check before the function call "free_arg"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 25 Jun 2015 16:13:47 +0200

The free_arg() 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.

---
 tools/lib/traceevent/parse-filter.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
tools/lib/traceevent/parse-filter.c +1 -2
index 0144b3d..724a3be 100644
@@ -1239,8 +1239,7 @@ filter_event(struct event_filter *filter, struct event_format *event,
 	if (filter_type = NULL)
 		return PEVENT_ERRNO__MEM_ALLOC_FAILED;
 
-	if (filter_type->filter)
-		free_arg(filter_type->filter);
+	free_arg(filter_type->filter);
 	filter_type->filter = arg;
 
 	return 0;
Signature · 1 line
2.4.4
maintainer Applied
#926 lore raw

Re: [PATCH] crypto-jitterentropy: Delete unnecessary checks before the function call "kzfree"

In reply to SF Markus Elfring
Quoted 9 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 23 Jun 2015 22:30:21 +0200

The kzfree() 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.

Applied.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
#946 lore raw

cover perf header: Deletion of an unnecessary check

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>

Further update suggestions were taken into account after a patch was applied from static source code analysis.

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

 tools/perf/util/header.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)
Signature · 1 line
2.4.4
#947 lore raw

PATCH 1/2 perf header: Delete an unnecessary check before the function call "free_event_desc"

From: Markus Elfring <[email protected]>
Date: Thu, 25 Jun 2015 17:12:32 +0200

The free_event_desc() 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.

---
 tools/perf/util/header.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
tools/perf/util/header.c +1 -2
index 21a77e7..03ace57 100644
@@ -1063,8 +1063,7 @@ out:
 	free(buf);
 	return events;
 error:
-	if (events)
-		free_event_desc(events);
+	free_event_desc(events);
 	events = NULL;
 	goto out;
 }
Signature · 1 line
2.4.4
#950 lore raw

PATCH 2/2 perf header: Less function calls in read_event_desc() after error detection

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 25 Jun 2015 17:50:37 +0200

The functions "free" and "free_event_desc" were called in a few cases by the function "read_event_desc" during error handling even if the passed variable contained a null pointer.

This implementation detail could be improved by the adjustment of jump targets. Drop unnecessary initialisations for the variables "buf" and "events" then.

---
 tools/perf/util/header.c | 29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)
tools/perf/util/header.c +15 -14
index 03ace57..8071163 100644
@@ -978,9 +978,9 @@ static void free_event_desc(struct perf_evsel *events)
 static struct perf_evsel *
 read_event_desc(struct perf_header *ph, int fd)
 {
-	struct perf_evsel *evsel, *events = NULL;
+	struct perf_evsel *evsel, *events;
 	u64 *id;
-	void *buf = NULL;
+	void *buf;
 	u32 nre, sz, nr, i, j;
 	ssize_t ret;
 	size_t msz;
@@ -988,14 +988,14 @@ read_event_desc(struct perf_header *ph, int fd)
 	/* number of events */
 	ret = readn(fd, &nre, sizeof(nre));
 	if (ret != (ssize_t)sizeof(nre))
-		goto error;
+		return NULL;
 
 	if (ph->needs_swap)
 		nre = bswap_32(nre);
 
 	ret = readn(fd, &sz, sizeof(sz));
 	if (ret != (ssize_t)sizeof(sz))
-		goto error;
+		return NULL;
 
 	if (ph->needs_swap)
 		sz = bswap_32(sz);
@@ -1003,12 +1003,12 @@ read_event_desc(struct perf_header *ph, int fd)
 	/* buffer to hold on file attr struct */
 	buf = malloc(sz);
 	if (!buf)
-		goto error;
+		return NULL;
 
 	/* the last event terminates with evsel->attr.size = 0: */
 	events = calloc(nre + 1, sizeof(*events));
 	if (!events)
-		goto error;
+		goto free_buffer;
 
 	msz = sizeof(evsel->attr);
 	if (sz < msz)
@@ -1023,7 +1023,7 @@ read_event_desc(struct perf_header *ph, int fd)
 		 */
 		ret = readn(fd, buf, sz);
 		if (ret != (ssize_t)sz)
-			goto error;
+			goto free_events;
 
 		if (ph->needs_swap)
 			perf_event__attr_swap(buf);
@@ -1032,7 +1032,7 @@ read_event_desc(struct perf_header *ph, int fd)
 
 		ret = readn(fd, &nr, sizeof(nr));
 		if (ret != (ssize_t)sizeof(nr))
-			goto error;
+			goto free_events;
 
 		if (ph->needs_swap) {
 			nr = bswap_32(nr);
@@ -1046,26 +1046,27 @@ read_event_desc(struct perf_header *ph, int fd)
 
 		id = calloc(nr, sizeof(*id));
 		if (!id)
-			goto error;
+			goto free_events;
 		evsel->ids = nr;
 		evsel->id = id;
 
 		for (j = 0 ; j < nr; j++) {
 			ret = readn(fd, id, sizeof(*id));
 			if (ret != (ssize_t)sizeof(*id))
-				goto error;
+				goto free_events;
 			if (ph->needs_swap)
 				*id = bswap_64(*id);
 			id++;
 		}
 	}
-out:
+
 	free(buf);
 	return events;
-error:
+free_events:
 	free_event_desc(events);
-	events = NULL;
-	goto out;
+free_buffer:
+	free(buf);
+	return NULL;
 }
 
 static int __desc_attr__fprintf(FILE *fp, const char *name, const char *val,
Signature · 1 line
2.4.4
#951 lore raw

Re: [PATCH 2/2] perf header: Less function calls in read_event_desc() after error detection

Em Thu, Jun 25, 2015 at 06:24:09PM +0200, SF Markus Elfring escreveu:

Quoted 6 lines

From: Markus Elfring <[email protected]>
Date: Thu, 25 Jun 2015 17:50:37 +0200

The functions "free" and "free_event_desc" were called in a few cases by the function "read_event_desc" during error handling even if the passed variable contained a null pointer.

And that is not a problem, free(NULL) is perfectly valid, as is valid to call free_event_desc(NULL).

But if you want to avoid those extra NULL checks done at those functions, then add a new out: label that just do 'return events;' that is NULL, etc.

- Arnaldo

Quoted 25 lines

This implementation detail could be improved by the adjustment of jump targets. Drop unnecessary initialisations for the variables "buf" and "events" then.

---
 tools/perf/util/header.c | 29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)
tools/perf/util/header.c +2 -2
index 03ace57..8071163 100644
@@ -978,9 +978,9 @@ static void free_event_desc(struct perf_evsel *events)
 static struct perf_evsel *
 read_event_desc(struct perf_header *ph, int fd)
 {
-	struct perf_evsel *evsel, *events = NULL;
+	struct perf_evsel *evsel, *events;
 	u64 *id;
-	void *buf = NULL;
+	void *buf;
 	u32 nre, sz, nr, i, j;
 	ssize_t ret;
 	size_t msz;

tools/perf/util/header.c read_event_desc(struct perf_header *ph, int fd) · line 991

Quoted 5 lines
tools/perf/util/header.c +1 -1
@@ -988,14 +988,14 @@ read_event_desc(struct perf_header *ph, int fd)
 	/* number of events */
 	ret = readn(fd, &nre, sizeof(nre));
 	if (ret != (ssize_t)sizeof(nre))
-		goto error;
+		return NULL;

Please leave the single point of exit, i.e. this should 'goto out:' and the out: label will return events, that is set to NULL

Quoted 80 lines
tools/perf/util/header.c +12 -11
 	if (ph->needs_swap)
 		nre = bswap_32(nre);
 
 	ret = readn(fd, &sz, sizeof(sz));
 	if (ret != (ssize_t)sizeof(sz))
-		goto error;
+		return NULL;
 
 	if (ph->needs_swap)
 		sz = bswap_32(sz);
@@ -1003,12 +1003,12 @@ read_event_desc(struct perf_header *ph, int fd)
 	/* buffer to hold on file attr struct */
 	buf = malloc(sz);
 	if (!buf)
-		goto error;
+		return NULL;
 
 	/* the last event terminates with evsel->attr.size = 0: */
 	events = calloc(nre + 1, sizeof(*events));
 	if (!events)
-		goto error;
+		goto free_buffer;
 
 	msz = sizeof(evsel->attr);
 	if (sz < msz)
@@ -1023,7 +1023,7 @@ read_event_desc(struct perf_header *ph, int fd)
 		 */
 		ret = readn(fd, buf, sz);
 		if (ret != (ssize_t)sz)
-			goto error;
+			goto free_events;
 
 		if (ph->needs_swap)
 			perf_event__attr_swap(buf);
@@ -1032,7 +1032,7 @@ read_event_desc(struct perf_header *ph, int fd)
 
 		ret = readn(fd, &nr, sizeof(nr));
 		if (ret != (ssize_t)sizeof(nr))
-			goto error;
+			goto free_events;
 
 		if (ph->needs_swap) {
 			nr = bswap_32(nr);
@@ -1046,26 +1046,27 @@ read_event_desc(struct perf_header *ph, int fd)
 
 		id = calloc(nr, sizeof(*id));
 		if (!id)
-			goto error;
+			goto free_events;
 		evsel->ids = nr;
 		evsel->id = id;
 
 		for (j = 0 ; j < nr; j++) {
 			ret = readn(fd, id, sizeof(*id));
 			if (ret != (ssize_t)sizeof(*id))
-				goto error;
+				goto free_events;
 			if (ph->needs_swap)
 				*id = bswap_64(*id);
 			id++;
 		}
 	}
-out:
+
 	free(buf);
 	return events;
-error:
+free_events:
 	free_event_desc(events);
-	events = NULL;
-	goto out;
+free_buffer:
+	free(buf);
+	return NULL;
 }
 
 static int __desc_attr__fprintf(FILE *fp, const char *name, const char *val,
Signature · 1 line
2.4.4
#948 lore raw

Re: [PATCH 1/2] perf header: Delete an unnecessary check before the function call "free_event_desc"

In reply to SF Markus Elfring

Em Thu, Jun 25, 2015 at 06:22:18PM +0200, SF Markus Elfring escreveu:

Quoted 7 lines

From: Markus Elfring <[email protected]>
Date: Thu, 25 Jun 2015 17:12:32 +0200

The free_event_desc() 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.

Thanks, applying.

- Arnaldo

Quoted 21 lines
---
 tools/perf/util/header.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
tools/perf/util/header.c +1 -2
index 21a77e7..03ace57 100644
@@ -1063,8 +1063,7 @@ out:
 	free(buf);
 	return events;
 error:
-	if (events)
-		free_event_desc(events);
+	free_event_desc(events);
 	events = NULL;
 	goto out;
 }
Signature · 1 line
2.4.4
Acked-by on v1 1/1
#409 lore raw

Re: [PATCH] SCSI-libfc: Delete an unnecessary check before the function call "fc_fcp_ddp_done"

In reply to SF Markus Elfring
Quoted 18 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 24 Jun 2015 17:50:32 +0200

The fc_fcp_ddp_done() 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.

---
 drivers/scsi/libfc/fc_exch.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/scsi/libfc/fc_exch.c +0 -0
index 1b3a094..aad6f48 100644

drivers/scsi/libfc/fc_exch.c static struct fc_seq *fc_exch_seq_send(struct fc_lport *lport, · line 2126

Quoted 9 lines
drivers/scsi/libfc/fc_exch.c +1 -2
@@ -2120,8 +2120,7 @@ static struct fc_seq *fc_exch_seq_send(struct fc_lport *lport,
 	spin_unlock_bh(&ep->ex_lock);
 	return sp;
 err:
-	if (fsp)
-		fc_fcp_ddp_done(fsp);
+	fc_fcp_ddp_done(fsp);
 	rc = fc_exch_done_locked(ep);
 	spin_unlock_bh(&ep->ex_lock);
 	if (!rc)

Looks good.

#952 lore raw

Re: [PATCH 2/2] perf header: Less function calls in read_event_desc() after error detection

In reply to Arnaldo Carvalho de Melo
Quoted 6 lines
Quoted 3 lines

The functions "free" and "free_event_desc" were called in a few cases by the function "read_event_desc" during error handling even if the passed variable contained a null pointer.

And that is not a problem, free(NULL) is perfectly valid, as is valid to call free_event_desc(NULL).

I hope that inefficient exception handling can be fixed.

Quoted 2 lines

But if you want to avoid those extra NULL checks done at those functions, then add a new out: label that just do 'return events;' that is NULL, etc.

I adjusted the jump labels in the affected function already.

Quoted 25 lines
Quoted 25 lines

This implementation detail could be improved by the adjustment of jump targets. Drop unnecessary initialisations for the variables "buf" and "events" then.

---
 tools/perf/util/header.c | 29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)
tools/perf/util/header.c +2 -2
index 03ace57..8071163 100644
@@ -978,9 +978,9 @@ static void free_event_desc(struct perf_evsel *events)
 static struct perf_evsel *
 read_event_desc(struct perf_header *ph, int fd)
 {
-	struct perf_evsel *evsel, *events = NULL;
+	struct perf_evsel *evsel, *events;
 	u64 *id;
-	void *buf = NULL;
+	void *buf;
 	u32 nre, sz, nr, i, j;
 	ssize_t ret;
 	size_t msz;
@@ -988,14 +988,14 @@ read_event_desc(struct perf_header *ph, int fd)
Quoted 8 lines

tools/perf/util/header.c read_event_desc(struct perf_header *ph, int fd) · line 991

Quoted 5 lines
tools/perf/util/header.c +1 -1
 	/* number of events */
 	ret = readn(fd, &nre, sizeof(nre));
 	if (ret != (ssize_t)sizeof(nre))
-		goto error;
+		return NULL;

Please leave the single point of exit, i.e. this should 'goto out:' and the out: label will return events, that is set to NULL

Does my update suggestion fit to the wording "If there is no cleanup needed then just return directly." from the Linux coding style documentation?

Quoted 79 lines
Quoted 79 lines
tools/perf/util/header.c +12 -11
 	if (ph->needs_swap)
 		nre = bswap_32(nre);
 
 	ret = readn(fd, &sz, sizeof(sz));
 	if (ret != (ssize_t)sizeof(sz))
-		goto error;
+		return NULL;
 
 	if (ph->needs_swap)
 		sz = bswap_32(sz);
@@ -1003,12 +1003,12 @@ read_event_desc(struct perf_header *ph, int fd)
 	/* buffer to hold on file attr struct */
 	buf = malloc(sz);
 	if (!buf)
-		goto error;
+		return NULL;
 
 	/* the last event terminates with evsel->attr.size = 0: */
 	events = calloc(nre + 1, sizeof(*events));
 	if (!events)
-		goto error;
+		goto free_buffer;
 
 	msz = sizeof(evsel->attr);
 	if (sz < msz)
@@ -1023,7 +1023,7 @@ read_event_desc(struct perf_header *ph, int fd)
 		 */
 		ret = readn(fd, buf, sz);
 		if (ret != (ssize_t)sz)
-			goto error;
+			goto free_events;
 
 		if (ph->needs_swap)
 			perf_event__attr_swap(buf);
@@ -1032,7 +1032,7 @@ read_event_desc(struct perf_header *ph, int fd)
 
 		ret = readn(fd, &nr, sizeof(nr));
 		if (ret != (ssize_t)sizeof(nr))
-			goto error;
+			goto free_events;
 
 		if (ph->needs_swap) {
 			nr = bswap_32(nr);
@@ -1046,26 +1046,27 @@ read_event_desc(struct perf_header *ph, int fd)
 
 		id = calloc(nr, sizeof(*id));
 		if (!id)
-			goto error;
+			goto free_events;
 		evsel->ids = nr;
 		evsel->id = id;
 
 		for (j = 0 ; j < nr; j++) {
 			ret = readn(fd, id, sizeof(*id));
 			if (ret != (ssize_t)sizeof(*id))
-				goto error;
+				goto free_events;
 			if (ph->needs_swap)
 				*id = bswap_64(*id);
 			id++;
 		}
 	}
-out:
+
 	free(buf);
 	return events;
-error:
+free_events:
 	free_event_desc(events);
-	events = NULL;
-	goto out;
+free_buffer:
+	free(buf);
+	return NULL;
 }
 
 static int __desc_attr__fprintf(FILE *fp, const char *name, const char *val,
Signature · 1 line
2.4.4
#195 lore raw

PATCH 1/1 lib/mpi: Delete unnecessary checks before the function call "mpi_free_limb_space"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 26 Jun 2015 10:11:19 +0200

The mpi_free_limb_space() 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.

---
 lib/mpi/mpi-pow.c  | 15 +++++----------
 lib/mpi/mpih-mul.c | 21 +++++++--------------
 2 files changed, 12 insertions(+), 24 deletions(-)
lib/mpi/mpi-pow.c +5 -10
index 5464c87..c28882f 100644
@@ -308,16 +308,11 @@ leave:
 enomem:
 	if (assign_rp)
 		mpi_assign_limb_space(res, rp, size);
-	if (mp_marker)
-		mpi_free_limb_space(mp_marker);
-	if (bp_marker)
-		mpi_free_limb_space(bp_marker);
-	if (ep_marker)
-		mpi_free_limb_space(ep_marker);
-	if (xp_marker)
-		mpi_free_limb_space(xp_marker);
-	if (tspace)
-		mpi_free_limb_space(tspace);
+	mpi_free_limb_space(mp_marker);
+	mpi_free_limb_space(bp_marker);
+	mpi_free_limb_space(ep_marker);
+	mpi_free_limb_space(xp_marker);
+	mpi_free_limb_space(tspace);
 	return rc;
 }
 EXPORT_SYMBOL_GPL(mpi_powm);
lib/mpi/mpih-mul.c +7 -14
index 7c84171..ff021cc 100644
@@ -339,8 +339,7 @@ mpihelp_mul_karatsuba_case(mpi_ptr_t prodp,
 	mpi_limb_t cy;
 
 	if (!ctx->tspace || ctx->tspace_size < vsize) {
-		if (ctx->tspace)
-			mpi_free_limb_space(ctx->tspace);
+		mpi_free_limb_space(ctx->tspace);
 		ctx->tspace = mpi_alloc_limb_space(2 * vsize);
 		if (!ctx->tspace)
 			return -ENOMEM;
@@ -354,12 +353,10 @@ mpihelp_mul_karatsuba_case(mpi_ptr_t prodp,
 	usize -= vsize;
 	if (usize >= vsize) {
 		if (!ctx->tp || ctx->tp_size < vsize) {
-			if (ctx->tp)
-				mpi_free_limb_space(ctx->tp);
+			mpi_free_limb_space(ctx->tp);
 			ctx->tp = mpi_alloc_limb_space(2 * vsize);
 			if (!ctx->tp) {
-				if (ctx->tspace)
-					mpi_free_limb_space(ctx->tspace);
+				mpi_free_limb_space(ctx->tspace);
 				ctx->tspace = NULL;
 				return -ENOMEM;
 			}
@@ -407,16 +404,12 @@ void mpihelp_release_karatsuba_ctx(struct karatsuba_ctx *ctx)
 {
 	struct karatsuba_ctx *ctx2;
 
-	if (ctx->tp)
-		mpi_free_limb_space(ctx->tp);
-	if (ctx->tspace)
-		mpi_free_limb_space(ctx->tspace);
+	mpi_free_limb_space(ctx->tp);
+	mpi_free_limb_space(ctx->tspace);
 	for (ctx = ctx->next; ctx; ctx = ctx2) {
 		ctx2 = ctx->next;
-		if (ctx->tp)
-			mpi_free_limb_space(ctx->tp);
-		if (ctx->tspace)
-			mpi_free_limb_space(ctx->tspace);
+		mpi_free_limb_space(ctx->tp);
+		mpi_free_limb_space(ctx->tspace);
 		kfree(ctx);
 	}
 }
Signature · 1 line
2.4.4
#949 lore raw

[tip:perf/urgent] perf header: Delete an unnecessary check before the calling free_event_desc()

In reply to SF Markus Elfring
perf header: Delete an unnecessary check before the calling free_event_desc()
Commit-ID:  4cc97614812e96c135e369f3d723fcda07d33437
Gitweb:     http://git.kernel.org/tip/4cc97614812e96c135e369f3d723fcda07d33437
Author:     Markus Elfring <[email protected]>
AuthorDate: Thu, 25 Jun 2015 17:12:32 +0200
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Thu, 25 Jun 2015 15:15:49 -0300

perf header: Delete an unnecessary check before the calling free_event_desc()

The free_event_desc() 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.

---
 tools/perf/util/header.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
tools/perf/util/header.c +1 -2
index 21a77e7..03ace57 100644
@@ -1063,8 +1063,7 @@ out:
 	free(buf);
 	return events;
 error:
-	if (events)
-		free_event_desc(events);
+	free_event_desc(events);
 	events = NULL;
 	goto out;
 }
#542 lore raw

PATCH 1/1 XFS: Delete unnecessary checks before the function call "xfs_qm_dqrele"

In reply to Dave Chinner

From: Markus Elfring <[email protected]>
Date: Fri, 26 Jun 2015 11:05:41 +0200

The xfs_qm_dqrele() 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.

---
 fs/xfs/xfs_qm_syscalls.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
fs/xfs/xfs_qm_syscalls.c +3 -3
index 3640c6e..6deee1e 100644
@@ -735,15 +735,15 @@ xfs_dqrele_inode(
 	}
 
 	xfs_ilock(ip, XFS_ILOCK_EXCL);
-	if ((flags & XFS_UQUOTA_ACCT) && ip->i_udquot) {
+	if (flags & XFS_UQUOTA_ACCT) {
 		xfs_qm_dqrele(ip->i_udquot);
 		ip->i_udquot = NULL;
 	}
-	if ((flags & XFS_GQUOTA_ACCT) && ip->i_gdquot) {
+	if (flags & XFS_GQUOTA_ACCT) {
 		xfs_qm_dqrele(ip->i_gdquot);
 		ip->i_gdquot = NULL;
 	}
-	if ((flags & XFS_PQUOTA_ACCT) && ip->i_pdquot) {
+	if (flags & XFS_PQUOTA_ACCT) {
 		xfs_qm_dqrele(ip->i_pdquot);
 		ip->i_pdquot = NULL;
 	}
Signature · 1 line
2.4.4
#547 lore raw

PATCH 1/1 fs-DLM: Delete unnecessary checks before the function call "kfree"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 26 Jun 2015 14:00:06 +0200

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.

---
 fs/dlm/lockspace.c | 6 ++----
 fs/dlm/memory.c    | 3 +--
 2 files changed, 3 insertions(+), 6 deletions(-)
fs/dlm/lockspace.c +2 -4
index f3e7278..41c53b3 100644
@@ -673,10 +673,8 @@ static int new_lockspace(const char *name, const char *cluster,
 	kfree(ls->ls_recover_buf);
  out_lkbidr:
 	idr_destroy(&ls->ls_lkbidr);
-	for (i = 0; i < DLM_REMOVE_NAMES_MAX; i++) {
-		if (ls->ls_remove_names[i])
-			kfree(ls->ls_remove_names[i]);
-	}
+	for (i = 0; i < DLM_REMOVE_NAMES_MAX; i++)
+		kfree(ls->ls_remove_names[i]);
  out_rsbtbl:
 	vfree(ls->ls_rsbtbl);
  out_lsfree:
fs/dlm/memory.c +1 -2
index 7cd24bc..2d2eaa0 100644
@@ -86,8 +86,7 @@ void dlm_free_lkb(struct dlm_lkb *lkb)
 		struct dlm_user_args *ua;
 		ua = lkb->lkb_ua;
 		if (ua) {
-			if (ua->lksb.sb_lvbptr)
-				kfree(ua->lksb.sb_lvbptr);
+			kfree(ua->lksb.sb_lvbptr);
 			kfree(ua);
 		}
 	}
Signature · 1 line
2.4.4
#256 lore raw

PATCH 1/1 configfs: Delete unnecessary checks before the function call "config_item_put"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 26 Jun 2015 15:20:43 +0200

The config_item_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.

---
 fs/configfs/file.c | 5 ++---
 fs/configfs/item.c | 3 +--
 2 files changed, 3 insertions(+), 5 deletions(-)
fs/configfs/file.c +2 -3
index 403269f..c70997f 100644
@@ -274,7 +274,7 @@ static int check_perm(struct inode * inode, struct file * file)
  Enomem:
 	module_put(attr->ca_owner);
  Done:
-	if (error && item)
+	if (error)
 		config_item_put(item);
 	return error;
 }
@@ -291,8 +291,7 @@ static int configfs_release(struct inode * inode, struct file * filp)
 	struct module * owner = attr->ca_owner;
 	struct configfs_buffer * buffer = filp->private_data;
 
-	if (item)
-		config_item_put(item);
+	config_item_put(item);
 	/* After this point, attr should not be accessed. */
 	module_put(owner);
 
fs/configfs/item.c +1 -2
index 4d6a30e..6173fa7 100644
@@ -152,8 +152,7 @@ static void config_item_cleanup(struct config_item *item)
 		t->ct_item_ops->release(item);
 	if (s)
 		config_group_put(s);
-	if (parent)
-		config_item_put(parent);
+	config_item_put(parent);
 }
 
 static void config_item_release(struct kref *kref)
Signature · 1 line
2.4.4
#953 lore raw

PATCH 1/1 keys: Delete an unnecessary check before the function call "key_put"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 26 Jun 2015 16:10:54 +0200

The key_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.

---
 fs/ext4/crypto_key.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/ext4/crypto_key.c +1 -2
index 442d24e..f8d15ae 100644
@@ -89,8 +89,7 @@ void ext4_free_crypt_info(struct ext4_crypt_info *ci)
 	if (!ci)
 		return;
 
-	if (ci->ci_keyring_key)
-		key_put(ci->ci_keyring_key);
+	key_put(ci->ci_keyring_key);
 	crypto_free_ablkcipher(ci->ci_ctfm);
 	kmem_cache_free(ext4_crypt_info_cachep, ci);
 }
Signature · 1 line
2.4.4
#954 lore raw

PATCH 1/1 fs-ext4 crypto: Delete an unnecessary check before the function call "key_put"

From: Markus Elfring <[email protected]>
Date: Fri, 26 Jun 2015 16:10:54 +0200
Subject: [PATCH] fs-ext4 crypto: Delete an unnecessary check before the
function call "key_put"

The key_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.

---
 fs/ext4/crypto_key.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/ext4/crypto_key.c +1 -2
index 442d24e..f8d15ae 100644
@@ -89,8 +89,7 @@ void ext4_free_crypt_info(struct ext4_crypt_info *ci)
 	if (!ci)
 		return;
 
-	if (ci->ci_keyring_key)
-		key_put(ci->ci_keyring_key);
+	key_put(ci->ci_keyring_key);
 	crypto_free_ablkcipher(ci->ci_ctfm);
 	kmem_cache_free(ext4_crypt_info_cachep, ci);
 }
Signature · 1 line
2.4.4
#955 lore raw

PATCH 1/1 f2fs crypto: Delete an unnecessary check before the function call "key_put"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 26 Jun 2015 17:28:55 +0200

The key_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.

---
 fs/f2fs/crypto_key.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/f2fs/crypto_key.c +1 -2
index 95b8f93..9f77de2 100644
@@ -92,8 +92,7 @@ static void f2fs_free_crypt_info(struct f2fs_crypt_info *ci)
 	if (!ci)
 		return;
 
-	if (ci->ci_keyring_key)
-		key_put(ci->ci_keyring_key);
+	key_put(ci->ci_keyring_key);
 	crypto_free_ablkcipher(ci->ci_ctfm);
 	kmem_cache_free(f2fs_crypt_info_cachep, ci);
 }
Signature · 1 line
2.4.4
#261 lore raw

Re: [osd-dev] [PATCH 1/1] exofs: Deletion of an unnecessary check before the function call "ore_put_io_state"

In reply to Boaz Harrosh
Quoted 13 lines
Quoted 13 lines

From: Markus Elfring <[email protected]>
Date: Tue, 18 Nov 2014 10:05:19 +0100

The ore_put_io_state() 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.

---
 fs/exofs/ore_raid.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
Quoted 15 lines

fs/exofs/ore_raid.c void _ore_free_raid_stuff(struct ore_io_state *ios) · line 720

Quoted 13 lines
fs/exofs/ore_raid.c +1 -2
index 84529b8..5dc7c4c 100644
@@ -716,6 +716,5 @@ void _ore_free_raid_stuff(struct ore_io_state *ios)
 		if (ios->extra_part_alloc)
 			kfree(ios->per_dev[0].sglist);
 	}
-	if (ios->ios_read_4_write)
-		ore_put_io_state(ios->ios_read_4_write);
+	ore_put_io_state(ios->ios_read_4_write);
 }

Thanks will submit for next Kernel

Is this small update suggestion still in the waiting queue for further software improvements?

Regards,
Markus

#956 lore raw

PATCH 1/1 eCryptfs: Delete a check before the function call "key_put"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 26 Jun 2015 18:18:54 +0200

The key_put() function tests whether its argument is NULL and then returns immediately. Thus the test around this call might not be needed.

This issue was detected by using the Coccinelle software.

---
 fs/ecryptfs/crypto.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/ecryptfs/crypto.c +1 -2
index 97315f2..80d6901 100644
@@ -258,8 +258,7 @@ void ecryptfs_destroy_mount_crypt_stat(
 				 &mount_crypt_stat->global_auth_tok_list,
 				 mount_crypt_stat_list) {
 		list_del(&auth_tok->mount_crypt_stat_list);
-		if (auth_tok->global_auth_tok_key
-		    && !(auth_tok->flags & ECRYPTFS_AUTH_TOK_INVALID))
+		if (!(auth_tok->flags & ECRYPTFS_AUTH_TOK_INVALID))
 			key_put(auth_tok->global_auth_tok_key);
 		kmem_cache_free(ecryptfs_global_auth_tok_cache, auth_tok);
 	}
Signature · 1 line
2.4.4
#273 lore raw

Re: [PATCH] fs-proc: One function call less in proc_sys_lookup() after error detection

In reply to SF Markus Elfring
Quoted 34 lines

From: Markus Elfring <[email protected]>
Date: Tue, 18 Nov 2014 15:42:43 +0100

The sysctl_head_finish() function was called in an inefficient way by the implementation of the proc_sys_lookup() function in case of a lookup failure. The corresponding source code was improved by deletion of an unnecessary null pointer check and a few adjustments for jump labels.

---
 fs/proc/proc_sysctl.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
fs/proc/proc_sysctl.c +2 -2
index f92d5dd..6606aaf 100644
@@ -457,21 +457,21 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
 		ret = sysctl_follow_link(&h, &p, current->nsproxy);
 		err = ERR_PTR(ret);
 		if (ret)
-			goto out;
+			goto inode_failure;
 	}
 
 	err = ERR_PTR(-ENOMEM);
 	inode = proc_sys_make_inode(dir->i_sb, h ? h : head, p);
 	if (!inode)
-		goto out;
+		goto inode_failure;
 
 	err = NULL;
 	d_set_d_op(dentry, &proc_sys_dentry_operations);

fs/proc/proc_sysctl.c static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry, · line 477

Quoted 10 lines
fs/proc/proc_sysctl.c +2 -2
 	d_add(dentry, inode);
 
+inode_failure:
+	sysctl_head_finish(h);
 out:
-	if (h)
-		sysctl_head_finish(h);
 	sysctl_head_finish(head);
 	return err;
 }

Would anybody like to integrate this update suggestion into a source code repository?

Regards,
Markus

#258 lore raw

Re: [PATCH] fs-eventpoll: Deletion of unnecessary checks before the function call "__pm_stay_awake"

In reply to SF Markus Elfring
Quoted 29 lines

From: Markus Elfring <[email protected]>
Date: Tue, 18 Nov 2014 09:27:16 +0100

The __pm_stay_awake() 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.

---
 fs/eventpoll.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
fs/eventpoll.c +1 -2
index 7bcfff9..eec2e85 100644
@@ -555,8 +555,7 @@ static inline void ep_pm_stay_awake(struct epitem *epi)
 {
 	struct wakeup_source *ws = ep_wakeup_source(epi);
 
-	if (ws)
-		__pm_stay_awake(ws);
+	__pm_stay_awake(ws);
 }
 
 static inline bool ep_has_wakeup_source(struct epitem *epi)

fs/eventpoll.c static inline void ep_pm_stay_awake_rcu(struct epitem *epi) · line 576

Quoted 9 lines
fs/eventpoll.c +1 -2
@@ -571,8 +570,7 @@ static inline void ep_pm_stay_awake_rcu(struct epitem *epi)
 
 	rcu_read_lock();
 	ws = rcu_dereference(epi->ws);
-	if (ws)
-		__pm_stay_awake(ws);
+	__pm_stay_awake(ws);
 	rcu_read_unlock();
 }
 

How are the chances to integrate this update suggestion into another source code repository?

Regards,
Markus

#958 lore raw

PATCH 1/1 crypto-qat: Deletion of unnecessary checks before two function calls

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 26 Jun 2015 20:30:11 +0200

The functions kfree() and release_firmware() test whether their argument is NULL and then return immediately.
Thus the test around the calls is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/crypto/qat/qat_common/adf_accel_engine.c | 5 +----
 drivers/crypto/qat/qat_common/adf_transport.c    | 2 +-
 2 files changed, 2 insertions(+), 5 deletions(-)
drivers/crypto/qat/qat_common/adf_accel_engine.c +1 -4
index 7f8b66c..fdda8e7 100644
@@ -88,10 +88,7 @@ void adf_ae_fw_release(struct adf_accel_dev *accel_dev)
 
 	qat_uclo_del_uof_obj(loader_data->fw_loader);
 	qat_hal_deinit(loader_data->fw_loader);
-
-	if (loader_data->uof_fw)
-		release_firmware(loader_data->uof_fw);
-
+	release_firmware(loader_data->uof_fw);
 	loader_data->uof_fw = NULL;
 	loader_data->fw_loader = NULL;
 }
drivers/crypto/qat/qat_common/adf_transport.c +1 -1
index ccec3274..db2926b 100644
@@ -449,7 +449,7 @@ static int adf_init_bank(struct adf_accel_dev *accel_dev,
 err:
 	for (i = 0; i < ADF_ETR_MAX_RINGS_PER_BANK; i++) {
 		ring = &bank->rings[i];
-		if (hw_data->tx_rings_mask & (1 << i) && ring->inflights)
+		if (hw_data->tx_rings_mask & (1 << i))
 			kfree(ring->inflights);
 	}
 	return -ENOMEM;
Signature · 1 line
2.4.4
#960 lore raw

PATCH 1/1 tc1100-wmi: Delete an unnecessary check before the function call "kfree"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 26 Jun 2015 21:21:16 +0200

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.

---
 drivers/platform/x86/tc1100-wmi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/tc1100-wmi.c +1 -1
index e365425..89aa976 100644
@@ -82,7 +82,7 @@ static int get_state(u32 *out, u8 instance)
 		tmp = 0;
 	}
 
-	if (result.length > 0 && result.pointer)
+	if (result.length > 0)
 		kfree(result.pointer);
 
 	switch (instance) {
Signature · 1 line
2.4.4
#962 lore raw

PATCH 1/1 staging: xgifb: Delete an unnecessary check before the function call "XGIfb_search_crt2type"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 26 Jun 2015 21:50:41 +0200

The XGIfb_search_crt2type() 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.

---
 drivers/staging/xgifb/XGI_main_26.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/xgifb/XGI_main_26.c +1 -2
index 943d463..ee0906e 100644
@@ -2090,8 +2090,7 @@ static int __init xgifb_init(void)
 {
 	char *option = NULL;
 
-	if (forcecrt2type != NULL)
-		XGIfb_search_crt2type(forcecrt2type);
+	XGIfb_search_crt2type(forcecrt2type);
 	if (fb_get_options("xgifb", &option))
 		return -ENODEV;
 	XGIfb_setup(option);
Signature · 1 line
2.4.4
#963 lore raw

PATCH 1/1 staging: lustre: Deletion of unnecessary checks before three function calls

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 26 Jun 2015 23:10:42 +0200

The following functions test whether their argument is NULL and then return immediately.
* kfree
* ll_file_data_put
* ptlrpc_connection_put

Thus the test around such calls is not needed.

This issue was detected by using the Coccinelle software.

See also a previous update suggestion:
"remove unneeded null test before free" by Julia Lawall
https://lkml.org/lkml/2015/5/1/498
https://www.mail-archive.com/[email protected]/msg878600.html

---
 drivers/staging/lustre/lustre/llite/file.c      | 3 +--
 drivers/staging/lustre/lustre/llite/llite_lib.c | 2 +-
 drivers/staging/lustre/lustre/ptlrpc/import.c   | 6 ++----
 drivers/staging/lustre/lustre/ptlrpc/service.c  | 4 +---
 4 files changed, 5 insertions(+), 10 deletions(-)
drivers/staging/lustre/lustre/llite/file.c +1 -2
index 3075db2..1a85c41 100644
@@ -702,8 +702,7 @@ out_och_free:
 out_openerr:
 		if (opendir_set != 0)
 			ll_stop_statahead(inode, lli->lli_opendir_key);
-		if (fd != NULL)
-			ll_file_data_put(fd);
+		ll_file_data_put(fd);
 	} else {
 		ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_OPEN, 1);
 	}
drivers/staging/lustre/lustre/llite/llite_lib.c +1 -1
index 2513988..ab4839c 100644
@@ -1114,7 +1114,7 @@ void ll_clear_inode(struct inode *inode)
 	if (lli->lli_mds_read_och)
 		ll_md_real_close(inode, FMODE_READ);
 
-	if (S_ISLNK(inode->i_mode) && lli->lli_symlink_name) {
+	if (S_ISLNK(inode->i_mode)) {
 		kfree(lli->lli_symlink_name);
 		lli->lli_symlink_name = NULL;
 	}
drivers/staging/lustre/lustre/ptlrpc/import.c +2 -4
index c9b8481..1eae389 100644
@@ -555,14 +555,12 @@ static int import_select_connection(struct obd_import *imp)
 	imp_conn->oic_last_attempt = cfs_time_current_64();
 
 	/* switch connection, don't mind if it's same as the current one */
-	if (imp->imp_connection)
-		ptlrpc_connection_put(imp->imp_connection);
+	ptlrpc_connection_put(imp->imp_connection);
 	imp->imp_connection = ptlrpc_connection_addref(imp_conn->oic_conn);
 
 	dlmexp = class_conn2export(&imp->imp_dlm_handle);
 	LASSERT(dlmexp != NULL);
-	if (dlmexp->exp_connection)
-		ptlrpc_connection_put(dlmexp->exp_connection);
+	ptlrpc_connection_put(dlmexp->exp_connection);
 	dlmexp->exp_connection = ptlrpc_connection_addref(imp_conn->oic_conn);
 	class_export_put(dlmexp);
 
drivers/staging/lustre/lustre/ptlrpc/service.c +1 -3
index 9117f1c..b9ae0b7 100644
@@ -2826,9 +2826,7 @@ void ptlrpc_hr_fini(void)
 	ptlrpc_stop_hr_threads();
 
 	cfs_percpt_for_each(hrp, i, ptlrpc_hr.hr_partitions) {
-		if (hrp->hrp_thrs != NULL) {
-			kfree(hrp->hrp_thrs);
-		}
+		kfree(hrp->hrp_thrs);
 	}
 
 	cfs_percpt_free(ptlrpc_hr.hr_partitions);
Signature · 1 line
2.4.4
Applied
#961 lore raw

Re: [PATCH] tc1100-wmi: Delete an unnecessary check before the function call "kfree"

In reply to SF Markus Elfring
Quoted 9 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 26 Jun 2015 21:21:16 +0200

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.

Queued, thanks.

Signature · 2 lines
Darren Hart
Intel Open Source Technology Center
#513 lore raw

Re: [PATCH 1/1] platform: x86: Deletion of checks before backlight_device_unregister()

In reply to Julia Lawall
Quoted 19 lines · Julia Lawall
Quoted 8 lines · SF Markus Elfring
Quoted 3 lines
Quoted 1 line

This issue was detected by using the Coccinelle software.

What script was used ?

A semantic patch approach which I published on the mailing lists in March is in action on my software development system for a while.

Quoted 6 lines
Quoted 1 line

Is it in scripts/coccinelle ?

Not yet.

I hope that the involved update suggestions got sufficient positive feedback to integrate five scripts there.

Quoted 9 lines

The current scripts are very complicated, involving the interaction between multiple scripts and a database, and I think they are not very suitable for make coccicheck. Also, the idea of removing the null checks is not appropriate in all contexts. Perhaps it could be possible to add a script to the Linux kernel that handles a number of common cases for which removing the null test is widely considered to be desirable.

julia

Julia, do you have any particular objection to this specific patch? I didn't see a reason to prevent it going in.

Signature · 2 lines
Darren Hart
Intel Open Source Technology Center
#514 lore raw

Re: [PATCH 1/1] platform: x86: Deletion of checks before backlight_device_unregister()

Quoted 27 lines · Darren Hart
Quoted 26 lines · Julia Lawall
Quoted 8 lines · SF Markus Elfring
Quoted 3 lines
Quoted 1 line

This issue was detected by using the Coccinelle software.

What script was used ?

A semantic patch approach which I published on the mailing lists in March is in action on my software development system for a while.

Quoted 6 lines
Quoted 1 line

Is it in scripts/coccinelle ?

Not yet.

I hope that the involved update suggestions got sufficient positive feedback to integrate five scripts there.

The current scripts are very complicated, involving the interaction between multiple scripts and a database, and I think they are not very suitable for make coccicheck. Also, the idea of removing the null checks is not appropriate in all contexts. Perhaps it could be possible to add a script to the Linux kernel that handles a number of common cases for which removing the null test is widely considered to be desirable.

Quoted 5 lines
Quoted 2 lines

julia

Julia, do you have any particular objection to this specific patch? I didn't see a reason to prevent it going in.

Sorry if I was unclear. If there is no problem with the current patch, I have no objection to it. I don't think that the semantic patch that caused this patch to be generated is suitable for inclusion in the Linux kernel.

julia

#515 lore raw

Re: platform: x86: Deletion of checks before backlight_device_unregister()

In reply to Darren Hart
Quoted 2 lines

Julia, do you have any particular objection to this specific patch? I didn't see a reason to prevent it going in.

Thanks for your interest around this concrete update suggestion.

* Would you like to distinguish the consequences a bit more for results from the application of the semantic patch language?

* Where do you prefer to store special extensions for Coccinelle's script collection

Regards,
Markus

#966 lore raw

PATCH 1/1 staging: comedi: adl_pci9118: Delete an unnecessary check before the function call "pci_dev_put"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 27 Jun 2015 13:50:43 +0200

The pci_dev_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/staging/comedi/drivers/adl_pci9118.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/comedi/drivers/adl_pci9118.c +1 -2
index fb3043d..19b5806 100644
@@ -1717,8 +1717,7 @@ static void pci9118_detach(struct comedi_device *dev)
 		pci9118_reset(dev);
 	comedi_pci_detach(dev);
 	pci9118_free_dma(dev);
-	if (pcidev)
-		pci_dev_put(pcidev);
+	pci_dev_put(pcidev);
 }
 
 static struct comedi_driver adl_pci9118_driver = {
Signature · 1 line
2.4.4
#516 lore raw

Re: [PATCH 1/1] platform: x86: Deletion of checks before backlight_device_unregister()

In reply to Darren Hart
Quoted 2 lines · Darren Hart

Julia, do you have any particular objection to this specific patch? I didn't see a reason to prevent it going in.

I hate these patches...

We're saying "these functions have sanity checks so let's pass nonsense values to them, it's fine." It makes the code harder to understand. There is no way for a human being to remember the complete list of functions with sanity checks and which don't have sanity checks.

Markus has introduced quite a few bugs as well (people have so far managed to catch his bugs before they were committed). He so far has resisted any suggestion that he should manually review his patches before sending them.

Btw do have a scripts/coccinelle/free/ifnullfree.cocci which removes checks before kfree, debugfs_remove, debugfs_remove_recursive, and usb_free_urb.

regards,
dan carpenter

#968 lore raw

cover staging: wilc1000: Deletion of two unnecessary checks

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>

Further update suggestions were taken into account after a patch was applied from static source code analysis.

Markus Elfring (2):
Delete unnecessary checks before two function calls One function call less in mac_ioctl() after error detection

 drivers/staging/wilc1000/linux_wlan.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)
Signature · 1 line
2.4.4
#969 lore raw

PATCH 1/2 staging: wilc1000: Delete unnecessary checks before two function calls

From: Markus Elfring <[email protected]>
Date: Sat, 27 Jun 2015 15:56:57 +0200

The functions kfree() and release_firmware() test whether their argument is NULL and then return immediately.
Thus the test around the calls is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/staging/wilc1000/linux_wlan.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/staging/wilc1000/linux_wlan.c +2 -7
index b352c50..2aa8d9b 100644
@@ -2421,11 +2421,7 @@ int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd)
 	}
 
 done:
-
-	if (buff != NULL) {
-		kfree(buff);
-	}
-
+	kfree(buff);
 	return s32Error;
 }
 
@@ -2707,8 +2703,7 @@ static void __exit exit_wilc_driver(void)
 		}
 	}
 
-
-	if ((g_linux_wlan != NULL) && g_linux_wlan->wilc_firmware != NULL) {
+	if (g_linux_wlan) {
 		release_firmware(g_linux_wlan->wilc_firmware);
 		g_linux_wlan->wilc_firmware = NULL;
 	}
Signature · 1 line
2.4.4
#988 lore raw

PATCH 2/2 staging: wilc1000: One function call less in mac_ioctl() after error detection

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 27 Jun 2015 16:00:59 +0200

The kfree() function was called in two cases by the mac_ioctl() function during error handling even if the passed variable did not contain a pointer for a valid data item.

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

* Drop an unnecessary initialisation for the variable "buff" then.

---
 drivers/staging/wilc1000/linux_wlan.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/staging/wilc1000/linux_wlan.c +4 -6
index 2aa8d9b..f492310 100644
@@ -2351,16 +2351,13 @@ int mac_close(struct net_device *ndev)
 
 int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd)
 {
-
-	u8 *buff = NULL;
+	u8 *buff;
 	s8 rssi;
 	u32 size = 0, length = 0;
 	perInterface_wlan_t *nic;
 	struct WILC_WFI_priv *priv;
 	s32 s32Error = WILC_SUCCESS;
 
-
-
 	/* struct iwreq *wrq = (struct iwreq *) req;	// tony moved to case SIOCSIWPRIV */
 	#ifdef USE_WIRELESS
 	nic = netdev_priv(ndev);
@@ -2405,7 +2402,7 @@ int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd)
 				if (copy_to_user(wrq->u.data.pointer, buff, size)) {
 					PRINT_ER("%s: failed to copy data to user buffer\n", __func__);
 					s32Error = -EFAULT;
-					goto done;
+					goto free_buffer;
 				}
 			}
 		}
@@ -2420,8 +2417,9 @@ int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd)
 	}
 	}
 
-done:
+free_buffer:
 	kfree(buff);
+done:
 	return s32Error;
 }
 
Signature · 1 line
2.4.4
#472 lore raw

Re: [PATCH 1/1] x86: PCI-Calgary: Deletion of an unnecessary check before the function call "free_tce_table"

In reply to Jon Mason
Quoted 27 lines
Quoted 9 lines

From: Markus Elfring <[email protected]>
Date: Sat, 22 Nov 2014 12:55:28 +0100

The free_tce_table() 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.

Looks good to me

Quoted 12 lines
---
 arch/x86/kernel/pci-calgary_64.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/x86/kernel/pci-calgary_64.c +0 -0
index 0497f71..d22a386 100644
@@ -1476,8 +1476,7 @@ cleanup:
        for (--bus; bus >= 0; --bus) {
                struct calgary_bus_info *info = &bus_info[bus];
 
Quoted 9 lines
Quoted 9 lines
arch/x86/kernel/pci-calgary_64.c +1 -3
-               if (info->tce_space)
-                       free_tce_table(info->tce_space);
+               free_tce_table(info->tce_space);
        }
        return -ENOMEM;
 }
--

2.1.3

Do the chances increase to integrate this update suggestion into another source code repository?

Regards,
Markus

#1002 lore raw

PATCH 1/1 ipmi: Delete an unnecessary check before the function call "cleanup_one_si"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 27 Jun 2015 18:12:14 +0200

The cleanup_one_si() 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.

---
 drivers/char/ipmi/ipmi_si_intf.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/char/ipmi/ipmi_si_intf.c +1 -3
index cb90f76..fbfed36 100644
@@ -2778,9 +2778,7 @@ static int ipmi_remove(struct platform_device *dev)
 {
 	struct smi_info *info = dev_get_drvdata(&dev->dev);
 
-	if (info)
-		cleanup_one_si(info);
-
+	cleanup_one_si(info);
 	return 0;
 }
 
Signature · 1 line
2.4.4
#989 lore raw

Re: [PATCH 2/2] staging: wilc1000: One function call less in mac_ioctl() after error detection

In reply to SF Markus Elfring
Quoted 26 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 27 Jun 2015 16:00:59 +0200

The kfree() function was called in two cases by the mac_ioctl() function during error handling even if the passed variable did not contain a pointer for a valid data item.

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

* Drop an unnecessary initialisation for the variable "buff" then.

---
 drivers/staging/wilc1000/linux_wlan.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/staging/wilc1000/linux_wlan.c +0 -1
index 2aa8d9b..f492310 100644
@@ -2351,16 +2351,13 @@ int mac_close(struct net_device *ndev)
 
 int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd)
 {
-

drivers/staging/wilc1000/linux_wlan.c int mac_close(struct net_device *ndev) · line 2363

Quoted 10 lines
drivers/staging/wilc1000/linux_wlan.c +1 -3
-	u8 *buff = NULL;
+	u8 *buff;
 	s8 rssi;
 	u32 size = 0, length = 0;
 	perInterface_wlan_t *nic;
 	struct WILC_WFI_priv *priv;
 	s32 s32Error = WILC_SUCCESS;
 
-
-

Removing these blank lines seems to have nothing to do with the topic of the patch.

julia

Quoted 31 lines
drivers/staging/wilc1000/linux_wlan.c +3 -3
 	/* struct iwreq *wrq = (struct iwreq *) req;	// tony moved to case SIOCSIWPRIV */
 	#ifdef USE_WIRELESS
 	nic = netdev_priv(ndev);
@@ -2405,7 +2402,7 @@ int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd)
 				if (copy_to_user(wrq->u.data.pointer, buff, size)) {
 					PRINT_ER("%s: failed to copy data to user buffer\n", __func__);
 					s32Error = -EFAULT;
-					goto done;
+					goto free_buffer;
 				}
 			}
 		}
@@ -2420,8 +2417,9 @@ int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd)
 	}
 	}
 
-done:
+free_buffer:
 	kfree(buff);
+done:
 	return s32Error;
 }
 
--

2.4.4

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#325 lore raw

Re: [PATCH] agp/intel-gtt: Deletion of unnecessary checks before the function call "pci_dev_put"

In reply to SF Markus Elfring
Quoted 21 lines

From: Markus Elfring <[email protected]>
Date: Wed, 19 Nov 2014 14:24:20 +0100

The pci_dev_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/char/agp/intel-gtt.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/char/agp/intel-gtt.c +0 -0
index 9a024f8..db5877e 100644
@@ -1434,10 +1434,8 @@ void intel_gmch_remove(void)
 	if (--intel_private.refcount)
 		return;

drivers/char/agp/intel-gtt.c void intel_gmch_remove(void) · line 1441

Quoted 10 lines
drivers/char/agp/intel-gtt.c +2 -4
 
-	if (intel_private.pcidev)
-		pci_dev_put(intel_private.pcidev);
-	if (intel_private.bridge_dev)
-		pci_dev_put(intel_private.bridge_dev);
+	pci_dev_put(intel_private.pcidev);
+	pci_dev_put(intel_private.bridge_dev);
 	intel_private.driver = NULL;
 }
 EXPORT_SYMBOL(intel_gmch_remove);

Would you like to integrate this update suggestion into a source code repository?

Regards,
Markus

#873 lore raw

Re: [PATCH] GPU-DRM-Exynos: Delete unnecessary checks before two function calls

In reply to Joonyoung Shim
Quoted 43 lines
Quoted 43 lines

From: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 21:54:45 +0100

The functions phy_power_on() and vunmap() perform also input parameter validation. Thus the test around their calls is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/gpu/drm/exynos/exynos_dp_core.c   | 6 ++----
 drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 2 +-
 2 files changed, 3 insertions(+), 5 deletions(-)
drivers/gpu/drm/exynos/exynos_dp_core.c +2 -4
index 34d46aa..306cf1d 100644
@@ -1057,14 +1057,12 @@ static int exynos_dp_create_connector(struct exynos_drm_display *display,
 
 static void exynos_dp_phy_init(struct exynos_dp_device *dp)
 {
-	if (dp->phy)
-		phy_power_on(dp->phy);
+	phy_power_on(dp->phy);
 }
 
 static void exynos_dp_phy_exit(struct exynos_dp_device *dp)
 {
-	if (dp->phy)
-		phy_power_off(dp->phy);
+	phy_power_off(dp->phy);
 }
 
 static void exynos_dp_poweron(struct exynos_drm_display *display)
drivers/gpu/drm/exynos/exynos_drm_fbdev.c +0 -0
index e12ea90..0dd448a 100644
@@ -313,7 +313,7 @@ static void exynos_drm_fbdev_destroy(struct drm_device *dev,
 	struct exynos_drm_gem_obj *exynos_gem_obj = exynos_fbd->exynos_gem_obj;
 	struct drm_framebuffer *fb;
 
Quoted 8 lines

drivers/gpu/drm/exynos/exynos_drm_fbdev.c static void exynos_drm_fbdev_destroy(struct drm_device *dev, · line 319

Quoted 6 lines
drivers/gpu/drm/exynos/exynos_drm_fbdev.c +1 -1
-	if (is_drm_iommu_supported(dev) && exynos_gem_obj->buffer->kvaddr)
+	if (is_drm_iommu_supported(dev))
 		vunmap(exynos_gem_obj->buffer->kvaddr);
 
 	/* release drm framebuffer and real buffer */

Do the chances increase to integrate this update suggestion into another source code repository?

Regards,
Markus

#517 lore raw

Re: platform: x86: Deletion of checks before backlight_device_unregister()

In reply to Dan Carpenter
Quoted 2 lines

There is no way for a human being to remember the complete list of functions with sanity checks and which don't have sanity checks.

I understand also this software development challenge.

Quoted 1 line

Markus has introduced quite a few bugs as well

I have only found other opinions about specific update suggestions. Which of such "bugs" are real mistakes?
Are you looking for a better consensus?

Quoted 1 line

(people have so far managed to catch his bugs before they were committed).

Would you like to refer to any concrete software developers?

Quoted 2 lines

He so far has resisted any suggestion that he should manually review his patches before sending them.

I am performing source code review to some degree. My approach does partly not fit to your expectations.

Regards,
Markus

#1003 lore raw

PATCH 1/1 drm/bridge: ps8622: Delete a check before backlight_device_unregister()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 27 Jun 2015 20:44:49 +0200

The backlight_device_unregister() 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.

---
 drivers/gpu/drm/bridge/ps8622.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/bridge/ps8622.c +1 -3
index 1a6607b..70dacb8 100644
@@ -646,9 +646,7 @@ static int ps8622_remove(struct i2c_client *client)
 {
 	struct ps8622_bridge *ps8622 = i2c_get_clientdata(client);
 
-	if (ps8622->bl)
-		backlight_device_unregister(ps8622->bl);
-
+	backlight_device_unregister(ps8622->bl);
 	drm_bridge_remove(&ps8622->bridge);
 
 	return 0;
Signature · 1 line
2.4.4
#1006 lore raw

cover drm/msm/dsi: Deletion of an unnecessary check

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>

Further update suggestions were taken into account after a patch was applied from static source code analysis.

Markus Elfring (2):
Delete an unnecessary check before the function call "dsi_destroy" One function call less in dsi_init() after error detection

 drivers/gpu/drm/msm/dsi/dsi.c | 26 ++++++++++----------------
 1 file changed, 10 insertions(+), 16 deletions(-)
Signature · 1 line
2.4.4
#1007 lore raw

PATCH 1/2 drm/msm/dsi: Delete an unnecessary check before the function call "dsi_destroy"

From: Markus Elfring <[email protected]>
Date: Sat, 27 Jun 2015 22:05:31 +0200

The dsi_destroy() 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.

---
 drivers/gpu/drm/msm/dsi/dsi.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/msm/dsi/dsi.c +1 -3
index 1f2561e..dc4f38f 100644
@@ -110,9 +110,7 @@ static struct msm_dsi *dsi_init(struct platform_device *pdev)
 	return msm_dsi;
 
 fail:
-	if (msm_dsi)
-		dsi_destroy(msm_dsi);
-
+	dsi_destroy(msm_dsi);
 	return ERR_PTR(ret);
 }
 
Signature · 1 line
2.4.4
#1008 lore raw

PATCH 2/2 drm/msm/dsi: One function call less in dsi_init() after error detection

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 27 Jun 2015 22:23:28 +0200

The dsi_destroy() function was called in two cases by the dsi_init() function during error handling even if the passed variable contained a null pointer.

* This implementation detail could be improved by adjustments for jump targets according to the Linux coding style convention.

* Drop an unnecessary initialisation for the variable "msm_dsi" then.

---
 drivers/gpu/drm/msm/dsi/dsi.c | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)
drivers/gpu/drm/msm/dsi/dsi.c +9 -13
index dc4f38f..971f000 100644
@@ -74,19 +74,15 @@ static void dsi_destroy(struct msm_dsi *msm_dsi)
 
 static struct msm_dsi *dsi_init(struct platform_device *pdev)
 {
-	struct msm_dsi *msm_dsi = NULL;
+	struct msm_dsi *msm_dsi;
 	int ret;
 
-	if (!pdev) {
-		ret = -ENXIO;
-		goto fail;
-	}
+	if (!pdev)
+		return -ENXIO;
 
 	msm_dsi = devm_kzalloc(&pdev->dev, sizeof(*msm_dsi), GFP_KERNEL);
-	if (!msm_dsi) {
-		ret = -ENOMEM;
-		goto fail;
-	}
+	if (!msm_dsi)
+		return -ENOMEM;
 	DBG("dsi probed=%p", msm_dsi);
 
 	msm_dsi->pdev = pdev;
@@ -95,21 +91,21 @@ static struct msm_dsi *dsi_init(struct platform_device *pdev)
 	/* Init dsi host */
 	ret = msm_dsi_host_init(msm_dsi);
 	if (ret)
-		goto fail;
+		goto destroy_dsi;
 
 	/* GET dsi PHY */
 	ret = dsi_get_phy(msm_dsi);
 	if (ret)
-		goto fail;
+		goto destroy_dsi;
 
 	/* Register to dsi manager */
 	ret = msm_dsi_manager_register(msm_dsi);
 	if (ret)
-		goto fail;
+		goto destroy_dsi;
 
 	return msm_dsi;
 
-fail:
+destroy_dsi:
 	dsi_destroy(msm_dsi);
 	return ERR_PTR(ret);
 }
Signature · 1 line
2.4.4
#1009 lore raw

PATCH 1/1 drm/amdgpu: Delete an unnecessary check before the function call "kfree"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 28 Jun 2015 10:27:35 +0200

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.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -2
index fec487d..a85cd08 100644
@@ -1575,8 +1575,7 @@ void amdgpu_device_fini(struct amdgpu_device *adev)
 	amdgpu_fence_driver_fini(adev);
 	amdgpu_fbdev_fini(adev);
 	r = amdgpu_fini(adev);
-	if (adev->ip_block_enabled)
-		kfree(adev->ip_block_enabled);
+	kfree(adev->ip_block_enabled);
 	adev->ip_block_enabled = NULL;
 	adev->accel_working = false;
 	/* free i2c buses */
Signature · 1 line
2.4.4
#1024 lore raw

PATCH 1/1 ALSA: hda: Delete an unnecessary check before the function call "snd_info_free_entry"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 28 Jun 2015 11:15:28 +0200

The snd_info_free_entry() 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.

---
 sound/pci/hda/patch_hdmi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/pci/hda/patch_hdmi.c +1 -1
index f852734..2f24338 100644
@@ -591,7 +591,7 @@ static int eld_proc_new(struct hdmi_spec_per_pin *per_pin, int index)
 
 static void eld_proc_free(struct hdmi_spec_per_pin *per_pin)
 {
-	if (!per_pin->codec->bus->shutdown && per_pin->proc_entry) {
+	if (!per_pin->codec->bus->shutdown) {
 		snd_info_free_entry(per_pin->proc_entry);
 		per_pin->proc_entry = NULL;
 	}
Signature · 1 line
2.4.4
#404 lore raw

Re: [PATCH] SCSI-OSD: Delete an unnecessary check before the function call "put_disk"

In reply to SF Markus Elfring
Quoted 9 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 24 Jun 2015 16:06:21 +0200

The put_disk() 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.

Quoted 20 lines
---
 drivers/scsi/osd/osd_uld.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/scsi/osd/osd_uld.c +1 -3
index 243eab3..e2075522 100644
@@ -407,9 +407,7 @@ static void __remove(struct device *dev)
 
 	OSD_INFO("osd_remove %s\n",
 		 oud->disk ? oud->disk->disk_name : NULL);
-
-	if (oud->disk)
-		put_disk(oud->disk);
+	put_disk(oud->disk);
 	ida_remove(&osd_minor_ida, oud->minor);
 
 	kfree(oud);
#314 lore raw

PATCH 1/1 PM-wakeup: Delete unnecessary checks before two function calls

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 28 Jun 2015 12:14:43 +0200

The functions dev_pm_disarm_wake_irq() and wakeup_source_unregister() test whether their argument is NULL and then return immediately. Thus the test around the calls is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/base/power/wakeup.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/base/power/wakeup.c +3 -7
index 40f7160..3741bc2 100644
@@ -341,8 +341,7 @@ void device_wakeup_arm_wake_irqs(void)
 
 	rcu_read_lock();
 	list_for_each_entry_rcu(ws, &wakeup_sources, entry) {
-		if (ws->wakeirq)
-			dev_pm_arm_wake_irq(ws->wakeirq);
+		dev_pm_arm_wake_irq(ws->wakeirq);
 	}
 	rcu_read_unlock();
 }
@@ -358,8 +357,7 @@ void device_wakeup_disarm_wake_irqs(void)
 
 	rcu_read_lock();
 	list_for_each_entry_rcu(ws, &wakeup_sources, entry) {
-		if (ws->wakeirq)
-			dev_pm_disarm_wake_irq(ws->wakeirq);
+		dev_pm_disarm_wake_irq(ws->wakeirq);
 	}
 	rcu_read_unlock();
 }
@@ -396,9 +394,7 @@ int device_wakeup_disable(struct device *dev)
 		return -EINVAL;
 
 	ws = device_wakeup_detach(dev);
-	if (ws)
-		wakeup_source_unregister(ws);
-
+	wakeup_source_unregister(ws);
 	return 0;
 }
 EXPORT_SYMBOL_GPL(device_wakeup_disable);
Signature · 1 line
2.4.4
#323 lore raw

Re: [PATCH] drbd: Deletion of an unnecessary check before the function call "lc_destroy"

In reply to SF Markus Elfring
Quoted 19 lines

From: Markus Elfring <[email protected]>
Date: Wed, 19 Nov 2014 13:33:32 +0100

The lc_destroy() 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.

---
 drivers/block/drbd/drbd_nl.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/block/drbd/drbd_nl.c +0 -0
index 1cd47df..0bcb3e0 100644

drivers/block/drbd/drbd_nl.c static int drbd_check_al_size(struct drbd_device *device, struct disk_conf *dc) · line 1121

Quoted 9 lines
drivers/block/drbd/drbd_nl.c +1 -2
@@ -1115,8 +1115,7 @@ static int drbd_check_al_size(struct drbd_device *device, struct disk_conf *dc)
 		lc_destroy(n);
 		return -EBUSY;
 	} else {
-		if (t)
-			lc_destroy(t);
+		lc_destroy(t);
 	}
 	drbd_md_mark_dirty(device); /* we changed device->act_log->nr_elemens */
 	return 0;

Would you like to integrate this update suggestion into another source code repository?

Regards,
Markus

#641 lore raw

Re: [PATCH] block-rsxx: Deletion of an unnecessary check before the function call "vfree"

In reply to SF Markus Elfring
Quoted 19 lines

From: Markus Elfring <[email protected]>
Date: Mon, 1 Dec 2014 19:19:25 +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.

---
 drivers/block/rsxx/dma.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/block/rsxx/dma.c +0 -0
index cf8cd29..0181387 100644

drivers/block/rsxx/dma.c failed_dma_setup: · line 966

Quoted 9 lines
drivers/block/rsxx/dma.c +1 -2
@@ -960,8 +960,7 @@ failed_dma_setup:
 			ctrl->done_wq = NULL;
 		}
 
-		if (ctrl->trackers)
-			vfree(ctrl->trackers);
+		vfree(ctrl->trackers);
 
 		if (ctrl->status.buf)
 			pci_free_consistent(card->dev, STATUS_BUFFER_SIZE8,

Would you like to integrate this update suggestion into another source code repository?

Regards,
Markus

#639 lore raw

Re: [PATCH] block-skd: Deletion of an unnecessary check before the function call "kfree"

In reply to SF Markus Elfring
Quoted 19 lines

From: Markus Elfring <[email protected]>
Date: Mon, 1 Dec 2014 18:15:46 +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.

---
 drivers/block/skd_main.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/block/skd_main.c +0 -0
index 1e46eb2..c4b0259 100644

drivers/block/skd_main.c static int skd_acquire_msix(struct skd_device *skdev) · line 4004

Quoted 9 lines
drivers/block/skd_main.c +1 -2
@@ -3998,8 +3998,7 @@ static int skd_acquire_msix(struct skd_device *skdev)
 	return 0;
 
 msix_out:
-	if (entries)
-		kfree(entries);
+	kfree(entries);
 	skd_release_msix(skdev);
 	return rc;
 }

Would anybody like to integrate this update suggestion into another source code repository?

Regards,
Markus

#345 lore raw

Re: [PATCH] HID-picoLCD: Deletion of unnecessary checks before three function calls

In reply to SF Markus Elfring
Quoted 49 lines

From: Markus Elfring <[email protected]>
Date: Wed, 19 Nov 2014 18:30:22 +0100

The functions backlight_device_unregister(), lcd_device_unregister() and rc_unregister_device() 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.

---
 drivers/hid/hid-picolcd_backlight.c | 3 +--
 drivers/hid/hid-picolcd_cir.c       | 3 +--
 drivers/hid/hid-picolcd_lcd.c       | 3 +--
 3 files changed, 3 insertions(+), 6 deletions(-)
drivers/hid/hid-picolcd_backlight.c +1 -2
index a32c5f8..808807a 100644
@@ -94,8 +94,7 @@ void picolcd_exit_backlight(struct picolcd_data *data)
 	struct backlight_device *bdev = data->backlight;
 
 	data->backlight = NULL;
-	if (bdev)
-		backlight_device_unregister(bdev);
+	backlight_device_unregister(bdev);
 }
 
 int picolcd_resume_backlight(struct picolcd_data *data)
drivers/hid/hid-picolcd_cir.c +1 -2
index 045f8eb..9628651 100644
@@ -145,7 +145,6 @@ void picolcd_exit_cir(struct picolcd_data *data)
 	struct rc_dev *rdev = data->rc_dev;
 
 	data->rc_dev = NULL;
-	if (rdev)
-		rc_unregister_device(rdev);
+	rc_unregister_device(rdev);
 }
 
drivers/hid/hid-picolcd_lcd.c +0 -0
index 89821c2..22dcbe1 100644

drivers/hid/hid-picolcd_lcd.c void picolcd_exit_lcd(struct picolcd_data *data) · line 98

Quoted 9 lines
drivers/hid/hid-picolcd_lcd.c +1 -2
@@ -92,8 +92,7 @@ void picolcd_exit_lcd(struct picolcd_data *data)
 	struct lcd_device *ldev = data->lcd;
 
 	data->lcd = NULL;
-	if (ldev)
-		lcd_device_unregister(ldev);
+	lcd_device_unregister(ldev);
 }
 
 int picolcd_resume_lcd(struct picolcd_data *data)

Would you like to integrate this update suggestion into another source code repository?

Regards,
Markus

#494 lore raw

Re: [PATCH v2] backlight: lp8788: Deletion of a check before backlight_device_unregister()

In reply to SF Markus Elfring
Quoted 18 lines

From: Markus Elfring <[email protected]>

The backlight_device_unregister() 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.

---
 drivers/video/backlight/lp8788_bl.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/video/backlight/lp8788_bl.c +0 -0
index d6c4f6a..24a055c 100644

drivers/video/backlight/lp8788_bl.c static void lp8788_backlight_unregister(struct lp8788_bl *bl) · line 227

Quoted 9 lines
drivers/video/backlight/lp8788_bl.c +1 -2
@@ -221,8 +221,7 @@ static void lp8788_backlight_unregister(struct lp8788_bl *bl)
 {
 	struct backlight_device *bl_dev = bl->bl_dev;
 
-	if (bl_dev)
-		backlight_device_unregister(bl_dev);
+	backlight_device_unregister(bl_dev);
 }
 
 static ssize_t lp8788_get_bl_ctl_mode(struct device *dev,

Would you like to integrate this update suggestion into another source code repository?

Regards,
Markus

#1026 lore raw

PATCH 1/1 video: fbdev: omap2: displays-new: Delete a check before backlight_device_unregister()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 28 Jun 2015 14:30:17 +0200

The backlight_device_unregister() 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.

---
 drivers/video/fbdev/omap2/displays-new/panel-dsi-cm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/video/fbdev/omap2/displays-new/panel-dsi-cm.c +1 -2
index 3414c26..d2caa41 100644
@@ -1323,8 +1323,7 @@ static int dsicm_probe(struct platform_device *pdev)
 	return 0;
 
 err_sysfs_create:
-	if (bldev != NULL)
-		backlight_device_unregister(bldev);
+	backlight_device_unregister(bldev);
 err_bl:
 	destroy_workqueue(ddata->workqueue);
 err_reg:
Signature · 1 line
2.4.4
#1027 lore raw

PATCH 1/1 USB-mxuport: Delete an unnecessary check before the function call "release_firmware"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 28 Jun 2015 14:59:04 +0200

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.

---
 drivers/usb/serial/mxuport.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/usb/serial/mxuport.c +1 -2
index 460a406..92f7aee 100644
@@ -1101,8 +1101,7 @@ static int mxuport_probe(struct usb_serial *serial,
 	 */
 	usb_set_serial_data(serial, (void *)id->driver_info);
 out:
-	if (fw_p)
-		release_firmware(fw_p);
+	release_firmware(fw_p);
 	return err;
 }
 
Signature · 1 line
2.4.4
#1029 lore raw

PATCH 1/1 iommu/arm-smmu: Delete an unnecessary check before the function call "free_io_pgtable_ops"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 28 Jun 2015 15:55:11 +0200

The free_io_pgtable_ops() 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.

---
 drivers/iommu/arm-smmu-v3.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/iommu/arm-smmu-v3.c +1 -2
index f141301..8e9ec81 100644
@@ -1389,8 +1389,7 @@ static void arm_smmu_domain_free(struct iommu_domain *domain)
 	struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);
 	struct arm_smmu_device *smmu = smmu_domain->smmu;
 
-	if (smmu_domain->pgtbl_ops)
-		free_io_pgtable_ops(smmu_domain->pgtbl_ops);
+	free_io_pgtable_ops(smmu_domain->pgtbl_ops);
 
 	/* Free the CD and ASID, if we allocated them */
 	if (smmu_domain->stage = ARM_SMMU_DOMAIN_S1) {
Signature · 1 line
2.4.4
#1031 lore raw

PATCH 1/1 PCI-iproc: Delete unnecessary checks before two function calls

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 28 Jun 2015 16:42:04 +0200

The functions phy_exit() and phy_power_off() test whether their argument is NULL and then return immediately.
Thus the test around the calls is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/pci/host/pcie-iproc.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/pci/host/pcie-iproc.c +2 -5
index d77481e..f875821 100644
@@ -239,12 +239,9 @@ err_rm_root_bus:
 	pci_remove_root_bus(bus);
 
 err_power_off_phy:
-	if (pcie->phy)
-		phy_power_off(pcie->phy);
+	phy_power_off(pcie->phy);
 err_exit_phy:
-	if (pcie->phy)
-		phy_exit(pcie->phy);
-
+	phy_exit(pcie->phy);
 	return ret;
 }
 EXPORT_SYMBOL(iproc_pcie_setup);
Signature · 1 line
2.4.4
#1037 lore raw

cover vfio: powerpc/spapr: Deletion of an unnecessary check

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>

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 "kfree" One function call less in tce_iommu_attach_group() after kzalloc() failure

 drivers/vfio/vfio_iommu_spapr_tce.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
Signature · 1 line
2.4.4
#1038 lore raw

PATCH 1/2 vfio: powerpc/spapr: Delete an unnecessary check before the function call "kfree"

From: Markus Elfring <[email protected]>
Date: Sun, 28 Jun 2015 17:43:48 +0200

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.

---
 drivers/vfio/vfio_iommu_spapr_tce.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/vfio/vfio_iommu_spapr_tce.c +1 -1
index 0582b72..50ddfac 100644
@@ -1215,7 +1215,7 @@ static int tce_iommu_attach_group(void *iommu_data,
 	}
 
 unlock_exit:
-	if (ret && tcegrp)
+	if (ret)
 		kfree(tcegrp);
 
 	mutex_unlock(&container->lock);
Signature · 1 line
2.4.4
#1039 lore raw

PATCH 2/2 vfio: powerpc/spapr: One function call less in tce_iommu_attach_group() after kzalloc() failure

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 28 Jun 2015 17:58:42 +0200

The kfree() function was called even if a previous memory allocation try failed.

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

---
 drivers/vfio/vfio_iommu_spapr_tce.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/vfio/vfio_iommu_spapr_tce.c +2 -2
index 50ddfac..2523075 100644
@@ -1200,7 +1200,7 @@ static int tce_iommu_attach_group(void *iommu_data,
 	tcegrp = kzalloc(sizeof(*tcegrp), GFP_KERNEL);
 	if (!tcegrp) {
 		ret = -ENOMEM;
-		goto unlock_exit;
+		goto unlock_container;
 	}
 
 	if (!table_group->ops || !table_group->ops->take_ownership ||
@@ -1217,7 +1217,7 @@ static int tce_iommu_attach_group(void *iommu_data,
 unlock_exit:
 	if (ret)
 		kfree(tcegrp);
-
+unlock_container:
 	mutex_unlock(&container->lock);
 
 	return ret;
Signature · 1 line
2.4.4
#1040 lore raw

Re: [PATCH 2/2] vfio: powerpc/spapr: One function call less in tce_iommu_attach_group() after kzalloc() failure

Quoted 5 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 28 Jun 2015 17:58:42 +0200

The kfree() function was called even if a previous memory allocation try failed.

tcegrp will be NULL and kfree() can handle this just fine (is not it the whole point of this patchset - remove the check and just call kfree() even if the pointer is NULL?). And if you wanted another label, than the existing one should have been renamed to "free_exit" or "free_unlock_exit" and new one would be "unlock_exit".

Quoted 31 lines

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

---
  drivers/vfio/vfio_iommu_spapr_tce.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/vfio/vfio_iommu_spapr_tce.c +2 -2
index 50ddfac..2523075 100644
@@ -1200,7 +1200,7 @@ static int tce_iommu_attach_group(void *iommu_data,
  	tcegrp = kzalloc(sizeof(*tcegrp), GFP_KERNEL);
  	if (!tcegrp) {
  		ret = -ENOMEM;
-		goto unlock_exit;
+		goto unlock_container;
  	}
 
  	if (!table_group->ops || !table_group->ops->take_ownership ||
@@ -1217,7 +1217,7 @@ static int tce_iommu_attach_group(void *iommu_data,
  unlock_exit:
  	if (ret)
  		kfree(tcegrp);
-
+unlock_container:
  	mutex_unlock(&container->lock);
 
  	return ret;
Signature · 1 line
Alexey
#1041 lore raw

Re: vfio: powerpc/spapr: One function call less in tce_iommu_attach_group() after kzalloc() failure

Quoted 1 line

tcegrp will be NULL and kfree() can handle this just fine

The affected function did not show this API knowledge, did it?

Quoted 2 lines

(is not it the whole point of this patchset
- remove the check and just call kfree() even if the pointer is NULL?).

Partly, yes.

Quoted 1 line

And if you wanted another label,

I suggest this to improve corresponding exception handling.

Quoted 2 lines

than the existing one should have been renamed to "free_exit" or "free_unlock_exit" and new one would be "unlock_exit".

I chose a smaller change at this place.

I am not familiar enough with other called functions there at the moment. Are the remaining goto statements also update candidates?

Regards,
Markus

maintainer Reviewed-by
#346 lore raw

Re: [PATCH] HID-picoLCD: Deletion of unnecessary checks before three function calls

In reply to SF Markus Elfring
Quoted 56 lines · On Sun, 28 Jun 2015 13:54:56 +0200 SF Markus Elfring wrote:
Quoted 56 lines

From: Markus Elfring <[email protected]>
Date: Wed, 19 Nov 2014 18:30:22 +0100

The functions backlight_device_unregister(), lcd_device_unregister() and rc_unregister_device() 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.

---
 drivers/hid/hid-picolcd_backlight.c | 3 +--
 drivers/hid/hid-picolcd_cir.c       | 3 +--
 drivers/hid/hid-picolcd_lcd.c       | 3 +--
 3 files changed, 3 insertions(+), 6 deletions(-)
drivers/hid/hid-picolcd_backlight.c +1 -2
index a32c5f8..808807a 100644
@@ -94,8 +94,7 @@ void picolcd_exit_backlight(struct picolcd_data *data)
 	struct backlight_device *bdev = data->backlight;
 
 	data->backlight = NULL;
-	if (bdev)
-		backlight_device_unregister(bdev);
+	backlight_device_unregister(bdev);
 }
 
 int picolcd_resume_backlight(struct picolcd_data *data)
drivers/hid/hid-picolcd_cir.c +1 -2
index 045f8eb..9628651 100644
@@ -145,7 +145,6 @@ void picolcd_exit_cir(struct picolcd_data *data)
 	struct rc_dev *rdev = data->rc_dev;
 
 	data->rc_dev = NULL;
-	if (rdev)
-		rc_unregister_device(rdev);
+	rc_unregister_device(rdev);
 }
 
drivers/hid/hid-picolcd_lcd.c +1 -2
index 89821c2..22dcbe1 100644
@@ -92,8 +92,7 @@ void picolcd_exit_lcd(struct picolcd_data *data)
 	struct lcd_device *ldev = data->lcd;
 
 	data->lcd = NULL;
-	if (ldev)
-		lcd_device_unregister(ldev);
+	lcd_device_unregister(ldev);
 }
 
Quoted 5 lines

drivers/hid/hid-picolcd_lcd.c void picolcd_exit_lcd(struct picolcd_data *data) · line 98

Quoted 2 lines
drivers/hid/hid-picolcd_lcd.c +0 -0
 int picolcd_resume_lcd(struct picolcd_data *data)

Would you like to integrate this update suggestion into another source code repository?

Sorry for forgetting about this patch.

Looks good to me:

Jiri, can you take it?

Best regards,
Bruno

Quoted 2 lines

Regards,
Markus

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer Applied
#959 lore raw

Re: [PATCH] crypto-qat: Deletion of unnecessary checks before two function calls

In reply to SF Markus Elfring
Quoted 10 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 26 Jun 2015 20:30:11 +0200

The functions kfree() and release_firmware() test whether their argument is NULL and then return immediately.
Thus the test around the calls is not needed.

This issue was detected by using the Coccinelle software.

Applied.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Applied
#1025 lore raw

Re: [PATCH] ALSA: hda: Delete an unnecessary check before the function call "snd_info_free_entry"

In reply to SF Markus Elfring

At Sun, 28 Jun 2015 11:21:36 +0200,

Quoted 10 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 28 Jun 2015 11:15:28 +0200

The snd_info_free_entry() 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.

Applied, thanks.

Takashi

Quoted 20 lines
---
 sound/pci/hda/patch_hdmi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/pci/hda/patch_hdmi.c +1 -1
index f852734..2f24338 100644
@@ -591,7 +591,7 @@ static int eld_proc_new(struct hdmi_spec_per_pin *per_pin, int index)
 
 static void eld_proc_free(struct hdmi_spec_per_pin *per_pin)
 {
-	if (!per_pin->codec->bus->shutdown && per_pin->proc_entry) {
+	if (!per_pin->codec->bus->shutdown) {
 		snd_info_free_entry(per_pin->proc_entry);
 		per_pin->proc_entry = NULL;
 	}
Signature · 1 line
2.4.4
#967 lore raw

Re: [PATCH] staging: comedi: adl_pci9118: Delete an unnecessary check before the function call "pci_dev_put"

In reply to SF Markus Elfring
Quoted 19 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 27 Jun 2015 13:50:43 +0200

The pci_dev_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
  drivers/staging/comedi/drivers/adl_pci9118.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/comedi/drivers/adl_pci9118.c +0 -0
index fb3043d..19b5806 100644

drivers/staging/comedi/drivers/adl_pci9118.c static void pci9118_detach(struct comedi_device *dev) · line 1723

Quoted 9 lines
drivers/staging/comedi/drivers/adl_pci9118.c +1 -2
@@ -1717,8 +1717,7 @@ static void pci9118_detach(struct comedi_device *dev)
  		pci9118_reset(dev);
  	comedi_pci_detach(dev);
  	pci9118_free_dma(dev);
-	if (pcidev)
-		pci_dev_put(pcidev);
+	pci_dev_put(pcidev);
  }
 
  static struct comedi_driver adl_pci9118_driver = {

The same patch was posted independently (and earlier) by Maninder Singh, but I think we concluded that the code was more understandable without this change, as the test within pci_dev_put() is more of a safety net.

Signature · 2 lines
-=( Ian Abbott @ MEV Ltd.    E-mail: <[email protected]> )=-
-=(                          Web: http://www.mev.co.uk/  )=-
#1045 lore raw

PATCH 1/1 net-Liquidio: Delete unnecessary checks before the function call "vfree"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Mon, 29 Jun 2015 12:22:24 +0200

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.

---
 drivers/net/ethernet/cavium/liquidio/octeon_device.c   | 11 +++--------
 drivers/net/ethernet/cavium/liquidio/octeon_droq.c     |  4 +---
 drivers/net/ethernet/cavium/liquidio/request_manager.c |  3 +--
 3 files changed, 5 insertions(+), 13 deletions(-)
drivers/net/ethernet/cavium/liquidio/octeon_device.c +3 -8
index 0d3106b..f67641a 100644
@@ -650,14 +650,12 @@ void octeon_free_device_mem(struct octeon_device *oct)
 
 	for (i = 0; i < MAX_OCTEON_OUTPUT_QUEUES; i++) {
 		/* could check  mask as well */
-		if (oct->droq[i])
-			vfree(oct->droq[i]);
+		vfree(oct->droq[i]);
 	}
 
 	for (i = 0; i < MAX_OCTEON_INSTR_QUEUES; i++) {
 		/* could check mask as well */
-		if (oct->instr_queue[i])
-			vfree(oct->instr_queue[i]);
+		vfree(oct->instr_queue[i]);
 	}
 
 	i = oct->octeon_id;
@@ -1078,10 +1076,7 @@ octeon_unregister_dispatch_fn(struct octeon_device *oct, u16 opcode,
 		oct->dispatch.count--;
 
 	spin_unlock_bh(&oct->dispatch.lock);
-
-	if (dfree)
-		vfree(dfree);
-
+	vfree(dfree);
 	return retval;
 }
 
drivers/net/ethernet/cavium/liquidio/octeon_droq.c +1 -3
index 94b502a..4dba86e 100644
@@ -216,9 +216,7 @@ int octeon_delete_droq(struct octeon_device *oct, u32 q_no)
 	dev_dbg(&oct->pci_dev->dev, "%s[%d]\n", __func__, q_no);
 
 	octeon_droq_destroy_ring_buffers(oct, droq);
-
-	if (droq->recv_buf_list)
-		vfree(droq->recv_buf_list);
+	vfree(droq->recv_buf_list);
 
 	if (droq->info_base_addr)
 		cnnic_free_aligned_dma(oct->pci_dev, droq->info_list,
drivers/net/ethernet/cavium/liquidio/request_manager.c +1 -2
index 356796b..a2a2465 100644
@@ -175,8 +175,7 @@ int octeon_delete_instr_queue(struct octeon_device *oct, u32 iq_no)
 		desc_size  		    CFG_GET_IQ_INSTR_TYPE(CHIP_FIELD(oct, cn6xxx, conf));
 
-	if (iq->request_list)
-		vfree(iq->request_list);
+	vfree(iq->request_list);
 
 	if (iq->base_addr) {
 		q_size = iq->max_count * desc_size;
Signature · 1 line
2.4.5
#347 lore raw

Re: [PATCH] HID-picoLCD: Deletion of unnecessary checks before three function calls

In reply to Bruno Prémont
Quoted 6 lines · Bruno Prémont

Sorry for forgetting about this patch.

Looks good to me:

Jiri, can you take it?

Could either of you please bounce me the original patch? I don't think I've seen in in my mailbox (or it's too long time ago).

Thanks,

Signature · 2 lines
Jiri Kosina
SUSE Labs
#254 lore raw

Re: [PATCH] hfs/hfs+: Deletion of unnecessary checks before the function call "hfs_bnode_put"

In reply to Vyacheslav Dubeyko
Quoted 72 lines
Quoted 8 lines

From: Markus Elfring <[email protected]>
Date: Mon, 17 Nov 2014 19:13:56 +0100

The hfs_bnode_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.

Thank you. It's the reasonable correction. Looks good for me.

Thanks,
Vyacheslav Dubeyko.

Quoted 56 lines
---
 fs/hfs/bfind.c     | 3 +--
 fs/hfs/brec.c      | 3 +--
 fs/hfsplus/bfind.c | 3 +--
 fs/hfsplus/brec.c  | 3 +--
 4 files changed, 4 insertions(+), 8 deletions(-)
fs/hfs/bfind.c +1 -2
index de69d8a..0e26523 100644
@@ -100,8 +100,7 @@ int hfs_brec_find(struct hfs_find_data *fd)
 	int height, res;
 
 	tree = fd->tree;
-	if (fd->bnode)
-		hfs_bnode_put(fd->bnode);
+	hfs_bnode_put(fd->bnode);
 	fd->bnode = NULL;
 	nidx = tree->root;
 	if (!nidx)
fs/hfs/brec.c +1 -2
index 9f4ee7f..3a52b2c 100644
@@ -272,8 +272,7 @@ static struct hfs_bnode *hfs_bnode_split(struct hfs_find_data *fd)
 		/* panic? */
 		hfs_bnode_put(node);
 		hfs_bnode_put(new_node);
-		if (next_node)
-			hfs_bnode_put(next_node);
+		hfs_bnode_put(next_node);
 		return ERR_PTR(-ENOSPC);
 	}
 
fs/hfsplus/bfind.c +1 -2
index c1422d9..7be88e3 100644
@@ -171,8 +171,7 @@ int hfs_brec_find(struct hfs_find_data *fd, search_strategy_t do_key_compare)
 	int height, res;
 
 	tree = fd->tree;
-	if (fd->bnode)
-		hfs_bnode_put(fd->bnode);
+	hfs_bnode_put(fd->bnode);
 	fd->bnode = NULL;
 	nidx = tree->root;
 	if (!nidx)
fs/hfsplus/brec.c +0 -0
index 6e560d5..59bab47 100644
@@ -276,8 +276,7 @@ static struct hfs_bnode *hfs_bnode_split(struct hfs_find_data *fd)
 		/* panic? */
Quoted 10 lines

fs/hfsplus/brec.c static struct hfs_bnode *hfs_bnode_split(struct hfs_find_data *fd) · line 282

Quoted 8 lines
fs/hfsplus/brec.c +1 -2
 		hfs_bnode_put(node);
 		hfs_bnode_put(new_node);
-		if (next_node)
-			hfs_bnode_put(next_node);
+		hfs_bnode_put(next_node);
 		return ERR_PTR(-ENOSPC);
 	}
 

Can this update suggestion be still integrated
into another source code repository?

Regards,
Markus

#1010 lore raw

Re: [PATCH] drm/amdgpu: Delete an unnecessary check before the function call "kfree"

In reply to SF Markus Elfring
Quoted 9 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 28 Jun 2015 10:27:35 +0200

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.

I already have the same patch from Maninder Singh.

Thanks!

Alex

Quoted 25 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -3
index fec487d..a85cd08 100644
@@ -1575,8 +1575,7 @@ void amdgpu_device_fini(struct amdgpu_device *adev)
        amdgpu_fence_driver_fini(adev);
        amdgpu_fbdev_fini(adev);
        r = amdgpu_fini(adev);
-       if (adev->ip_block_enabled)
-               kfree(adev->ip_block_enabled);
+       kfree(adev->ip_block_enabled);
        adev->ip_block_enabled = NULL;
        adev->accel_working = false;
        /* free i2c buses */
--

2.4.4

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

maintainer Applied
#1046 lore raw

Re: [PATCH] net-Liquidio: Delete unnecessary checks before the function call "vfree"

In reply to SF Markus Elfring

From: SF Markus Elfring <[email protected]>
Date: Mon, 29 Jun 2015 12:48:16 +0200

Quoted 9 lines

From: Markus Elfring <[email protected]>
Date: Mon, 29 Jun 2015 12:22:24 +0200

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.

Applied.

maintainer
#1032 lore raw

Re: [PATCH] PCI-iproc: Delete unnecessary checks before two function calls

In reply to SF Markus Elfring

Hi Markus,

Quoted 24 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 28 Jun 2015 16:42:04 +0200

The functions phy_exit() and phy_power_off() test whether their argument is NULL and then return immediately.
Thus the test around the calls is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/pci/host/pcie-iproc.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/pci/host/pcie-iproc.c +0 -1
index d77481e..f875821 100644
@@ -239,12 +239,9 @@ err_rm_root_bus:
 	pci_remove_root_bus(bus);
 
 err_power_off_phy:
-	if (pcie->phy)

drivers/pci/host/pcie-iproc.c err_rm_root_bus: · line 247

Quoted 10 lines
drivers/pci/host/pcie-iproc.c +2 -4
-		phy_power_off(pcie->phy);
+	phy_power_off(pcie->phy);
 err_exit_phy:
-	if (pcie->phy)
-		phy_exit(pcie->phy);
-
+	phy_exit(pcie->phy);
 	return ret;
 }
 EXPORT_SYMBOL(iproc_pcie_setup);

Thanks for catching this. Could you please help to make similar changes to both phy_init and phy_power_on calls in the driver, to make it consistent?

Thanks,

Ray

#543 lore raw

Re: [PATCH] XFS: Delete unnecessary checks before the function call "xfs_qm_dqrele"

In reply to SF Markus Elfring
Quoted 5 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 26 Jun 2015 11:05:41 +0200

The xfs_qm_dqrele() function tests whether its argument is NULL and then returns immediately.

True.

Quoted 1 line

Thus the test around the call is not needed.

But wrong.

xfs_dqrele_inode() gets called on every inode in the inode cache, and this change results in a cacheline in every inode being dirtied even if they don't have dquots attached. Given the inode cache can hold tens to hundreds of millions of inodes on large machines, we don't want to dirty any cachelines we don't need to while walking the inode cache and releasing dquots...

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]
#1042 lore raw

Re: vfio: powerpc/spapr: One function call less in tce_iommu_attach_group() after kzalloc() failure

In reply to SF Markus Elfring
Quoted 3 lines · SF Markus Elfring
Quoted 1 line

tcegrp will be NULL and kfree() can handle this just fine

The affected function did not show this API knowledge, did it?

but you fixed this in 1/2 :)

Quoted 10 lines
Quoted 4 lines

(is not it the whole point of this patchset
- remove the check and just call kfree() even if the pointer is NULL?).

Partly, yes.

Quoted 1 line

And if you wanted another label,

Quoted 7 lines

I suggest this to improve corresponding exception handling.

Quoted 2 lines

than the existing one should have been renamed to "free_exit" or "free_unlock_exit" and new one would be "unlock_exit".

I chose a smaller change at this place.

I'd just drop this patch.

Quoted 2 lines

I am not familiar enough with other called functions there at the moment. Are the remaining goto statements also update candidates?

Signature · 1 line
Alexey
#1043 lore raw

Re: vfio: powerpc/spapr: One function call less in tce_iommu_attach_group() after kzalloc() failure

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

than the existing one should have been renamed to "free_exit" or "free_unlock_exit" and new one would be "unlock_exit".

I chose a smaller change at this place.

I'd just drop this patch.

How do you think about to improve the affected jump labels a bit more there?

Regards,
Markus

#870 lore raw

Re: [PATCH] macintosh: Delete an unnecessary check before the function call "of_node_put"

In reply to SF Markus Elfring

Am 04.02.2015 um 21:36 schrieb SF Markus Elfring:

Quoted 19 lines

From: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 21:32:27 +0100

The of_node_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.

---
 drivers/macintosh/smu.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/macintosh/smu.c +0 -0
index 10ae69b..d531f80 100644

drivers/macintosh/smu.c int __init smu_init (void) · line 563

Quoted 9 lines
drivers/macintosh/smu.c +1 -2
@@ -557,8 +557,7 @@ int __init smu_init (void)
 	return 0;
 
 fail_msg_node:
-	if (smu->msg_node)
-		of_node_put(smu->msg_node);
+	of_node_put(smu->msg_node);
 fail_db_node:
 	of_node_put(smu->db_node);
 fail_bootmem:

Would you like to integrate this update suggestion into another source code repository?

Regards,
Markus

#1044 lore raw

Re: vfio: powerpc/spapr: One function call less in tce_iommu_attach_group() after kzalloc() failure

In reply to SF Markus Elfring
Quoted 9 lines · SF Markus Elfring
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

than the existing one should have been renamed to "free_exit" or "free_unlock_exit" and new one would be "unlock_exit".

I chose a smaller change at this place.

I'd just drop this patch.

How do you think about to improve the affected jump labels a bit more there?

This branch is very unlikely to work ever so I cannot think of any improvement here.

Signature · 1 line
Alexey
#463 lore raw

PATCH 1/1 ARM: OMAP2: Delete unnecessary checks before three function calls

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 30 Jun 2015 14:00:16 +0200

The functions clk_disable(), of_node_put() and omap_device_delete() 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.

---
 arch/arm/mach-omap2/omap_device.c | 3 +--
 arch/arm/mach-omap2/omap_hwmod.c  | 5 +----
 arch/arm/mach-omap2/timer.c       | 3 +--
 3 files changed, 3 insertions(+), 8 deletions(-)
arch/arm/mach-omap2/omap_device.c +1 -2
index 4cb8fd9..196366e 100644
@@ -193,8 +193,7 @@ static int _omap_device_notifier_call(struct notifier_block *nb,
 
 	switch (event) {
 	case BUS_NOTIFY_DEL_DEVICE:
-		if (pdev->archdata.od)
-			omap_device_delete(pdev->archdata.od);
+		omap_device_delete(pdev->archdata.od);
 		break;
 	case BUS_NOTIFY_ADD_DEVICE:
 		if (pdev->dev.of_node)
arch/arm/mach-omap2/omap_hwmod.c +1 -4
index d78c12e..1091ee7 100644
@@ -921,10 +921,7 @@ static int _disable_clocks(struct omap_hwmod *oh)
 	int i = 0;
 
 	pr_debug("omap_hwmod: %s: disabling clocks\n", oh->name);
-
-	if (oh->_clk)
-		clk_disable(oh->_clk);
-
+	clk_disable(oh->_clk);
 	p = oh->slave_ports.next;
 
 	while (i < oh->slaves_cnt) {
arch/arm/mach-omap2/timer.c +1 -2
index cac46d8..15448221 100644
@@ -208,8 +208,7 @@ static void __init omap_dmtimer_init(void)
 	/* If we are a secure device, remove any secure timer nodes */
 	if ((omap_type() != OMAP2_DEVICE_TYPE_GP)) {
 		np = omap_get_timer_dt(omap_timer_match, "ti,timer-secure");
-		if (np)
-			of_node_put(np);
+		of_node_put(np);
 	}
 }
 
Signature · 1 line
2.4.5
#416 lore raw

Re: [PATCH] SCSI-bfa: Deletion of an unnecessary check before the function call "vfree"

In reply to Anil Gurumurthy
Quoted 37 lines

Patch looks good.
Thanks!

-----Original Message-----
From: SF Markus Elfring [mailto:[email protected]]
Sent: 21 November 2014 04:17
To: Anil Gurumurthy; James E. J. Bottomley; Sudarsana Kalluru; linux-scsi
Cc: linux-kernel; [email protected]; Julia Lawall
Subject: [PATCH 1/1] SCSI-bfa: Deletion of an unnecessary check before the function call "vfree"

From: Markus Elfring <[email protected]>
Date: Thu, 20 Nov 2014 23:43:17 +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.

---
 drivers/scsi/bfa/bfad_debugfs.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/scsi/bfa/bfad_debugfs.c +1 -3
@@ -399,8 +399,7 @@ bfad_debugfs_release_fwtrc(struct inode *inode, struct file *file)
 	if (!fw_debug)
 		return 0;
 
-	if (fw_debug->debug_buffer)
-		vfree(fw_debug->debug_buffer);
+	vfree(fw_debug->debug_buffer);
 
 	file->private_data = NULL;
 	kfree(fw_debug);
--
Quoted 2 lines

2.1.3

Would you like to integrate this update suggestion into another source code repository?

Regards,
Markus

#413 lore raw

Re: [PATCH] SCSI-aic94xx: Deletion of an unnecessary check before the function call "kfree"

In reply to SF Markus Elfring
Quoted 19 lines

From: Markus Elfring <[email protected]>
Date: Thu, 20 Nov 2014 23:18:56 +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.

---
 drivers/scsi/aic94xx/aic94xx_init.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/scsi/aic94xx/aic94xx_init.c +0 -0
index c56741f..0bfdcba 100644

drivers/scsi/aic94xx/aic94xx_init.c static void asd_destroy_ha_caches(struct asd_ha_struct *asd_ha) · line 603

Quoted 9 lines
drivers/scsi/aic94xx/aic94xx_init.c +1 -2
@@ -597,8 +597,7 @@ static void asd_destroy_ha_caches(struct asd_ha_struct *asd_ha)
 	if (asd_ha->hw_prof.scb_ext)
 		asd_free_coherent(asd_ha, asd_ha->hw_prof.scb_ext);
 
-	if (asd_ha->hw_prof.ddb_bitmap)
-		kfree(asd_ha->hw_prof.ddb_bitmap);
+	kfree(asd_ha->hw_prof.ddb_bitmap);
 	asd_ha->hw_prof.ddb_bitmap = NULL;
 
 	for (i = 0; i < ASD_MAX_PHYS; i++) {

How are the chances to integrate this update suggestion into another source code repository?

Regards,
Markus

#411 lore raw

Re: [PATCH] SCSI-eata_pio: Deletion of an unnecessary check before the function call "pci_dev_put"

In reply to SF Markus Elfring
Quoted 19 lines

From: Markus Elfring <[email protected]>
Date: Thu, 20 Nov 2014 20:37:30 +0100

The pci_dev_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/scsi/eata_pio.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/scsi/eata_pio.c +0 -0
index 8319d2b..707f64d 100644

drivers/scsi/eata_pio.c static int eata_pio_release(struct Scsi_Host *sh) · line 128

Quoted 9 lines
drivers/scsi/eata_pio.c +1 -2
@@ -122,8 +122,7 @@ static int eata_pio_release(struct Scsi_Host *sh)
 			release_region(sh->io_port, sh->n_io_port);
 	}
 	/* At this point the PCI reference can go */
-	if (hd->pdev)
-		pci_dev_put(hd->pdev);
+	pci_dev_put(hd->pdev);
 	return 1;
 }
 

Would you like to integrate this update suggestion into another source code repository?

Regards,
Markus

#544 lore raw

Re: XFS: Fine-tuning for checks before the function call "xfs_qm_dqrele"?

In reply to Dave Chinner
Quoted 6 lines

xfs_dqrele_inode() gets called on every inode in the inode cache, and this change results in a cacheline in every inode being dirtied even if they don't have dquots attached. Given the inode cache can hold tens to hundreds of millions of inodes on large machines, we don't want to dirty any cachelines we don't need to while walking the inode cache and releasing dquots...

Would it make sense to annotate checks before such function calls as "LIKELY"?

Regards,
Markus

#495 lore raw

Re: [PATCH v2] backlight: lp8788: Deletion of a check before backlight_device_unregister()

In reply to SF Markus Elfring
Quoted 25 lines · SF Markus Elfring
Quoted 25 lines

From: Markus Elfring <[email protected]>

The backlight_device_unregister() 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.

---
 drivers/video/backlight/lp8788_bl.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/video/backlight/lp8788_bl.c +1 -2
index d6c4f6a..24a055c 100644
@@ -221,8 +221,7 @@ static void lp8788_backlight_unregister(struct lp8788_bl *bl)
 {
 	struct backlight_device *bl_dev = bl->bl_dev;
 
-	if (bl_dev)
-		backlight_device_unregister(bl_dev);
+	backlight_device_unregister(bl_dev);
 }
 
Quoted 5 lines

drivers/video/backlight/lp8788_bl.c static void lp8788_backlight_unregister(struct lp8788_bl *bl) · line 227

Quoted 2 lines
drivers/video/backlight/lp8788_bl.c +0 -0
 static ssize_t lp8788_get_bl_ctl_mode(struct device *dev,

Would you like to integrate this update suggestion into another source code repository?

If this patch has not received any attention in some time, it's possible that it may have slipped through the gaps. Please re-submit the set.

Signature · 8 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#349 lore raw

Re: [PATCH] InfiniBand: Deletion of unnecessary checks before two function calls

In reply to SF Markus Elfring
Quoted 34 lines

From: Markus Elfring <[email protected]>
Date: Wed, 19 Nov 2014 19:19:21 +0100

The functions kfree() and pci_dev_put() 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.

---
 drivers/infiniband/hw/mlx4/main.c         | 3 +--
 drivers/infiniband/hw/mthca/mthca_reset.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)
drivers/infiniband/hw/mlx4/main.c +1 -2
index 8b72cf3..50dee1a 100644
@@ -2512,8 +2512,7 @@ static void do_slave_init(struct mlx4_ib_dev *ibdev, int slave, int do_init)
 		if (!dm[i]) {
 			pr_err("failed to allocate memory for tunneling qp update work struct\n");
 			for (i = 0; i < dev->caps.num_ports; i++) {
-				if (dm[i])
-					kfree(dm[i]);
+				kfree(dm[i]);
 			}
 			goto out;
 		}
drivers/infiniband/hw/mthca/mthca_reset.c +0 -0
index 74c6a94..c521654 100644

drivers/infiniband/hw/mthca/mthca_reset.c good: · line 285

Quoted 9 lines
drivers/infiniband/hw/mthca/mthca_reset.c +1 -2
@@ -279,8 +279,7 @@ good:
 	}
 
 out:
-	if (bridge)
-		pci_dev_put(bridge);
+	pci_dev_put(bridge);
 	kfree(bridge_header);
 	kfree(hca_header);
 

More software developers became interested in similar source code improvements.

infiniband: Remove redundant NULL check before kfree
https://lkml.org/lkml/2015/6/26/45
https://www.mail-archive.com/linux-kernel%40vger.kernel.org/msg919966.html

Regards,
Markus

#496 lore raw

PATCH v3 1/1 video-lp8788: Delete a check before backlight_device_unregister()

In reply to Lee Jones

From: Markus Elfring <[email protected]>
Date: Wed, 1 Jul 2015 12:08:31 +0200

The backlight_device_unregister() 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.

---
 drivers/video/backlight/lp8788_bl.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/video/backlight/lp8788_bl.c +1 -2
index e418d5b..5d583d7 100644
@@ -221,8 +221,7 @@ static void lp8788_backlight_unregister(struct lp8788_bl *bl)
 {
 	struct backlight_device *bl_dev = bl->bl_dev;
 
-	if (bl_dev)
-		backlight_device_unregister(bl_dev);
+	backlight_device_unregister(bl_dev);
 }
 
 static ssize_t lp8788_get_bl_ctl_mode(struct device *dev,
Signature · 1 line
2.4.5
#545 lore raw

Re: XFS: Fine-tuning for checks before the function call "xfs_qm_dqrele"?

In reply to SF Markus Elfring
Quoted 9 lines · SF Markus Elfring
Quoted 6 lines

xfs_dqrele_inode() gets called on every inode in the inode cache, and this change results in a cacheline in every inode being dirtied even if they don't have dquots attached. Given the inode cache can hold tens to hundreds of millions of inodes on large machines, we don't want to dirty any cachelines we don't need to while walking the inode cache and releasing dquots...

Would it make sense to annotate checks before such function calls as "LIKELY"?

No - it will be random as to whether the inodes have dquots attached or not and so a static hint is always going to be wrong for someone....

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]
maintainer Acked-by on v3 1/1
#497 lore raw

Re: [PATCH v3] video-lp8788: Delete a check before backlight_device_unregister()

In reply to SF Markus Elfring
Quoted 6 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 1 Jul 2015 12:08:31 +0200

Quoted 7 lines

The backlight_device_unregister() 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.

It looks good.

Quoted 21 lines

---
drivers/video/backlight/lp8788_bl.c | 3 +--

1 file changed, 1 insertion(+), 2 deletions(-)
drivers/video/backlight/lp8788_bl.c +1 -2
index e418d5b..5d583d7 100644
@@ -221,8 +221,7 @@ static void lp8788_backlight_unregister(struct lp8788_bl *bl)
 {
   struct backlight_device *bl_dev = bl->bl_dev;
 
-    if (bl_dev)
-        backlight_device_unregister(bl_dev);
+    backlight_device_unregister(bl_dev);
 }
 
 static ssize_t lp8788_get_bl_ctl_mode(struct device *dev,
Signature · 1 line
2.4.5
#1047 lore raw

PATCH 1/1 net-ipv6: Delete an unnecessary check before the function call "free_percpu"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 2 Jul 2015 16:30:24 +0200

The free_percpu() 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.

---
 net/ipv6/route.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
net/ipv6/route.c +1 -4
index 1a1122a..6090969 100644
@@ -369,10 +369,7 @@ static void ip6_dst_destroy(struct dst_entry *dst)
 	struct inet6_dev *idev;
 
 	dst_destroy_metrics_generic(dst);
-
-	if (rt->rt6i_pcpu)
-		free_percpu(rt->rt6i_pcpu);
-
+	free_percpu(rt->rt6i_pcpu);
 	rt6_uncached_list_del(rt);
 
 	idev = rt->rt6i_idev;
Signature · 1 line
2.4.5
#282 lore raw

PATCH 1/1 net-ipvs: Delete an unnecessary check before the function call "module_put"

In reply to Pablo Neira Ayuso

From: Markus Elfring <[email protected]>
Date: Thu, 2 Jul 2015 17:00:14 +0200

The module_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.

---
 net/netfilter/ipvs/ip_vs_sched.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/ipvs/ip_vs_sched.c +1 -1
index 199760c..e50221b 100644
@@ -137,7 +137,7 @@ struct ip_vs_scheduler *ip_vs_scheduler_get(const char *sched_name)
 
 void ip_vs_scheduler_put(struct ip_vs_scheduler *scheduler)
 {
-	if (scheduler && scheduler->module)
+	if (scheduler)
 		module_put(scheduler->module);
 }
 
Signature · 1 line
2.4.5
#1049 lore raw

PATCH 1/1 net-RDS: Delete an unnecessary check before the function call "module_put"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 2 Jul 2015 17:58:21 +0200

The module_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.

---
 net/rds/transport.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/rds/transport.c +1 -1
index 8b4a6cd..83498e1 100644
@@ -73,7 +73,7 @@ EXPORT_SYMBOL_GPL(rds_trans_unregister);
 
 void rds_trans_put(struct rds_transport *trans)
 {
-	if (trans && trans->t_owner)
+	if (trans)
 		module_put(trans->t_owner);
 }
 
Signature · 1 line
2.4.5
#1051 lore raw

PATCH 1/1 netlink: Delete an unnecessary check before the function call "module_put"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 2 Jul 2015 18:38:12 +0200

The module_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.

---
 net/netlink/af_netlink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/netlink/af_netlink.c +1 -1
index dea9253..9a0ae71 100644
@@ -158,7 +158,7 @@ static int __netlink_remove_tap(struct netlink_tap *nt)
 out:
 	spin_unlock(&netlink_tap_lock);
 
-	if (found && nt->module)
+	if (found)
 		module_put(nt->module);
 
 	return found ? 0 : -ENODEV;
Signature · 1 line
2.4.5
#1053 lore raw

cover tools/testing/nvdimm: Deletion of two unnecessary checks

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>

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 "vfree" Improve error detection in __test_alloc()

 tools/testing/nvdimm/test/nfit.c | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)
Signature · 1 line
2.4.5
#1054 lore raw

PATCH 1/2 tools/testing/nvdimm: Delete an unnecessary check before the function call "vfree"

From: Markus Elfring <[email protected]>
Date: Thu, 2 Jul 2015 19:24:27 +0200

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.

---
 tools/testing/nvdimm/test/nfit.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/nvdimm/test/nfit.c +1 -1
index 4b69b83..9c910f1 100644
@@ -270,7 +270,7 @@ static void *__test_alloc(struct nfit_test *t, size_t size, dma_addr_t *dma,
  err:
 	if (buf && !is_vmalloc_addr(buf))
 		dma_free_coherent(dev, size, buf, *dma);
-	else if (buf)
+	else
 		vfree(buf);
 	kfree(res);
 	kfree(nfit_res);
Signature · 1 line
2.4.5
#1055 lore raw

PATCH 2/2 tools/testing/nvdimm: Improve error detection in __test_alloc()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 2 Jul 2015 20:45:53 +0200

Three checks were combined at the beginning of the __test_alloc() function. This implementation detail can become safer according to the Linux coding style convention.

* Return directly if a null pointer was passed for the variable "buf". Delete an unnecessary check then.

* Allocate memory for the data structure "nfit_test_resource" only if a previous allocation succeeded.

* Rename a jump label.

---
 tools/testing/nvdimm/test/nfit.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)
tools/testing/nvdimm/test/nfit.c +13 -8
index 9c910f1..d5f22ea 100644
@@ -244,16 +244,21 @@ static void *__test_alloc(struct nfit_test *t, size_t size, dma_addr_t *dma,
 		void *buf)
 {
 	struct device *dev = &t->pdev.dev;
-	struct resource *res = kzalloc(sizeof(*res) * 2, GFP_KERNEL);
-	struct nfit_test_resource *nfit_res = kzalloc(sizeof(*nfit_res),
-			GFP_KERNEL);
+	struct resource *res;
+	struct nfit_test_resource *nfit_res = NULL;
 	int rc;
 
-	if (!res || !buf || !nfit_res)
-		goto err;
+	if (!buf)
+		return NULL;
+	res = kzalloc(sizeof(*res) * 2, GFP_KERNEL);
+	if (!res)
+		goto free_memory;
+	nfit_res = kzalloc(sizeof(*nfit_res), GFP_KERNEL);
+	if (!nfit_res)
+		goto free_memory;
 	rc = devm_add_action(dev, release_nfit_res, nfit_res);
 	if (rc)
-		goto err;
+		goto free_memory;
 	INIT_LIST_HEAD(&nfit_res->list);
 	memset(buf, 0, size);
 	nfit_res->dev = dev;
@@ -267,8 +272,8 @@ static void *__test_alloc(struct nfit_test *t, size_t size, dma_addr_t *dma,
 	spin_unlock(&nfit_test_lock);
 
 	return nfit_res->buf;
- err:
-	if (buf && !is_vmalloc_addr(buf))
+free_memory:
+	if (!is_vmalloc_addr(buf))
 		dma_free_coherent(dev, size, buf, *dma);
 	else
 		vfree(buf);
Signature · 1 line
2.4.5
maintainer Applied
#1048 lore raw

Re: [PATCH] net-ipv6: Delete an unnecessary check before the function call "free_percpu"

In reply to SF Markus Elfring

From: SF Markus Elfring <[email protected]>
Date: Thu, 02 Jul 2015 16:43:43 +0200

Quoted 9 lines

From: Markus Elfring <[email protected]>
Date: Thu, 2 Jul 2015 16:30:24 +0200

The free_percpu() 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.

Applied.

maintainer Applied
#1050 lore raw

Re: [PATCH] net-RDS: Delete an unnecessary check before the function call "module_put"

In reply to SF Markus Elfring

From: SF Markus Elfring <[email protected]>
Date: Thu, 02 Jul 2015 18:08:19 +0200

Quoted 9 lines

From: Markus Elfring <[email protected]>
Date: Thu, 2 Jul 2015 17:58:21 +0200

The module_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.

Applied.

maintainer Applied
#1052 lore raw

Re: [PATCH] netlink: Delete an unnecessary check before the function call "module_put"

In reply to SF Markus Elfring

From: SF Markus Elfring <[email protected]>
Date: Thu, 02 Jul 2015 18:45:53 +0200

Quoted 9 lines

From: Markus Elfring <[email protected]>
Date: Thu, 2 Jul 2015 18:38:12 +0200

The module_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.

Applied.

#247 lore raw

PATCH 1/1 perf probe: Delete an unnecessary check before the function call "strfilter__delete"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 4 Jul 2015 07:44:22 +0200

The strfilter__delete() 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.

---
 tools/perf/builtin-probe.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
tools/perf/builtin-probe.c +1 -2
index 1272559..b81cec3 100644
@@ -297,8 +297,7 @@ static void cleanup_params(void)
 		clear_perf_probe_event(params.events + i);
 	line_range__clear(&params.line_range);
 	free(params.target);
-	if (params.filter)
-		strfilter__delete(params.filter);
+	strfilter__delete(params.filter);
 	memset(&params, 0, sizeof(params));
 }
 
Signature · 1 line
2.4.5
#1056 lore raw

PATCH 1/1 kernel-sched: Delete an unnecessary check before unregister_sysctl_table()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 4 Jul 2015 09:06:32 +0200

The unregister_sysctl_table() 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.

---
 kernel/sched/core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/sched/core.c +1 -2
index b803e1b..4756d1c 100644
@@ -5298,8 +5298,7 @@ static void register_sched_domain_sysctl(void)
 /* may be called multiple times per register */
 static void unregister_sched_domain_sysctl(void)
 {
-	if (sd_sysctl_header)
-		unregister_sysctl_table(sd_sysctl_header);
+	unregister_sysctl_table(sd_sysctl_header);
 	sd_sysctl_header = NULL;
 	if (sd_ctl_dir[0].child)
 		sd_free_ctl_entry(&sd_ctl_dir[0].child);
Signature · 1 line
2.4.5
#217 lore raw

PATCH 1/1 kprobes: Delete an unnecessary check before the function call "module_put"

In reply to Masami Hiramatsu

From: Markus Elfring <[email protected]>
Date: Sat, 4 Jul 2015 10:00:26 +0200

The module_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.

---
 kernel/kprobes.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
kernel/kprobes.c +1 -4
index c90e417..52e3529 100644
@@ -1531,10 +1531,7 @@ int register_kprobe(struct kprobe *p)
 
 out:
 	mutex_unlock(&kprobe_mutex);
-
-	if (probed_mod)
-		module_put(probed_mod);
-
+	module_put(probed_mod);
 	return ret;
 }
 EXPORT_SYMBOL_GPL(register_kprobe);
Signature · 1 line
2.4.5
#268 lore raw

PATCH 1/1 fs-namespace: Delete unnecessary checks before the function call "mntput"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 4 Jul 2015 11:21:17 +0200

The mntput() 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.

---
 fs/namespace.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
fs/namespace.c +2 -6
index e0b2f36..bc689bd 100644
@@ -2809,12 +2809,8 @@ struct mnt_namespace *copy_mnt_ns(unsigned long flags, struct mnt_namespace *ns,
 			p = next_mnt(p, old);
 	}
 	namespace_unlock();
-
-	if (rootmnt)
-		mntput(rootmnt);
-	if (pwdmnt)
-		mntput(pwdmnt);
-
+	mntput(rootmnt);
+	mntput(pwdmnt);
 	return new_ns;
 }
 
Signature · 1 line
2.4.5
#538 lore raw

Re: [PATCH] fs-notify: Deletion of an unnecessary check before the function call "iput"

In reply to SF Markus Elfring
Quoted 19 lines

From: Markus Elfring <[email protected]>
Date: Sat, 29 Nov 2014 16:42:50 +0100

The iput() 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.

---
 fs/notify/inode_mark.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/notify/inode_mark.c +0 -0
index 3daf513..d8157a6 100644

fs/notify/inode_mark.c void fsnotify_unmount_inodes(struct list_head *list) · line 237

Quoted 9 lines
fs/notify/inode_mark.c +1 -2
@@ -231,8 +231,7 @@ void fsnotify_unmount_inodes(struct list_head *list)
 		 */
 		spin_unlock(&inode_sb_list_lock);
 
-		if (need_iput_tmp)
-			iput(need_iput_tmp);
+		iput(need_iput_tmp);
 
 		/* for each watch, send FS_UNMOUNT and then remove it */
 		fsnotify(inode, FS_UNMOUNT, inode, FSNOTIFY_EVENT_INODE, NULL, 0);

Would anybody like to integrate this update suggestion into another source code repository?

Regards,
Markus

#155 lore raw

Re: [PATCH] ntfs: Deletion of unnecessary checks before the function call "iput"

In reply to SF Markus Elfring
Quoted 52 lines

From: Markus Elfring <[email protected]>
Date: Sat, 15 Nov 2014 19:35:05 +0100

The iput() 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.

---
 fs/ntfs/super.c | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)
fs/ntfs/super.c +6 -12
index 6c3296e..8f22a47 100644
@@ -2204,17 +2204,12 @@ get_ctx_vol_failed:
 	return true;
 #ifdef NTFS_RW
 iput_usnjrnl_err_out:
-	if (vol->usnjrnl_j_ino)
-		iput(vol->usnjrnl_j_ino);
-	if (vol->usnjrnl_max_ino)
-		iput(vol->usnjrnl_max_ino);
-	if (vol->usnjrnl_ino)
-		iput(vol->usnjrnl_ino);
+	iput(vol->usnjrnl_j_ino);
+	iput(vol->usnjrnl_max_ino);
+	iput(vol->usnjrnl_ino);
 iput_quota_err_out:
-	if (vol->quota_q_ino)
-		iput(vol->quota_q_ino);
-	if (vol->quota_ino)
-		iput(vol->quota_ino);
+	iput(vol->quota_q_ino);
+	iput(vol->quota_ino);
 	iput(vol->extend_ino);
 #endif /* NTFS_RW */
 iput_sec_err_out:
@@ -2223,8 +2218,7 @@ iput_root_err_out:
 	iput(vol->root_ino);
 iput_logfile_err_out:
 #ifdef NTFS_RW
-	if (vol->logfile_ino)
-		iput(vol->logfile_ino);
+	iput(vol->logfile_ino);
 iput_vol_err_out:
 #endif /* NTFS_RW */
 	iput(vol->vol_ino);

fs/ntfs/super.c iput_mftbmp_err_out: · line 2254

Quoted 9 lines
fs/ntfs/super.c +1 -2
@@ -2254,8 +2248,7 @@ iput_mftbmp_err_out:
 	iput(vol->mftbmp_ino);
 iput_mirr_err_out:
 #ifdef NTFS_RW
-	if (vol->mftmirr_ino)
-		iput(vol->mftmirr_ino);
+	iput(vol->mftmirr_ino);
 #endif /* NTFS_RW */
 	return false;
 }

Would you like to integrate this update suggestion into another source code repository?

Regards,
Markus

Reviewed-by
#156 lore raw

Re: [PATCH] ntfs: Deletion of unnecessary checks before the function call "iput"

Hi Andrew,

Can you please take up this trivial patch and merge it upstream?

Thanks a lot in advance!

Best regards,

Anton

Quoted 69 lines · SF Markus Elfring
Quoted 58 lines

From: Markus Elfring <[email protected]>
Date: Sat, 15 Nov 2014 19:35:05 +0100

The iput() 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.

---
fs/ntfs/super.c | 21 +++++++--------------

1 file changed, 7 insertions(+), 14 deletions(-)
fs/ntfs/super.c +0 -0
index 6c3296e..8f22a47 100644
@@ -2204,17 +2204,12 @@ get_ctx_vol_failed:
 	return true;
 #ifdef NTFS_RW

iput_usnjrnl_err_out:

fs/ntfs/super.c +3 -6
-	if (vol->usnjrnl_j_ino)
-		iput(vol->usnjrnl_j_ino);
-	if (vol->usnjrnl_max_ino)
-		iput(vol->usnjrnl_max_ino);
-	if (vol->usnjrnl_ino)
-		iput(vol->usnjrnl_ino);
+	iput(vol->usnjrnl_j_ino);
+	iput(vol->usnjrnl_max_ino);
+	iput(vol->usnjrnl_ino);

iput_quota_err_out:

fs/ntfs/super.c +2 -4
-	if (vol->quota_q_ino)
-		iput(vol->quota_q_ino);
-	if (vol->quota_ino)
-		iput(vol->quota_ino);
+	iput(vol->quota_q_ino);
+	iput(vol->quota_ino);
	iput(vol->extend_ino);

#endif /* NTFS_RW */
iput_sec_err_out:

fs/ntfs/super.c +0 -0
@@ -2223,8 +2218,7 @@ iput_root_err_out:
 	iput(vol->root_ino);

iput_logfile_err_out:
#ifdef NTFS_RW

fs/ntfs/super.c +1 -2
-	if (vol->logfile_ino)
-		iput(vol->logfile_ino);
+	iput(vol->logfile_ino);

iput_vol_err_out:

#endif /* NTFS_RW */
	iput(vol->vol_ino);
fs/ntfs/super.c +0 -0
@@ -2254,8 +2248,7 @@ iput_mftbmp_err_out:
 	iput(vol->mftbmp_ino);

iput_mirr_err_out:
#ifdef NTFS_RW

fs/ntfs/super.c +1 -2
-	if (vol->mftmirr_ino)
-		iput(vol->mftmirr_ino);
+	iput(vol->mftmirr_ino);
Quoted 4 lines
#endif /* NTFS_RW */
	return false;
}

Would you like to integrate this update suggestion into another source code repository?

Regards,
Markus

Signature · 3 lines
Anton Altaparmakov <anton at tuxera.com> (replace at with @)
Lead in File System Development, Tuxera Inc., http://www.tuxera.com/
Linux NTFS maintainer
#119 lore raw

cover ocfs2: Deletion of some unnecessary checks

In reply to Julia Lawall

From: Markus Elfring <[email protected]>

Further update suggestions were taken into account after two patches were applied from static source code analysis.

Markus Elfring (11):
Delete an unnecessary check before unregister_sysctl_table() Delete unnecessary checks before the function call "iput" Less checks in ocfs2_rename() after error detection
One check less in ocfs2_statfs()
Less error log repetition in ocfs2_begin_truncate_log_recovery() Two checks less in ocfs2_local_alloc_slide_window()
Less function calls in ocfs2_shutdown_local_alloc() after error detection Less checks in ocfs2_load_local_alloc()
One function call less in ocfs2_trylock_journal() after error detection Less function calls in ocfs2_replay_journal() after error detection One function call less in ocfs2_journal_shutdown() from input checks

 fs/ocfs2/alloc.c      | 24 +++++++--------
 fs/ocfs2/ioctl.c      |  4 +--
 fs/ocfs2/journal.c    | 62 +++++++++++++++----------------------
 fs/ocfs2/localalloc.c | 84 +++++++++++++++++++++------------------------------
 fs/ocfs2/namei.c      | 17 +++++------
 fs/ocfs2/slot_map.c   |  3 +-
 fs/ocfs2/stackglue.c  |  3 +-
 fs/ocfs2/super.c      | 22 ++++++--------
 8 files changed, 90 insertions(+), 129 deletions(-)
Signature · 1 line
2.4.5
#120 lore raw

PATCH 1/11 ocfs2: Delete an unnecessary check before unregister_sysctl_table()

From: Markus Elfring <[email protected]>
Date: Sat, 4 Jul 2015 13:20:13 +0200

The unregister_sysctl_table() 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.

---
 fs/ocfs2/stackglue.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/ocfs2/stackglue.c +1 -2
index 5d965e8..4222f93 100644
@@ -737,8 +737,7 @@ static void __exit ocfs2_stack_glue_exit(void)
 	locking_max_version.pv_major = 0;
 	locking_max_version.pv_minor = 0;
 	ocfs2_sysfs_exit();
-	if (ocfs2_table_header)
-		unregister_sysctl_table(ocfs2_table_header);
+	unregister_sysctl_table(ocfs2_table_header);
 }
 
 MODULE_AUTHOR("Oracle");
Signature · 1 line
2.4.5
#121 lore raw

PATCH 2/11 ocfs2: Delete unnecessary checks before the function call "iput"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 4 Jul 2015 13:40:07 +0200

The iput() 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.

---
 fs/ocfs2/alloc.c      |  3 +--
 fs/ocfs2/ioctl.c      |  4 +---
 fs/ocfs2/journal.c    | 11 +++--------
 fs/ocfs2/localalloc.c | 13 +++----------
 fs/ocfs2/namei.c      |  4 +---
 fs/ocfs2/slot_map.c   |  3 +--
 fs/ocfs2/super.c      |  3 +--
 7 files changed, 11 insertions(+), 30 deletions(-)
fs/ocfs2/alloc.c +1 -2
index 0afb4cb..f36dcaa 100644
@@ -6197,8 +6197,7 @@ int ocfs2_begin_truncate_log_recovery(struct ocfs2_super *osb,
 	}
 
 bail:
-	if (tl_inode)
-		iput(tl_inode);
+	iput(tl_inode);
 	brelse(tl_bh);
 
 	if (status < 0 && (*tl_copy)) {
fs/ocfs2/ioctl.c +1 -3
index 53e6c40..a7dae26 100644
@@ -606,9 +606,7 @@ bail:
 	if (gb_inode)
 		mutex_unlock(&gb_inode->i_mutex);
 
-	if (gb_inode)
-		iput(gb_inode);
-
+	iput(gb_inode);
 	brelse(bh);
 
 	return status;
fs/ocfs2/journal.c +3 -8
index 8f853ea..c644997 100644
@@ -1026,8 +1026,7 @@ void ocfs2_journal_shutdown(struct ocfs2_super *osb)
 
 //	up_write(&journal->j_trans_barrier);
 done:
-	if (inode)
-		iput(inode);
+	iput(inode);
 }
 
 static void ocfs2_clear_journal_error(struct super_block *sb,
@@ -1671,9 +1670,7 @@ done:
 	if (got_lock)
 		ocfs2_inode_unlock(inode, 1);
 
-	if (inode)
-		iput(inode);
-
+	iput(inode);
 	brelse(bh);
 
 	return status;
@@ -1780,9 +1777,7 @@ static int ocfs2_trylock_journal(struct ocfs2_super *osb,
 
 	ocfs2_inode_unlock(inode, 1);
 bail:
-	if (inode)
-		iput(inode);
-
+	iput(inode);
 	return status;
 }
 
fs/ocfs2/localalloc.c +3 -10
index 0a4457f..a614037 100644
@@ -358,9 +358,7 @@ int ocfs2_load_local_alloc(struct ocfs2_super *osb)
 bail:
 	if (status < 0)
 		brelse(alloc_bh);
-	if (inode)
-		iput(inode);
-
+	iput(inode);
 	trace_ocfs2_load_local_alloc(osb->local_alloc_bits);
 
 	if (status)
@@ -473,9 +471,7 @@ out_mutex:
 	iput(main_bm_inode);
 
 out:
-	if (local_alloc_inode)
-		iput(local_alloc_inode);
-
+	iput(local_alloc_inode);
 	kfree(alloc_copy);
 }
 
@@ -1326,10 +1322,7 @@ bail:
 		ocfs2_commit_trans(osb, handle);
 
 	brelse(main_bm_bh);
-
-	if (main_bm_inode)
-		iput(main_bm_inode);
-
+	iput(main_bm_inode);
 	kfree(alloc_copy);
 
 	if (ac)
fs/ocfs2/namei.c +1 -3
index af9c4c8..a04d70b 100644
@@ -1655,9 +1655,7 @@ bail:
 	if (new_inode)
 		sync_mapping_buffers(old_inode->i_mapping);
 
-	if (new_inode)
-		iput(new_inode);
-
+	iput(new_inode);
 	ocfs2_free_dir_lookup_result(&target_lookup_res);
 	ocfs2_free_dir_lookup_result(&old_entry_lookup);
 	ocfs2_free_dir_lookup_result(&old_inode_dot_dot_res);
fs/ocfs2/slot_map.c +1 -2
index e78a203..47bba1b 100644
@@ -322,8 +322,7 @@ static void __ocfs2_free_slot_info(struct ocfs2_slot_info *si)
 	if (si = NULL)
 		return;
 
-	if (si->si_inode)
-		iput(si->si_inode);
+	iput(si->si_inode);
 	if (si->si_bh) {
 		for (i = 0; i < si->si_blocks; i++) {
 			if (si->si_bh[i]) {
fs/ocfs2/super.c +1 -2
index 2fc02f7..37e418f 100644
@@ -1726,8 +1726,7 @@ static int ocfs2_statfs(struct dentry *dentry, struct kstatfs *buf)
 	ocfs2_inode_unlock(inode, 0);
 	status = 0;
 bail:
-	if (inode)
-		iput(inode);
+	iput(inode);
 
 	if (status)
 		mlog_errno(status);
Signature · 1 line
2.4.5
#122 lore raw

PATCH 3/11 ocfs2: Less checks in ocfs2_rename() after error detection

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 4 Jul 2015 15:30:18 +0200

Skip checks for a few variables in three error handling cases within the ocfs2_rename() function by adjustment of a few jump targets according to the Linux coding style convention.

---
 fs/ocfs2/namei.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
fs/ocfs2/namei.c +7 -6
index a04d70b..04a61cb 100644
@@ -1255,7 +1255,7 @@ static int ocfs2_rename(struct inode *old_dir,
 		status = ocfs2_rename_lock(osb);
 		if (status < 0) {
 			mlog_errno(status);
-			goto bail;
+			goto basic_clean_up;
 		}
 		rename_lock = 1;
 
@@ -1265,13 +1265,13 @@ static int ocfs2_rename(struct inode *old_dir,
 				old_inode->i_ino);
 		if (status < 0) {
 			mlog_errno(status);
-			goto bail;
+			goto rename_unlock;
 		} else if (status = 1) {
 			status = -EPERM;
 			trace_ocfs2_rename_not_permitted(
 					(unsigned long long)old_inode->i_ino,
 					(unsigned long long)new_dir->i_ino);
-			goto bail;
+			goto rename_unlock;
 		}
 	}
 
@@ -1630,9 +1630,10 @@ static int ocfs2_rename(struct inode *old_dir,
 	ocfs2_dentry_move(old_dentry, new_dentry, old_dir, new_dir);
 	status = 0;
 bail:
-	if (rename_lock)
+	if (rename_lock) {
+rename_unlock:
 		ocfs2_rename_unlock(osb);
-
+	}
 	if (handle)
 		ocfs2_commit_trans(osb, handle);
 
@@ -1651,7 +1652,7 @@ bail:
 		mutex_unlock(&orphan_dir->i_mutex);
 		iput(orphan_dir);
 	}
-
+basic_clean_up:
 	if (new_inode)
 		sync_mapping_buffers(old_inode->i_mapping);
 
Signature · 1 line
2.4.5
#126 lore raw

PATCH 4/11 ocfs2: One check less in ocfs2_statfs()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 4 Jul 2015 16:28:50 +0200

Delete a check for the variable "status" by adjustment of two jump targets according to the Linux coding style convention.
Separate the exception handling statements from the ordinary execution path.

---
 fs/ocfs2/super.c | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)
fs/ocfs2/super.c +8 -11
index 37e418f..ed16f08 100644
@@ -1692,14 +1692,12 @@ static int ocfs2_statfs(struct dentry *dentry, struct kstatfs *buf)
 	if (!inode) {
 		mlog(ML_ERROR, "failed to get bitmap inode\n");
 		status = -EIO;
-		goto bail;
+		goto log_error;
 	}
 
 	status = ocfs2_inode_lock(inode, &bh, 0);
-	if (status < 0) {
-		mlog_errno(status);
-		goto bail;
-	}
+	if (status < 0)
+		goto put_inode;
 
 	bm_lock = (struct ocfs2_dinode *) bh->b_data;
 
@@ -1724,13 +1722,12 @@ static int ocfs2_statfs(struct dentry *dentry, struct kstatfs *buf)
 	brelse(bh);
 
 	ocfs2_inode_unlock(inode, 0);
-	status = 0;
-bail:
 	iput(inode);
-
-	if (status)
-		mlog_errno(status);
-
+	return 0;
+put_inode:
+	iput(inode);
+log_error:
+	mlog_errno(status);
 	return status;
 }
 
Signature · 1 line
2.4.5
#127 lore raw

PATCH 5/11 ocfs2: Less error log repetition in ocfs2_begin_truncate_log_recovery()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 4 Jul 2015 17:23:08 +0200

Delete three direct calls of the mlog_errno() function within ocfs2_begin_truncate_log_recovery().
A single logging call can be sufficient.

Drop initialisation for the variables "tl_inode" and "tl_bh" then.

---
 fs/ocfs2/alloc.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)
fs/ocfs2/alloc.c +10 -11
index f36dcaa..59e639e 100644
@@ -6147,8 +6147,8 @@ int ocfs2_begin_truncate_log_recovery(struct ocfs2_super *osb,
 				      struct ocfs2_dinode **tl_copy)
 {
 	int status;
-	struct inode *tl_inode = NULL;
-	struct buffer_head *tl_bh = NULL;
+	struct inode *tl_inode;
+	struct buffer_head *tl_bh;
 	struct ocfs2_dinode *di;
 	struct ocfs2_truncate_log *tl;
 
@@ -6157,10 +6157,8 @@ int ocfs2_begin_truncate_log_recovery(struct ocfs2_super *osb,
 	trace_ocfs2_begin_truncate_log_recovery(slot_num);
 
 	status = ocfs2_get_truncate_log_info(osb, slot_num, &tl_inode, &tl_bh);
-	if (status < 0) {
-		mlog_errno(status);
-		goto bail;
-	}
+	if (status < 0)
+		goto log_error;
 
 	di = (struct ocfs2_dinode *) tl_bh->b_data;
 
@@ -6176,7 +6174,6 @@ int ocfs2_begin_truncate_log_recovery(struct ocfs2_super *osb,
 		*tl_copy = kmalloc(tl_bh->b_size, GFP_KERNEL);
 		if (!(*tl_copy)) {
 			status = -ENOMEM;
-			mlog_errno(status);
 			goto bail;
 		}
 
@@ -6191,7 +6188,6 @@ int ocfs2_begin_truncate_log_recovery(struct ocfs2_super *osb,
 		ocfs2_compute_meta_ecc(osb->sb, tl_bh->b_data, &di->i_check);
 		status = ocfs2_write_block(osb, tl_bh, INODE_CACHE(tl_inode));
 		if (status < 0) {
-			mlog_errno(status);
 			goto bail;
 		}
 	}
@@ -6200,9 +6196,12 @@ bail:
 	iput(tl_inode);
 	brelse(tl_bh);
 
-	if (status < 0 && (*tl_copy)) {
-		kfree(*tl_copy);
-		*tl_copy = NULL;
+	if (status < 0) {
+		if (*tl_copy) {
+			kfree(*tl_copy);
+			*tl_copy = NULL;
+		}
+log_error:
 		mlog_errno(status);
 	}
 
Signature · 1 line
2.4.5
#128 lore raw

PATCH 6/11 ocfs2: Two checks less in ocfs2_local_alloc_slide_window()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 4 Jul 2015 18:18:23 +0200

* Return directly from the ocfs2_local_alloc_slide_window() function if a call of the ocfs2_local_alloc_reserve_for_window() function failed at the beginning.

* Rename jump labels according to the Linux coding style convention.

* Drop an unnecessary initialisation for the variable "handle" then.

* Delete a call of the mlog_errno() function at the end.

---
 fs/ocfs2/localalloc.c | 25 ++++++++++---------------
 1 file changed, 10 insertions(+), 15 deletions(-)
fs/ocfs2/localalloc.c +10 -15
index a614037..16579ed 100644
@@ -1248,7 +1248,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
 	int status = 0;
 	struct buffer_head *main_bm_bh = NULL;
 	struct inode *main_bm_inode = NULL;
-	handle_t *handle = NULL;
+	handle_t *handle;
 	struct ocfs2_dinode *alloc;
 	struct ocfs2_dinode *alloc_copy = NULL;
 	struct ocfs2_alloc_context *ac = NULL;
@@ -1263,15 +1263,14 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
 	if (status < 0) {
 		if (status != -ENOSPC)
 			mlog_errno(status);
-		goto bail;
+		return status;
 	}
 
 	handle = ocfs2_start_trans(osb, OCFS2_WINDOW_MOVE_CREDITS);
 	if (IS_ERR(handle)) {
 		status = PTR_ERR(handle);
-		handle = NULL;
 		mlog_errno(status);
-		goto bail;
+		goto clean_up_main;
 	}
 
 	alloc = (struct ocfs2_dinode *) osb->local_alloc_bh->b_data;
@@ -1285,7 +1284,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
 	if (!alloc_copy) {
 		status = -ENOMEM;
 		mlog_errno(status);
-		goto bail;
+		goto commit;
 	}
 	memcpy(alloc_copy, alloc, osb->local_alloc_bh->b_size);
 
@@ -1295,7 +1294,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
 					 OCFS2_JOURNAL_ACCESS_WRITE);
 	if (status < 0) {
 		mlog_errno(status);
-		goto bail;
+		goto commit;
 	}
 
 	ocfs2_clear_local_alloc(alloc);
@@ -1305,31 +1304,27 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
 					  main_bm_inode, main_bm_bh);
 	if (status < 0) {
 		mlog_errno(status);
-		goto bail;
+		goto commit;
 	}
 
 	status = ocfs2_local_alloc_new_window(osb, handle, ac);
 	if (status < 0) {
 		if (status != -ENOSPC)
 			mlog_errno(status);
-		goto bail;
+		goto commit;
 	}
 
 	atomic_inc(&osb->alloc_stats.moves);
 
-bail:
-	if (handle)
-		ocfs2_commit_trans(osb, handle);
-
+commit:
+	ocfs2_commit_trans(osb, handle);
+clean_up_main:
 	brelse(main_bm_bh);
 	iput(main_bm_inode);
 	kfree(alloc_copy);
 
 	if (ac)
 		ocfs2_free_alloc_context(ac);
-
-	if (status)
-		mlog_errno(status);
 	return status;
 }
 
Signature · 1 line
2.4.5
#129 lore raw

PATCH 7/11 ocfs2: Less function calls in ocfs2_shutdown_local_alloc() after error detection

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 4 Jul 2015 21:02:05 +0200

The functions kfree() and iput() were called in a few cases by the ocfs2_shutdown_local_alloc() function during error handling even if the passed variables contained still a null pointer.

* Return directly if the local allocation feature is unused or if a call for the ocfs2_get_system_file_inode() function failed.

* Adjust jump targets.

* Drop unnecessary initialisations for the variables "alloc", "alloc_copy", "bh", "local_alloc_inode" and "main_bm_inode" then.

---
 fs/ocfs2/localalloc.c | 27 ++++++++++++---------------
 1 file changed, 12 insertions(+), 15 deletions(-)
fs/ocfs2/localalloc.c +12 -15
index 16579ed..e6d5074 100644
@@ -377,18 +377,18 @@ void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb)
 {
 	int status;
 	handle_t *handle;
-	struct inode *local_alloc_inode = NULL;
-	struct buffer_head *bh = NULL;
+	struct inode *local_alloc_inode;
+	struct buffer_head *bh;
 	struct buffer_head *main_bm_bh = NULL;
-	struct inode *main_bm_inode = NULL;
-	struct ocfs2_dinode *alloc_copy = NULL;
-	struct ocfs2_dinode *alloc = NULL;
+	struct inode *main_bm_inode;
+	struct ocfs2_dinode *alloc_copy;
+	struct ocfs2_dinode *alloc;
 
 	cancel_delayed_work(&osb->la_enable_wq);
 	flush_workqueue(ocfs2_wq);
 
 	if (osb->local_alloc_state = OCFS2_LA_UNUSED)
-		goto out;
+		return;
 
 	local_alloc_inode  		ocfs2_get_system_file_inode(osb,
@@ -397,7 +397,7 @@ void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb)
 	if (!local_alloc_inode) {
 		status = -ENOENT;
 		mlog_errno(status);
-		goto out;
+		return;
 	}
 
 	osb->local_alloc_state = OCFS2_LA_DISABLED;
@@ -410,7 +410,7 @@ void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb)
 	if (!main_bm_inode) {
 		status = -EINVAL;
 		mlog_errno(status);
-		goto out;
+		goto put_local_alloc_inode;
 	}
 
 	mutex_lock(&main_bm_inode->i_mutex);
@@ -443,7 +443,7 @@ void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb)
 					 bh, OCFS2_JOURNAL_ACCESS_WRITE);
 	if (status < 0) {
 		mlog_errno(status);
-		goto out_commit;
+		goto free_copy;
 	}
 
 	ocfs2_clear_local_alloc(alloc);
@@ -458,21 +458,18 @@ void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb)
 	if (status < 0)
 		mlog_errno(status);
 
+free_copy:
+	kfree(alloc_copy);
 out_commit:
 	ocfs2_commit_trans(osb, handle);
-
 out_unlock:
 	brelse(main_bm_bh);
-
 	ocfs2_inode_unlock(main_bm_inode, 1);
-
 out_mutex:
 	mutex_unlock(&main_bm_inode->i_mutex);
 	iput(main_bm_inode);
-
-out:
+put_local_alloc_inode:
 	iput(local_alloc_inode);
-	kfree(alloc_copy);
 }
 
 /*
Signature · 1 line
2.4.5
#130 lore raw

PATCH 8/11 ocfs2: Less checks in ocfs2_load_local_alloc()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 4 Jul 2015 22:06:32 +0200

* Skip checks for the variable "status" in a few cases within the ocfs2_load_local_alloc() function by adjustment of two jump targets according to the Linux coding style convention.

* Drop unnecessary initialisations for the variables "alloc" and "inode" then.

---
 fs/ocfs2/localalloc.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)
fs/ocfs2/localalloc.c +10 -9
index e6d5074..08f812b 100644
@@ -284,14 +284,14 @@ bail:
 int ocfs2_load_local_alloc(struct ocfs2_super *osb)
 {
 	int status = 0;
-	struct ocfs2_dinode *alloc = NULL;
+	struct ocfs2_dinode *alloc;
 	struct buffer_head *alloc_bh = NULL;
 	u32 num_used;
-	struct inode *inode = NULL;
+	struct inode *inode;
 	struct ocfs2_local_alloc *la;
 
-	if (osb->local_alloc_bits = 0)
-		goto bail;
+	if (osb->local_alloc_bits)
+		goto trace_bits;
 
 	if (osb->local_alloc_bits >= osb->bitmap_cpg) {
 		mlog(ML_NOTICE, "Requested local alloc window %d is larger "
@@ -308,14 +308,14 @@ int ocfs2_load_local_alloc(struct ocfs2_super *osb)
 	if (!inode) {
 		status = -EINVAL;
 		mlog_errno(status);
-		goto bail;
+		goto trace_bits;
 	}
 
 	status = ocfs2_read_inode_block_full(inode, &alloc_bh,
 					     OCFS2_BH_IGNORE_CACHE);
 	if (status < 0) {
 		mlog_errno(status);
-		goto bail;
+		goto put_inode;
 	}
 
 	alloc = (struct ocfs2_dinode *) alloc_bh->b_data;
@@ -326,6 +326,7 @@ int ocfs2_load_local_alloc(struct ocfs2_super *osb)
 		mlog(ML_ERROR, "Invalid local alloc inode, %llu\n",
 		     (unsigned long long)OCFS2_I(inode)->ip_blkno);
 		status = -EINVAL;
+		mlog_errno(status);
 		goto bail;
 	}
 
@@ -334,6 +335,7 @@ int ocfs2_load_local_alloc(struct ocfs2_super *osb)
 		mlog(ML_ERROR, "Local alloc size is invalid (la_size = %u)\n",
 		     le16_to_cpu(la->la_size));
 		status = -EINVAL;
+		mlog_errno(status);
 		goto bail;
 	}
 
@@ -358,11 +360,10 @@ int ocfs2_load_local_alloc(struct ocfs2_super *osb)
 bail:
 	if (status < 0)
 		brelse(alloc_bh);
+put_inode:
 	iput(inode);
+trace_bits:
 	trace_ocfs2_load_local_alloc(osb->local_alloc_bits);
-
-	if (status)
-		mlog_errno(status);
 	return status;
 }
 
Signature · 1 line
2.4.5
#131 lore raw

PATCH 9/11 ocfs2: One function call less in ocfs2_trylock_journal() after error detection

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 4 Jul 2015 22:34:43 +0200

The iput() function was called in one case by the ocfs2_trylock_journal() function during error handling even if the passed variable "inode" contained still a null pointer.

* Return directly if a call of the ocfs2_get_system_file_inode() function failed at the beginning.

* Rename a jump label according to the Linux coding style convention.

---
 fs/ocfs2/journal.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)
fs/ocfs2/journal.c +5 -8
index c644997..c343e36 100644
@@ -1749,21 +1749,18 @@ static int ocfs2_trylock_journal(struct ocfs2_super *osb,
 				 int slot_num)
 {
 	int status, flags;
-	struct inode *inode = NULL;
+	struct inode *inode;
 
 	inode = ocfs2_get_system_file_inode(osb, JOURNAL_SYSTEM_INODE,
 					    slot_num);
 	if (inode = NULL) {
 		mlog(ML_ERROR, "access error\n");
-		status = -EACCES;
-		goto bail;
+		return -EACCES;
 	}
 	if (is_bad_inode(inode)) {
 		mlog(ML_ERROR, "access error (bad inode)\n");
-		iput(inode);
-		inode = NULL;
 		status = -EACCES;
-		goto bail;
+		goto put_inode;
 	}
 	SET_INODE_JOURNAL(inode);
 
@@ -1772,11 +1769,11 @@ static int ocfs2_trylock_journal(struct ocfs2_super *osb,
 	if (status < 0) {
 		if (status != -EAGAIN)
 			mlog_errno(status);
-		goto bail;
+		goto put_inode;
 	}
 
 	ocfs2_inode_unlock(inode, 1);
-bail:
+put_inode:
 	iput(inode);
 	return status;
 }
Signature · 1 line
2.4.5
#132 lore raw

PATCH 10/11 ocfs2: Less function calls in ocfs2_replay_journal() after error detection

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 5 Jul 2015 12:23:37 +0200

The functions brelse() and iput() were called in one case by the ocfs2_replay_journal() function during error handling even if the passed variables contained still a pointer which did not refer to valid data.

* Return directly if a call of the ocfs2_read_journal_inode() function failed at the beginning.

* Rename jump labels according to the Linux coding style convention.

* Delete the variable "got_lock" then.

---
 fs/ocfs2/journal.c | 23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)
fs/ocfs2/journal.c +10 -13
index c343e36..7bb50f4 100644
@@ -1544,7 +1544,6 @@ static int ocfs2_replay_journal(struct ocfs2_super *osb,
 				int slot_num)
 {
 	int status;
-	int got_lock = 0;
 	unsigned int flags;
 	struct inode *inode = NULL;
 	struct ocfs2_dinode *fe;
@@ -1555,7 +1554,7 @@ static int ocfs2_replay_journal(struct ocfs2_super *osb,
 	status = ocfs2_read_journal_inode(osb, slot_num, &bh, &inode);
 	if (status) {
 		mlog_errno(status);
-		goto done;
+		return status;
 	}
 
 	fe = (struct ocfs2_dinode *)bh->b_data;
@@ -1576,7 +1575,7 @@ static int ocfs2_replay_journal(struct ocfs2_super *osb,
 		     osb->slot_recovery_generations[slot_num], slot_reco_gen);
 		osb->slot_recovery_generations[slot_num] = slot_reco_gen;
 		status = -EBUSY;
-		goto done;
+		goto put_inode;
 	}
 
 	/* Continue with recovery as the journal has not yet been recovered */
@@ -1586,9 +1585,8 @@ static int ocfs2_replay_journal(struct ocfs2_super *osb,
 		trace_ocfs2_replay_journal_lock_err(status);
 		if (status != -ERESTARTSYS)
 			mlog(ML_ERROR, "Could not lock journal!\n");
-		goto done;
+		goto put_inode;
 	}
-	got_lock = 1;
 
 	fe = (struct ocfs2_dinode *) bh->b_data;
 
@@ -1599,7 +1597,7 @@ static int ocfs2_replay_journal(struct ocfs2_super *osb,
 		trace_ocfs2_replay_journal_skip(node_num);
 		/* Refresh recovery generation for the slot */
 		osb->slot_recovery_generations[slot_num] = slot_reco_gen;
-		goto done;
+		goto unlock_inode;
 	}
 
 	/* we need to run complete recovery for offline orphan slots */
@@ -1614,14 +1612,14 @@ static int ocfs2_replay_journal(struct ocfs2_super *osb,
 	status = ocfs2_force_read_journal(inode);
 	if (status < 0) {
 		mlog_errno(status);
-		goto done;
+		goto unlock_inode;
 	}
 
 	journal = jbd2_journal_init_inode(inode);
 	if (journal = NULL) {
 		mlog(ML_ERROR, "Linux journal layer error\n");
 		status = -EIO;
-		goto done;
+		goto unlock_inode;
 	}
 
 	status = jbd2_journal_load(journal);
@@ -1630,7 +1628,7 @@ static int ocfs2_replay_journal(struct ocfs2_super *osb,
 		if (!igrab(inode))
 			BUG();
 		jbd2_journal_destroy(journal);
-		goto done;
+		goto unlock_inode;
 	}
 
 	ocfs2_clear_journal_error(osb->sb, journal, slot_num);
@@ -1665,11 +1663,10 @@ static int ocfs2_replay_journal(struct ocfs2_super *osb,
 	printk(KERN_NOTICE "ocfs2: End replay journal (node %d, slot %d) on "\
 	       "device (%u,%u)\n", node_num, slot_num, MAJOR(osb->sb->s_dev),
 	       MINOR(osb->sb->s_dev));
-done:
+unlock_inode:
 	/* drop the lock on this nodes journal */
-	if (got_lock)
-		ocfs2_inode_unlock(inode, 1);
-
+	ocfs2_inode_unlock(inode, 1);
+put_inode:
 	iput(inode);
 	brelse(bh);
 
Signature · 1 line
2.4.5
#133 lore raw

PATCH 11/11 ocfs2: One function call less in ocfs2_journal_shutdown() from input checks

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 5 Jul 2015 14:54:33 +0200

The iput() function was called in one case by the ocfs2_journal_shutdown() function during input parameter validation even if the passed variable contained still a null pointer.

* Return directly if received values indicate that at the beginning.

* Delete the unnecessary jump label "done".

* Drop unnecessary initialisations for the variables "inode", "journal" and "num_running_trans" then.

---
 fs/ocfs2/journal.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)
fs/ocfs2/journal.c +6 -9
index 7bb50f4..f13e6fdb 100644
@@ -951,22 +951,20 @@ static int ocfs2_journal_toggle_dirty(struct ocfs2_super *osb,
  */
 void ocfs2_journal_shutdown(struct ocfs2_super *osb)
 {
-	struct ocfs2_journal *journal = NULL;
+	struct ocfs2_journal *journal;
 	int status = 0;
-	struct inode *inode = NULL;
-	int num_running_trans = 0;
+	struct inode *inode;
+	int num_running_trans;
 
 	BUG_ON(!osb);
 
 	journal = osb->journal;
 	if (!journal)
-		goto done;
-
-	inode = journal->j_inode;
-
+		return;
 	if (journal->j_state != OCFS2_JOURNAL_LOADED)
-		goto done;
+		return;
 
+	inode = journal->j_inode;
 	/* need to inc inode use count - jbd2_journal_destroy will iput. */
 	if (!igrab(inode))
 		BUG();
@@ -1025,7 +1023,6 @@ void ocfs2_journal_shutdown(struct ocfs2_super *osb)
 	journal->j_state = OCFS2_JOURNAL_FREE;
 
 //	up_write(&journal->j_trans_barrier);
-done:
 	iput(inode);
 }
 
Signature · 1 line
2.4.5
#58 lore raw

PATCH 1/1 GPU-DRM-nouveau: Delete unnecessary checks before two function calls

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 5 Jul 2015 20:15:12 +0200

The functions nvkm_namedb_put() and pci_dev_put() test whether their argument is NULL and then return immediately.
Thus the test around the calls is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/gpu/drm/nouveau/nouveau_drm.c      | 3 +--
 drivers/gpu/drm/nouveau/nvkm/core/handle.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)
drivers/gpu/drm/nouveau/nouveau_drm.c +1 -2
index 36b40c9..8ca3d0c 100644
@@ -515,8 +515,7 @@ nouveau_drm_unload(struct drm_device *dev)
 	nouveau_vga_fini(drm);
 
 	nvif_device_fini(&drm->device);
-	if (drm->hdmi_device)
-		pci_dev_put(drm->hdmi_device);
+	pci_dev_put(drm->hdmi_device);
 	nouveau_cli_destroy(&drm->client);
 	return 0;
 }
drivers/gpu/drm/nouveau/nvkm/core/handle.c +1 -2
index dc7ff10..165f3ff 100644
@@ -216,6 +216,5 @@ nvkm_handle_get_cinst(struct nvkm_object *engctx, u32 cinst)
 void
 nvkm_handle_put(struct nvkm_handle *handle)
 {
-	if (handle)
-		nvkm_namedb_put(handle);
+	nvkm_namedb_put(handle);
 }
Signature · 1 line
2.4.5
#1058 lore raw

PATCH 1/1 GPU-DRM: Delete an unnecessary check before drm_property_unreference_blob()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 5 Jul 2015 21:55:10 +0200

The drm_property_unreference_blob() 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.

---
 drivers/gpu/drm/drm_crtc.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/drm_crtc.c +1 -3
index 2d57fc5..6e4c8b0 100644
@@ -4469,9 +4469,7 @@ static int drm_property_replace_global_blob(struct drm_device *dev,
 			goto err_created;
 	}
 
-	if (old_blob)
-		drm_property_unreference_blob(old_blob);
-
+	drm_property_unreference_blob(old_blob);
 	*replace = new_blob;
 
 	return 0;
Signature · 1 line
2.4.5
#1065 lore raw

PATCH 1/1 GPU-DRM-IMX: Delete an unnecessary check before drm_fbdev_cma_restore_mode()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 5 Jul 2015 22:45:23 +0200

The drm_fbdev_cma_restore_mode() 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.

---
 drivers/gpu/drm/imx/imx-drm-core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/imx/imx-drm-core.c +1 -2
index 74f505b..9172c0e 100644
@@ -63,8 +63,7 @@ static void imx_drm_driver_lastclose(struct drm_device *drm)
 #if IS_ENABLED(CONFIG_DRM_IMX_FB_HELPER)
 	struct imx_drm_device *imxdrm = drm->dev_private;
 
-	if (imxdrm->fbhelper)
-		drm_fbdev_cma_restore_mode(imxdrm->fbhelper);
+	drm_fbdev_cma_restore_mode(imxdrm->fbhelper);
 #endif
 }
 
Signature · 1 line
2.4.5
Reviewed-by on v1 1/1
#1059 lore raw

Re: [PATCH] GPU-DRM: Delete an unnecessary check before drm_property_unreference_blob()

In reply to SF Markus Elfring
Quoted 11 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 5 Jul 2015 21:55:10 +0200

The drm_property_unreference_blob() 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.

Quoted 28 lines
---
 drivers/gpu/drm/drm_crtc.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/drm_crtc.c +1 -3
index 2d57fc5..6e4c8b0 100644
@@ -4469,9 +4469,7 @@ static int drm_property_replace_global_blob(struct
 drm_device *dev,
                        goto err_created;
        }
 
-       if (old_blob)
-               drm_property_unreference_blob(old_blob);
-
+       drm_property_unreference_blob(old_blob);
        *replace = new_blob;
 
        return 0;

--
2.4.5

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

Signature · 6 lines
Best regards
Junwang Zhao
Microprocessor Research and Develop Center
Department of Computer Science &Technology
Peking University
Beijing, 100871, PRC

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#1060 lore raw

Re: [PATCH] GPU-DRM: Delete an unnecessary check before drm_property_unreference_blob()

Quoted 10 lines · John Hunter
Quoted 7 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 5 Jul 2015 21:55:10 +0200

The drm_property_unreference_blob() function tests whether its argument is NULL and then returns immediately.
Thus the test around the call is not needed.

Quoted 6 lines
Quoted 4 lines

This issue was detected by using the Coccinelle software.

Applied to topic/drm-misc, thanks.
-Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
#337 lore raw

Re: [PATCH 1/1] DRM-vmwgfx: Deletion of an unnecessary check before the function call "vfree"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Mon, 6 Jul 2015 09:49:11 +0200

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.

---
 drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +1 -3
index 654c8da..f718a6d 100644
@@ -2292,9 +2292,7 @@ static int vmw_resize_cmd_bounce(struct vmw_sw_context *sw_context,
 				   (sw_context->cmd_bounce_size >> 1));
 	}
 
-	if (sw_context->cmd_bounce != NULL)
-		vfree(sw_context->cmd_bounce);
-
+	vfree(sw_context->cmd_bounce);
 	sw_context->cmd_bounce = vmalloc(sw_context->cmd_bounce_size);
 
 	if (sw_context->cmd_bounce == NULL) {
Signature · 1 line
2.4.5
#123 lore raw

Re: [PATCH 03/11] ocfs2: Less checks in ocfs2_rename() after error detection

In reply to SF Markus Elfring
Quoted 8 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 4 Jul 2015 15:30:18 +0200

Skip checks for a few variables in three error handling cases within the ocfs2_rename() function by adjustment of a few jump targets according to the Linux coding style convention.

I don't think this is an improvement.

regards,
dan carpenter

maintainer
#1028 lore raw

Re: [PATCH] USB-mxuport: Delete an unnecessary check before the function call "release_firmware"

In reply to SF Markus Elfring
Quoted 18 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 28 Jun 2015 14:59:04 +0200

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.

---
 drivers/usb/serial/mxuport.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/usb/serial/mxuport.c +0 -0
index 460a406..92f7aee 100644

drivers/usb/serial/mxuport.c static int mxuport_probe(struct usb_serial *serial, · line 1106

Quoted 8 lines
drivers/usb/serial/mxuport.c +1 -2
@@ -1101,8 +1101,7 @@ static int mxuport_probe(struct usb_serial *serial,
 	 */
 	usb_set_serial_data(serial, (void *)id->driver_info);
 out:
-	if (fw_p)
-		release_firmware(fw_p);
+	release_firmware(fw_p);
 	return err;
 }

You sent the exact same patch last year and it was rejected then as it does not improve readability:

	https://www.marc.info/?l=linux-usb&m=141682024201419&w=3

So I'll drop this one again.

Johan

Acked-by on v1 1/1
#218 lore raw

Re: [PATCH] kprobes: Delete an unnecessary check before the function call "module_put"

In reply to SF Markus Elfring
Quoted 8 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 4 Jul 2015 10:00:26 +0200

The module_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.

OK, looks good to me.

Quoted 22 lines
---
 kernel/kprobes.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
kernel/kprobes.c +1 -4
index c90e417..52e3529 100644
@@ -1531,10 +1531,7 @@ int register_kprobe(struct kprobe *p)
 
 out:
 	mutex_unlock(&kprobe_mutex);
-
-	if (probed_mod)
-		module_put(probed_mod);
-
+	module_put(probed_mod);
 	return ret;
 }
 EXPORT_SYMBOL_GPL(register_kprobe);
Signature · 5 lines
Masami HIRAMATSU
Linux Technology Research Center, System Productivity Research Dept.
Center for Technology Innovation - Systems Engineering
Hitachi, Ltd., Research & Development Group
E-mail: [email protected]
Acked-by on v1 1/1
#248 lore raw

Re: [PATCH] perf probe: Delete an unnecessary check before the function call "strfilter__delete"

In reply to SF Markus Elfring
Quoted 8 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 4 Jul 2015 07:44:22 +0200

The strfilter__delete() 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.

This looks OK for me.

Quoted 20 lines
---
 tools/perf/builtin-probe.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
tools/perf/builtin-probe.c +1 -2
index 1272559..b81cec3 100644
@@ -297,8 +297,7 @@ static void cleanup_params(void)
 		clear_perf_probe_event(params.events + i);
 	line_range__clear(&params.line_range);
 	free(params.target);
-	if (params.filter)
-		strfilter__delete(params.filter);
+	strfilter__delete(params.filter);
 	memset(&params, 0, sizeof(params));
 }
 
Signature · 5 lines
Masami HIRAMATSU
Linux Technology Research Center, System Productivity Research Dept.
Center for Technology Innovation - Systems Engineering
Hitachi, Ltd., Research & Development Group
E-mail: [email protected]
#249 lore raw

[tip:perf/core] perf probe: Delete an unnecessary check before the function call "strfilter__delete"

In reply to SF Markus Elfring
perf probe: Delete an unnecessary check before the function call "strfilter__delete"
Commit-ID:  200802a4a79b3a7a1cf924ad870d3265023d0787
Gitweb:     http://git.kernel.org/tip/200802a4a79b3a7a1cf924ad870d3265023d0787
Author:     Markus Elfring <[email protected]>
AuthorDate: Sat, 4 Jul 2015 07:44:22 +0200
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Mon, 6 Jul 2015 08:58:36 -0300

perf probe: Delete an unnecessary check before the function call "strfilter__delete"

The strfilter__delete() 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.

---
 tools/perf/builtin-probe.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
tools/perf/builtin-probe.c +1 -2
index 1272559..b81cec3 100644
@@ -297,8 +297,7 @@ static void cleanup_params(void)
 		clear_perf_probe_event(params.events + i);
 	line_range__clear(&params.line_range);
 	free(params.target);
-	if (params.filter)
-		strfilter__delete(params.filter);
+	strfilter__delete(params.filter);
 	memset(&params, 0, sizeof(params));
 }
 
#933 lore raw

Re: [PATCH] kdbus: Delete an unnecessary check before the function call "kdbus_domain_unref"

In reply to SF Markus Elfring

Hi

Quoted 6 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 24 Jun 2015 14:30:17 +0200

The kdbus_domain_unref() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

Quoted 6 lines

This issue was detected by using the Coccinelle software.

---
 ipc/kdbus/fs.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Applied!

Thanks
David

Quoted 18 lines
ipc/kdbus/fs.c +1 -4
index d01f33b..205a3ad 100644
@@ -325,9 +325,7 @@ static void fs_super_kill(struct super_block *sb)
        }
 
        kill_anon_super(sb);
-
-       if (domain)
-               kdbus_domain_unref(domain);
+       kdbus_domain_unref(domain);
 }
 
 static int fs_super_set(struct super_block *sb, void *data)
--

2.4.4

maintainer
#157 lore raw

Re: [PATCH] ntfs: Deletion of unnecessary checks before the function call "iput"

In reply to Anton Altaparmakov
Quoted 6 lines · On Sat, 4 Jul 2015 10:36:57 +0000 Anton Altaparmakov <[email protected]> wrote:

Hi Andrew,

Can you please take up this trivial patch and merge it upstream?

Nobody responded to Julia's review comment: "I don't have time to look at the code now, but since there is an exit label here, have you checked whether you could improve the gotos in these cases?"

She has a good point. We can either change those gotos to go to the correct place (current code is rather bizarre) or we can simply do

fs/ntfs/super.c renamed from fs/ntfs/super.c~a +3 -14
@@ -2202,36 +2202,26 @@ get_ctx_vol_failed:
 	}
 #endif /* NTFS_RW */
 	return true;
+out:
 #ifdef NTFS_RW
-iput_usnjrnl_err_out:
 	iput(vol->usnjrnl_j_ino);
 	iput(vol->usnjrnl_max_ino);
 	iput(vol->usnjrnl_ino);
-iput_quota_err_out:
 	iput(vol->quota_q_ino);
 	iput(vol->quota_ino);
 	iput(vol->extend_ino);
 #endif /* NTFS_RW */
-iput_sec_err_out:
 	iput(vol->secure_ino);
-iput_root_err_out:
 	iput(vol->root_ino);
-iput_logfile_err_out:
 #ifdef NTFS_RW
 	iput(vol->logfile_ino);
-iput_vol_err_out:
 #endif /* NTFS_RW */
 	iput(vol->vol_ino);
-iput_lcnbmp_err_out:
 	iput(vol->lcnbmp_ino);
-iput_attrdef_err_out:
 	vol->attrdef_size = 0;
-	if (vol->attrdef) {
-		ntfs_free(vol->attrdef);
-		vol->attrdef = NULL;
-	}
+	ntfs_free(vol->attrdef);
+	vol->attrdef = NULL;
 #ifdef NTFS_RW
-iput_upcase_err_out:
 #endif /* NTFS_RW */
 	vol->upcase_len = 0;
 	mutex_lock(&ntfs_lock);
@@ -2246,7 +2236,6 @@ iput_upcase_err_out:
 	}
 iput_mftbmp_err_out:
 	iput(vol->mftbmp_ino);
-iput_mirr_err_out:
 #ifdef NTFS_RW
 	iput(vol->mftmirr_ino);
 #endif /* NTFS_RW */

(note that ntfs_free(NULL) is OK)

then change all the appropriate gotos to good old "goto out;".

Or we can not bother ;)

#970 lore raw

Re: [PATCH 1/2] staging: wilc1000: Delete unnecessary checks before two function calls

In reply to SF Markus Elfring
Quoted 2 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 27 Jun 2015 15:56:57 +0200

Why is this in the body of the email? Please fix your email client or just use git send-email properly.

#990 lore raw

Re: [PATCH 2/2] staging: wilc1000: One function call less in mac_ioctl() after error detection

In reply to SF Markus Elfring
Quoted 2 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 27 Jun 2015 16:00:59 +0200

Again, please fix.

Quoted 9 lines

The kfree() function was called in two cases by the mac_ioctl() function during error handling even if the passed variable did not contain a pointer for a valid data item.

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

* Drop an unnecessary initialisation for the variable "buff" then.

That's a different issue, please fix it in a separate patch.

thanks,

greg k-h

#971 lore raw

Re: Clarification for the use of additional fields in the message body

In reply to Greg Kroah-Hartman
Quoted 4 lines
Quoted 2 lines

From: Markus Elfring <[email protected]>
Date: Sat, 27 Jun 2015 15:56:57 +0200

Why is this in the body of the email?

Does the canonical patch format support to preserve specific details about a shown commit by specification of fields like "Date" and "From" in the message body?

Regards,
Markus

#972 lore raw

Re: Clarification for the use of additional fields in the message body

Quoted 8 lines · SF Markus Elfring
Quoted 4 lines
Quoted 2 lines

From: Markus Elfring <[email protected]>
Date: Sat, 27 Jun 2015 15:56:57 +0200

Why is this in the body of the email?

Does the canonical patch format support to preserve specific details about a shown commit by specification of fields like "Date" and "From" in the message body?

Using "From:" in the body can be used to provide your properly spelled name, or the name/e-mail of the actual author, if that happens not to be the sender. git-send-email will do that automagically for you. If "From:" is not specified in the message body, the e-mails sender will be used as author.

The date, as far as I know, is ignored. It is the commit date, not the authoring date, and once your patch is applied by a maintainer (i.e. committed), the date gets reset anyway. No need to try and preserve it.

Frans

Applied
#498 lore raw

Re: [PATCH v3] video-lp8788: Delete a check before backlight_device_unregister()

In reply to SF Markus Elfring
Quoted 7 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 1 Jul 2015 12:08:31 +0200

The backlight_device_unregister() function tests whether its argument is NULL and then returns immediately.
Thus the test around the call is not needed.

Quoted 6 lines

This issue was detected by using the Coccinelle software.

---
 drivers/video/backlight/lp8788_bl.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Applied, thanks.

Quoted 14 lines
drivers/video/backlight/lp8788_bl.c +1 -2
index e418d5b..5d583d7 100644
@@ -221,8 +221,7 @@ static void lp8788_backlight_unregister(struct lp8788_bl *bl)
 {
 	struct backlight_device *bl_dev = bl->bl_dev;
 
-	if (bl_dev)
-		backlight_device_unregister(bl_dev);
+	backlight_device_unregister(bl_dev);
 }
 
 static ssize_t lp8788_get_bl_ctl_mode(struct device *dev,
Signature · 8 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#973 lore raw

Re: Clarification for the use of additional fields in the message body

In reply to Frans Klaver
Quoted 3 lines

The date, as far as I know, is ignored. It is the commit date, not the authoring date, and once your patch is applied by a maintainer (i.e. committed), the date gets reset anyway.

Thanks for your feedback.

Quoted 1 line

No need to try and preserve it.

I find that it might occasionally help to share and keep the record on timestamps about the evolution for an original update suggestion.

Regards,
Markus

#974 lore raw

Re: Clarification for the use of additional fields in the message body

Quoted 4 lines · SF Markus Elfring
Quoted 1 line

No need to try and preserve it.

I find that it might occasionally help to share and keep the record on timestamps about the evolution for an original update suggestion.

I think that as far as these kernel mailing lists are concerned, the date of the update suggestion is the date on which you submitted the patch, rather than the date you originally committed it to your local tree. If you wish to keep track of this evolution for yourself, or wish to share it, you're better off stashing it somewhere in a (public) git repo that you control. If you wish, you can always make mention of that repo below the ---, just above the diffstat. If you insist on placing the date somewhere, you can also put the date there if you wish. It'll be ignored by git when applied.

Cheers,
Frans

#975 lore raw

Re: Clarification for the use of additional fields in the message body

Quoted 3 lines

I think that as far as these kernel mailing lists are concerned, the date of the update suggestion is the date on which you submitted the patch, rather than the date you originally committed it to your local tree.

I imagine that there are committers who would like to keep corresponding software development history a bit more accurate.

Quoted 3 lines

If you wish to keep track of this evolution for yourself, or wish to share it, you're better off stashing it somewhere in a (public) git repo that you control.

Would it be nicer to preserve such data directly also by the usual mail interface?

Quoted 2 lines

If you insist on placing the date somewhere, you can also put the date there if you wish. It'll be ignored by git when applied.

This content management tool provides the capability to store the discussed information by the parameters "--author=" and "--date=", doesn't it?
Is the environment variable "GIT_AUTHOR_DATE" also interesting occasionally?

How often do you take extra care for passing appropriate data there?

Regards,
Markus

#976 lore raw

Re: Clarification for the use of additional fields in the message body

Quoted 6 lines · SF Markus Elfring
Quoted 3 lines

I think that as far as these kernel mailing lists are concerned, the date of the update suggestion is the date on which you submitted the patch, rather than the date you originally committed it to your local tree.

I imagine that there are committers who would like to keep corresponding software development history a bit more accurate.

I guess it depends on what your view on accurate is.

Quoted 11 lines
Quoted 3 lines

If you wish to keep track of this evolution for yourself, or wish to share it, you're better off stashing it somewhere in a (public) git repo that you control.

Would it be nicer to preserve such data directly also by the usual mail interface?

Quoted 2 lines

If you insist on placing the date somewhere, you can also put the date there if you wish. It'll be ignored by git when applied.

Quoted 6 lines

This content management tool provides the capability to store the discussed information by the parameters "--author=" and "--date=", doesn't it?
Is the environment variable "GIT_AUTHOR_DATE" also interesting occasionally?

How often do you take extra care for passing appropriate data there?

I can't remember ever changing or explicitly preserving the commit date. I don't think I care enough. I did change the author on botched patches, but that's an exception. Remembering the author separately from the committer is something git does by design anyway.

Frans

#977 lore raw

Re: Clarification for the use of additional fields in the message body

Quoted 2 lines

I can't remember ever changing or explicitly preserving the commit date. I don't think I care enough.

Would any more software developers and maintainers like to share their experiences around such details?

When do commit timestamps become relevant as a documentation item for contribution authorship?

Quoted 2 lines

Remembering the author separately from the committer is something git does by design anyway.

Do you usually just reuse a procedure from a well-known command for which a description is provided like the following?
http://git-scm.com/docs/git-am
'…
"From: " and "Subject: " lines starting the body override the respective commit author name and title values taken from the headers.
…'

Will further fields be eventually mentioned there?

Regards,
Markus

#149 lore raw

PATCH v3 1/1 kconfig: Delete unnecessary checks before the function call "sym_calc_value"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 7 Jul 2015 21:48:23 +0200

The sym_calc_value() 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.

---
 scripts/kconfig/confdata.c | 7 ++-----
 scripts/kconfig/symbol.c   | 3 +--
 2 files changed, 3 insertions(+), 7 deletions(-)
scripts/kconfig/confdata.c +2 -5
index c814f57..0b7dc2f 100644
@@ -268,8 +268,7 @@ int conf_read_simple(const char *name, int def)
 			goto load;
 		sym_add_change_count(1);
 		if (!sym_defconfig_list) {
-			if (modules_sym)
-				sym_calc_value(modules_sym);
+			sym_calc_value(modules_sym);
 			return 1;
 		}
 
@@ -404,9 +403,7 @@ setsym:
 	}
 	free(line);
 	fclose(in);
-
-	if (modules_sym)
-		sym_calc_value(modules_sym);
+	sym_calc_value(modules_sym);
 	return 0;
 }
 
scripts/kconfig/symbol.c +1 -2
index 70c5ee1..50878dc 100644
@@ -467,8 +467,7 @@ void sym_clear_all_valid(void)
 	for_all_symbols(i, sym)
 		sym->flags &= ~SYMBOL_VALID;
 	sym_add_change_count(1);
-	if (modules_sym)
-		sym_calc_value(modules_sym);
+	sym_calc_value(modules_sym);
 }
 
 bool sym_tristate_within_range(struct symbol *sym, tristate val)
Signature · 1 line
2.4.5
#978 lore raw

Re: Clarification for the use of additional fields in the message body

In reply to SF Markus Elfring

Hi Markus,

Quoted 8 lines · SF Markus Elfring
Quoted 2 lines

I can't remember ever changing or explicitly preserving the commit date. I don't think I care enough.

Would any more software developers and maintainers like to share their experiences around such details?

When do commit timestamps become relevant as a documentation item for contribution authorship?

They are never relevant.

"When" a commit happened is never relevant except in relation to other things, at which point the actual date and time is almost completely irrelevant.

Just submit your patches using git-format-patch or git-send-email and friends. There's a file in the documentation directory of the kernel tree describing submitting patches and email client setup. Read them both, do what they say without anything extra.

Quoted 12 lines
Quoted 2 lines

Remembering the author separately from the committer is something git does by design anyway.

Do you usually just reuse a procedure from a well-known command for which a description is provided like the following?
http://git-scm.com/docs/git-am
'…
"From: " and "Subject: " lines starting the body override the respective commit author name and title values taken from the headers.
…'

Quoted 1 line

Will further fields be eventually mentioned there?

Why? Just do what is described in SubmittingPatches. Your attempts to "improve" on the system are unnecessary and annoying people. The instructions there are the recommended way to do things for a reason.

Thanks,

Signature · 4 lines
Julian Calaby

Email: [email protected]
Profile: http://www.google.com/profiles/julian.calaby/
Reviewed-by
#338 lore raw

Re: [PATCH 1/1] DRM-vmwgfx: Deletion of an unnecessary check before the function call "vfree"

In reply to SF Markus Elfring
Quoted 10 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Mon, 6 Jul 2015 09:49:11 +0200

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.

kfree will check that.

Quoted 29 lines
---
 drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +1 -3
index 654c8da..f718a6d 100644
@@ -2292,9 +2292,7 @@ static int vmw_resize_cmd_bounce(struct
 vmw_sw_context *sw_context,
                                   (sw_context->cmd_bounce_size >> 1));
        }
 
-       if (sw_context->cmd_bounce != NULL)
-               vfree(sw_context->cmd_bounce);
-
+       vfree(sw_context->cmd_bounce);
        sw_context->cmd_bounce = vmalloc(sw_context->cmd_bounce_size);
 
        if (sw_context->cmd_bounce == NULL) {

--
2.4.5

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

Signature · 6 lines
Best regards
Junwang Zhao
Microprocessor Research and Develop Center
Department of Computer Science &Technology
Peking University
Beijing, 100871, PRC

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#979 lore raw

Re: Clarification for the use of additional fields in the message body

In reply to Julian Calaby
Quoted 3 lines

There's a file in the documentation directory of the kernel tree describing submitting patches and email client setup. Read them both,

I read this information several times.

Quoted 1 line

do what they say without anything extra.

Do you see any special consequences if a bit of "extra" functionality is already provided by the Git software for a while?

Quoted 1 line

Your attempts to "improve" on the system are unnecessary

It seems that my approach does not need improvements for the current command "git am".
Would a few extensions for the available documentation help to clarify the situation?

Do items like "commit mail address" and "commit timestamp" belong together for the data structure "author" by design in this content management system?

Quoted 1 line

and annoying people.

I understand that various update suggestions can be surprising. It is also usual that corresponding acceptance might take a bit longer than what some contributors would prefer.

Regards,
Markus

#980 lore raw

Re: Clarification for the use of additional fields in the message body

Hi Markus,

Quoted 11 lines · SF Markus Elfring
Quoted 3 lines

There's a file in the documentation directory of the kernel tree describing submitting patches and email client setup. Read them both,

I read this information several times.

Quoted 1 line

do what they say without anything extra.

Do you see any special consequences if a bit of "extra" functionality is already provided by the Git software for a while?

If it's harmless, then no, but in this case, people are questioning why you're adding it as it adds no value to anyone and makes it look like you don't know what you're doing.

Quoted 6 lines
Quoted 1 line

Your attempts to "improve" on the system are unnecessary

It seems that my approach does not need improvements for the current command "git am".
Would a few extensions for the available documentation help to clarify the situation?

The issue is that the headers you're adding, From: and Date: are unnecessary.

The From: header you add is unnecessary as your email's From: header has the exact same information. The reason it's there is because sometimes people forward patches on from other people, e.g. if I were to resend one of your patches, I'd add a From: header to the body of the email so it'd be credited to you.

The Date: header you add is unnecessary as git-format-patch sets the date header in the email it produces to the author date stored in the commit. (see below) So if you're sending your patches in emails produced by git-format-patch, there's absolutely no reason to include it.

Quoted 3 lines

Do items like "commit mail address" and "commit timestamp" belong together for the data structure "author" by design in this content management system?

The information stored for a commit is:

= = = = =
tree 09496defc9eb793c665a7b80aa22f24c7bd5f204
parent 63c07589832bfe5ec49f2523ddb0e94a20af0f31
author Julian Calaby <[email protected]> 1435196810 +1000 committer Julian Calaby <[email protected]> 1436322540 +1000

= = = = =
Then the subject and commit message.

The numbers after the email addresses are the timestamps. They are both almost completely irrelevant for most workflows as people are less interested in when a commit was made and more interested in what release it's in, how it was merged, etc. All of which should be determined without using the timestamp.

To be honest, I've only ever used that timestamp for reporting purposes at work, and I'd be surprised if anyone was doing anything other than that with them.

In short, nobody cares, and nobody's going to be upset if the actual time you authored a patch is different to the time recorded upstream.

Quoted 5 lines
Quoted 1 line

and annoying people.

I understand that various update suggestions can be surprising. It is also usual that corresponding acceptance might take a bit longer than what some contributors would prefer.

How would you feel if someone came in to your place of work and told you to change how you do the job you've been doing for years without a good reason?

Thanks,

Signature · 4 lines
Julian Calaby

Email: [email protected]
Profile: http://www.google.com/profiles/julian.calaby/
#991 lore raw

Re: staging: wilc1000: One function call less in mac_ioctl() after error detection

In reply to Greg Kroah-Hartman
Quoted 10 lines
Quoted 8 lines

The kfree() function was called in two cases by the mac_ioctl() function during error handling even if the passed variable did not contain a pointer for a valid data item.

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

* Drop an unnecessary initialisation for the variable "buff" then.

That's a different issue, please fix it in a separate patch.

I have got an other opinion here.
This update suggestion depends on a small source code clean-up from the previous patch, doesn't it?

Do you want that I split the second suggestion from this series into more steps?

Regards,
Markus

#981 lore raw

Re: Clarification for the use of additional fields in the message body

In reply to Julian Calaby
Quoted 2 lines

If it's harmless, then no, but in this case, people are questioning why you're adding it as it adds no value

Some Git software developers care to keep the information complete for the author commit.

Quoted 1 line

to anyone and makes it look like you don't know what you're doing.

I specify message field overrides in my update suggestions intentionally.

Quoted 1 line

The issue is that the headers you're adding, From: and Date: are unnecessary.

We have got different opinions about the purpose.

Quoted 2 lines

The From: header you add is unnecessary as your email's From: header has the exact same information.

I would like to point out that there is a slight difference in my use case.

Quoted 3 lines

The reason it's there is because sometimes people forward patches on from other people, e.g. if I were to resend one of your patches, I'd add a From: header to the body of the email so it'd be credited to you.

I am also interested in such an use case.

Quoted 2 lines

The Date: header you add is unnecessary as git-format-patch sets the date header in the email it produces to the author date stored in the commit.

How do you think about my extra patch preparation for the mentioned mail forwarding?

Quoted 2 lines

So if you're sending your patches in emails produced by git-format-patch, there's absolutely no reason to include it.

I disagree here to some degree.

The difference in suggested commit timestamps of a few minutes might look negligible for some patches. There are few occasions where the delay between a concrete commit and its publishing by an interface like email can become days.

Quoted 4 lines

They are both almost completely irrelevant for most workflows as people are less interested in when a commit was made and more interested in what release it's in, how it was merged, etc. All of which should be determined without using the timestamp.

How often will it matter who made and published a change first?

Quoted 3 lines

To be honest, I've only ever used that timestamp for reporting purposes at work, and I'd be surprised if anyone was doing anything other than that with them.

Thanks for your detailed feedback.

Quoted 3 lines

How would you feel if someone came in to your place of work and told you to change how you do the job you've been doing for years without a good reason?

You might feel uncomfortable for a moment if you would interpret such a suggestion as a personal attack.

I guess that I point only a few technical details out which can change the popularity of existing functionality from the Git software.

Regards,
Markus

#982 lore raw

Re: Clarification for the use of additional fields in the message body

Hi Markus,

Quoted 7 lines · SF Markus Elfring
Quoted 2 lines

If it's harmless, then no, but in this case, people are questioning why you're adding it as it adds no value

Some Git software developers care to keep the information complete for the author commit.

Quoted 8 lines
Quoted 1 line

to anyone and makes it look like you don't know what you're doing.

I specify message field overrides in my update suggestions intentionally.

Quoted 1 line

The issue is that the headers you're adding, From: and Date: are unnecessary.

We have got different opinions about the purpose.

Let me rephrase that: they _should_ be unnecessary.

Quoted 4 lines
Quoted 2 lines

The From: header you add is unnecessary as your email's From: header has the exact same information.

I would like to point out that there is a slight difference in my use case.

Then fix your email client or patch submission process.

Quoted 5 lines
Quoted 3 lines

The reason it's there is because sometimes people forward patches on from other people, e.g. if I were to resend one of your patches, I'd add a From: header to the body of the email so it'd be credited to you.

I am also interested in such an use case.

This happens automatically if you use git-format-patch on a commit you didn't author. Nobody is adding this manually.

Quoted 5 lines
Quoted 2 lines

The Date: header you add is unnecessary as git-format-patch sets the date header in the email it produces to the author date stored in the commit.

How do you think about my extra patch preparation for the mentioned mail forwarding?

It sounds like you're using what could only be described as a Rube-Goldberg process to send email. Is there truly no way to simplify that process? (Also, are the servers you send it through re-writing the original headers?)

You should be sending the patches directly with SMTP using git-send-email, if you're not, then you're making things overly complicated for yourself.

Quoted 9 lines
Quoted 2 lines

So if you're sending your patches in emails produced by git-format-patch, there's absolutely no reason to include it.

I disagree here to some degree.

The difference in suggested commit timestamps of a few minutes might look negligible for some patches. There are few occasions where the delay between a concrete commit and its publishing by an interface like email can become days.

I made a commit a month ago, it got rebased today, in fact, I sent it's metadata in my previous email. When I ran git-format-patch on it, the timestamp in the headers of the email produced was the date from a month ago.

If I then sent that email, I believe it'd make it to the list here with that date intact. If it hadn't, I'd be trying to figure out why and either fix it or find a different path to get my patch here.

Quoted 6 lines
Quoted 4 lines

They are both almost completely irrelevant for most workflows as people are less interested in when a commit was made and more interested in what release it's in, how it was merged, etc. All of which should be determined without using the timestamp.

How often will it matter who made and published a change first?

If multiple people are submitting identical changes, then the one that is applied is the one the maintainer sees first, which will most likely be determined by which one hit their inbox / list first. Nobody is going to look at timestamps in emails to determine which one will be applied.

If you're worried about which one of several versions of a patch will be applied, change the subject to [PATCH v2] ..... instead of [PATCH] .... for the second version.

Quoted 7 lines
Quoted 3 lines

To be honest, I've only ever used that timestamp for reporting purposes at work, and I'd be surprised if anyone was doing anything other than that with them.

Thanks for your detailed feedback.

Quoted 6 lines
Quoted 3 lines

How would you feel if someone came in to your place of work and told you to change how you do the job you've been doing for years without a good reason?

You might feel uncomfortable for a moment if you would interpret such a suggestion as a personal attack.

I'm not interpreting this as a personal attack.

Quoted 2 lines

I guess that I point only a few technical details out which can change the popularity of existing functionality from the Git software.

Git was originally written to manage the Linux kernel. This feature was probably added by either Linus himself or one of the original developers who I believe were kernel developers. The patch submission process has been around for a long time, if this feature isn't used, it's for a good reason.

Having a feature doesn't mean that it should be used.

Thanks,

Signature · 4 lines
Julian Calaby

Email: [email protected]
Profile: http://www.google.com/profiles/julian.calaby/
#983 lore raw

Re: Clarification for the use of additional fields in the message body

Quoted 1 line

Is there truly no way to simplify that process?

I see some software development possibilities which could improve the communication with high volume mailing lists.

Quoted 1 line

You should be sending the patches directly with SMTP using git-send-email,

This tool is also fine for the publishing of a lot of patches.

Quoted 1 line

if you're not, then you're making things overly complicated for yourself.

But I prefer a graphical user interface for my mail handling so far.

Quoted 1 line

Having a feature doesn't mean that it should be used.

Does any of the "questionable functionality" get occasionally overlooked a bit too often?

Regards,
Markus

maintainer
#985 lore raw

Re: Clarification for the use of additional fields in the message body

In reply to Julian Calaby
Quoted 5 lines · Julian Calaby

If multiple people are submitting identical changes, then the one that is applied is the one the maintainer sees first, which will most likely be determined by which one hit their inbox / list first. Nobody is going to look at timestamps in emails to determine which one will be applied.

And some maintainers may choose *not* to act on a patch first, even if they see it first. They might be focused on bug fix patches, and not act on cleanup or feature patches until -rc3 or rc4. Or maybe they will use separate branches for "urgent_for_linus" patches, so two different patchs may end up in completely different git flows.

Quoted 3 lines

If you're worried about which one of several versions of a patch will be applied, change the subject to [PATCH v2] ..... instead of [PATCH] .... for the second version.

*Please* do this. In fact, this is the one thing I wish git send-email would do automatically, along with having a place to edit and track the 0/N summary patch.

Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

To be honest, I've only ever used that timestamp for reporting purposes at work, and I'd be surprised if anyone was doing anything other than that with them.

Thanks for your detailed feedback.

Note also that some maintainers have work flow that deliberately smash the date (i.e., because they are using a system such as guilt), so if you are depending on the submitted timestamp, it's going to break on you.

- Ted

#986 lore raw

Re: Clarification for the use of additional fields in the message body

Quoted 4 lines

Note also that some maintainers have work flow that deliberately smash the date (i.e., because they are using a system such as guilt), so if you are depending on the submitted timestamp, it's going to break on you.

Thanks for your hint.

I am just trying to offer the possibility for the reuse of a more precise commit timestamp together with an appropriate author mail address for my update suggestions.
Do you reject any more such message field overrides?

Regards,
Markus

#360 lore raw

Re: [PATCH] bcache: Deletion of an unnecessary check before the function call "kobject_put"

In reply to SF Markus Elfring
Quoted 19 lines

From: Markus Elfring <[email protected]>
Date: Wed, 19 Nov 2014 21:25:39 +0100

The kobject_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.

---
 drivers/md/bcache/super.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/md/bcache/super.c +0 -0
index d4713d0..1443c55 100644

drivers/md/bcache/super.c static void bcache_exit(void) · line 2082

Quoted 9 lines
drivers/md/bcache/super.c +1 -2
@@ -2076,8 +2076,7 @@ static void bcache_exit(void)
 {
 	bch_debug_exit();
 	bch_request_exit();
-	if (bcache_kobj)
-		kobject_put(bcache_kobj);
+	kobject_put(bcache_kobj);
 	if (bcache_wq)
 		destroy_workqueue(bcache_wq);
 	if (bcache_major)

Would you like to integrate this update suggestion into another source code repository?

Regards,
Markus

#879 lore raw

Re: [PATCH] GPU-DRM-Tegra: Delete an unnecessary check before the function call "vunmap"

In reply to SF Markus Elfring
Quoted 19 lines

From: Markus Elfring <[email protected]>
Date: Thu, 5 Feb 2015 10:12:51 +0100

The vunmap() function performs also input parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/gpu/drm/tegra/fb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/tegra/fb.c +0 -0
index e9c715d..803598e 100644

drivers/gpu/drm/tegra/fb.c static void tegra_fb_destroy(struct drm_framebuffer *framebuffer) · line 72

Quoted 8 lines
drivers/gpu/drm/tegra/fb.c +1 -1
@@ -66,7 +66,7 @@ static void tegra_fb_destroy(struct drm_framebuffer *framebuffer)
 		struct tegra_bo *bo = fb->planes[i];
 
 		if (bo) {
-			if (bo->pages && bo->vaddr)
+			if (bo->pages)
 				vunmap(bo->vaddr);
 
 			drm_gem_object_unreference_unlocked(&bo->gem);

Would you like to integrate this update suggestion into another source code repository?

Regards,
Markus

#1067 lore raw

PATCH 1/1 ALSA: hda: Delete an unnecessary check before the function call "kobject_put"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 8 Jul 2015 21:26:02 +0200

The kobject_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.

---
 sound/hda/hdac_sysfs.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
sound/hda/hdac_sysfs.c +1 -2
index 0a6ce3b..089b35f 100644
@@ -321,8 +321,7 @@ static void widget_tree_free(struct hdac_device *codec)
 			free_widget_node(*p, &widget_node_group);
 		kfree(tree->nodes);
 	}
-	if (tree->root)
-		kobject_put(tree->root);
+	kobject_put(tree->root);
 	kfree(tree);
 	codec->widgets = NULL;
 }
Signature · 1 line
2.4.5
#1069 lore raw

PATCH 1/1 i2c-HID: Delete unnecessary checks before the function call "gpiod_put"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 8 Jul 2015 22:12:25 +0200

The gpiod_put() function performs also input parameter validation by forwarding its single input pointer to the gpiod_free() function. Thus the test around the calls is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/hid/i2c-hid/i2c-hid.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/hid/i2c-hid/i2c-hid.c +2 -6
index f77469d..09ff4e7 100644
@@ -1048,9 +1048,7 @@ err_pm:
 	pm_runtime_disable(&client->dev);
 
 err:
-	if (ihid->desc)
-		gpiod_put(ihid->desc);
-
+	gpiod_put(ihid->desc);
 	i2c_hid_free_buffers(ihid);
 	kfree(ihid);
 	return ret;
@@ -1074,9 +1072,7 @@ static int i2c_hid_remove(struct i2c_client *client)
 	if (ihid->bufsize)
 		i2c_hid_free_buffers(ihid);
 
-	if (ihid->desc)
-		gpiod_put(ihid->desc);
-
+	gpiod_put(ihid->desc);
 	kfree(ihid);
 
 	acpi_dev_remove_driver_gpios(ACPI_COMPANION(&client->dev));
Signature · 1 line
2.4.5
#984 lore raw

Re: Clarification for the use of additional fields in the message body

In reply to SF Markus Elfring

Hi Markus,

Quoted 4 lines · SF Markus Elfring
Quoted 1 line

Is there truly no way to simplify that process?

I see some software development possibilities which could improve the communication with high volume mailing lists.

You shouldn't need any software development, most people's processes are:

1. Make changes
2. git add <files>
3. git commit
4. Repeat 1-3 for all changes they want to make
5. git-format-patch
6. git-send-email through some SMTP server to the list and appropriate other people

From what I've read, you appear to have some semi-automatic tool for steps 1 through 4. I'd strongly recommend changing your patch submission process to use git-format-patch and git-send-email. If Sourceforge's email system doesn't let you send emails with SMTP directly, then you might want to try sending emails through your ISP's mail server.

Maintainers use a very similar process, however they collect and review patches in some personal repository in addition to making changes and committing them. Tools like patchwork are simply fancy methods of accumulating patches into git trees. Most people are using git-format-patch and git-send-email, possibly with some scripting around them, to format and send patches.

Quoted 3 lines
Quoted 1 line

You should be sending the patches directly with SMTP using git-send-email,

This tool is also fine for the publishing of a lot of patches.

git-send-email or some other tool?

Quoted 3 lines
Quoted 1 line

if you're not, then you're making things overly complicated for yourself.

But I prefer a graphical user interface for my mail handling so far.

I send my patches using git-send-email through gmail's servers then deal with literally everything else through gmail's web interface or Android app. Using git-send-email doesn't mean you can't use a graphical mail interface.

I used to send patches through a carefully configured instance of Thunderbird, however this required too many steps and it loved to mangle patches in ways that annoyed people.

Quoted 4 lines
Quoted 1 line

Having a feature doesn't mean that it should be used.

Does any of the "questionable functionality" get occasionally overlooked a bit too often?

It's not "questionable functionality", it's functionality we don't see a need for.

If I wanted to, I could insert a patch at any point in the history of Linux in my own repository, however any attempt to push that upstream would cause enormous amounts of pain and annoyance, to everyone who attempted to deal with it, so I don't.

Thanks,

Signature · 4 lines
Julian Calaby

Email: [email protected]
Profile: http://www.google.com/profiles/julian.calaby/
#340 lore raw

Re: DRM-vmwgfx: Deletion of an unnecessary check before the function call "vfree"

In reply to SF Markus Elfring
Quoted 8 lines · SF Markus Elfring
Quoted 3 lines

kfree will check that.

How does this feedback fit to a check before a call of the vfree() function?

I might have made a mistake, the ctl^] lead me to the vfree in mm/nommu.c,

there is also a vfree() function in mm/vmalloc.c.

Anyway, I think the catch is reasonable.

Quoted 3 lines

Regards,
Markus

Signature · 6 lines
Best regards
Junwang Zhao
Microprocessor Research and Develop Center
Department of Computer Science &Technology
Peking University
Beijing, 100871, PRC

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

maintainer Applied
#283 lore raw

Re: [PATCH] net-ipvs: Delete an unnecessary check before the function call "module_put"

In reply to SF Markus Elfring
Quoted 7 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 2 Jul 2015 17:00:14 +0200

The module_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.

Thanks, applied to ipvs-next for v4.3.

#532 lore raw

PATCH v2 1/1 HID: Wacom: Delete unnecessary checks before the function call "input_free_device"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 9 Jul 2015 08:00:10 +0200

The input_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.

---
 drivers/hid/wacom_sys.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/hid/wacom_sys.c +3 -6
index 4c0ffca..936ad77 100644
@@ -1149,12 +1149,9 @@ static void wacom_free_inputs(struct wacom *wacom)
 {
 	struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
 
-	if (wacom_wac->pen_input)
-		input_free_device(wacom_wac->pen_input);
-	if (wacom_wac->touch_input)
-		input_free_device(wacom_wac->touch_input);
-	if (wacom_wac->pad_input)
-		input_free_device(wacom_wac->pad_input);
+	input_free_device(wacom_wac->pen_input);
+	input_free_device(wacom_wac->touch_input);
+	input_free_device(wacom_wac->pad_input);
 	wacom_wac->pen_input = NULL;
 	wacom_wac->touch_input = NULL;
 	wacom_wac->pad_input = NULL;
Signature · 1 line
2.4.5
#1077 lore raw

PATCH 1/1 cdrom: Delete an unnecessary check before unregister_sysctl_table()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 9 Jul 2015 09:52:24 +0200

The unregister_sysctl_table() 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.

---
 drivers/cdrom/cdrom.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/cdrom/cdrom.c +1 -2
index 5d28a45..e43e84d 100644
@@ -3698,8 +3698,7 @@ static void cdrom_sysctl_register(void)
 
 static void cdrom_sysctl_unregister(void)
 {
-	if (cdrom_sysctl_header)
-		unregister_sysctl_table(cdrom_sysctl_header);
+	unregister_sysctl_table(cdrom_sysctl_header);
 }
 
 #else /* CONFIG_SYSCTL */
Signature · 1 line
2.4.5
#1070 lore raw

Re: [PATCH] i2c-HID: Delete unnecessary checks before the function call "gpiod_put"

In reply to SF Markus Elfring

This one deserves some extra review because it introduces a call to:

	WARN_ON(extra_checks);

in gpiod_free(). That may or may not matter...

regards,
dan carpenter