Remove unnecessary null pointer checks?
Subsystems (270)
Re: [PATCH] NetCP: Deletion of unnecessary checks before two function calls
In reply to SF Markus ElfringFrom: 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 +0100The functions
cpsw_ale_destroy()andof_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.
Signed-off-by Markus Elfring <[email protected]>
Applied.
Re: [PATCH] cxgb4: Delete an unnecessary check before the function call "release_firmware"
In reply to SF Markus ElfringFrom: 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 +0100The
release_firmware()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Applied.
Re: [PATCH] myri10ge: Delete an unnecessary check before the function call "kfree"
In reply to SF Markus ElfringFrom: 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 +0100The
kfree()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Applied.
Re: [PATCH] net: fec: Delete unnecessary checks before the function call "kfree"
In reply to SF Markus ElfringFrom: 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 +0100The
kfree()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Applied.
Re: [PATCH] netxen: Delete an unnecessary check before the function call "kfree"
In reply to SF Markus ElfringFrom: 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 +0100The
kfree()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Applied.
Re: [PATCH] GPU-DRM-Exynos: Delete unnecessary checks before two function calls
In reply to SF Markus ElfringHi,
Quoted 41 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 21:54:45 +0100The functions
phy_power_on()andvunmap()perform also input parameter validation. Thus the test around their calls is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- 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@@ -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
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
Re: [PATCH] qlogic: Deletion of unnecessary checks before two function calls
In reply to SF Markus ElfringFrom: 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 +0100The functions
kfree()andvfree()perform also input parameter validation. Thus the test around their calls is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Applied.
David Miller
maintainerRe: [PATCH] net: Mellanox: Delete unnecessary checks before the function call "vunmap"
In reply to SF Markus ElfringFrom: 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 +0100The
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.
Signed-off-by Markus Elfring <[email protected]>
This does not apply cleanly to the net-next tree, please respin.
Re: [PATCH] net: ep93xx_eth: Delete unnecessary checks before the function call "kfree"
In reply to SF Markus ElfringFrom: 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 +0100The
kfree()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Applied.
PATCH 1/1 GPU-DRM-Tegra: Delete an unnecessary check before the function call "vunmap"
In reply to SF Markus ElfringFrom: 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
@@ -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
PATCH 1/1 driver core: Delete an unnecessary check before the function call "put_device"
In reply to SF Markus ElfringFrom: 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
@@ -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
Re: [PATCH] NetCP: Deletion of unnecessary checks before two function calls
In reply to SF Markus ElfringHi Wingman,
There are some bugs in this error handling.
Quoted 6 lines · SF Markus Elfring
drivers/net/ethernet/ti/netcp_ethss.c +0
-0@@ -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
-4if (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
-0devm_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
PATCH 1/1 InfiniBand: Delete unnecessary checks before the function, call "srp_destroy_fr_pool"
In reply to SF Markus ElfringFrom: 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
@@ -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
PATCH 1/1 au1100fb: Delete unnecessary checks before two function calls
In reply to SF Markus ElfringFrom: 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
@@ -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
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 +0100The functions
clk_enable()andclk_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
Re: [PATCH] au1100fb: Delete unnecessary checks before two function calls
Quoted 4 lines
Quoted 2 lines
The functions
clk_enable()andclk_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
Re: [PATCH] InfiniBand: Delete unnecessary checks before the function, call "srp_destroy_fr_pool"
In reply to SF Markus ElfringQuoted 35 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Thu, 5 Feb 2015 13:20:42 +0100The
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.
Signed-off-by Markus Elfring <[email protected]>--- drivers/infiniband/ulp/srp/ib_srp.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)drivers/infiniband/ulp/srp/ib_srp.c +1
-6@@ -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.
PATCH 1/1 USB: appledisplay: Deletion of a check before backlight_device_unregister()
In reply to SF Markus ElfringFrom: 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
@@ -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
PATCH 1/1 ueagle-atm: Delete unnecessary checks before the function call "release_firmware"
In reply to SF Markus ElfringFrom: 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
@@ -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
RE: [PATCH] NetCP: Deletion of unnecessary checks before two function calls
In reply to Dan CarpenterRGFuLA0KDQpUaGFua3MuICBXZSdsbCBsb29rIGludG8gaXQgYW5kIHNlbmQgYSBwYXRjaCBzb29u 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
PATCH 1/1 USB: whci-hcd: Delete an unnecessary check before the function call "usb_put_hcd"
In reply to SF Markus ElfringFrom: 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
@@ -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
PATCH 1/1 Input: Delete an unnecessary check before the function call "input_free_device"
In reply to SF Markus ElfringFrom: 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
@@ -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
PATCH 1/1 IOMMU-Tegra: gart: Delete an unnecessary check before the function call "vfree"
In reply to SF Markus ElfringFrom: 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
@@ -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
Re: [PATCH] au1100fb: Delete unnecessary checks before two function calls
In reply to SF Markus ElfringQuoted 7 lines · SF Markus Elfring
Quoted 4 lines
Quoted 2 lines
The functions
clk_enable()andclk_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
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
PATCH 1/1 uwb/whci: Delete an unnecessary check before the function call "umc_device_unregister"
In reply to SF Markus ElfringFrom: 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
@@ -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
PATCH 1/1 SCSI-bfa: Delete more unnecessary checks before the function call "vfree"
In reply to SF Markus ElfringFrom: 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
@@ -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
PATCH 1/1 SCSI-aic7...: Delete unnecessary checks before the function call "kfree"
In reply to SF Markus ElfringFrom: 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
@@ -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
cover SCSI-lpfc: Deletion of an unnecessary check
In reply to SF Markus ElfringFrom: 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
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
@@ -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
PATCH 2/2 SCSI-lpfc: One function call less in lpfc_bsg_hba_set_event() after error detection
In reply to SF Markus ElfringFrom: 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
@@ -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
Re: [1/2] cw1200: Delete an unnecessary check before the function call "release_firmware"
In reply to SF Markus ElfringQuoted 10 lines
From: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 16:32:15 +0100The
release_firmware()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
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
Kalle Valo
AppliedRe: ath9k: Delete an unnecessary check before the function call"relay_close"
In reply to SF Markus ElfringQuoted 10 lines
From: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 18:48:28 +0100The
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.
Signed-off-by Markus Elfring <[email protected]>
Thanks, applied to wireless-drivers-next.git.
Kalle Valo
Kalle Valo
AppliedRe: orinoco: Delete an unnecessary check before the function call "kfree"
In reply to SF Markus ElfringQuoted 10 lines
From: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 19:53:11 +0100The
kfree()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Thanks, applied to wireless-drivers-next.git.
Kalle Valo
Kalle Valo
AppliedRe: hostap: Delete an unnecessary check before the function call "kfree"
In reply to SF Markus ElfringQuoted 10 lines
From: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 20:06:39 +0100The
kfree()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Thanks, applied to wireless-drivers-next.git.
Kalle Valo
Kalle Valo
AppliedRe: brcm80211: Delete unnecessary checks before two function calls
In reply to SF Markus ElfringQuoted 9 lines
From: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 20:28:49 +0100The functions
brcmu_pkt_buf_free_skb()andusb_free_urb()test whether their argument is NULL and then return immediately. Thus the test around the call is not needed.Signed-off-by Markus Elfring <[email protected]>
Thanks, applied to wireless-drivers-next.git.
Kalle Valo
cover SCSI-debug: Deletion of a few unnecessary checks
In reply to SF Markus ElfringFrom: 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
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
@@ -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
PATCH 2/3 SCSI-debug: Less function calls in scsi_debug_init() after error detection
In reply to SF Markus ElfringFrom: 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
@@ -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
PATCH 3/3 SCSI-debug: Fix exception handling for an alignment/granularity mismatch in scsi_debug_init()
In reply to SF Markus ElfringFrom: 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
@@ -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
PATCH 1/1 SCSI-csiostor: Delete an unnecessary check before the function call "release_firmware"
In reply to SF Markus ElfringFrom: 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
@@ -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
Mike Snitzer
NAKRe: [PATCH 3/3] dm ioctl: Delete an unnecessary check before the function call "dm_table_destroy"
In reply to SF Markus ElfringQuoted 7 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Mon, 2 Feb 2015 15:30:37 +0100The
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.
cover SCSI-QLA4...: Deletion of some unnecessary checks
In reply to SF Markus ElfringFrom: 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
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
@@ -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
@@ -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
PATCH 2/4 SCSI-QLA4...: Less function calls in qla4xxx_is_session_exists() after error detection
In reply to SF Markus ElfringFrom: 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
@@ -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
PATCH 3/4 SCSI-QLA4...: Less function calls in qla4xxx_is_flash_ddb_exists() after error detection
In reply to SF Markus ElfringFrom: 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
@@ -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
PATCH 4/4 SCSI-QLA4...: Less function calls in qla4xxx_sysfs_ddb_logout() after error detection
In reply to SF Markus ElfringFrom: 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
@@ -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
Re: [PATCH 2/4] SCSI-QLA4...: Less function calls in qla4xxx_is_session_exists() after error detection
In reply to SF Markus ElfringQuoted 5 lines · SF Markus Elfring
drivers/scsi/qla4xxx/ql4_os.c +0
-0
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
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@@ -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
-0int 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
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@@ -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
-0int 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
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
Re: [PATCH 3/3] dm ioctl: Delete an unnecessary check before the function call "dm_table_destroy"
In reply to Mike SnitzerQuoted 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
Re: thunderbolt: Deletion of unnecessary checks before the function call "ring_free"
In reply to Andreas NoeverQuoted 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
Re: [PATCH 3/3] dm ioctl: Delete an unnecessary check before the function call "dm_table_destroy"
In reply to SF Markus ElfringQuoted 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.
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
PATCH v2 1/1 net: Mellanox: Delete unnecessary checks before the function call "vunmap"
In reply to David MillerFrom: 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
@@ -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
@@ -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
David Miller
AppliedRe: [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 +0100The
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.
Signed-off-by Markus Elfring <[email protected]>Acked-by Eli Cohen <[email protected]>
Applied.
Re: [PATCH] Input: Delete an unnecessary check before the function call "input_free_device"
In reply to SF Markus ElfringQuoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Thu, 5 Feb 2015 17:35:35 +0100The
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.
Signed-off-by Markus Elfring <[email protected]>
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@@ -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
Re: [PATCH 0/2] SCSI-lpfc: Deletion of an unnecessary check
In reply to SF Markus ElfringMarkus,
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 +0100Another 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 inlpfc_bsg_hba_set_event()after error detectiondrivers/scsi/lpfc/lpfc_bsg.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
tip-bot for Markus Elfring
merge bot[tip:perf/core] perf/x86/intel/uncore: Delete an unnecessary check before pci_dev_put() call
In reply to SF Markus Elfringperf/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
@@ -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 ; }
PATCH 1/1 video: fbdev-SIS: Deletion of unnecessary checks before three function calls
In reply to SF Markus ElfringFrom: 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
@@ -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
cover ocfs2: Deletion of some unnecessary checks
In reply to Julia LawallFrom: 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
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
@@ -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
@@ -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
@@ -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
PATCH 2/7 ocfs2: Less function calls in ocfs2_convert_inline_data_to_extents() after error detection
In reply to SF Markus ElfringFrom: 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
@@ -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
PATCH 3/7 ocfs2: Less function calls in ocfs2_figure_merge_contig_type() after error detection
In reply to SF Markus ElfringFrom: 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
@@ -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
PATCH 4/7 ocfs2: One function call less in ocfs2_merge_rec_left() after error detection
In reply to SF Markus ElfringFrom: 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
@@ -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
PATCH 5/7 ocfs2: One function call less in ocfs2_merge_rec_right() after error detection
In reply to SF Markus ElfringFrom: 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
@@ -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
PATCH 6/7 ocfs2: One function call less in ocfs2_init_slot_info() after error detection
In reply to SF Markus ElfringFrom: 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
@@ -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
PATCH 7/7 ocfs2: One function call less in user_cluster_connect() after error detection
In reply to SF Markus ElfringFrom: 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
@@ -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
Re: [PATCH 1/3] SCSI-debug: Deletion of unnecessary checks before the function call "vfree"
In reply to SF Markus ElfringQuoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 6 Feb 2015 16:56:57 +0100The
vfree()function performs also input parameter validation. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Quoted 36 lines
--- drivers/scsi/scsi_debug.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)drivers/scsi/scsi_debug.c +3
-9@@ -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); }
Re: [PATCH 2/3] SCSI-debug: Less function calls in scsi_debug_init() after error detection
In reply to SF Markus ElfringQuoted 11 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 6 Feb 2015 17:48:34 +0100The
vfree()function was called in two cases by thescsi_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.
Signed-off-by Markus Elfring <[email protected]>
Quoted 49 lines
--- drivers/scsi/scsi_debug.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)drivers/scsi/scsi_debug.c +6
-4@@ -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; }
Re: [PATCH 3/3] SCSI-debug: Fix exception handling for an alignment/granularity mismatch in scsi_debug_init()
In reply to SF Markus ElfringQuoted 11 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 6 Feb 2015 17:57:32 +0100The
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.
Signed-off-by Markus Elfring <[email protected]>
Quoted 19 lines
--- drivers/scsi/scsi_debug.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/scsi/scsi_debug.c +2
-1@@ -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 ;
Kalle Valo
AppliedRe: [PATCH] ath10k: Delete unnecessary checks before the function call "release_firmware"
In reply to SF Markus ElfringQuoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 19:30:23 +0100The
release_firmware()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Thanks, applied to ath.git.
Signature · 1 line
Kalle Valo
PATCH 1/1 crypto-jitterentropy: Delete unnecessary checks before the function call "kzfree"
In reply to SF Markus ElfringFrom: 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
@@ -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
Stephan Mueller
NAKRe: [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 +0200The
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
Signed-off-by Markus Elfring <[email protected]>--- crypto/jitterentropy.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)crypto/jitterentropy.c +2
-4@@ -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
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
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 callingkzfree(entropy_collector->mem); ^^^^^^^^^^^^^^^^^^^^^^Dereference.
I don't understand the patch that you sent. We shouldn't be introducing
jent_zalloc()orjent_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
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
ACPI-APEI: Make exception handling a bit more efficient in __einj_error_trigger()
In reply to SF Markus ElfringFrom: 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
@@ -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
PATCH 1/1 ACPICA: Delete an unnecessary check before the function call "acpi_ds_delete_walk_state"
In reply to SF Markus ElfringFrom: 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
@@ -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
PATCH 1/1 kdbus: Delete an unnecessary check before the function call "kdbus_domain_unref"
In reply to SF Markus ElfringFrom: 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
@@ -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
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 +0200The
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.
Signed-off-by Markus Elfring <[email protected]>--- ipc/kdbus/fs.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)ipc/kdbus/fs.c +0
-0
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
Re: [PATCH] kdbus: Delete an unnecessary check before the function call "kdbus_domain_unref"
In reply to SF Markus ElfringQuoted 31 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 24 Jun 2015 14:30:17 +0200The
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.
Signed-off-by Markus Elfring <[email protected]>--- ipc/kdbus/fs.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)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); }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
PATCH 1/1 keys: Delete an unnecessary check before the function call "key_put"
In reply to SF Markus ElfringFrom: 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
@@ -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
PATCH 1/1 SCSI-OSD: Delete an unnecessary check before the function call "put_disk"
In reply to SF Markus ElfringFrom: 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
@@ -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
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 +0200The
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.
Signed-off-by Markus Elfring <[email protected]>--- drivers/scsi/osd/osd_uld.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)drivers/scsi/osd/osd_uld.c +1
-3@@ -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
RE: [PATCH] ACPICA: Delete an unnecessary check before the function call "acpi_ds_delete_walk_state"
In reply to SF Markus ElfringGot 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 +0200The
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.cindex 85bb951..188b254 100644drivers/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
PATCH 1/1 SCSI-wd33c93: Deletion of a check before the function call "wd33c93_setup"
In reply to SF Markus ElfringFrom: 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
@@ -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
PATCH 1/1 SCSI-libfc: Delete an unnecessary check before the function call "fc_fcp_ddp_done"
In reply to SF Markus ElfringFrom: 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
@@ -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
PATCH 1/1 SCSI: Delete unnecessary checks before the function call "put_device"
In reply to SF Markus ElfringFrom: 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
@@ -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
@@ -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
PATCH 1/1 SCSI-fnic: Delete an unnecessary check before the function call "vfree"
In reply to SF Markus ElfringFrom: 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
@@ -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
PATCH 1/1 s390/process: Delete an unnecessary check before the function call "kfree"
In reply to SF Markus ElfringFrom: 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
@@ -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
Re: [PATCH] SCSI-wd33c93: Deletion of a check before the function call "wd33c93_setup"
In reply to SF Markus ElfringQuoted 6 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 24 Jun 2015 17:15:17 +0200The
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
Re: [PATCH] s390/process: Delete an unnecessary check before the function call "kfree"
In reply to SF Markus ElfringAm 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 +0200The
kfree()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- arch/s390/kernel/process.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)arch/s390/kernel/process.c +0
-0
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
cover ARM-OMAP2+: Deletion of unnecessary checks before two function calls
In reply to SF Markus ElfringFrom: 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
Re: [PATCH] s390/process: Delete an unnecessary check before the function call "kfree"
In reply to walter harmsQuoted 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 +0200The
kfree()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- arch/s390/kernel/process.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)arch/s390/kernel/process.c +0
-0@@ -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
-2void 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
-0int copy_thread(unsigned long clone_flags, unsigned long new_stackp,maybe the intention was to check tsk != NULL ?
No.
PATCH 1/2 ARM-OMAP2+: Delete an unnecessary check before the function call "omap_device_delete"
In reply to SF Markus ElfringFrom: 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
@@ -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
PATCH 2/2 ARM-OMAP2+: Delete an unnecessary check before the function call "of_node_put"
In reply to SF Markus ElfringFrom: 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
@@ -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
Re: [PATCH] keys: Delete an unnecessary check before the function call "key_put"
In reply to SF Markus ElfringQuoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 24 Jun 2015 15:16:35 +0200The
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.
Signed-off-by Markus Elfring <[email protected]>
Quoted 21 lines
--- security/keys/process_keys.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)security/keys/process_keys.c +1
-3@@ -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
cover ARM-kernel: Deletion of unnecessary checks before two function calls
In reply to SF Markus ElfringFrom: 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
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
@@ -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
PATCH 2/2 ARM-kernel: Delete an unnecessary check before the function call "unwind_table_del"
In reply to SF Markus ElfringFrom: 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
@@ -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
PATCH 1/1 tools lib traceevent: Delete an unnecessary check before the function call "free_arg"
In reply to SF Markus ElfringFrom: 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
@@ -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
Re: [PATCH] crypto-jitterentropy: Delete unnecessary checks before the function call "kzfree"
In reply to SF Markus ElfringQuoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Tue, 23 Jun 2015 22:30:21 +0200The
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.
Signed-off-by Markus Elfring <[email protected]>
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
cover perf header: Deletion of an unnecessary check
In reply to SF Markus ElfringFrom: 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
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
@@ -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
PATCH 2/2 perf header: Less function calls in read_event_desc() after error detection
In reply to SF Markus ElfringFrom: 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
@@ -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
Arnaldo Carvalho de Melo
maintainerRe: [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 +0200The 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.
Signed-off-by Markus Elfring <[email protected]>--- tools/perf/util/header.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-)tools/perf/util/header.c +2
-2@@ -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
-11if (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
Arnaldo Carvalho de Melo
maintainerRe: [PATCH 1/2] perf header: Delete an unnecessary check before the function call "free_event_desc"
In reply to SF Markus ElfringEm 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 +0200The
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
Signed-off-by Markus Elfring <[email protected]>--- tools/perf/util/header.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)tools/perf/util/header.c +1
-2@@ -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
Re: [PATCH] SCSI-libfc: Delete an unnecessary check before the function call "fc_fcp_ddp_done"
In reply to SF Markus ElfringQuoted 18 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 24 Jun 2015 17:50:32 +0200The
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.
Signed-off-by Markus Elfring <[email protected]>--- drivers/scsi/libfc/fc_exch.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/scsi/libfc/fc_exch.c +0
-0
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.
Re: [PATCH 2/2] perf header: Less function calls in read_event_desc() after error detection
In reply to Arnaldo Carvalho de MeloQuoted 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.
Signed-off-by Markus Elfring <[email protected]>--- tools/perf/util/header.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-)tools/perf/util/header.c +2
-2@@ -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
-11if (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
PATCH 1/1 lib/mpi: Delete unnecessary checks before the function call "mpi_free_limb_space"
In reply to SF Markus ElfringFrom: 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
@@ -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
@@ -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
tip-bot for Markus Elfring
merge bot[tip:perf/urgent] perf header: Delete an unnecessary check before the calling free_event_desc()
In reply to SF Markus Elfringperf 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
@@ -1063,8 +1063,7 @@ out:free (buf);return events; error: -if (events) -free_event_desc (events); +free_event_desc (events); events =NULL ; goto out; }
PATCH 1/1 XFS: Delete unnecessary checks before the function call "xfs_qm_dqrele"
In reply to Dave ChinnerFrom: 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
@@ -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
PATCH 1/1 fs-DLM: Delete unnecessary checks before the function call "kfree"
In reply to SF Markus ElfringFrom: 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
@@ -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
@@ -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
PATCH 1/1 configfs: Delete unnecessary checks before the function call "config_item_put"
In reply to SF Markus ElfringFrom: 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
@@ -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
@@ -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
PATCH 1/1 keys: Delete an unnecessary check before the function call "key_put"
In reply to SF Markus ElfringFrom: 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
@@ -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
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
@@ -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
PATCH 1/1 f2fs crypto: Delete an unnecessary check before the function call "key_put"
In reply to SF Markus ElfringFrom: 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
@@ -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
Re: [osd-dev] [PATCH 1/1] exofs: Deletion of an unnecessary check before the function call "ore_put_io_state"
In reply to Boaz HarroshQuoted 13 lines
Quoted 13 lines
From: Markus Elfring <[email protected]>
Date: Tue, 18 Nov 2014 10:05:19 +0100The
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.
Signed-off-by Markus Elfring <[email protected]>--- 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@@ -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
PATCH 1/1 eCryptfs: Delete a check before the function call "key_put"
In reply to SF Markus ElfringFrom: 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
@@ -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
Re: [PATCH] fs-proc: One function call less in proc_sys_lookup() after error detection
In reply to SF Markus ElfringQuoted 34 lines
From: Markus Elfring <[email protected]>
Date: Tue, 18 Nov 2014 15:42:43 +0100The
sysctl_head_finish()function was called in an inefficient way by the implementation of theproc_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.Signed-off-by Markus Elfring <[email protected]>--- fs/proc/proc_sysctl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)fs/proc/proc_sysctl.c +2
-2@@ -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
-2d_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
Re: [PATCH] fs-eventpoll: Deletion of unnecessary checks before the function call "__pm_stay_awake"
In reply to SF Markus ElfringQuoted 29 lines
From: Markus Elfring <[email protected]>
Date: Tue, 18 Nov 2014 09:27:16 +0100The
__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.
Signed-off-by Markus Elfring <[email protected]>--- fs/eventpoll.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)fs/eventpoll.c +1
-2@@ -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
PATCH 1/1 crypto-qat: Deletion of unnecessary checks before two function calls
In reply to SF Markus ElfringFrom: 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
@@ -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
@@ -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
PATCH 1/1 tc1100-wmi: Delete an unnecessary check before the function call "kfree"
In reply to SF Markus ElfringFrom: 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
@@ -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
PATCH 1/1 staging: xgifb: Delete an unnecessary check before the function call "XGIfb_search_crt2type"
In reply to SF Markus ElfringFrom: 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
@@ -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
PATCH 1/1 staging: lustre: Deletion of unnecessary checks before three function calls
In reply to SF Markus ElfringFrom: 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
@@ -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
@@ -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
@@ -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
@@ -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
Darren Hart
AppliedRe: [PATCH] tc1100-wmi: Delete an unnecessary check before the function call "kfree"
In reply to SF Markus ElfringQuoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 26 Jun 2015 21:21:16 +0200The
kfree()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Queued, thanks.
Signature · 2 lines
Darren Hart Intel Open Source Technology Center
Re: [PATCH 1/1] platform: x86: Deletion of checks before backlight_device_unregister()
In reply to Julia LawallQuoted 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
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
Re: platform: x86: Deletion of checks before backlight_device_unregister()
In reply to Darren HartQuoted 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
PATCH 1/1 staging: comedi: adl_pci9118: Delete an unnecessary check before the function call "pci_dev_put"
In reply to SF Markus ElfringFrom: 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
@@ -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
Re: [PATCH 1/1] platform: x86: Deletion of checks before backlight_device_unregister()
In reply to Darren HartQuoted 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
cover staging: wilc1000: Deletion of two unnecessary checks
In reply to SF Markus ElfringFrom: 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
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
@@ -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
PATCH 2/2 staging: wilc1000: One function call less in mac_ioctl() after error detection
In reply to SF Markus ElfringFrom: 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
@@ -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
Re: [PATCH 1/1] x86: PCI-Calgary: Deletion of an unnecessary check before the function call "free_tce_table"
In reply to Jon MasonQuoted 27 lines
Quoted 9 lines
From: Markus Elfring <[email protected]>
Date: Sat, 22 Nov 2014 12:55:28 +0100The
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.
Signed-off-by Markus Elfring <[email protected]>Looks good to me
Acked-by Jon Mason <[email protected]>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@@ -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
PATCH 1/1 ipmi: Delete an unnecessary check before the function call "cleanup_one_si"
In reply to SF Markus ElfringFrom: 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
@@ -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
Re: [PATCH 2/2] staging: wilc1000: One function call less in mac_ioctl() after error detection
In reply to SF Markus ElfringQuoted 26 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 27 Jun 2015 16:00:59 +0200The
kfree()function was called in two cases by themac_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.
Signed-off-by Markus Elfring <[email protected]>--- drivers/staging/wilc1000/linux_wlan.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)drivers/staging/wilc1000/linux_wlan.c +0
-1@@ -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
Re: [PATCH] agp/intel-gtt: Deletion of unnecessary checks before the function call "pci_dev_put"
In reply to SF Markus ElfringQuoted 21 lines
From: Markus Elfring <[email protected]>
Date: Wed, 19 Nov 2014 14:24:20 +0100The
pci_dev_put()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/char/agp/intel-gtt.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)drivers/char/agp/intel-gtt.c +0
-0@@ -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
Re: [PATCH] GPU-DRM-Exynos: Delete unnecessary checks before two function calls
In reply to Joonyoung ShimQuoted 43 lines
Quoted 43 lines
From: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 21:54:45 +0100The functions
phy_power_on()andvunmap()perform also input parameter validation. Thus the test around their calls is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- 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@@ -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@@ -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 */ Acked-by Joonyoung Shim <[email protected]>
Do the chances increase to integrate this update suggestion into another source code repository?
Regards,
Markus
Re: platform: x86: Deletion of checks before backlight_device_unregister()
In reply to Dan CarpenterQuoted 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
PATCH 1/1 drm/bridge: ps8622: Delete a check before backlight_device_unregister()
In reply to SF Markus ElfringFrom: 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
@@ -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
cover drm/msm/dsi: Deletion of an unnecessary check
In reply to SF Markus ElfringFrom: 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
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
@@ -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
PATCH 2/2 drm/msm/dsi: One function call less in dsi_init() after error detection
In reply to SF Markus ElfringFrom: 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
@@ -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
PATCH 1/1 drm/amdgpu: Delete an unnecessary check before the function call "kfree"
In reply to SF Markus ElfringFrom: 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
@@ -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
PATCH 1/1 ALSA: hda: Delete an unnecessary check before the function call "snd_info_free_entry"
In reply to SF Markus ElfringFrom: 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
@@ -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
Re: [PATCH] SCSI-OSD: Delete an unnecessary check before the function call "put_disk"
In reply to SF Markus ElfringQuoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 24 Jun 2015 16:06:21 +0200The
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.
Signed-off-by Markus Elfring <[email protected]>
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@@ -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);
PATCH 1/1 PM-wakeup: Delete unnecessary checks before two function calls
In reply to SF Markus ElfringFrom: 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
@@ -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
Re: [PATCH] drbd: Deletion of an unnecessary check before the function call "lc_destroy"
In reply to SF Markus ElfringQuoted 19 lines
From: Markus Elfring <[email protected]>
Date: Wed, 19 Nov 2014 13:33:32 +0100The
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.
Signed-off-by Markus Elfring <[email protected]>--- drivers/block/drbd/drbd_nl.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/block/drbd/drbd_nl.c +0
-0
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
Re: [PATCH] block-rsxx: Deletion of an unnecessary check before the function call "vfree"
In reply to SF Markus ElfringQuoted 19 lines
From: Markus Elfring <[email protected]>
Date: Mon, 1 Dec 2014 19:19:25 +0100The
vfree()function performs also input parameter validation. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/block/rsxx/dma.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/block/rsxx/dma.c +0
-0
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
Re: [PATCH] block-skd: Deletion of an unnecessary check before the function call "kfree"
In reply to SF Markus ElfringQuoted 19 lines
From: Markus Elfring <[email protected]>
Date: Mon, 1 Dec 2014 18:15:46 +0100The
kfree()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/block/skd_main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/block/skd_main.c +0
-0
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
Re: [PATCH] HID-picoLCD: Deletion of unnecessary checks before three function calls
In reply to SF Markus ElfringQuoted 49 lines
From: Markus Elfring <[email protected]>
Date: Wed, 19 Nov 2014 18:30:22 +0100The functions
backlight_device_unregister(),lcd_device_unregister()andrc_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.
Signed-off-by Markus Elfring <[email protected]>--- 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@@ -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@@ -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
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
Re: [PATCH v2] backlight: lp8788: Deletion of a check before backlight_device_unregister()
In reply to SF Markus ElfringQuoted 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.
Signed-off-by Markus Elfring <[email protected]>--- drivers/video/backlight/lp8788_bl.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/video/backlight/lp8788_bl.c +0
-0
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
PATCH 1/1 video: fbdev: omap2: displays-new: Delete a check before backlight_device_unregister()
In reply to SF Markus ElfringFrom: 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
@@ -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
PATCH 1/1 USB-mxuport: Delete an unnecessary check before the function call "release_firmware"
In reply to SF Markus ElfringFrom: 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
@@ -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
PATCH 1/1 iommu/arm-smmu: Delete an unnecessary check before the function call "free_io_pgtable_ops"
In reply to SF Markus ElfringFrom: 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
@@ -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
PATCH 1/1 PCI-iproc: Delete unnecessary checks before two function calls
In reply to SF Markus ElfringFrom: 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
@@ -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
cover vfio: powerpc/spapr: Deletion of an unnecessary check
In reply to SF Markus ElfringFrom: 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
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
@@ -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
PATCH 2/2 vfio: powerpc/spapr: One function call less in tce_iommu_attach_group() after kzalloc() failure
In reply to SF Markus ElfringFrom: 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
@@ -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
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 +0200The
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.
Signed-off-by Markus Elfring <[email protected]>--- drivers/vfio/vfio_iommu_spapr_tce.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/vfio/vfio_iommu_spapr_tce.c +2
-2@@ -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
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 callkfree()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
Re: [PATCH] HID-picoLCD: Deletion of unnecessary checks before three function calls
In reply to SF Markus ElfringQuoted 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 +0100The functions
backlight_device_unregister(),lcd_device_unregister()andrc_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.
Signed-off-by Markus Elfring <[email protected]>--- 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@@ -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@@ -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@@ -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
-0int 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
Re: [PATCH] crypto-qat: Deletion of unnecessary checks before two function calls
In reply to SF Markus ElfringQuoted 10 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 26 Jun 2015 20:30:11 +0200The functions
kfree()andrelease_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.
Signed-off-by Markus Elfring <[email protected]>
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
Takashi Iwai
AppliedRe: [PATCH] ALSA: hda: Delete an unnecessary check before the function call "snd_info_free_entry"
In reply to SF Markus ElfringAt 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 +0200The
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.
Signed-off-by Markus Elfring <[email protected]>
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@@ -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
Re: [PATCH] staging: comedi: adl_pci9118: Delete an unnecessary check before the function call "pci_dev_put"
In reply to SF Markus ElfringQuoted 19 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 27 Jun 2015 13:50:43 +0200The
pci_dev_put()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/staging/comedi/drivers/adl_pci9118.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/staging/comedi/drivers/adl_pci9118.c +0
-0
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/ )=-
PATCH 1/1 net-Liquidio: Delete unnecessary checks before the function call "vfree"
In reply to SF Markus ElfringFrom: 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
@@ -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
@@ -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
@@ -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
Re: [PATCH] HID-picoLCD: Deletion of unnecessary checks before three function calls
In reply to Bruno PrémontQuoted 6 lines · Bruno Prémont
Sorry for forgetting about this patch.
Looks good to me:
Reviewed-by Bruno Prémont <[email protected]>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
Re: [PATCH] hfs/hfs+: Deletion of unnecessary checks before the function call "hfs_bnode_put"
In reply to Vyacheslav DubeykoQuoted 72 lines
Quoted 8 lines
From: Markus Elfring <[email protected]>
Date: Mon, 17 Nov 2014 19:13:56 +0100The
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.
Reviewed-by Vyacheslav Dubeyko <[email protected]>Thanks,
Vyacheslav Dubeyko.Quoted 56 lines
Signed-off-by Markus Elfring <[email protected]>--- 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@@ -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@@ -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@@ -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@@ -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
-2hfs_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
Re: [PATCH] drm/amdgpu: Delete an unnecessary check before the function call "kfree"
In reply to SF Markus ElfringQuoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 28 Jun 2015 10:27:35 +0200The
kfree()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
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@@ -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
Re: [PATCH] net-Liquidio: Delete unnecessary checks before the function call "vfree"
In reply to SF Markus ElfringFrom: 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 +0200The
vfree()function performs also input parameter validation. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Applied.
Ray Jui
maintainerRe: [PATCH] PCI-iproc: Delete unnecessary checks before two function calls
In reply to SF Markus ElfringHi Markus,
Quoted 24 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 28 Jun 2015 16:42:04 +0200The functions
phy_exit()andphy_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.
Signed-off-by Markus Elfring <[email protected]>--- drivers/pci/host/pcie-iproc.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)drivers/pci/host/pcie-iproc.c +0
-1@@ -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
Re: [PATCH] XFS: Delete unnecessary checks before the function call "xfs_qm_dqrele"
In reply to SF Markus ElfringQuoted 5 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 26 Jun 2015 11:05:41 +0200The
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]
Re: vfio: powerpc/spapr: One function call less in tce_iommu_attach_group() after kzalloc() failure
In reply to SF Markus ElfringQuoted 3 lines · SF Markus Elfring
Quoted 1 line
tcegrp will be NULL and
kfree()can handle this just fineThe 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 callkfree()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
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
Re: [PATCH] macintosh: Delete an unnecessary check before the function call "of_node_put"
In reply to SF Markus ElfringAm 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 +0100The
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.
Signed-off-by Markus Elfring <[email protected]>--- drivers/macintosh/smu.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/macintosh/smu.c +0
-0
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
Re: vfio: powerpc/spapr: One function call less in tce_iommu_attach_group() after kzalloc() failure
In reply to SF Markus ElfringQuoted 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
PATCH 1/1 ARM: OMAP2: Delete unnecessary checks before three function calls
In reply to SF Markus ElfringFrom: 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
@@ -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
@@ -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
@@ -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
Re: [PATCH] SCSI-bfa: Deletion of an unnecessary check before the function call "vfree"
In reply to Anil GurumurthyQuoted 37 lines
Patch looks good.
Thanks!Acked-by Anil Gurumurthy <[email protected]>-----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 +0100The
vfree()function performs also input parameter validation. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- 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
Re: [PATCH] SCSI-aic94xx: Deletion of an unnecessary check before the function call "kfree"
In reply to SF Markus ElfringQuoted 19 lines
From: Markus Elfring <[email protected]>
Date: Thu, 20 Nov 2014 23:18:56 +0100The
kfree()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/scsi/aic94xx/aic94xx_init.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/scsi/aic94xx/aic94xx_init.c +0
-0
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
Re: [PATCH] SCSI-eata_pio: Deletion of an unnecessary check before the function call "pci_dev_put"
In reply to SF Markus ElfringQuoted 19 lines
From: Markus Elfring <[email protected]>
Date: Thu, 20 Nov 2014 20:37:30 +0100The
pci_dev_put()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/scsi/eata_pio.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/scsi/eata_pio.c +0
-0
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
Re: XFS: Fine-tuning for checks before the function call "xfs_qm_dqrele"?
In reply to Dave ChinnerQuoted 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
Re: [PATCH v2] backlight: lp8788: Deletion of a check before backlight_device_unregister()
In reply to SF Markus ElfringQuoted 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.
Signed-off-by Markus Elfring <[email protected]>--- drivers/video/backlight/lp8788_bl.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)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); }
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
-0static 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
Re: [PATCH] InfiniBand: Deletion of unnecessary checks before two function calls
In reply to SF Markus ElfringQuoted 34 lines
From: Markus Elfring <[email protected]>
Date: Wed, 19 Nov 2014 19:19:21 +0100The functions
kfree()andpci_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.
Signed-off-by Markus Elfring <[email protected]>--- 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@@ -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
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
PATCH v3 1/1 video-lp8788: Delete a check before backlight_device_unregister()
In reply to Lee JonesFrom: 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
@@ -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
Re: XFS: Fine-tuning for checks before the function call "xfs_qm_dqrele"?
In reply to SF Markus ElfringQuoted 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]
Re: [PATCH v3] video-lp8788: Delete a check before backlight_device_unregister()
In reply to SF Markus ElfringQuoted 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.
Signed-off-by Markus Elfring <[email protected]>
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@@ -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
PATCH 1/1 net-ipv6: Delete an unnecessary check before the function call "free_percpu"
In reply to SF Markus ElfringFrom: 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
@@ -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
PATCH 1/1 net-ipvs: Delete an unnecessary check before the function call "module_put"
In reply to Pablo Neira AyusoFrom: 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
@@ -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
PATCH 1/1 net-RDS: Delete an unnecessary check before the function call "module_put"
In reply to SF Markus ElfringFrom: 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
@@ -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
PATCH 1/1 netlink: Delete an unnecessary check before the function call "module_put"
In reply to SF Markus ElfringFrom: 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
@@ -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
cover tools/testing/nvdimm: Deletion of two unnecessary checks
In reply to SF Markus ElfringFrom: 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
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
@@ -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
PATCH 2/2 tools/testing/nvdimm: Improve error detection in __test_alloc()
In reply to SF Markus ElfringFrom: 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
@@ -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
Re: [PATCH] net-ipv6: Delete an unnecessary check before the function call "free_percpu"
In reply to SF Markus ElfringFrom: 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 +0200The
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.
Signed-off-by Markus Elfring <[email protected]>
Applied.
Re: [PATCH] net-RDS: Delete an unnecessary check before the function call "module_put"
In reply to SF Markus ElfringFrom: 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 +0200The
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.
Signed-off-by Markus Elfring <[email protected]>
Applied.
Re: [PATCH] netlink: Delete an unnecessary check before the function call "module_put"
In reply to SF Markus ElfringFrom: 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 +0200The
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.
Signed-off-by Markus Elfring <[email protected]>
Applied.
PATCH 1/1 perf probe: Delete an unnecessary check before the function call "strfilter__delete"
In reply to SF Markus ElfringFrom: 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
@@ -297,8 +297,7 @@ static void cleanup_params(void)clear_perf_probe_event (params.events + i);line_range__clear (¶ms.line_range);free (params.target); -if (params.filter) -strfilter__delete (params.filter); +strfilter__delete (params.filter);memset (¶ms,0 ,sizeof (params)); }
Signature · 1 line
2.4.5
PATCH 1/1 kernel-sched: Delete an unnecessary check before unregister_sysctl_table()
In reply to SF Markus ElfringFrom: 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
@@ -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
PATCH 1/1 kprobes: Delete an unnecessary check before the function call "module_put"
In reply to Masami HiramatsuFrom: 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
@@ -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
PATCH 1/1 fs-namespace: Delete unnecessary checks before the function call "mntput"
In reply to SF Markus ElfringFrom: 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
@@ -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
Re: [PATCH] fs-notify: Deletion of an unnecessary check before the function call "iput"
In reply to SF Markus ElfringQuoted 19 lines
From: Markus Elfring <[email protected]>
Date: Sat, 29 Nov 2014 16:42:50 +0100The
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.
Signed-off-by Markus Elfring <[email protected]>--- fs/notify/inode_mark.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)fs/notify/inode_mark.c +0
-0
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
Re: [PATCH] ntfs: Deletion of unnecessary checks before the function call "iput"
In reply to SF Markus ElfringQuoted 52 lines
From: Markus Elfring <[email protected]>
Date: Sat, 15 Nov 2014 19:35:05 +0100The
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.
Signed-off-by Markus Elfring <[email protected]>--- fs/ntfs/super.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-)fs/ntfs/super.c +6
-12@@ -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
Anton Altaparmakov
Reviewed-byRe: [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 +0100The
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.
Signed-off-by Markus Elfring <[email protected]>---
fs/ntfs/super.c| 21 +++++++--------------1 file changed, 7 insertions(+), 14 deletions(-)fs/ntfs/super.c +0
-0@@ -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:
#ifdefNTFS_RWfs/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:
#ifdefNTFS_RWfs/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
cover ocfs2: Deletion of some unnecessary checks
In reply to Julia LawallFrom: 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
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
@@ -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
PATCH 2/11 ocfs2: Delete unnecessary checks before the function call "iput"
In reply to SF Markus ElfringFrom: 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH 3/11 ocfs2: Less checks in ocfs2_rename() after error detection
In reply to SF Markus ElfringFrom: 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
@@ -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
PATCH 4/11 ocfs2: One check less in ocfs2_statfs()
In reply to SF Markus ElfringFrom: 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
@@ -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
PATCH 5/11 ocfs2: Less error log repetition in ocfs2_begin_truncate_log_recovery()
In reply to SF Markus ElfringFrom: 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
@@ -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
PATCH 6/11 ocfs2: Two checks less in ocfs2_local_alloc_slide_window()
In reply to SF Markus ElfringFrom: 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
@@ -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
PATCH 7/11 ocfs2: Less function calls in ocfs2_shutdown_local_alloc() after error detection
In reply to SF Markus ElfringFrom: 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
@@ -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
PATCH 8/11 ocfs2: Less checks in ocfs2_load_local_alloc()
In reply to SF Markus ElfringFrom: 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
@@ -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
PATCH 9/11 ocfs2: One function call less in ocfs2_trylock_journal() after error detection
In reply to SF Markus ElfringFrom: 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
@@ -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
PATCH 10/11 ocfs2: Less function calls in ocfs2_replay_journal() after error detection
In reply to SF Markus ElfringFrom: 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
@@ -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
PATCH 11/11 ocfs2: One function call less in ocfs2_journal_shutdown() from input checks
In reply to SF Markus ElfringFrom: 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
@@ -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
PATCH 1/1 GPU-DRM-nouveau: Delete unnecessary checks before two function calls
In reply to SF Markus ElfringFrom: 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
@@ -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
@@ -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
PATCH 1/1 GPU-DRM: Delete an unnecessary check before drm_property_unreference_blob()
In reply to SF Markus ElfringFrom: 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
@@ -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
PATCH 1/1 GPU-DRM-IMX: Delete an unnecessary check before drm_fbdev_cma_restore_mode()
In reply to SF Markus ElfringFrom: 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
@@ -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
Re: [PATCH] GPU-DRM: Delete an unnecessary check before drm_property_unreference_blob()
In reply to SF Markus ElfringQuoted 11 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 5 Jul 2015 21:55:10 +0200The
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.
Signed-off-by Markus Elfring <[email protected]>
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@@ -4469,9 +4469,7 @@ static int drm_property_replace_global_blob(structdrm_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
Daniel Vetter
AppliedRe: [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 +0200The
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.
Signed-off-by Markus Elfring <[email protected]>Reviewed-by Zhao Junwang <[email protected]>
Applied to topic/drm-misc, thanks.
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Re: [PATCH 1/1] DRM-vmwgfx: Deletion of an unnecessary check before the function call "vfree"
In reply to SF Markus ElfringFrom: 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
@@ -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
Re: [PATCH 03/11] ocfs2: Less checks in ocfs2_rename() after error detection
In reply to SF Markus ElfringQuoted 8 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 4 Jul 2015 15:30:18 +0200Skip 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.Signed-off-by Markus Elfring <[email protected]>
I don't think this is an improvement.
regards,
dan carpenter
Johan Hovold
maintainerRe: [PATCH] USB-mxuport: Delete an unnecessary check before the function call "release_firmware"
In reply to SF Markus ElfringQuoted 18 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 28 Jun 2015 14:59:04 +0200The
release_firmware()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/usb/serial/mxuport.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/usb/serial/mxuport.c +0
-0
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
Re: [PATCH] kprobes: Delete an unnecessary check before the function call "module_put"
In reply to SF Markus ElfringQuoted 8 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 4 Jul 2015 10:00:26 +0200The
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
Signed-off-by Markus Elfring <[email protected]>--- kernel/kprobes.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)kernel/kprobes.c +1
-4@@ -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]
Re: [PATCH] perf probe: Delete an unnecessary check before the function call "strfilter__delete"
In reply to SF Markus ElfringQuoted 8 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 4 Jul 2015 07:44:22 +0200The
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
Signed-off-by Markus Elfring <[email protected]>--- tools/perf/builtin-probe.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)tools/perf/builtin-probe.c +1
-2@@ -297,8 +297,7 @@ static void cleanup_params(void)clear_perf_probe_event (params.events + i);line_range__clear (¶ms.line_range);free (params.target); -if (params.filter) -strfilter__delete (params.filter); +strfilter__delete (params.filter);memset (¶ms,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]
tip-bot for Markus Elfring
merge bot[tip:perf/core] perf probe: Delete an unnecessary check before the function call "strfilter__delete"
In reply to SF Markus Elfringperf 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
@@ -297,8 +297,7 @@ static void cleanup_params(void)clear_perf_probe_event (params.events + i);line_range__clear (¶ms.line_range);free (params.target); -if (params.filter) -strfilter__delete (params.filter); +strfilter__delete (params.filter);memset (¶ms,0 ,sizeof (params)); }
David Herrmann
AppliedRe: [PATCH] kdbus: Delete an unnecessary check before the function call "kdbus_domain_unref"
In reply to SF Markus ElfringHi
Quoted 6 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 24 Jun 2015 14:30:17 +0200The
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.
Signed-off-by Markus Elfring <[email protected]>--- ipc/kdbus/fs.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
Applied!
Thanks
David
Quoted 18 lines
ipc/kdbus/fs.c +1
-4@@ -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
Andrew Morton
maintainerRe: [PATCH] ntfs: Deletion of unnecessary checks before the function call "iput"
In reply to Anton AltaparmakovQuoted 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?
Reviewed-by Anton Altaparmakov <[email protected]>
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 ;)
Greg Kroah-Hartman
maintainerRe: [PATCH 1/2] staging: wilc1000: Delete unnecessary checks before two function calls
In reply to SF Markus ElfringQuoted 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.
Greg Kroah-Hartman
maintainerRe: [PATCH 2/2] staging: wilc1000: One function call less in mac_ioctl() after error detection
In reply to SF Markus ElfringQuoted 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 themac_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
Re: Clarification for the use of additional fields in the message body
In reply to Greg Kroah-HartmanQuoted 4 lines
Quoted 2 lines
From: Markus Elfring <[email protected]>
Date: Sat, 27 Jun 2015 15:56:57 +0200Why 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
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 +0200Why 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
Lee Jones
AppliedRe: [PATCH v3] video-lp8788: Delete a check before backlight_device_unregister()
In reply to SF Markus ElfringQuoted 7 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 1 Jul 2015 12:08:31 +0200The
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.
Signed-off-by Markus Elfring <[email protected]>--- 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@@ -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
Re: Clarification for the use of additional fields in the message body
In reply to Frans KlaverQuoted 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
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
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
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
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
PATCH v3 1/1 kconfig: Delete unnecessary checks before the function call "sym_calc_value"
In reply to SF Markus ElfringFrom: 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
@@ -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
@@ -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
Re: Clarification for the use of additional fields in the message body
In reply to SF Markus ElfringHi 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/
John Hunter
Reviewed-byRe: [PATCH 1/1] DRM-vmwgfx: Deletion of an unnecessary check before the function call "vfree"
In reply to SF Markus ElfringQuoted 10 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Mon, 6 Jul 2015 09:49:11 +0200The
vfree()function performs also input parameter validation. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
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@@ -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
Re: Clarification for the use of additional fields in the message body
In reply to Julian CalabyQuoted 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
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/
Re: staging: wilc1000: One function call less in mac_ioctl() after error detection
In reply to Greg Kroah-HartmanQuoted 10 lines
Quoted 8 lines
The
kfree()function was called in two cases by themac_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
Re: Clarification for the use of additional fields in the message body
In reply to Julian CalabyQuoted 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
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/
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
Theodore Ts'o
maintainerRe: Clarification for the use of additional fields in the message body
In reply to Julian CalabyQuoted 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
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
Re: DRM-vmwgfx: Deletion of an unnecessary check before the function call "vfree"
In reply to John HunterQuoted 3 lines
Reviewed-by Zhao Junwang <[email protected]>kfree will check that.
How does this feedback fit to a check before a call of the vfree() function?
Regards,
Markus
Re: [PATCH] bcache: Deletion of an unnecessary check before the function call "kobject_put"
In reply to SF Markus ElfringQuoted 19 lines
From: Markus Elfring <[email protected]>
Date: Wed, 19 Nov 2014 21:25:39 +0100The
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.
Signed-off-by Markus Elfring <[email protected]>--- drivers/md/bcache/super.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/md/bcache/super.c +0
-0
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
Re: [PATCH] GPU-DRM-Tegra: Delete an unnecessary check before the function call "vunmap"
In reply to SF Markus ElfringQuoted 19 lines
From: Markus Elfring <[email protected]>
Date: Thu, 5 Feb 2015 10:12:51 +0100The
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.
Signed-off-by Markus Elfring <[email protected]>--- drivers/gpu/drm/tegra/fb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/tegra/fb.c +0
-0
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
PATCH 1/1 ALSA: hda: Delete an unnecessary check before the function call "kobject_put"
In reply to SF Markus ElfringFrom: 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
@@ -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
PATCH 1/1 i2c-HID: Delete unnecessary checks before the function call "gpiod_put"
In reply to SF Markus ElfringFrom: 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
@@ -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
Re: Clarification for the use of additional fields in the message body
In reply to SF Markus ElfringHi 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/
Re: DRM-vmwgfx: Deletion of an unnecessary check before the function call "vfree"
In reply to SF Markus ElfringQuoted 8 lines · SF Markus Elfring
Quoted 3 lines
Reviewed-by Zhao Junwang <[email protected]>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
Re: [PATCH] net-ipvs: Delete an unnecessary check before the function call "module_put"
In reply to SF Markus ElfringQuoted 7 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Thu, 2 Jul 2015 17:00:14 +0200The
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.
PATCH v2 1/1 HID: Wacom: Delete unnecessary checks before the function call "input_free_device"
In reply to SF Markus ElfringFrom: 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
@@ -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
PATCH 1/1 cdrom: Delete an unnecessary check before unregister_sysctl_table()
In reply to SF Markus ElfringFrom: 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
@@ -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
Re: [PATCH] i2c-HID: Delete unnecessary checks before the function call "gpiod_put"
In reply to SF Markus ElfringThis 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