Remove unnecessary null pointer checks?
Subsystems (270)
Alex Deucher
AppliedRe: [PATCH] GPU-DRM-Radeon: Delete an unnecessary check before drm_gem_object_unreference_unlocked()
In reply to SF Markus ElfringQuoted 10 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Tue, 12 Jul 2016 22:00:55 +0200The
drm_gem_object_unreference_unlocked()function tests whether its argument 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!
Alex
Quoted 26 lines
--- drivers/gpu/drm/radeon/radeon_display.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)drivers/gpu/drm/radeon/radeon_display.c +1
-4@@ -1324,9 +1324,7 @@ static void radeon_user_framebuffer_destroy(struct drm_framebuffer *fb) {struct radeon_framebuffer *radeon_fb =to_radeon_framebuffer (fb); -if (radeon_fb->obj) { -drm_gem_object_unreference_unlocked (radeon_fb->obj); - } +drm_gem_object_unreference_unlocked (radeon_fb->obj);drm_framebuffer_cleanup (fb);kfree (radeon_fb); } --2.9.0
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
cover drm/msm: Deletion of a few unnecessary checks
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 13 Jul 2016 19:46:45 +0200
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (3):
HDMI: Delete an unnecessary check before the function call "kfree" Delete unnecessary checks before drm_gem_object_unreference_unlocked() Delete an unnecessary check before drm_gem_object_unreference()
drivers/gpu/drm/msm/hdmi/hdmi_hdcp.c | 2 +- drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c | 3 +-- drivers/gpu/drm/msm/msm_fb.c | 4 ++-- drivers/gpu/drm/msm/msm_gem.c | 8 ++------ 4 files changed, 6 insertions(+), 11 deletions(-)
Signature · 1 line
2.9.0
PATCH 1/3 drm/msm/hdmi: Delete an unnecessary check before the function call "kfree"
From: Markus Elfring <[email protected]>
Date: Wed, 13 Jul 2016 18:54:11 +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/msm/hdmi/hdmi_hdcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/hdmi/hdmi_hdcp.c +1 -1
@@ -1430,7 +1430,7 @@ struct hdmi_hdcp_ctrl *msm_hdmi_hdcp_init(struct hdmi *hdmi)void msm_hdmi_hdcp_destroy (struct hdmi *hdmi) { -if (hdmi && hdmi->hdcp_ctrl) { +if (hdmi) {kfree (hdmi->hdcp_ctrl); hdmi->hdcp_ctrl =NULL ; }
Signature · 1 line
2.9.0
PATCH 2/3 drm/msm: Delete unnecessary checks before drm_gem_object_unreference_unlocked()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 13 Jul 2016 19:15:35 +0200
The drm_gem_object_unreference_unlocked() function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c | 3 +-- drivers/gpu/drm/msm/msm_fb.c | 4 ++-- drivers/gpu/drm/msm/msm_gem.c | 4 +--- 3 files changed, 4 insertions(+), 7 deletions(-)
drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c +1 -2
@@ -168,8 +168,7 @@ static void mdp4_destroy(struct msm_kms *kms)if (mdp4_kms->blank_cursor_iova)msm_gem_put_iova (mdp4_kms->blank_cursor_bo, mdp4_kms->id); -if (mdp4_kms->blank_cursor_bo) -drm_gem_object_unreference_unlocked (mdp4_kms->blank_cursor_bo); +drm_gem_object_unreference_unlocked (mdp4_kms->blank_cursor_bo);if (mdp4_kms->rpm_enabled)pm_runtime_disable (dev);
drivers/gpu/drm/msm/msm_fb.c +2 -2
@@ -49,8 +49,8 @@ static void msm_framebuffer_destroy(struct drm_framebuffer *fb)for (i =0 ; i < n; i++) {struct drm_gem_object *bo = msm_fb->planes[i]; -if (bo) -drm_gem_object_unreference_unlocked (bo); + +drm_gem_object_unreference_unlocked (bo); }kfree (msm_fb);
drivers/gpu/drm/msm/msm_gem.c +1 -3
@@ -875,8 +875,6 @@ struct drm_gem_object *msm_gem_import(struct drm_device *dev,return obj; fail: -if (obj) -drm_gem_object_unreference_unlocked (obj); - +drm_gem_object_unreference_unlocked (obj);return ERR_PTR (ret); }
Signature · 1 line
2.9.0
PATCH 3/3 drm/msm: Delete an unnecessary check before drm_gem_object_unreference()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 13 Jul 2016 19:29:19 +0200
The drm_gem_object_unreference() function tests whether its argument 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/msm_gem.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/msm/msm_gem.c +1 -3
@@ -830,9 +830,7 @@ struct drm_gem_object *msm_gem_new(struct drm_device *dev,return obj; fail: -if (obj) -drm_gem_object_unreference (obj); - +drm_gem_object_unreference (obj);return ERR_PTR (ret); }
Signature · 1 line
2.9.0
Re: [PATCH 0/3] drm/msm: Deletion of a few unnecessary checks
In reply to SF Markus ElfringQuoted 10 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 13 Jul 2016 19:46:45 +0200A few update suggestions were taken into account
from static source code analysis.Markus Elfring (3):
HDMI: Delete an unnecessary check before the function call "kfree" Delete unnecessary checks beforedrm_gem_object_unreference_unlocked()Delete an unnecessary check beforedrm_gem_object_unreference()
thanks, I've pushed these to msm-next
BR,
-R
Quoted 9 lines
drivers/gpu/drm/msm/hdmi/hdmi_hdcp.c | 2 +- drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c | 3 +-- drivers/gpu/drm/msm/msm_fb.c | 4 ++-- drivers/gpu/drm/msm/msm_gem.c | 8 ++------ 4 files changed, 6 insertions(+), 11 deletions(-)--
2.9.0
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 1/1 drm/bochs: Delete an unnecessary check before drm_gem_object_unreference_unlocked()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 15 Jul 2016 14:23:15 +0200
The drm_gem_object_unreference_unlocked() function tests whether its argument 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/bochs/bochs_mm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/bochs/bochs_mm.c +2 -2
@@ -474,8 +474,8 @@ int bochs_dumb_mmap_offset(struct drm_file *file, struct drm_device *dev,static void bochs_user_framebuffer_destroy (struct drm_framebuffer *fb) {struct bochs_framebuffer *bochs_fb =to_bochs_framebuffer (fb); -if (bochs_fb->obj) -drm_gem_object_unreference_unlocked (bochs_fb->obj); + +drm_gem_object_unreference_unlocked (bochs_fb->obj);drm_framebuffer_cleanup (fb);kfree (fb); }
Signature · 1 line
2.9.1
PATCH 1/1 drm/rockchip: Delete an unnecessary check before drm_gem_object_unreference_unlocked()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 15 Jul 2016 15:23:22 +0200
The drm_gem_object_unreference_unlocked() function tests whether its argument 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/rockchip/rockchip_drm_fb.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/gpu/drm/rockchip/rockchip_drm_fb.c +2 -6
@@ -43,14 +43,10 @@ struct drm_gem_object *rockchip_fb_get_gem_obj(struct drm_framebuffer *fb,static void rockchip_drm_fb_destroy (struct drm_framebuffer *fb) {struct rockchip_drm_fb *rockchip_fb =to_rockchip_fb (fb); -struct drm_gem_object *obj;int i; -for (i =0 ; i <ROCKCHIP_MAX_FB_BUFFER ; i++) { - obj = rockchip_fb->obj[i]; -if (obj) -drm_gem_object_unreference_unlocked (obj); - } +for (i =0 ; i <ROCKCHIP_MAX_FB_BUFFER ; i++) +drm_gem_object_unreference_unlocked (rockchip_fb->obj[i]);drm_framebuffer_cleanup (fb);kfree (rockchip_fb);
Signature · 1 line
2.9.1
Re: [PATCH] drm/rockchip: Delete an unnecessary check before drm_gem_object_unreference_unlocked()
Quoted 23 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 15 Jul 2016 15:23:22 +0200The
drm_gem_object_unreference_unlocked()function tests whether its argument 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/gpu/drm/rockchip/rockchip_drm_fb.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)drivers/gpu/drm/rockchip/rockchip_drm_fb.c +0
-1@@ -43,14 +43,10 @@ struct drm_gem_object *rockchip_fb_get_gem_obj(struct drm_framebuffer *fb,static void rockchip_drm_fb_destroy (struct drm_framebuffer *fb) {struct rockchip_drm_fb *rockchip_fb =to_rockchip_fb (fb); -struct drm_gem_object *obj;
drivers/gpu/drm/rockchip/rockchip_drm_fb.c struct drm_gem_object *rockchip_fb_get_gem_obj(struct drm_framebuffer *fb, · line 50
Quoted 10 lines
drivers/gpu/drm/rockchip/rockchip_drm_fb.c +2
-5int i; -for (i =0 ; i <ROCKCHIP_MAX_FB_BUFFER ; i++) { - obj = rockchip_fb->obj[i]; -if (obj) -drm_gem_object_unreference_unlocked (obj); - } +for (i =0 ; i <ROCKCHIP_MAX_FB_BUFFER ; i++) +drm_gem_object_unreference_unlocked (rockchip_fb->obj[i]);
Good, Thanks for the fixes, Applied to my drm-fixes.
Quoted 2 lines
drivers/gpu/drm/rockchip/rockchip_drm_fb.c +0
-0drm_framebuffer_cleanup (fb);kfree (rockchip_fb);
Signature · 1 line
Mark Yao
PATCH 1/1 drm/arcpgu: Delete an unnecessary check before drm_fbdev_cma_hotplug_event()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 15 Jul 2016 21:52:40 +0200
The drm_fbdev_cma_hotplug_event() function tests whether its argument 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/arc/arcpgu_drv.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/arc/arcpgu_drv.c +1 -2
@@ -28,8 +28,7 @@ static void arcpgu_fb_output_poll_changed(struct drm_device *dev) {struct arcpgu_drm_private *arcpgu = dev->dev_private; -if (arcpgu->fbdev) -drm_fbdev_cma_hotplug_event (arcpgu->fbdev); +drm_fbdev_cma_hotplug_event (arcpgu->fbdev); }static struct drm_mode_config_funcs arcpgu_drm_modecfg_funcs = {
Signature · 1 line
2.9.1
Re: [PATCH] drm/arcpgu: Delete an unnecessary check before drm_fbdev_cma_hotplug_event()
Hi Markus,
Quoted 10 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 15 Jul 2016 21:52:40 +-0200The
drm_fbdev_cma_hotplug_event()function tests whether its argument 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]>
Good catch!
PATCH 1/1 drm/virtgpu: Delete unnecessary checks before drm_gem_object_unreference_unlocked()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 15 Jul 2016 22:38:42 +0200
The drm_gem_object_unreference_unlocked() function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/gpu/drm/virtio/virtgpu_display.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/gpu/drm/virtio/virtgpu_display.c +2 -4
@@ -53,8 +53,7 @@ static void virtio_gpu_user_framebuffer_destroy(struct drm_framebuffer *fb)struct virtio_gpu_framebuffer *virtio_gpu_fb =to_virtio_gpu_framebuffer (fb); -if (virtio_gpu_fb->obj) -drm_gem_object_unreference_unlocked (virtio_gpu_fb->obj); +drm_gem_object_unreference_unlocked (virtio_gpu_fb->obj);drm_framebuffer_cleanup (fb);kfree (virtio_gpu_fb); }
@@ -326,8 +325,7 @@ virtio_gpu_user_framebuffer_create(struct drm_device *dev, ret =virtio_gpu_framebuffer_init (dev, virtio_gpu_fb, mode_cmd, obj);if (ret) {kfree (virtio_gpu_fb); -if (obj) -drm_gem_object_unreference_unlocked (obj); +drm_gem_object_unreference_unlocked (obj);return NULL ; }
Signature · 1 line
2.9.1
PATCH 1/1 drm/cirrus: Delete an unnecessary check before drm_gem_object_unreference_unlocked()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 16 Jul 2016 08:28:13 +0200
The drm_gem_object_unreference_unlocked() function tests whether its argument 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/cirrus/cirrus_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/cirrus/cirrus_main.c +2 -2
@@ -17,8 +17,8 @@static void cirrus_user_framebuffer_destroy (struct drm_framebuffer *fb) {struct cirrus_framebuffer *cirrus_fb =to_cirrus_framebuffer (fb); -if (cirrus_fb->obj) -drm_gem_object_unreference_unlocked (cirrus_fb->obj); + +drm_gem_object_unreference_unlocked (cirrus_fb->obj);drm_framebuffer_cleanup (fb);kfree (fb); }
Signature · 1 line
2.9.1
PATCH 1/1 drm/hdlcd: Delete an unnecessary check before drm_fbdev_cma_hotplug_event()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 16 Jul 2016 09:10:40 +0200
The drm_fbdev_cma_hotplug_event() function tests whether its argument 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/arm/hdlcd_drv.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/arm/hdlcd_drv.c +1 -2
@@ -102,8 +102,7 @@ static void hdlcd_fb_output_poll_changed(struct drm_device *drm) {struct hdlcd_drm_private *hdlcd = drm->dev_private; -if (hdlcd->fbdev) -drm_fbdev_cma_hotplug_event (hdlcd->fbdev); +drm_fbdev_cma_hotplug_event (hdlcd->fbdev); }static const struct drm_mode_config_funcs hdlcd_mode_config_funcs = {
Signature · 1 line
2.9.1
Re: [PATCH] drm/hdlcd: Delete an unnecessary check before drm_fbdev_cma_hotplug_event()
Quoted 10 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 16 Jul 2016 09:10:40 +0200The
drm_fbdev_cma_hotplug_event()function tests whether its argument 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 25 lines
--- drivers/gpu/drm/arm/hdlcd_drv.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/gpu/drm/arm/hdlcd_drv.c +1
-2@@ -102,8 +102,7 @@ static void hdlcd_fb_output_poll_changed(struct drm_device *drm) {struct hdlcd_drm_private *hdlcd = drm->dev_private; -if (hdlcd->fbdev) -drm_fbdev_cma_hotplug_event (hdlcd->fbdev); +drm_fbdev_cma_hotplug_event (hdlcd->fbdev); }static const struct drm_mode_config_funcs hdlcd_mode_config_funcs = {Signature · 6 lines
2.9.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 8 lines
==========
| I would like to |
| fix the world, |
| but they're not |
| giving me the |
\ source code! /
---------------
¯\_(ツ)_/¯PATCH 1/1 drm/ast: Delete an unnecessary check before drm_gem_object_unreference_unlocked()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 16 Jul 2016 09:54:22 +0200
The drm_gem_object_unreference_unlocked() function tests whether its argument 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/ast/ast_main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/ast/ast_main.c +1 -2
@@ -295,9 +295,8 @@ static int ast_get_dram_info(struct drm_device *dev)static void ast_user_framebuffer_destroy (struct drm_framebuffer *fb) {struct ast_framebuffer *ast_fb =to_ast_framebuffer (fb); -if (ast_fb->obj) -drm_gem_object_unreference_unlocked (ast_fb->obj); +drm_gem_object_unreference_unlocked (ast_fb->obj);drm_framebuffer_cleanup (fb);kfree (fb); }
Signature · 1 line
2.9.1
Re: [PATCH] drm/ast: Delete an unnecessary check before drm_gem_object_unreference_unlocked()
Quoted 10 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 16 Jul 2016 09:54:22 +0200The
drm_gem_object_unreference_unlocked()function tests whether its argument 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]>
Ok, I merged all the non-amd ones from your latest round to drm-misc. Two small nitpicks:
- for cocci patches I prefer if you include the (simplified, if it's a large one) semantic patch in the commit message. Cocci is really badly documented, it's good to see new examples of how.
- threading seems funny in your series. Please generate mail threads using git format-patch --cover-letter $sha1_range and send them out using git send-email. That'll get all the details right. Also pls don't reply with new patches to an old series, that hides the patches and confuses the discussion. Just start a new thread (even when the patches are on the same or similar topic).
Thanks, Daniel
Quoted 26 lines
--- drivers/gpu/drm/ast/ast_main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/gpu/drm/ast/ast_main.c +1
-2@@ -295,9 +295,8 @@ static int ast_get_dram_info(struct drm_device *dev)static void ast_user_framebuffer_destroy (struct drm_framebuffer *fb) {struct ast_framebuffer *ast_fb =to_ast_framebuffer (fb); -if (ast_fb->obj) -drm_gem_object_unreference_unlocked (ast_fb->obj); +drm_gem_object_unreference_unlocked (ast_fb->obj);drm_framebuffer_cleanup (fb);kfree (fb); }Signature · 6 lines
2.9.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
PATCH 1/1 s390/pci: Delete an unnecessary check before the function call "pci_dev_put"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 16 Jul 2016 20:15:17 +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.
--- arch/s390/pci/pci_event.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/s390/pci/pci_event.c +1 -2
@@ -145,8 +145,7 @@ static void __zpci_event_availability(struct zpci_ccdf_avail *ccdf)default :break ; } -if (pdev) -pci_dev_put (pdev); +pci_dev_put (pdev); }void zpci_event_availability (void *data)
Signature · 1 line
2.9.1
Martin Schwidefsky
AppliedRe: [PATCH] s390/pci: Delete an unnecessary check before the function call "pci_dev_put"
Quoted 18 lines · On Sat, 16 Jul 2016 20:40:23 +0200 SF Markus Elfring…
From: Markus Elfring <[email protected]>
Date: Sat, 16 Jul 2016 20:15:17 +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]>--- arch/s390/pci/pci_event.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)arch/s390/pci/pci_event.c +0
-0
arch/s390/pci/pci_event.c static void __zpci_event_availability(struct zpci_ccdf_avail *ccdf) · line 151
Quoted 9 lines
arch/s390/pci/pci_event.c +1
-2@@ -145,8 +145,7 @@ static void __zpci_event_availability(struct zpci_ccdf_avail *ccdf)default :break ; } -if (pdev) -pci_dev_put (pdev); +pci_dev_put (pdev); }void zpci_event_availability (void *data)
Applied, thanks.
Signature · 4 lines
blue skies, Martin. "Reality continues to ruin my life." - Calvin.
cover xen-scsiback: Fine-tuning for scsiback_device_action()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 16 Jul 2016 22:06:54 +0200
Further update suggestions were taken into account after a patch was applied from static source code analysis.
Markus Elfring (3):
Delete an unnecessary check before the function call "kfree" One function call less in scsiback_device_action() after error detection Pass a failure indication as a constant
drivers/xen/xen-scsiback.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
Signature · 1 line
2.9.1
PATCH 1/3 xen-scsiback: Delete an unnecessary check before the function call "kfree"
From: Markus Elfring <[email protected]>
Date: Sat, 16 Jul 2016 21:21:05 +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/xen/xen-scsiback.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/xen/xen-scsiback.c +1 -2
@@ -627,8 +627,7 @@ static void scsiback_device_action(struct vscsibk_pend *pending_req,transport_generic_free_cmd (&pending_req->se_cmd,1 );return ; err: -if (tmr) -kfree (tmr); +kfree (tmr);scsiback_do_resp_with_sense (NULL , err,0 , pending_req); }
Signature · 1 line
2.9.1
Re: [PATCH 1/3] xen-scsiback: Delete an unnecessary check before the function call "kfree"
Quoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 16 Jul 2016 21:21:05 +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]>
Juergen
Re: [PATCH 1/3] xen-scsiback: 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: Sat, 16 Jul 2016 21:21:05 +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]>
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 1/3 xen-scsiback: Delete an unnecessary check before the function call "kfree"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 16 Jul 2016 21:21:05 +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/xen/xen-scsiback.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/xen/xen-scsiback.c +1 -2
@@ -627,8 +627,7 @@ static void scsiback_device_action(struct vscsibk_pend *pending_req,transport_generic_free_cmd (&pending_req->se_cmd,1 );return ; err: -if (tmr) -kfree (tmr); +kfree (tmr);scsiback_do_resp_with_sense (NULL , err,0 , pending_req); }
Signature · 7 lines
2.9.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH 2/3 xen-scsiback: One function call less in scsiback_device_action() after error detection
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 16 Jul 2016 21:42:42 +0200
The kfree() function was called in one case by the scsiback_device_action() function during error handling even if the passed variable "tmr" contained a null pointer.
Adjust jump targets according to the Linux coding style convention.
--- drivers/xen/xen-scsiback.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/xen/xen-scsiback.c +4 -3
@@ -606,7 +606,7 @@ static void scsiback_device_action(struct vscsibk_pend *pending_req, tmr =kzalloc (sizeof (struct scsiback_tmr ),GFP_KERNEL );if (!tmr) {target_put_sess_cmd (se_cmd); - goto err; + goto do_resp; }init_waitqueue_head (&tmr->tmr_wait);
@@ -616,7 +616,7 @@ static void scsiback_device_action(struct vscsibk_pend *pending_req, unpacked_lun, tmr, act,GFP_KERNEL , tag, TARGET_SCF_ACK_KREF);if (rc) - goto err; + goto free_tmr;wait_event (tmr->tmr_wait,atomic_read (&tmr->tmr_complete));
@@ -626,8 +626,9 @@ static void scsiback_device_action(struct vscsibk_pend *pending_req,scsiback_do_resp_with_sense (NULL , err,0 , pending_req);transport_generic_free_cmd (&pending_req->se_cmd,1 );return ; -err: +free_tmr:kfree (tmr); +do_resp:scsiback_do_resp_with_sense (NULL , err,0 , pending_req); }
Signature · 1 line
2.9.1
Juergen Gross
maintainerRe: [PATCH 2/3] xen-scsiback: One function call less in scsiback_device_action() after error detection
Quoted 19 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 16 Jul 2016 21:42:42 +0200The
kfree()function was called in one case by thescsiback_device_action()function during error handling even if the passed variable "tmr" contained a null pointer.Adjust jump targets according to the Linux coding style convention.
Signed-off-by Markus Elfring <[email protected]>--- drivers/xen/xen-scsiback.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/xen/xen-scsiback.c +0
-0
drivers/xen/xen-scsiback.c static void scsiback_device_action(struct vscsibk_pend *pending_req, · line 610
Quoted 6 lines
drivers/xen/xen-scsiback.c +1
-1@@ -606,7 +606,7 @@ static void scsiback_device_action(struct vscsibk_pend *pending_req, tmr =kzalloc (sizeof (struct scsiback_tmr ),GFP_KERNEL );if (!tmr) {target_put_sess_cmd (se_cmd); - goto err; + goto do_resp; }
Hmm, I'm not convinced this is an improvement.
I'd rather rename the new error label to "put_cmd" and get rid of the braces in above if statement:
- if (!tmr) {
- target_put_sess_cmd(se_cmd);
- goto err;
- }
+ if (!tmr)
+ goto put_cmd;
and then in the error path:
-err:
+put_cmd:
+ target_put_sess_cmd(se_cmd);
+free_tmr:
kfree(tmr);
Juergen
Quoted 23 lines
drivers/xen/xen-scsiback.c +3
-2init_waitqueue_head (&tmr->tmr_wait);@@ -616,7 +616,7 @@ static void scsiback_device_action(struct vscsibk_pend *pending_req, unpacked_lun, tmr, act,GFP_KERNEL , tag, TARGET_SCF_ACK_KREF);if (rc) - goto err; + goto free_tmr;wait_event (tmr->tmr_wait,atomic_read (&tmr->tmr_complete));@@ -626,8 +626,9 @@ static void scsiback_device_action(struct vscsibk_pend *pending_req,scsiback_do_resp_with_sense (NULL , err,0 , pending_req);transport_generic_free_cmd (&pending_req->se_cmd,1 );return ; -err: +free_tmr:kfree (tmr); +do_resp:scsiback_do_resp_with_sense (NULL , err,0 , pending_req); }
Re: [PATCH 2/3] xen-scsiback: One function call less in scsiback_device_action() after error detection
Quoted 22 lines
drivers/xen/xen-scsiback.c static void scsiback_device_action(struct vscsibk_pend *pending_req, · line 610
Quoted 7 lines
drivers/xen/xen-scsiback.c +1
-1@@ -606,7 +606,7 @@ static void scsiback_device_action(struct vscsibk_pend *pending_req, tmr =kzalloc (sizeof (struct scsiback_tmr ),GFP_KERNEL );if (!tmr) {target_put_sess_cmd (se_cmd); - goto err; + goto do_resp; }Hmm, I'm not convinced this is an improvement.
I'd rather rename the new error label to "
put_cmd" and get rid of the braces in above if statement:(quoted diff) +2
-4- if (!tmr) { - target_put_sess_cmd(se_cmd); - goto err; - } + if (!tmr) + goto put_cmd;and then in the error path:
Review
Quoted 3 lines
(quoted diff) +2
-1-err: +put_cmd: + target_put_sess_cmd(se_cmd);
I am unsure on the relevance of this function on such a source position. Would it make sense to move it further down at the end?
Quoted 2 lines
+free_tmr:
kfree(tmr);
How do you think about to skip this function call after a memory allocation failure?
Regards,
Markus
Juergen Gross
maintainerRe: [PATCH 2/3] xen-scsiback: One function call less in scsiback_device_action() after error detection
Quoted 20 lines · SF Markus Elfring
Quoted 20 lines
drivers/xen/xen-scsiback.c static void scsiback_device_action(struct vscsibk_pend *pending_req, · line 610
Quoted 7 lines
drivers/xen/xen-scsiback.c +1
-1@@ -606,7 +606,7 @@ static void scsiback_device_action(struct vscsibk_pend *pending_req, tmr =kzalloc (sizeof (struct scsiback_tmr ),GFP_KERNEL );if (!tmr) {target_put_sess_cmd (se_cmd); - goto err; + goto do_resp; }Hmm, I'm not convinced this is an improvement.
I'd rather rename the new error label to "
put_cmd" and get rid of the braces in above if statement:(quoted diff) +2
-4- if (!tmr) { - target_put_sess_cmd(se_cmd); - goto err; - } + if (!tmr) + goto put_cmd;
Quoted 8 lines
Review
Quoted 5 lines
and then in the error path:
(quoted diff) +2
-1-err: +put_cmd: + target_put_sess_cmd(se_cmd);I am unsure on the relevance of this function on such a source position. Would it make sense to move it further down at the end?
You only want to call it in the first error case (allocation failure).
Quoted 5 lines
Quoted 2 lines
+free_tmr:
kfree(tmr);How do you think about to skip this function call after a memory allocation failure?
I think this just doesn't matter. If it were a hot path, yes. But trying to do micro-optimizations in an error path is just not worth the effort.
I like a linear error path containing all the needed cleanups best.
Juergen
Re: [PATCH 2/3] xen-scsiback: One function call less in scsiback_device_action() after error detection
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
drivers/xen/xen-scsiback.c static void scsiback_device_action(struct vscsibk_pend *pending_req, · line 610
Quoted 7 lines
drivers/xen/xen-scsiback.c +1
-1@@ -606,7 +606,7 @@ static void scsiback_device_action(struct vscsibk_pend *pending_req, tmr =kzalloc (sizeof (struct scsiback_tmr ),GFP_KERNEL );if (!tmr) {target_put_sess_cmd (se_cmd); - goto err; + goto do_resp; }Hmm, I'm not convinced this is an improvement.
I'd rather rename the new error label to "
put_cmd" and get rid of the braces in above if statement:(quoted diff) +2
-4- if (!tmr) { - target_put_sess_cmd(se_cmd); - goto err; - } + if (!tmr) + goto put_cmd;and then in the error path:
Quoted 8 lines
Quoted 6 lines
Review
Quoted 3 lines
(quoted diff) +2
-1-err: +put_cmd: + target_put_sess_cmd(se_cmd);I am unsure on the relevance of this function on such a source position. Would it make sense to move it further down at the end?
You only want to call it in the first error case (allocation failure).
Thanks for your clarification.
I find that my update suggestion (from Saturday) is still appropriate in this case.
https://lkml.org/lkml/2016/7/16/172
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
+free_tmr:
kfree(tmr);How do you think about to skip this function call after a memory allocation failure?
I think this just doesn't matter. If it were a hot path, yes. But trying to do micro-optimizations in an error path is just not worth the effort.
Would you like to reduce also the amount of function calls in such special run-time situations?
Quoted 1 line
I like a linear error path containing all the needed cleanups best.
I would prefer to keep the discussed single function call within the basic block of the if statement.
Have we got different opinions about the shown implementation details?
Regards,
Markus
Juergen Gross
maintainerRe: [PATCH 2/3] xen-scsiback: One function call less in scsiback_device_action() after error detection
Quoted 29 lines · SF Markus Elfring
Quoted 29 lines
Quoted 28 lines
Quoted 22 lines
drivers/xen/xen-scsiback.c static void scsiback_device_action(struct vscsibk_pend *pending_req, · line 610
Quoted 7 lines
drivers/xen/xen-scsiback.c +1
-1@@ -606,7 +606,7 @@ static void scsiback_device_action(struct vscsibk_pend *pending_req, tmr =kzalloc (sizeof (struct scsiback_tmr ),GFP_KERNEL );if (!tmr) {target_put_sess_cmd (se_cmd); - goto err; + goto do_resp; }Hmm, I'm not convinced this is an improvement.
I'd rather rename the new error label to "
put_cmd" and get rid of the braces in above if statement:(quoted diff) +2
-4- if (!tmr) { - target_put_sess_cmd(se_cmd); - goto err; - } + if (!tmr) + goto put_cmd;and then in the error path:
Review
Quoted 3 lines
(quoted diff) +2
-1-err: +put_cmd: + target_put_sess_cmd(se_cmd);I am unsure on the relevance of this function on such a source position. Would it make sense to move it further down at the end?
Quoted 7 lines
Quoted 1 line
You only want to call it in the first error case (allocation failure).
Thanks for your clarification.
I find that my update suggestion (from Saturday) is still appropriate in this case.
https://lkml.org/lkml/2016/7/16/172
And I still think it isn't an improvement: Nack
Quoted 11 lines
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
+free_tmr:
kfree(tmr);How do you think about to skip this function call after a memory allocation failure?
I think this just doesn't matter. If it were a hot path, yes. But trying to do micro-optimizations in an error path is just not worth the effort.
Would you like to reduce also the amount of function calls in such special run-time situations?
I just don't care for the extra 2 or 3 nsecs. Readability is more important here.
Quoted 6 lines
Quoted 1 line
I like a linear error path containing all the needed cleanups best.
I would prefer to keep the discussed single function call within the basic block of the if statement.
Have we got different opinions about the shown implementation details?
Yes.
Juergen
v2 cover xen-scsiback: Fine-tuning for scsiback_device_action()
From: Markus Elfring <[email protected]>
Date: Wed, 20 Jul 2016 13:20:04 +0200
Further update suggestions were taken into account after a patch was applied from static source code analysis.
Markus Elfring (3):
Delete an unnecessary check before the function call "kfree" Rename jump labels in scsiback_device_action() Pass a failure indication as a constant
drivers/xen/xen-scsiback.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
Signature · 1 line
2.9.2
PATCH v2 1/3 xen-scsiback: Delete an unnecessary check before the function call "kfree"
From: Markus Elfring <[email protected]>
Date: Tue, 19 Jul 2016 15:42:19 +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.
---
v2: Rebased on source files from "Linux next-20160719"
drivers/xen/xen-scsiback.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/xen/xen-scsiback.c +1 -2
@@ -627,8 +627,7 @@ static void scsiback_device_action(struct vscsibk_pend *pending_req,transport_generic_free_cmd (&pending_req->se_cmd,1 );return ; err: -if (tmr) -kfree (tmr); +kfree (tmr);scsiback_do_resp_with_sense (NULL , err,0 , pending_req); }
Signature · 1 line
2.9.2
Re: [PATCH v2 1/3] xen-scsiback: Delete an unnecessary check before the function call "kfree"
Quoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Tue, 19 Jul 2016 15:42:19 +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]>
Even if already given, here it is again:
Juergen
Re: [PATCH v2 1/3] xen-scsiback: 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: Tue, 19 Jul 2016 15:42:19 +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]>
Even if already given, here it is again:
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH v2 2/3 xen-scsiback: Rename jump labels in scsiback_device_action()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 20 Jul 2016 13:03:16 +0200
* Adjust jump targets according to the Linux coding style convention.
* A bit of refactoring for the control flow
---
v2: Rebased on source files from "Linux next-20160719"
Changes from a bit of code review
drivers/xen/xen-scsiback.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/xen/xen-scsiback.c +6 -6
@@ -604,10 +604,8 @@ static void scsiback_device_action(struct vscsibk_pend *pending_req,int rc, err =FAILED ; tmr =kzalloc (sizeof (struct scsiback_tmr ),GFP_KERNEL ); -if (!tmr) { -target_put_sess_cmd (se_cmd); - goto err; - } +if (!tmr) + goto put_cmd;init_waitqueue_head (&tmr->tmr_wait);
@@ -616,7 +614,7 @@ static void scsiback_device_action(struct vscsibk_pend *pending_req, unpacked_lun, tmr, act,GFP_KERNEL , tag, TARGET_SCF_ACK_KREF);if (rc) - goto err; + goto free_tmr;wait_event (tmr->tmr_wait,atomic_read (&tmr->tmr_complete));
@@ -626,7 +624,9 @@ static void scsiback_device_action(struct vscsibk_pend *pending_req,scsiback_do_resp_with_sense (NULL , err,0 , pending_req);transport_generic_free_cmd (&pending_req->se_cmd,1 );return ; -err: +put_cmd: +target_put_sess_cmd (se_cmd); +free_tmr:kfree (tmr);scsiback_do_resp_with_sense (NULL , err,0 , pending_req); }
Signature · 6 lines
2.9.2 -- 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 v2 2/3] xen-scsiback: Rename jump labels in scsiback_device_action()
Quoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 20 Jul 2016 13:03:16 +0200* Adjust jump targets according to the Linux coding style convention.
* A bit of refactoring for the control flow
Suggested-by Jürgen Groß <[email protected]>Signed-off-by Markus Elfring <[email protected]>
Juergen
--
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 v2 2/3] xen-scsiback: Rename jump labels in scsiback_device_action()
In reply to SF Markus ElfringQuoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 20 Jul 2016 13:03:16 +0200* Adjust jump targets according to the Linux coding style convention.
* A bit of refactoring for the control flow
Suggested-by Jürgen Groß <[email protected]>Signed-off-by Markus Elfring <[email protected]>
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH v2 3/3 xen-scsiback: Pass a failure indication as a constant
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 20 Jul 2016 13:12:33 +0200
Pass the constant "FAILED" in a function call directly instead of using an intialisation for a local variable.
---
v2: Rebased on source files from "Linux next-20160719"
drivers/xen/xen-scsiback.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/xen/xen-scsiback.c +2 -2
@@ -601,7 +601,7 @@ static void scsiback_device_action(struct vscsibk_pend *pending_req,struct se_cmd *se_cmd = &pending_req->se_cmd;struct scsiback_tmr *tmr;u64 unpacked_lun = pending_req->v2p->lun; -int rc, err =FAILED ; +int rc, err; tmr =kzalloc (sizeof (struct scsiback_tmr ),GFP_KERNEL );if (!tmr)
@@ -628,7 +628,7 @@ put_cmd:target_put_sess_cmd (se_cmd); free_tmr:kfree (tmr); -scsiback_do_resp_with_sense (NULL , err,0 , pending_req); +scsiback_do_resp_with_sense (NULL ,FAILED ,0 , pending_req); }/*
Signature · 1 line
2.9.2
Re: [PATCH v2 3/3] xen-scsiback: Pass a failure indication as a constant
Quoted 7 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 20 Jul 2016 13:12:33 +0200Pass the constant "FAILED" in a function call directly instead of using an intialisation for a local variable.
Signed-off-by Markus Elfring <[email protected]>
Even if already given, here it is again:
Juergen
Re: [PATCH v2 3/3] xen-scsiback: Pass a failure indication as a constant
In reply to SF Markus ElfringQuoted 7 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 20 Jul 2016 13:12:33 +0200Pass the constant "FAILED" in a function call directly instead of using an intialisation for a local variable.
Signed-off-by Markus Elfring <[email protected]>
Even if already given, here it is again:
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Juergen Gross
maintainerRe: [PATCH 2/3] xen-scsiback: One function call less in scsiback_device_action() after error detection
In reply to SF Markus ElfringQuoted 29 lines · SF Markus Elfring
Quoted 29 lines
Quoted 28 lines
Quoted 22 lines
drivers/xen/xen-scsiback.c static void scsiback_device_action(struct vscsibk_pend *pending_req, · line 610
Quoted 7 lines
drivers/xen/xen-scsiback.c +1
-1@@ -606,7 +606,7 @@ static void scsiback_device_action(struct vscsibk_pend *pending_req, tmr =kzalloc (sizeof (struct scsiback_tmr ),GFP_KERNEL );if (!tmr) {target_put_sess_cmd (se_cmd); - goto err; + goto do_resp; }Hmm, I'm not convinced this is an improvement.
I'd rather rename the new error label to "
put_cmd" and get rid of the braces in above if statement:(quoted diff) +2
-4- if (!tmr) { - target_put_sess_cmd(se_cmd); - goto err; - } + if (!tmr) + goto put_cmd;and then in the error path:
Review
Quoted 3 lines
(quoted diff) +2
-1-err: +put_cmd: + target_put_sess_cmd(se_cmd);I am unsure on the relevance of this function on such a source position. Would it make sense to move it further down at the end?
Quoted 7 lines
Quoted 1 line
You only want to call it in the first error case (allocation failure).
Thanks for your clarification.
I find that my update suggestion (from Saturday) is still appropriate in this case.
https://lkml.org/lkml/2016/7/16/172
And I still think it isn't an improvement: Nack
Quoted 11 lines
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
+free_tmr:
kfree(tmr);How do you think about to skip this function call after a memory allocation failure?
I think this just doesn't matter. If it were a hot path, yes. But trying to do micro-optimizations in an error path is just not worth the effort.
Would you like to reduce also the amount of function calls in such special run-time situations?
I just don't care for the extra 2 or 3 nsecs. Readability is more important here.
Quoted 6 lines
Quoted 1 line
I like a linear error path containing all the needed cleanups best.
I would prefer to keep the discussed single function call within the basic block of the if statement.
Have we got different opinions about the shown implementation details?
Yes.
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Juergen Gross
maintainerRe: [PATCH 2/3] xen-scsiback: One function call less in scsiback_device_action() after error detection
In reply to SF Markus ElfringQuoted 20 lines · SF Markus Elfring
Quoted 20 lines
drivers/xen/xen-scsiback.c static void scsiback_device_action(struct vscsibk_pend *pending_req, · line 610
Quoted 7 lines
drivers/xen/xen-scsiback.c +1
-1@@ -606,7 +606,7 @@ static void scsiback_device_action(struct vscsibk_pend *pending_req, tmr =kzalloc (sizeof (struct scsiback_tmr ),GFP_KERNEL );if (!tmr) {target_put_sess_cmd (se_cmd); - goto err; + goto do_resp; }Hmm, I'm not convinced this is an improvement.
I'd rather rename the new error label to "
put_cmd" and get rid of the braces in above if statement:(quoted diff) +2
-4- if (!tmr) { - target_put_sess_cmd(se_cmd); - goto err; - } + if (!tmr) + goto put_cmd;
Quoted 8 lines
Review
Quoted 5 lines
and then in the error path:
(quoted diff) +2
-1-err: +put_cmd: + target_put_sess_cmd(se_cmd);I am unsure on the relevance of this function on such a source position. Would it make sense to move it further down at the end?
You only want to call it in the first error case (allocation failure).
Quoted 5 lines
Quoted 2 lines
+free_tmr:
kfree(tmr);How do you think about to skip this function call after a memory allocation failure?
I think this just doesn't matter. If it were a hot path, yes. But trying to do micro-optimizations in an error path is just not worth the effort.
I like a linear error path containing all the needed cleanups best.
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Juergen Gross
maintainerRe: [PATCH 2/3] xen-scsiback: One function call less in scsiback_device_action() after error detection
In reply to SF Markus ElfringQuoted 19 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 16 Jul 2016 21:42:42 +0200The
kfree()function was called in one case by thescsiback_device_action()function during error handling even if the passed variable "tmr" contained a null pointer.Adjust jump targets according to the Linux coding style convention.
Signed-off-by Markus Elfring <[email protected]>--- drivers/xen/xen-scsiback.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/xen/xen-scsiback.c +0
-0
drivers/xen/xen-scsiback.c static void scsiback_device_action(struct vscsibk_pend *pending_req, · line 610
Quoted 6 lines
drivers/xen/xen-scsiback.c +1
-1@@ -606,7 +606,7 @@ static void scsiback_device_action(struct vscsibk_pend *pending_req, tmr =kzalloc (sizeof (struct scsiback_tmr ),GFP_KERNEL );if (!tmr) {target_put_sess_cmd (se_cmd); - goto err; + goto do_resp; }
Hmm, I'm not convinced this is an improvement.
I'd rather rename the new error label to "put_cmd" and get rid of the braces in above if statement:
- if (!tmr) {
- target_put_sess_cmd(se_cmd);
- goto err;
- }
+ if (!tmr)
+ goto put_cmd;
and then in the error path:
-err:
+put_cmd:
+ target_put_sess_cmd(se_cmd);
+free_tmr:
kfree(tmr);
Juergen
Quoted 13 lines
drivers/xen/xen-scsiback.c +1
-1init_waitqueue_head (&tmr->tmr_wait);@@ -616,7 +616,7 @@ static void scsiback_device_action(struct vscsibk_pend *pending_req, unpacked_lun, tmr, act,GFP_KERNEL , tag, TARGET_SCF_ACK_KREF);if (rc) - goto err; + goto free_tmr;wait_event (tmr->tmr_wait,atomic_read (&tmr->tmr_complete));
drivers/xen/xen-scsiback.c static void scsiback_device_action(struct vscsibk_pend *pending_req, · line 634
Quoted 10 lines
drivers/xen/xen-scsiback.c +2
-1@@ -626,8 +626,9 @@ static void scsiback_device_action(struct vscsibk_pend *pending_req,scsiback_do_resp_with_sense (NULL , err,0 , pending_req);transport_generic_free_cmd (&pending_req->se_cmd,1 );return ; -err: +free_tmr:kfree (tmr); +do_resp:scsiback_do_resp_with_sense (NULL , err,0 , pending_req); }
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 2/3 xen-scsiback: One function call less in scsiback_device_action() after error detection
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 16 Jul 2016 21:42:42 +0200
The kfree() function was called in one case by the scsiback_device_action() function during error handling even if the passed variable "tmr" contained a null pointer.
Adjust jump targets according to the Linux coding style convention.
--- drivers/xen/xen-scsiback.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/xen/xen-scsiback.c +4 -3
@@ -606,7 +606,7 @@ static void scsiback_device_action(struct vscsibk_pend *pending_req, tmr =kzalloc (sizeof (struct scsiback_tmr ),GFP_KERNEL );if (!tmr) {target_put_sess_cmd (se_cmd); - goto err; + goto do_resp; }init_waitqueue_head (&tmr->tmr_wait);
@@ -616,7 +616,7 @@ static void scsiback_device_action(struct vscsibk_pend *pending_req, unpacked_lun, tmr, act,GFP_KERNEL , tag, TARGET_SCF_ACK_KREF);if (rc) - goto err; + goto free_tmr;wait_event (tmr->tmr_wait,atomic_read (&tmr->tmr_complete));
@@ -626,8 +626,9 @@ static void scsiback_device_action(struct vscsibk_pend *pending_req,scsiback_do_resp_with_sense (NULL , err,0 , pending_req);transport_generic_free_cmd (&pending_req->se_cmd,1 );return ; -err: +free_tmr:kfree (tmr); +do_resp:scsiback_do_resp_with_sense (NULL , err,0 , pending_req); }
Signature · 7 lines
2.9.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH 3/3 xen-scsiback: Pass a failure indication as a constant
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 16 Jul 2016 21:55:01 +0200
Pass the constant "FAILED" in a function call directly instead of using an intialisation for a local variable.
--- drivers/xen/xen-scsiback.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/xen/xen-scsiback.c +2 -2
@@ -601,7 +601,7 @@ static void scsiback_device_action(struct vscsibk_pend *pending_req,struct se_cmd *se_cmd = &pending_req->se_cmd;struct scsiback_tmr *tmr;u64 unpacked_lun = pending_req->v2p->lun; -int rc, err =FAILED ; +int rc, err; tmr =kzalloc (sizeof (struct scsiback_tmr ),GFP_KERNEL );if (!tmr) {
@@ -629,7 +629,7 @@ static void scsiback_device_action(struct vscsibk_pend *pending_req, free_tmr:kfree (tmr); do_resp: -scsiback_do_resp_with_sense (NULL , err,0 , pending_req); +scsiback_do_resp_with_sense (NULL ,FAILED ,0 , pending_req); }/*
Signature · 1 line
2.9.1
Re: [PATCH 3/3] xen-scsiback: Pass a failure indication as a constant
Quoted 7 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 16 Jul 2016 21:55:01 +0200Pass the constant "FAILED" in a function call directly instead of using an intialisation for a local variable.
Signed-off-by Markus Elfring <[email protected]>
Juergen
Re: [PATCH 3/3] xen-scsiback: Pass a failure indication as a constant
In reply to SF Markus ElfringQuoted 7 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 16 Jul 2016 21:55:01 +0200Pass the constant "FAILED" in a function call directly instead of using an intialisation for a local variable.
Signed-off-by Markus Elfring <[email protected]>
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 3/3 xen-scsiback: Pass a failure indication as a constant
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 16 Jul 2016 21:55:01 +0200
Pass the constant "FAILED" in a function call directly instead of using an intialisation for a local variable.
--- drivers/xen/xen-scsiback.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/xen/xen-scsiback.c +2 -2
@@ -601,7 +601,7 @@ static void scsiback_device_action(struct vscsibk_pend *pending_req,struct se_cmd *se_cmd = &pending_req->se_cmd;struct scsiback_tmr *tmr;u64 unpacked_lun = pending_req->v2p->lun; -int rc, err =FAILED ; +int rc, err; tmr =kzalloc (sizeof (struct scsiback_tmr ),GFP_KERNEL );if (!tmr) {
@@ -629,7 +629,7 @@ static void scsiback_device_action(struct vscsibk_pend *pending_req, free_tmr:kfree (tmr); do_resp: -scsiback_do_resp_with_sense (NULL , err,0 , pending_req); +scsiback_do_resp_with_sense (NULL ,FAILED ,0 , pending_req); }/*
Signature · 7 lines
2.9.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
cover xen-scsiback: Fine-tuning for scsiback_device_action()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 16 Jul 2016 22:06:54 +0200
Further update suggestions were taken into account after a patch was applied from static source code analysis.
Markus Elfring (3):
Delete an unnecessary check before the function call "kfree" One function call less in scsiback_device_action() after error detection Pass a failure indication as a constant
drivers/xen/xen-scsiback.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
Signature · 7 lines
2.9.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
cover staging: ks7010: Fine-tuning for a SDIO card driver
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 17 Jul 2016 19:54:32 +0200
Further update suggestions were taken into account after a patch was applied from static source code analysis.
Markus Elfring (9):
Delete unnecessary checks before the function call "kfree" Delete unnecessary assignments for buffer variables Return directly after a failed kmalloc()
Rename jump labels
Delete unnecessary uses of the variable "retval" Delete unnecessary braces
Replace three printk() calls by pr_err()
Delete a variable in write_to_device()
Delete three unnecessary variable initialisations
drivers/staging/ks7010/ks7010_sdio.c | 263 ++++++++++++++--------------------- 1 file changed, 107 insertions(+), 156 deletions(-)
Signature · 1 line
2.9.1
PATCH 1/9 staging: ks7010: Delete unnecessary checks before the function call "kfree"
From: Markus Elfring <[email protected]>
Date: Sun, 17 Jul 2016 13:14:57 +0200
The kfree() function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/staging/ks7010/ks7010_sdio.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
drivers/staging/ks7010/ks7010_sdio.c +4 -9
@@ -732,8 +732,7 @@ static int ks7010_sdio_update_index(struct ks_wlan_private *priv, u32 index) goto error_out; } error_out: -if (data_buf) -kfree (data_buf); +kfree (data_buf);return rc; }
@@ -763,8 +762,7 @@ static int ks7010_sdio_data_compare(struct ks_wlan_private *priv, u32 address, goto error_out; } error_out: -if (read_buf) -kfree (read_buf); +kfree (read_buf);return rc; }
@@ -879,8 +877,7 @@ static int ks7010_upload_firmware(struct ks_wlan_private *priv,release_firmware (fw_entry); error_out0:sdio_release_host (card->func); -if (rom_buf) -kfree (rom_buf); +kfree (rom_buf);return rc; }
@@ -1199,9 +1196,7 @@ static void ks7010_sdio_remove(struct sdio_func *func)unregister_netdev (netdev);trx_device_exit (priv); -if (priv->ks_wlan_hw.read_buf) { -kfree (priv->ks_wlan_hw.read_buf); - } +kfree (priv->ks_wlan_hw.read_buf);free_netdev (priv->net_dev); card->priv =NULL ; }
Signature · 1 line
2.9.1
Re: [PATCH 1/9] staging: ks7010: Delete unnecessary checks before the function call "kfree"
Quoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 17 Jul 2016 13:14:57 +0200The
kfree()function tests whether its argument is NULL and then returns 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]>
PATCH 2/9 staging: ks7010: Delete unnecessary assignments for buffer variables
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 17 Jul 2016 13:38:46 +0200
A few variables were assigned a null pointer despite of the detail that they were immediately reassigned by the following statement. Thus remove such unnecessary assignments.
--- drivers/staging/ks7010/ks7010_sdio.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/staging/ks7010/ks7010_sdio.c +1 -4
@@ -711,7 +711,6 @@ static int ks7010_sdio_update_index(struct ks_wlan_private *priv, u32 index)int rc =0 ;int retval;unsigned char *data_buf; - data_buf =NULL ; data_buf =kmalloc (sizeof (u32),GFP_KERNEL );if (!data_buf) {
@@ -743,7 +742,7 @@ static int ks7010_sdio_data_compare(struct ks_wlan_private *priv, u32 address,int rc =0 ;int retval;unsigned char *read_buf; - read_buf =NULL ; + read_buf =kmalloc (ROM_BUFF_SIZE ,GFP_KERNEL );if (!read_buf) { rc =1 ;
@@ -776,8 +775,6 @@ static int ks7010_upload_firmware(struct ks_wlan_private *priv,int length;const struct firmware *fw_entry =NULL ; - rom_buf =NULL ; -/* buffer allocate */ rom_buf =kmalloc (ROM_BUFF_SIZE ,GFP_KERNEL );if (!rom_buf) {
Signature · 1 line
2.9.1
Re: [PATCH 2/9] staging: ks7010: Delete unnecessary assignments for buffer variables
Quoted 8 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 17 Jul 2016 13:38:46 +0200A few variables were assigned a null pointer despite of the detail that they were immediately reassigned by the following statement. Thus remove such unnecessary assignments.
Signed-off-by Markus Elfring <[email protected]>
PATCH 3/9 staging: ks7010: Return directly after a failed kmalloc()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 17 Jul 2016 15:55:02 +0200
Return directly after a memory allocation failed at the beginning.
--- drivers/staging/ks7010/ks7010_sdio.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-)
drivers/staging/ks7010/ks7010_sdio.c +7 -12
@@ -713,10 +713,8 @@ static int ks7010_sdio_update_index(struct ks_wlan_private *priv, u32 index)unsigned char *data_buf; data_buf =kmalloc (sizeof (u32),GFP_KERNEL ); -if (!data_buf) { - rc =1 ; - goto error_out; - } +if (!data_buf) +return 1 ;memcpy (data_buf, &index,sizeof (index)); retval =ks7010_sdio_write (priv,WRITE_INDEX , data_buf,sizeof (index));
@@ -744,10 +742,9 @@ static int ks7010_sdio_data_compare(struct ks_wlan_private *priv, u32 address,unsigned char *read_buf; read_buf =kmalloc (ROM_BUFF_SIZE ,GFP_KERNEL ); -if (!read_buf) { - rc =1 ; - goto error_out; - } +if (!read_buf) +return 1 ; + retval =ks7010_sdio_read (priv, address, read_buf, size);if (retval) { rc =2 ;
@@ -777,10 +774,8 @@ static int ks7010_upload_firmware(struct ks_wlan_private *priv,/* buffer allocate */ rom_buf =kmalloc (ROM_BUFF_SIZE ,GFP_KERNEL ); -if (!rom_buf) { - rc =3 ; - goto error_out0; - } +if (!rom_buf) +return 3 ;sdio_claim_host (card->func);
Signature · 1 line
2.9.1
Re: [PATCH 3/9] staging: ks7010: Return directly after a failed kmalloc()
Quoted 15 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 17 Jul 2016 15:55:02 +0200Return directly after a memory allocation failed at the beginning.
Signed-off-by Markus Elfring <[email protected]>--- drivers/staging/ks7010/ks7010_sdio.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-)drivers/staging/ks7010/ks7010_sdio.c +0
-0
drivers/staging/ks7010/ks7010_sdio.c static int ks7010_sdio_update_index(struct ks_wlan_private *priv, u32 index) · line 717
Quoted 9 lines
drivers/staging/ks7010/ks7010_sdio.c +2
-4@@ -713,10 +713,8 @@ static int ks7010_sdio_update_index(struct ks_wlan_private *priv, u32 index)unsigned char *data_buf; data_buf =kmalloc (sizeof (u32),GFP_KERNEL ); -if (!data_buf) { - rc =1 ; - goto error_out; - } +if (!data_buf) +return 1 ;
One could rather wonder why the function has such strange error values...
julia
Quoted 34 lines
drivers/staging/ks7010/ks7010_sdio.c +5
-9memcpy (data_buf, &index,sizeof (index)); retval =ks7010_sdio_write (priv,WRITE_INDEX , data_buf,sizeof (index));@@ -744,10 +742,9 @@ static int ks7010_sdio_data_compare(struct ks_wlan_private *priv, u32 address,unsigned char *read_buf; read_buf =kmalloc (ROM_BUFF_SIZE ,GFP_KERNEL ); -if (!read_buf) { - rc =1 ; - goto error_out; - } +if (!read_buf) +return 1 ; + retval =ks7010_sdio_read (priv, address, read_buf, size);if (retval) { rc =2 ;@@ -777,10 +774,8 @@ static int ks7010_upload_firmware(struct ks_wlan_private *priv,/* buffer allocate */ rom_buf =kmalloc (ROM_BUFF_SIZE ,GFP_KERNEL ); -if (!rom_buf) { - rc =3 ; - goto error_out0; - } +if (!rom_buf) +return 3 ;sdio_claim_host (card->func); --2.9.1
Re: [PATCH 3/9] staging: ks7010: Return directly after a failed kmalloc()
Quoted 21 lines · Julia Lawall
Quoted 17 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 17 Jul 2016 15:55:02 +0200Return directly after a memory allocation failed at the beginning.
Signed-off-by Markus Elfring <[email protected]>--- drivers/staging/ks7010/ks7010_sdio.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-)drivers/staging/ks7010/ks7010_sdio.c +0
-0@@ -713,10 +713,8 @@ static int ks7010_sdio_update_index(struct ks_wlan_private *priv, u32 index)unsigned char *data_buf;
Quoted 9 lines
drivers/staging/ks7010/ks7010_sdio.c static int ks7010_sdio_update_index(struct ks_wlan_private *priv, u32 index) · line 717
Quoted 7 lines
drivers/staging/ks7010/ks7010_sdio.c +2
-4data_buf =kmalloc (sizeof (u32),GFP_KERNEL ); -if (!data_buf) { - rc =1 ; - goto error_out; - } +if (!data_buf) +return 1 ;One could rather wonder why the function has such strange error values...
Agreed. Markus, can you check if we can use -ENOMEM in those places.
Re: [PATCH 3/9] staging: ks7010: Return directly after a failed kmalloc()
Quoted 13 lines
Quoted 12 lines
drivers/staging/ks7010/ks7010_sdio.c static int ks7010_sdio_update_index(struct ks_wlan_private *priv, u32 index) · line 717
Quoted 10 lines
drivers/staging/ks7010/ks7010_sdio.c +2
-4@@ -713,10 +713,8 @@ static int ks7010_sdio_update_index(struct ks_wlan_private *priv, u32 index)unsigned char *data_buf; data_buf =kmalloc (sizeof (u32),GFP_KERNEL ); -if (!data_buf) { - rc =1 ; - goto error_out; - } +if (!data_buf) +return 1 ;One could rather wonder why the function has such strange error values...
Quoted 1 line
Agreed. Markus, can you check if we can use
-ENOMEMin those places.
I find that I do not know this software good enough at the moment so that I could safely decide on the shown special error values. I guess that further clarification might be needed for affected implementation details.
Regards,
Markus
Wolfram Sang
Acked-byRe: [PATCH 3/9] staging: ks7010: Return directly after a failed kmalloc()
Quoted 13 lines · SF Markus Elfring
Quoted 13 lines
Quoted 12 lines
drivers/staging/ks7010/ks7010_sdio.c static int ks7010_sdio_update_index(struct ks_wlan_private *priv, u32 index) · line 717
Quoted 10 lines
drivers/staging/ks7010/ks7010_sdio.c +2
-4@@ -713,10 +713,8 @@ static int ks7010_sdio_update_index(struct ks_wlan_private *priv, u32 index)unsigned char *data_buf; data_buf =kmalloc (sizeof (u32),GFP_KERNEL ); -if (!data_buf) { - rc =1 ; - goto error_out; - } +if (!data_buf) +return 1 ;One could rather wonder why the function has such strange error values...
Quoted 6 lines
Quoted 1 line
Agreed. Markus, can you check if we can use
-ENOMEMin those places.I find that I do not know this software good enough at the moment so that I could safely decide on the shown special error values. I guess that further clarification might be needed for affected implementation details.
That's OK, too.
Re: staging: ks7010: Return directly after a failed kmalloc()
Quoted 6 lines
Quoted 2 lines
I guess that further clarification might be needed for affected implementation details.
That's OK, too.
Acked-by Wolfram Sang <[email protected]>
Does this acknowledgement include also the acceptance for the suggested change around calls of the functions "sdio_claim_host" and "sdio_release_host" within the implementation of the function "ks7010_upload_firmware"?
https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/drivers/staging/ks7010/ks7010_sdio.c?id123042d0dbf7635f052efc2ae69fd9af624f1d#n771
Regards,
Markus
Re: staging: ks7010: Return directly after a failed kmalloc()
Quoted 11 lines · SF Markus Elfring
Quoted 6 lines
Quoted 2 lines
I guess that further clarification might be needed for affected implementation details.
That's OK, too.
Acked-by Wolfram Sang <[email protected]>Does this acknowledgement include also the acceptance for the suggested change around calls of the functions "
sdio_claim_host" and "sdio_release_host" within the implementation of the function "ks7010_upload_firmware"?
Likely. Send a patch and we will see.
PATCH 4/9 staging: ks7010: Rename jump labels
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 17 Jul 2016 16:26:18 +0200
Adjust jump targets according to the Linux coding style convention.
--- drivers/staging/ks7010/ks7010_sdio.c | 81 +++++++++++++++++------------------- 1 file changed, 38 insertions(+), 43 deletions(-)
drivers/staging/ks7010/ks7010_sdio.c +38 -43
@@ -113,7 +113,7 @@ void ks_wlan_hw_sleep_doze_request(struct ks_wlan_private *priv)DPRINTK (1 ,"sleep_mode=%d\n" , priv->sleep_mode); } - out: +out: priv->sleep_mode =atomic_read (&priv->sleepstatus.status);return ; }
@@ -144,7 +144,7 @@ void ks_wlan_hw_sleep_wakeup_request(struct ks_wlan_private *priv)DPRINTK (1 ,"sleep_mode=%d\n" , priv->sleep_mode); } - out: +out: priv->sleep_mode =atomic_read (&priv->sleepstatus.status);return ; }
@@ -480,7 +480,7 @@ static void ks_wlan_hw_rx(void *dev, uint16_t size)/* rx_event_task((void *)priv); */ tasklet_schedule (&priv->ks_wlan_hw.rx_bh_task); - error_out: +error_out:return ; }
@@ -523,18 +523,18 @@ static void ks7010_rw_function(struct work_struct *work)queue_delayed_work (priv->ks_wlan_hw.ks7010sdio_wq, &priv->ks_wlan_hw.rw_wq,1 ); } - goto err_out; + goto release_host; }/* sleep mode doze */ if (atomic_read (&priv->sleepstatus.doze_request) =1 ) {ks_wlan_hw_sleep_doze_request (priv); - goto err_out; + goto release_host; }/* sleep mode wakeup */ if (atomic_read (&priv->sleepstatus.wakeup_request) =1 ) {ks_wlan_hw_sleep_wakeup_request (priv); - goto err_out; + goto release_host; }/* read (WriteStatus/ReadDataSize FN1:00_0014) */
@@ -543,7 +543,7 @@ static void ks7010_rw_function(struct work_struct *work)if (retval) {DPRINTK (1 ," error : WSTATUS_RSIZE=%02X psstatus=%d\n" , rw_data,atomic_read (&priv->psstatus.status)); - goto err_out; + goto release_host; }DPRINTK (4 ,"WSTATUS_RSIZE=%02X\n" , rw_data);
@@ -555,8 +555,7 @@ static void ks7010_rw_function(struct work_struct *work)tx_device_task ((void *)priv); }_ks_wlan_hw_power_save (priv); - - err_out: +release_host:sdio_release_host (priv->ks_wlan_hw.sdio_card->func);return ;
@@ -664,7 +663,7 @@ static void ks_sdio_interrupt(struct sdio_func *func) }while (rsize); } - intr_out: +intr_out:queue_delayed_work (priv->ks_wlan_hw.ks7010sdio_wq, &priv->ks_wlan_hw.rw_wq,0 );return ;
@@ -720,15 +719,13 @@ static int ks7010_sdio_update_index(struct ks_wlan_private *priv, u32 index) retval =ks7010_sdio_write (priv,WRITE_INDEX , data_buf,sizeof (index));if (retval) { rc =2 ; - goto error_out; + goto free_buf; } retval =ks7010_sdio_write (priv,READ_INDEX , data_buf,sizeof (index)); -if (retval) { +if (retval) rc =3 ; - goto error_out; - } - error_out: +free_buf:kfree (data_buf);return rc; }
@@ -748,16 +745,15 @@ static int ks7010_sdio_data_compare(struct ks_wlan_private *priv, u32 address, retval =ks7010_sdio_read (priv, address, read_buf, size);if (retval) { rc =2 ; - goto error_out; + goto free_buf; } retval =memcmp (data, read_buf, size);if (retval) {DPRINTK (0 ,"data compare error (%d) \n" , retval); rc =3 ; - goto error_out; } - error_out: +free_buf:kfree (read_buf);return rc; }
@@ -784,7 +780,7 @@ static int ks7010_upload_firmware(struct ks_wlan_private *priv,if (rw_data =GCR_A_RUN ) {DPRINTK (0 ,"MAC firmware running ...\n" ); rc =0 ; - goto error_out0; + goto release_host; } retval =request_firmware (&fw_entry,ROM_FILE , &priv->ks_wlan_hw.sdio_card->func->dev);
@@ -814,14 +810,14 @@ static int ks7010_upload_firmware(struct ks_wlan_private *priv, KS7010_IRAM_ADDRESS + offset);if (retval) { rc =6 ; - goto error_out1; + goto release_fw; }/* Write data */ retval =ks7010_sdio_write (priv,DATA_WINDOW , rom_buf, size);if (retval) { rc =8 ; - goto error_out1; + goto release_fw; }/* compare */
@@ -829,7 +825,7 @@ static int ks7010_upload_firmware(struct ks_wlan_private *priv,ks7010_sdio_data_compare (priv,DATA_WINDOW , rom_buf, size);if (retval) { rc =9 ; - goto error_out1; + goto release_fw; } n += size;
@@ -840,7 +836,7 @@ static int ks7010_upload_firmware(struct ks_wlan_private *priv, retval =ks7010_sdio_write (priv,GCR_A , &rw_data,sizeof (rw_data));if (retval) { rc =11 ; - goto error_out1; + goto release_fw; }DPRINTK (4 ," REMAP Request : GCR_A=%02X\n" , rw_data);
@@ -851,7 +847,7 @@ static int ks7010_upload_firmware(struct ks_wlan_private *priv,ks7010_sdio_read (priv,GCR_A , &rw_data,sizeof (rw_data));if (retval) { rc =11 ; - goto error_out1; + goto release_fw; }if (rw_data =GCR_A_RUN )break ;
@@ -860,14 +856,13 @@ static int ks7010_upload_firmware(struct ks_wlan_private *priv,if ((50 ) <= n) {DPRINTK (1 ,"firmware can't start\n" ); rc =12 ; - goto error_out1; + goto release_fw; } rc =0 ; - - error_out1: +release_fw:release_firmware (fw_entry); - error_out0: +release_host:sdio_release_host (card->func);kfree (rom_buf);return rc;
@@ -994,20 +989,20 @@ static int ks7010_sdio_probe(struct sdio_func *func, ret =sdio_enable_func (func);DPRINTK (5 ,"sdio_enable_func() %d\n" , ret);if (ret) - goto error_free_card; + goto free_card;/* interrupt disable */ sdio_writeb (func,0 ,INT_ENABLE , &ret);if (ret) - goto error_free_card; + goto free_card;sdio_writeb (func,0xff ,INT_PENDING , &ret);if (ret) - goto error_disable_func; + goto disable_func;/* setup interrupt handler */ ret =sdio_claim_irq (func, ks_sdio_interrupt);if (ret) - goto error_disable_func; + goto disable_func;sdio_release_host (func);
@@ -1020,11 +1015,11 @@ static int ks7010_sdio_probe(struct sdio_func *func, netdev =alloc_etherdev (sizeof (*priv));if (netdev =NULL ) {printk (KERN_ERR "ks7010 : Unable to alloc new net device\n" ); - goto error_release_irq; + goto release_irq; }if (dev_alloc_name (netdev,"wlan%d" ) <0 ) {printk (KERN_ERR "ks7010 : Couldn't get name!\n" ); - goto error_free_netdev; + goto free_dev; } priv =netdev_priv (netdev);
@@ -1038,7 +1033,7 @@ static int ks7010_sdio_probe(struct sdio_func *func, priv->ks_wlan_hw.read_buf =NULL ; priv->ks_wlan_hw.read_buf =kmalloc (RX_DATA_SIZE ,GFP_KERNEL );if (!priv->ks_wlan_hw.read_buf) { - goto error_free_netdev; + goto free_dev; } priv->dev_state =DEVICE_STATE_PREBOOT ; priv->net_dev = netdev;
@@ -1066,7 +1061,7 @@ static int ks7010_sdio_probe(struct sdio_func *func,printk (KERN_ERR "ks7010: firmware load failed !! retern code = %d\n" , ret); - goto error_free_read_buf; + goto free_buf; }/* interrupt setting */
@@ -1094,7 +1089,7 @@ static int ks7010_sdio_probe(struct sdio_func *func, priv->ks_wlan_hw.ks7010sdio_wq =create_workqueue ("ks7010sdio_wq" );if (!priv->ks_wlan_hw.ks7010sdio_wq) {DPRINTK (1 ,"create_workqueue failed !!\n" ); - goto error_free_read_buf; + goto free_buf; }INIT_DELAYED_WORK (&priv->ks_wlan_hw.rw_wq, ks7010_rw_function);
@@ -1102,22 +1097,22 @@ static int ks7010_sdio_probe(struct sdio_func *func, ret =register_netdev (priv->net_dev);if (ret) - goto error_free_read_buf; + goto free_buf;return 0 ; - error_free_read_buf: +free_buf:kfree (priv->ks_wlan_hw.read_buf); priv->ks_wlan_hw.read_buf =NULL ; - error_free_netdev: +free_dev:free_netdev (priv->net_dev); card->priv =NULL ; - error_release_irq: +release_irq:sdio_claim_host (func);sdio_release_irq (func); - error_disable_func: +disable_func:sdio_disable_func (func); - error_free_card: +free_card:sdio_release_host (func);sdio_set_drvdata (func,NULL );kfree (card);
Signature · 1 line
2.9.1
Re: [PATCH 4/9] staging: ks7010: Rename jump labels
Quoted 4 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 17 Jul 2016 16:26:18 +0200Adjust jump targets according to the Linux coding style convention.
Really? Is that documented somewhere?
Quoting Jean Delvare:
"> It is generally accepted to indent labels with a single space. This
Quoted 1 line
avoids breaking the -p option of diff."
So, NACK for now unless we know 'diff' has been fixed.
Re: staging: ks7010: Rename jump labels
Quoted 3 lines
Quoted 1 line
Adjust jump targets according to the Linux coding style convention.
Really? Is that documented somewhere?
How do you think about information from the chapter "7: Centralized exiting of functions"?
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/CodingStyle?idGef4ad2684d380dd6d596140fb79395115c3950#n389
Quoted 4 lines
Quoting Jean Delvare:
"> It is generally accepted to indent labels with a single space. This
Quoted 1 line
avoids breaking the -p option of diff."
Would you like to take another look at the warning "LEADING_SPACE"?
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/scripts/checkpatch.pl?idGef4ad2684d380dd6d596140fb79395115c3950#n3004
Does such a check need further considerations?
Quoted 1 line
So, NACK for now unless we know 'diff' has been fixed.
I am also curious on corresponding software evolution.
Regards,
Markus
Re: staging: ks7010: Rename jump labels
Hello Markus, Wolfram,
Quoted 6 lines · SF Markus Elfring
Quoted 3 lines
Quoted 1 line
Adjust jump targets according to the Linux coding style convention.
Really? Is that documented somewhere?
How do you think about information from the chapter "7: Centralized exiting of functions"?
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/CodingStyle?idGef4ad2684d380dd6d596140fb79395115c3950#n389
I'm not impressed by this piece of documentation. For example, <<also don't name them after the goto location like "err_kmalloc_failed:">> is as unclear as you can get. It would be much better to tell what to name them, if the author thinks it really matters. (Personally I think it is out of scope of coding style rules.)
Back to the lack of space before labels, it's at best a personal preference. If you insist on standardizing, I'd call it a bug in the documentation, which should be fixed. One space before label is the way to go.
Quoted 1 line
Quoted 1 line
Quoting Jean Delvare:
I'm honored :)
Quoted 7 lines
Quoted 2 lines
"> It is generally accepted to indent labels with a single space. This
Quoted 1 line
avoids breaking the -p option of diff."
Would you like to take another look at the warning "
LEADING_SPACE"?
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/scripts/checkpatch.pl?idGef4ad2684d380dd6d596140fb79395115c3950#n3004Does such a check need further considerations?
checkpatch has become so complex, it's full of false positives, trying to enforce rules just because one developer wants to force his view on all others. I stopped following everything the script says long ago. I'm cherry-picking now.
That being said... checkpatch does not complain about leading space before labels. Not even with --strict. So why are you mentioning it here?
Quoted 1 line
Quoted 1 line
So, NACK for now unless we know 'diff' has been fixed.
Full nack from myself as well. Just looking at the thread on lkml makes me feel dizzy. When you are about to send that amount of messages, you should pause and think again. Is it really worth it? I think I'd be less annoyed by regular spam.
Quoted 1 line
I am also curious on corresponding software evolution.
I wouldn't consider it a bug. Despite the description of option -p in the diff man page calling it C specific, it looks very generic to me. As I understand it, it looks for any line not starting with a blank and containing at least one letter (or maybe just starting with a letter - I didn't look at the code.) Thankfully it doesn't try to parse C. So it depends on how you indent your code. Live with it.
It's been that way for so long that changing it now is hardly an option. That change would be seen as a gratuitous regression by many (including myself.) And for the record, "git diff" behaves exactly the same. So it's a de facto standard.
Signature · 2 lines
Jean Delvare SUSE L3 Support
Re: staging: ks7010: Rename jump labels
Thank you very much for the heads up, Jean!
Re: staging: ks7010: Rename jump labels
In reply to Jean DelvareQuoted 4 lines
Quoted 2 lines
How do you think about information from the chapter "7: Centralized exiting of functions"?
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/CodingStyle?idGef4ad2684d380dd6d596140fb79395115c3950#n389I'm not impressed by this piece of documentation.
I would also appreciate further improvements there.
Quoted 3 lines
Back to the lack of space before labels, it's at best a personal preference. If you insist on standardizing, I'd call it a bug in the documentation, which should be fixed. One space before label is the way to go.
Would you like to contribute another patch for such a coding style issue?
Quoted 2 lines
That being said... checkpatch does not complain about leading space before labels. Not even with --strict. So why are you mentioning it here?
How do you think about a similar software update?
staging: lustre: Fix a jump label position in osc_get_info()
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?idÇ1d264543f759fea147734cb63de36397817534
https://lkml.org/lkml/2015/12/21/401
Quoted 1 line
Just looking at the thread on lkml makes me feel dizzy.
I understand your concern to some degree.
Quoted 2 lines
When you are about to send that amount of messages, you should pause and think again.
This happened already.
Quoted 1 line
Is it really worth it?
I came to such a conclusion for the shown source code clean-up. Some software developers can also support it.
Quoted 1 line
I think I'd be less annoyed by regular spam.
It can be harder occasionally to become familiar and comfortable with the suggested change pattern.
Could you accept other details from my update suggestion?
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: staging: ks7010: Rename jump labels
Hi Markus,
Quoted 5 lines · SF Markus Elfring
Quoted 4 lines
Quoted 2 lines
How do you think about information from the chapter "7: Centralized exiting of functions"?
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/CodingStyle?idGef4ad2684d380dd6d596140fb79395115c3950#n389I'm not impressed by this piece of documentation.
Quoted 8 lines
I would also appreciate further improvements there.
Quoted 3 lines
Back to the lack of space before labels, it's at best a personal preference. If you insist on standardizing, I'd call it a bug in the documentation, which should be fixed. One space before label is the way to go.
Would you like to contribute another patch for such a coding style issue?
I just sent a patch out, let's see what people think about it.
Quoted 8 lines
Quoted 2 lines
That being said... checkpatch does not complain about leading space before labels. Not even with --strict. So why are you mentioning it here?
How do you think about a similar software update?
staging: lustre: Fix a jump label position in
osc_get_info()
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?idÇ1d264543f759fea147734cb63de36397817534
https://lkml.org/lkml/2015/12/21/401
Intending labels with a tab is wrong, so fixing it is welcome. I'd turn the tab into a space instead, for reasons explained before, but no indentation at all is still better than a tab.
Signature · 6 lines
Jean Delvare SUSE L3 Support -- 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: staging: ks7010: Rename jump labels
In reply to Jean DelvareQuoted 2 lines
That being said... checkpatch does not complain about leading space before labels. Not even with --strict. So why are you mentioning it here?
I remembered a warning like "INDENTED_LABEL" instead.
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/scripts/checkpatch.pl?id’d21ac74a9e3c09b0b01c764e530657e4c85c49#n4326
How do you generally think about jump label renaming?
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: staging: ks7010: Rename jump labels
Hi Markus,
Quoted 5 lines · SF Markus Elfring
Quoted 2 lines
That being said... checkpatch does not complain about leading space before labels. Not even with --strict. So why are you mentioning it here?
I remembered a warning like "
INDENTED_LABEL" instead.
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/scripts/checkpatch.pl?id’d21ac74a9e3c09b0b01c764e530657e4c85c49#n4326
"#goto labels aren't indented, allow a single space however"
Can't be clearer :-)
Quoted 1 line
How do you generally think about jump label renaming?
Renaming from "out0:", "out1:" etc to something meaningful, yes. Did you have anything else in mind?
Signature · 6 lines
Jean Delvare SUSE L3 Support -- 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: staging: ks7010: Rename jump labels
Quoted 5 lines
"#goto labels aren't indented, allow a single space however"
Can't be clearer :-)
Should such information from a comment in this script be also explicitly mentioned in the document "CodingStyle" anyhow?
How should the support for indentation of jump labels with
a single space be expressed in all relevant Linux development documentation?
Quoted 3 lines
Quoted 1 line
How do you generally think about jump label renaming?
Renaming from "out0:", "out1:" etc to something meaningful, yes.
I suggest to take another look at such identifiers.
Would you like to support the renaming of a label like "error_out1" (in the function "ks7010_upload_firmware" for example)?
Quoted 1 line
Did you have anything else in mind?
Not really for this update suggestion.
Will the software evolution be continued also with information from the topic "Source code review around jump label usage"?
https://lkml.org/lkml/2015/12/11/378
http://article.gmane.org/gmane.linux.kernel/2106190
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: staging: ks7010: Rename jump labels
Hi Markus,
Quoted 8 lines · SF Markus Elfring
Quoted 3 lines
Quoted 1 line
How do you generally think about jump label renaming?
Renaming from "out0:", "out1:" etc to something meaningful, yes.
I suggest to take another look at such identifiers.
Would you like to support the renaming of a label like "
error_out1" (in the function "ks7010_upload_firmware" for example)?
They should be renamed too. Anything using numbers instead of explicit labels should be updated. I included the reasons in the patch I just sent, hopefully the documentation is clearer now.
Quoted 4 lines
Will the software evolution be continued also with information from the topic "Source code review around jump label usage"?
https://lkml.org/lkml/2015/12/11/378
http://article.gmane.org/gmane.linux.kernel/2106190
Personally I see no value in such statistics. Either labels are wrong (either wrong indentation or wrong name) and should be fixed, or they are correct and you should not touch them. Whether the same label name is used somewhere else is irrelevant. Labels are local by nature, so uniqueness isn't a goal at all, only correctness.
Signature · 2 lines
Jean Delvare SUSE L3 Support
Re: staging: ks7010: Rename jump labels
Quoted 4 lines
Quoted 2 lines
Would you like to support the renaming of a label like "
error_out1" (in the function "ks7010_upload_firmware" for example)?They should be renamed too. Anything using numbers instead of explicit
Interesting …
Quoted 1 line
Anything using numbers instead of explicit labels should be updated.
Would you dare to search for corresponding update candidates explicitly by special semantic patch scripts?
Quoted 2 lines
I included the reasons in the patch I just sent,
hopefully the documentation is clearer now.
I am curious on how feedback will evolve for your suggestion "CodingStyle: Clarify and complete chapter 7".
https://lkml.org/lkml/2016/7/25/207
How do you think about to show a shorter label like "free_bar" (instead of "err_free_bar") as an example?
Quoted 5 lines
Quoted 3 lines
"Source code review around jump label usage"?
https://lkml.org/lkml/2015/12/11/378
http://article.gmane.org/gmane.linux.kernel/2106190Personally I see no value in such statistics.
Do they indicate any code smells eventually?
Quoted 2 lines
Either labels are wrong (either wrong indentation or wrong name) and should be fixed, or they are correct and you should not touch them.
Do you find such changes worthwhile (without touching also any surrounding source code)?
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: staging: ks7010: Rename jump labels
Hello Markus,
Quoted 5 lines · SF Markus Elfring
Quoted 4 lines
Quoted 2 lines
Would you like to support the renaming of a label like "
error_out1" (in the function "ks7010_upload_firmware" for example)?They should be renamed too. Anything using numbers instead of explicit
Quoted 7 lines
Interesting …
Quoted 1 line
Anything using numbers instead of explicit labels should be updated.
Would you dare to search for corresponding update candidates explicitly by special semantic patch scripts?
No. You started it all, and I do not have more time to devote to it. I do not find it all particularly interesting, to be honest. I have a lot of other things to work on, of much greater interest (to me.)
Quoted 9 lines
Quoted 2 lines
I included the reasons in the patch I just sent,
hopefully the documentation is clearer now.I am curious on how feedback will evolve for your suggestion "CodingStyle: Clarify and complete chapter 7".
https://lkml.org/lkml/2016/7/25/207How do you think about to show a shorter label like "
free_bar" (instead of "err_free_bar") as an example?
Up to whoever writes and maintains the code. As most things should be in the absence of a compelling reason to normalize.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
"Source code review around jump label usage"?
https://lkml.org/lkml/2015/12/11/378
http://article.gmane.org/gmane.linux.kernel/2106190Personally I see no value in such statistics.
Do they indicate any code smells eventually?
I have no idea what you mean, sorry.
Quoted 5 lines
Quoted 2 lines
Either labels are wrong (either wrong indentation or wrong name) and should be fixed, or they are correct and you should not touch them.
Do you find such changes worthwhile (without touching also any surrounding source code)?
You keep asking more and more from me. May I remind you this is your "project" in the first place, not mine? If you have no idea what should be done, or even whether anything should be done, then just move on to something else. I have already expressed all my views on this topic and am not willing to say anything more about it.
Thanks,
Signature · 7 lines
Jean Delvare SUSE L3 Support -- 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: staging: ks7010: Rename jump labels
Quoted 1 line
I have a lot of other things to work on, of much greater interest (to me.)
This is fine.
Thanks for your feedback.
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Personally I see no value in such statistics.
Do they indicate any code smells eventually?
I have no idea what you mean, sorry.
How do you think about to take another look at additional views around software development methodologies?
Examples:
https://en.wikipedia.org/wiki/Code_smell
https://en.wikipedia.org/wiki/Software_metric#Common_software_measurements
Do you occasionally care about a length distribution for identifiers (like goto labels) of up to 39 characters?
Quoted 1 line
You keep asking more and more from me.
I am looking also for further clarification based on your responses.
Quoted 1 line
May I remind you this is your "project" in the first place, not mine?
I invite also others to contribute to such a software evolution.
Quoted 1 line
If you have no idea what should be done,
I have got some ideas for changes. I am just unsure on how the corresponding acceptance will evolve.
Quoted 1 line
or even whether anything should be done, then just move on to something else.
This can also happen.
Quoted 1 line
I have already expressed all my views on this topic
I guess that related information will be reconsidered later.
Quoted 1 line
and am not willing to say anything more about it.
I would interpret the suggestion "CodingStyle: Clarify and complete chapter 7" in the way that your interest grew for a moment.
https://lkml.org/lkml/2016/7/25/207
https://www.mail-archive.com/[email protected]/msg1195846.html
I am curious if you are going to contribute to the proposed improvement a bit more.
Regards,
Markus
PATCH 5/9 staging: ks7010: Delete unnecessary uses of the variable "retval"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 17 Jul 2016 18:15:23 +0200
Some return values can also be directly used for various condition checks. Thus remove a local variable for intermediate assignments.
--- drivers/staging/ks7010/ks7010_sdio.c | 81 +++++++++++++++--------------------- 1 file changed, 34 insertions(+), 47 deletions(-)
drivers/staging/ks7010/ks7010_sdio.c +34 -38
@@ -90,7 +90,6 @@ static int ks7010_sdio_write(struct ks_wlan_private *priv, unsigned int address,void ks_wlan_hw_sleep_doze_request (struct ks_wlan_private *priv) {unsigned char rw_data; -int retval;DPRINTK (4 ,"\n" );
@@ -99,9 +98,10 @@ void ks_wlan_hw_sleep_doze_request(struct ks_wlan_private *priv)if (atomic_read (&priv->sleepstatus.status) =0 ) { rw_data =GCR_B_DOZE ; - retval -ks7010_sdio_write (priv,GCR_B , &rw_data,sizeof (rw_data)); -if (retval) { +if (ks7010_sdio_write (priv, +GCR_B , + &rw_data, +sizeof (rw_data))) {DPRINTK (1 ," error : GCR_B=%02X\n" , rw_data); goto out; }
@@ -121,7 +121,6 @@ out:void ks_wlan_hw_sleep_wakeup_request (struct ks_wlan_private *priv) {unsigned char rw_data; -int retval;DPRINTK (4 ,"\n" );
@@ -130,9 +129,10 @@ void ks_wlan_hw_sleep_wakeup_request(struct ks_wlan_private *priv)if (atomic_read (&priv->sleepstatus.status) =1 ) { rw_data =WAKEUP_REQ ; - retval -ks7010_sdio_write (priv,WAKEUP , &rw_data,sizeof (rw_data)); -if (retval) { +if (ks7010_sdio_write (priv, +WAKEUP , + &rw_data, +sizeof (rw_data))) {DPRINTK (1 ," error : WAKEUP=%02X\n" , rw_data); goto out; }
@@ -152,16 +152,15 @@ out:void ks_wlan_hw_wakeup_request (struct ks_wlan_private *priv) {unsigned char rw_data; -int retval;DPRINTK (4 ,"\n" );if (atomic_read (&priv->psstatus.status) =PS_SNOOZE ) { rw_data =WAKEUP_REQ ; - retval -ks7010_sdio_write (priv,WAKEUP , &rw_data,sizeof (rw_data)); -if (retval) { +if (ks7010_sdio_write (priv, +WAKEUP , + &rw_data, +sizeof (rw_data)))DPRINTK (1 ," error : WAKEUP=%02X\n" , rw_data); - }DPRINTK (4 ,"wake up : WAKEUP=%02X\n" , rw_data); priv->last_wakeup = jiffies; ++priv->wakeup_count;
@@ -175,7 +174,6 @@ int _ks_wlan_hw_power_save(struct ks_wlan_private *priv) {int rc =0 ;unsigned char rw_data; -int retval;if (priv->reg.powermgt =POWMGT_ACTIVE_MODE )return rc;
@@ -198,11 +196,11 @@ int _ks_wlan_hw_power_save(struct ks_wlan_private *priv)if (!atomic_read (&priv->psstatus.confirm_wait) && !atomic_read (&priv->psstatus.snooze_guard) && !cnt_txqbody (priv)) { - retval -ks7010_sdio_read (priv,INT_PENDING , +if (ks7010_sdio_read (priv, +INT_PENDING , &rw_data, -sizeof (rw_data)); -if (retval) { +sizeof (rw_data)) + ) {DPRINTK (1 ," error : INT_PENDING=%02X\n" , rw_data);
@@ -212,12 +210,11 @@ int _ks_wlan_hw_power_save(struct ks_wlan_private *priv) }if (!rw_data) { rw_data =GCR_B_DOZE ; - retval -ks7010_sdio_write (priv, +if (ks7010_sdio_write (priv,GCR_B , &rw_data, -sizeof (rw_data)); -if (retval) { +sizeof (rw_data)) + ) {DPRINTK (1 ," error : GCR_B=%02X\n" , rw_data);
@@ -413,7 +410,6 @@ static void rx_event_task(unsigned long dev)static void ks_wlan_hw_rx (void *dev,uint16_t size) {struct ks_wlan_private *priv = (struct ks_wlan_private *)dev; -int retval;struct rx_device_buffer *rx_buffer;struct hostif_hdr *hdr;unsigned char read_status;
@@ -429,12 +425,11 @@ static void ks_wlan_hw_rx(void *dev, uint16_t size) } rx_buffer = &priv->rx_dev.rx_dev_buff[priv->rx_dev.qtail]; - retval -ks7010_sdio_read (priv,DATA_WINDOW , &rx_buffer->data[0 ], -hif_align_size (size)); -if (retval) { +if (ks7010_sdio_read (priv, +DATA_WINDOW , + &rx_buffer->data[0 ], +hif_align_size (size))) goto error_out; - }/* length check */ if (size >2046 || size =0 ) {
@@ -446,12 +441,11 @@ static void ks_wlan_hw_rx(void *dev, uint16_t size)#endif /* rx_status update */ read_status =READ_STATUS_IDLE ; - retval -ks7010_sdio_write (priv,READ_STATUS , &read_status, -sizeof (read_status)); -if (retval) { +if (ks7010_sdio_write (priv, +READ_STATUS , + &read_status, +sizeof (read_status)))DPRINTK (1 ," error : READ_STATUS=%02X\n" , read_status); - } goto error_out; }
@@ -462,12 +456,11 @@ static void ks_wlan_hw_rx(void *dev, uint16_t size)/* read status update */ read_status =READ_STATUS_IDLE ; - retval -ks7010_sdio_write (priv,READ_STATUS , &read_status, -sizeof (read_status)); -if (retval) { +if (ks7010_sdio_write (priv, +READ_STATUS , + &read_status, +sizeof (read_status)))DPRINTK (1 ," error : READ_STATUS=%02X\n" , read_status); - }DPRINTK (4 ,"READ_STATUS=%02X\n" , read_status);if (atomic_read (&priv->psstatus.confirm_wait)) {
@@ -489,7 +482,6 @@ static void ks7010_rw_function(struct work_struct *work)struct hw_info_t *hw;struct ks_wlan_private *priv;unsigned char rw_data; -int retval; hw = container_of(work, struct hw_info_t, rw_wq.work); priv = container_of(hw, struct ks_wlan_private, ks_wlan_hw);
@@ -538,9 +530,7 @@ static void ks7010_rw_function(struct work_struct *work) }/* read (WriteStatus/ReadDataSize FN1:00_0014) */ - retval -ks7010_sdio_read (priv,WSTATUS_RSIZE , &rw_data,sizeof (rw_data)); -if (retval) { +if (ks7010_sdio_read (priv,WSTATUS_RSIZE , &rw_data,sizeof (rw_data))) {DPRINTK (1 ," error : WSTATUS_RSIZE=%02X psstatus=%d\n" , rw_data,atomic_read (&priv->psstatus.status)); goto release_host;
@@ -708,7 +698,6 @@ static void trx_device_exit(struct ks_wlan_private *priv)static int ks7010_sdio_update_index (struct ks_wlan_private *priv,u32 index) {int rc =0 ; -int retval;unsigned char *data_buf; data_buf =kmalloc (sizeof (u32),GFP_KERNEL );
@@ -716,14 +705,12 @@ static int ks7010_sdio_update_index(struct ks_wlan_private *priv, u32 index)return 1 ;memcpy (data_buf, &index,sizeof (index)); - retval =ks7010_sdio_write (priv,WRITE_INDEX , data_buf,sizeof (index)); -if (retval) { +if (ks7010_sdio_write (priv,WRITE_INDEX , data_buf,sizeof (index))) { rc =2 ; goto free_buf; } - retval =ks7010_sdio_write (priv,READ_INDEX , data_buf,sizeof (index)); -if (retval) +if (ks7010_sdio_write (priv,READ_INDEX , data_buf,sizeof (index))) rc =3 ; free_buf:kfree (data_buf);
Signature · 1 line
2.9.1
Re: [PATCH 5/9] staging: ks7010: Delete unnecessary uses of the variable "retval"
Quoted 24 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 17 Jul 2016 18:15:23 +0200Some return values can also be directly used for various condition checks. Thus remove a local variable for intermediate assignments.
Signed-off-by Markus Elfring <[email protected]>--- drivers/staging/ks7010/ks7010_sdio.c | 81 +++++++++++++++--------------------- 1 file changed, 34 insertions(+), 47 deletions(-)drivers/staging/ks7010/ks7010_sdio.c +0
-1@@ -90,7 +90,6 @@ static int ks7010_sdio_write(struct ks_wlan_private *priv, unsigned int address,void ks_wlan_hw_sleep_doze_request (struct ks_wlan_private *priv) {unsigned char rw_data; -int retval;DPRINTK (4 ,"\n" );
drivers/staging/ks7010/ks7010_sdio.c void ks_wlan_hw_sleep_doze_request(struct ks_wlan_private *priv) · line 104
Quoted 9 lines
drivers/staging/ks7010/ks7010_sdio.c +4
-2@@ -99,9 +98,10 @@ void ks_wlan_hw_sleep_doze_request(struct ks_wlan_private *priv)if (atomic_read (&priv->sleepstatus.status) =0 ) { rw_data =GCR_B_DOZE ; - retval > -ks7010_sdio_write (priv,GCR_B , &rw_data,sizeof (rw_data)); -if (retval) { +if (ks7010_sdio_write (priv, +GCR_B , + &rw_data, +sizeof (rw_data))) {
A multi-line function call in an if test does not look nice at all. The original code was an easy-to-read expectable pattern.
julia
Quoted 185 lines
drivers/staging/ks7010/ks7010_sdio.c +30
-36DPRINTK (1 ," error : GCR_B=%02X\n" , rw_data); goto out; }@@ -121,7 +121,6 @@ out:void ks_wlan_hw_sleep_wakeup_request (struct ks_wlan_private *priv) {unsigned char rw_data; -int retval;DPRINTK (4 ,"\n" );@@ -130,9 +129,10 @@ void ks_wlan_hw_sleep_wakeup_request(struct ks_wlan_private *priv)if (atomic_read (&priv->sleepstatus.status) =1 ) { rw_data =WAKEUP_REQ ; - retval > -ks7010_sdio_write (priv,WAKEUP , &rw_data,sizeof (rw_data)); -if (retval) { +if (ks7010_sdio_write (priv, +WAKEUP , + &rw_data, +sizeof (rw_data))) {DPRINTK (1 ," error : WAKEUP=%02X\n" , rw_data); goto out; }@@ -152,16 +152,15 @@ out:void ks_wlan_hw_wakeup_request (struct ks_wlan_private *priv) {unsigned char rw_data; -int retval;DPRINTK (4 ,"\n" );if (atomic_read (&priv->psstatus.status) =PS_SNOOZE ) { rw_data =WAKEUP_REQ ; - retval > -ks7010_sdio_write (priv,WAKEUP , &rw_data,sizeof (rw_data)); -if (retval) { +if (ks7010_sdio_write (priv, +WAKEUP , + &rw_data, +sizeof (rw_data)))DPRINTK (1 ," error : WAKEUP=%02X\n" , rw_data); - }DPRINTK (4 ,"wake up : WAKEUP=%02X\n" , rw_data); priv->last_wakeup = jiffies; ++priv->wakeup_count;@@ -175,7 +174,6 @@ int _ks_wlan_hw_power_save(struct ks_wlan_private *priv) {int rc =0 ;unsigned char rw_data; -int retval;if (priv->reg.powermgt =POWMGT_ACTIVE_MODE )return rc;@@ -198,11 +196,11 @@ int _ks_wlan_hw_power_save(struct ks_wlan_private *priv)if (!atomic_read (&priv->psstatus.confirm_wait) && !atomic_read (&priv->psstatus.snooze_guard) && !cnt_txqbody (priv)) { - retval > -ks7010_sdio_read (priv,INT_PENDING , +if (ks7010_sdio_read (priv, +INT_PENDING , &rw_data, -sizeof (rw_data)); -if (retval) { +sizeof (rw_data)) + ) {DPRINTK (1 ," error : INT_PENDING=%02X\n" , rw_data);@@ -212,12 +210,11 @@ int _ks_wlan_hw_power_save(struct ks_wlan_private *priv) }if (!rw_data) { rw_data =GCR_B_DOZE ; - retval > -ks7010_sdio_write (priv, +if (ks7010_sdio_write (priv,GCR_B , &rw_data, -sizeof (rw_data)); -if (retval) { +sizeof (rw_data)) + ) {DPRINTK (1 ," error : GCR_B=%02X\n" , rw_data);@@ -413,7 +410,6 @@ static void rx_event_task(unsigned long dev)static void ks_wlan_hw_rx (void *dev,uint16_t size) {struct ks_wlan_private *priv = (struct ks_wlan_private *)dev; -int retval;struct rx_device_buffer *rx_buffer;struct hostif_hdr *hdr;unsigned char read_status;@@ -429,12 +425,11 @@ static void ks_wlan_hw_rx(void *dev, uint16_t size) } rx_buffer = &priv->rx_dev.rx_dev_buff[priv->rx_dev.qtail]; - retval > -ks7010_sdio_read (priv,DATA_WINDOW , &rx_buffer->data[0 ], -hif_align_size (size)); -if (retval) { +if (ks7010_sdio_read (priv, +DATA_WINDOW , + &rx_buffer->data[0 ], +hif_align_size (size))) goto error_out; - }/* length check */ if (size >2046 || size =0 ) {@@ -446,12 +441,11 @@ static void ks_wlan_hw_rx(void *dev, uint16_t size)#endif /* rx_status update */ read_status =READ_STATUS_IDLE ; - retval > -ks7010_sdio_write (priv,READ_STATUS , &read_status, -sizeof (read_status)); -if (retval) { +if (ks7010_sdio_write (priv, +READ_STATUS , + &read_status, +sizeof (read_status)))DPRINTK (1 ," error : READ_STATUS=%02X\n" , read_status); - } goto error_out; }@@ -462,12 +456,11 @@ static void ks_wlan_hw_rx(void *dev, uint16_t size)/* read status update */ read_status =READ_STATUS_IDLE ; - retval > -ks7010_sdio_write (priv,READ_STATUS , &read_status, -sizeof (read_status)); -if (retval) { +if (ks7010_sdio_write (priv, +READ_STATUS , + &read_status, +sizeof (read_status)))DPRINTK (1 ," error : READ_STATUS=%02X\n" , read_status); - }DPRINTK (4 ,"READ_STATUS=%02X\n" , read_status);if (atomic_read (&priv->psstatus.confirm_wait)) {@@ -489,7 +482,6 @@ static void ks7010_rw_function(struct work_struct *work)struct hw_info_t *hw;struct ks_wlan_private *priv;unsigned char rw_data; -int retval; hw = container_of(work, struct hw_info_t, rw_wq.work); priv = container_of(hw, struct ks_wlan_private, ks_wlan_hw);@@ -538,9 +530,7 @@ static void ks7010_rw_function(struct work_struct *work) }/* read (WriteStatus/ReadDataSize FN1:00_0014) */ - retval > -ks7010_sdio_read (priv,WSTATUS_RSIZE , &rw_data,sizeof (rw_data)); -if (retval) { +if (ks7010_sdio_read (priv,WSTATUS_RSIZE , &rw_data,sizeof (rw_data))) {DPRINTK (1 ," error : WSTATUS_RSIZE=%02X psstatus=%d\n" , rw_data,atomic_read (&priv->psstatus.status)); goto release_host;@@ -708,7 +698,6 @@ static void trx_device_exit(struct ks_wlan_private *priv)static int ks7010_sdio_update_index (struct ks_wlan_private *priv,u32 index) {int rc =0 ; -int retval;unsigned char *data_buf; data_buf =kmalloc (sizeof (u32),GFP_KERNEL );@@ -716,14 +705,12 @@ static int ks7010_sdio_update_index(struct ks_wlan_private *priv, u32 index)return 1 ;memcpy (data_buf, &index,sizeof (index)); - retval =ks7010_sdio_write (priv,WRITE_INDEX , data_buf,sizeof (index)); -if (retval) { +if (ks7010_sdio_write (priv,WRITE_INDEX , data_buf,sizeof (index))) { rc =2 ; goto free_buf; } - retval =ks7010_sdio_write (priv,READ_INDEX , data_buf,sizeof (index)); -if (retval) +if (ks7010_sdio_write (priv,READ_INDEX , data_buf,sizeof (index))) rc =3 ; free_buf:kfree (data_buf); --2.9.1
Re: [PATCH 5/9] staging: ks7010: Delete unnecessary uses of the variable "retval"
Quoted 29 lines · Julia Lawall
Quoted 25 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 17 Jul 2016 18:15:23 +0200Some return values can also be directly used for various condition checks. Thus remove a local variable for intermediate assignments.
Signed-off-by Markus Elfring <[email protected]>--- drivers/staging/ks7010/ks7010_sdio.c | 81 +++++++++++++++--------------------- 1 file changed, 34 insertions(+), 47 deletions(-)drivers/staging/ks7010/ks7010_sdio.c +0
-1@@ -90,7 +90,6 @@ static int ks7010_sdio_write(struct ks_wlan_private *priv, unsigned int address,void ks_wlan_hw_sleep_doze_request (struct ks_wlan_private *priv) {unsigned char rw_data; -int retval;DPRINTK (4 ,"\n" );@@ -99,9 +98,10 @@ void ks_wlan_hw_sleep_doze_request(struct ks_wlan_private *priv)
Quoted 12 lines
drivers/staging/ks7010/ks7010_sdio.c void ks_wlan_hw_sleep_doze_request(struct ks_wlan_private *priv) · line 104
Quoted 9 lines
drivers/staging/ks7010/ks7010_sdio.c +4
-3if (atomic_read (&priv->sleepstatus.status) ==0 ) { rw_data =GCR_B_DOZE ; - retval = -ks7010_sdio_write (priv,GCR_B , &rw_data,sizeof (rw_data)); -if (retval) { +if (ks7010_sdio_write (priv, +GCR_B , + &rw_data, +sizeof (rw_data))) {A multi-line function call in an if test does not look nice at all. The original code was an easy-to-read expectable pattern.
I agree. I am not strict on the 80 char limit, especially in cases like the above.
Re: [PATCH 5/9] staging: ks7010: Delete unnecessary uses of the variable "retval"
Quoted 22 lines
Quoted 10 lines
Quoted 10 lines
drivers/staging/ks7010/ks7010_sdio.c +0
-1@@ -90,7 +90,6 @@ static int ks7010_sdio_write(struct ks_wlan_private *priv, unsigned int address,void ks_wlan_hw_sleep_doze_request (struct ks_wlan_private *priv) {unsigned char rw_data; -int retval;DPRINTK (4 ,"\n" );@@ -99,9 +98,10 @@ void ks_wlan_hw_sleep_doze_request(struct ks_wlan_private *priv)Quoted 11 lines
drivers/staging/ks7010/ks7010_sdio.c void ks_wlan_hw_sleep_doze_request(struct ks_wlan_private *priv) · line 104
Quoted 8 lines
drivers/staging/ks7010/ks7010_sdio.c +4
-2if (atomic_read (&priv->sleepstatus.status) =0 ) { rw_data =GCR_B_DOZE ; - retval >>> - ks7010_sdio_write(priv, GCR_B, &rw_data, sizeof(rw_data)); -if (retval) { +if (ks7010_sdio_write (priv, +GCR_B , + &rw_data, +sizeof (rw_data))) {A multi-line function call in an if test does not look nice at all. The original code was an easy-to-read expectable pattern.
Quoted 2 lines
I agree. I am not strict on the 80 char limit, especially in cases like the above.
Would you try an other source code formatting for the suggested change pattern?
Regards,
Markus
Re: [PATCH 5/9] staging: ks7010: Delete unnecessary uses of the variable "retval"
Quoted 14 lines
Quoted 14 lines
Quoted 13 lines
drivers/staging/ks7010/ks7010_sdio.c void ks_wlan_hw_sleep_doze_request(struct ks_wlan_private *priv) · line 104
Quoted 10 lines
drivers/staging/ks7010/ks7010_sdio.c +4
-3if (atomic_read (&priv->sleepstatus.status) ==0 ) { rw_data =GCR_B_DOZE ; - retval = -ks7010_sdio_write (priv,GCR_B , &rw_data,sizeof (rw_data)); -if (retval) { +if (ks7010_sdio_write (priv, +GCR_B , + &rw_data, +sizeof (rw_data))) {A multi-line function call in an if test does not look nice at all. The original code was an easy-to-read expectable pattern.
Quoted 4 lines
Quoted 2 lines
I agree. I am not strict on the 80 char limit, especially in cases like the above.
Would you try an other source code formatting for the suggested change pattern?
I don't understand the question?
Re: [PATCH 5/9] staging: ks7010: Delete unnecessary uses of the variable "retval"
Quoted 13 lines · Wolfram Sang
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
drivers/staging/ks7010/ks7010_sdio.c void ks_wlan_hw_sleep_doze_request(struct ks_wlan_private *priv) · line 104
Quoted 9 lines
drivers/staging/ks7010/ks7010_sdio.c +4
-2if (atomic_read (&priv->sleepstatus.status) =0 ) { rw_data =GCR_B_DOZE ; - retval > > >>> - ks7010_sdio_write(priv, GCR_B, &rw_data, sizeof(rw_data)); -if (retval) { +if (ks7010_sdio_write (priv, +GCR_B , + &rw_data, +sizeof (rw_data))) {A multi-line function call in an if test does not look nice at all. The original code was an easy-to-read expectable pattern.
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
I agree. I am not strict on the 80 char limit, especially in cases like the above.
Would you try an other source code formatting for the suggested change pattern?
I don't understand the question?
I think the original code was fine. x = blah(); if (x) ... is a perfectly familiar kernel coding pattern. There is no benefit in terms of performance or understandability in dropping the variable.
julia
Re: [PATCH 5/9] staging: ks7010: Delete unnecessary uses of the variable "retval"
Quoted 21 lines · Julia Lawall
Quoted 17 lines · Wolfram Sang
Quoted 17 lines
Quoted 16 lines
Quoted 13 lines
drivers/staging/ks7010/ks7010_sdio.c void ks_wlan_hw_sleep_doze_request(struct ks_wlan_private *priv) · line 104
Quoted 10 lines
drivers/staging/ks7010/ks7010_sdio.c +4
-3if (atomic_read (&priv->sleepstatus.status) ==0 ) { rw_data =GCR_B_DOZE ; - retval = -ks7010_sdio_write (priv,GCR_B , &rw_data,sizeof (rw_data)); -if (retval) { +if (ks7010_sdio_write (priv, +GCR_B , + &rw_data, +sizeof (rw_data))) {A multi-line function call in an if test does not look nice at all. The original code was an easy-to-read expectable pattern.
I agree. I am not strict on the 80 char limit, especially in cases like the above.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Would you try an other source code formatting for the suggested change pattern?
I don't understand the question?
I think the original code was fine. x =
blah(); if (x) ... is a perfectly familiar kernel coding pattern. There is no benefit in terms of performance or understandability in dropping the variable.
I certainly agree to that.
Re: staging: ks7010: Delete unnecessary uses of the variable "retval"
In reply to Julia LawallQuoted 1 line
I think the original code was fine.
I suggest to reconsider involved implementation details once more.
Quoted 1 line
x =
blah(); if (x) ... is a perfectly familiar kernel coding pattern.
I can agree to such a general information.
Quoted 1 line
There is no benefit in terms of performance
It might be possible that a good compiler can also optimise some unnecessary variable accesses away.
Examples for further background information:
* "Minimize local variables"
https://eventhelix.com/realtimemantra/basics/optimizingcandcppcode.htm#Minimize%20Local%20Variables
* "Temporary Objects" by Danny Kalev
http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum8
Quoted 1 line
or understandability in dropping the variable.
I guess that we have got different opinions on such an aspect.
* Do you really want to assign every return value from a function call to an extra variable before it is used again?
* How many reading and understanding capacity do you need for each extra variable?
Regards,
Markus
Re: staging: ks7010: Delete unnecessary uses of the variable "retval"
Quoted 7 lines · SF Markus Elfring
Quoted 1 line
I think the original code was fine.
I suggest to reconsider involved implementation details once more.
Quoted 1 line
x =
blah(); if (x) ... is a perfectly familiar kernel coding pattern.
Quoted 7 lines
I can agree to such a general information.
Quoted 1 line
There is no benefit in terms of performance
It might be possible that a good compiler can also optimise some unnecessary variable accesses away.
A compiler written by an undergrad can optimize the variable away in this case. That's what compilers do.
Quoted 8 lines
Examples for further background information:
* "Minimize local variables"
https://eventhelix.com/realtimemantra/basics/optimizingcandcppcode.htm#Minimize%20Local%20Variables* "Temporary Objects" by Danny Kalev
http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum8
Quoted 6 lines
Quoted 1 line
or understandability in dropping the variable.
I guess that we have got different opinions on such an aspect.
* Do you really want to assign every return value from a function call to an extra variable before it is used again?
If it's a choice between 1) function call on many lines, 2) function call over 80 characters, and 3) extra variable, I definitely prefer the extra variable.
julia
Quoted 11 lines
* How many reading and understanding capacity do you need for each extra variable?
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: staging: ks7010: Delete unnecessary uses of the variable "retval"
Quoted 7 lines
Quoted 3 lines
* Do you really want to assign every return value from a function call to an extra variable before it is used again?
If it's a choice between 1) function call on many lines, 2) function call over 80 characters, and 3) extra variable, I definitely prefer the extra variable.
+1
Re: staging: ks7010: Delete unnecessary uses of the variable "retval"
In reply to Wolfram SangQuoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
drivers/staging/ks7010/ks7010_sdio.c void ks_wlan_hw_sleep_doze_request(struct ks_wlan_private *priv) · line 104
Quoted 8 lines
drivers/staging/ks7010/ks7010_sdio.c +4
-2if (atomic_read (&priv->sleepstatus.status) =0 ) { rw_data =GCR_B_DOZE ; - retval >>>>> - ks7010_sdio_write(priv, GCR_B, &rw_data, sizeof(rw_data)); -if (retval) { +if (ks7010_sdio_write (priv, +GCR_B , + &rw_data, +sizeof (rw_data))) {A multi-line function call in an if test does not look nice at all. The original code was an easy-to-read expectable pattern.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
I agree. I am not strict on the 80 char limit, especially in cases like the above.
Will this line length limitation trigger any more collateral evolution in the discussed software module?
Quoted 3 lines
Quoted 1 line
Would you try an other source code formatting for the suggested change pattern?
I don't understand the question?
Can you follow expectations around the proposed refactoring of any function implementations?
Regards,
Markus
Re: staging: ks7010: Delete unnecessary uses of the variable "retval"
Quoted 20 lines · SF Markus Elfring
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
drivers/staging/ks7010/ks7010_sdio.c void ks_wlan_hw_sleep_doze_request(struct ks_wlan_private *priv) · line 104
Quoted 9 lines
drivers/staging/ks7010/ks7010_sdio.c +4
-3if (atomic_read (&priv->sleepstatus.status) ==0 ) { rw_data =GCR_B_DOZE ; - retval = -ks7010_sdio_write (priv,GCR_B , &rw_data,sizeof (rw_data)); -if (retval) { +if (ks7010_sdio_write (priv, +GCR_B , + &rw_data, +sizeof (rw_data))) {A multi-line function call in an if test does not look nice at all. The original code was an easy-to-read expectable pattern.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
I agree. I am not strict on the 80 char limit, especially in cases like the above.
Will this line length limitation trigger any more collateral evolution in the discussed software module?
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Would you try an other source code formatting for the suggested change pattern?
I don't understand the question?
Can you follow expectations around the proposed refactoring of any function implementations?
I don't understand both questions. Maybe you need to give examples?
[Cocci] Changing return value determination in if statements with SmPL
Hello,
I am trying the software combination "spatch version 1.0.5-00058-g36edc2b-dirty compiled with OCaml version 4.03.0" out a bit more with the following approach.
@checking_function_calls_directly@
identifier checker, retval, work;
parameter list pl;
statement is, es;
type rt;
@@
rt checker(...)
{
...
-retval = work(pl);
if (
- retval
+ work(pl)
)
is else
es
...
}
elfring at Sonne:~/Projekte/Coccinelle/janitor> spatch.opt -sp-file checking_function_calls_directly1.cocci ~/Projekte/Linux/next-patched/drivers/staging/ks7010/ks7010_sdio.cinit_defs_builtins: /usr/local/lib64/coccinelle/standard.h
minus: parse error:
File "checking_function_calls_directly1.cocci", line 10, column 15, charpos = 151
around = 'pl',
whole content = -retval = work(pl);
Do I overlook anything in my SmPL script?
Regards,
Markus
[Cocci] Changing return value determination in if statements with SmPL
Quoted 36 lines · SF Markus Elfring
Hello,
I am trying the software combination "spatch version 1.0.5-00058-g36edc2b-dirty compiled with OCaml version 4.03.0" out a bit more with the following approach.
@checking_function_calls_directly@
identifier checker, retval, work;
parameter list pl;
statement is, es;
type rt;
@@
rt checker(...)
{
...(quoted diff) +1
-2-retval = work(pl); if ( - retval + work(pl) ) is else es }elfring at Sonne:~/Projekte/Coccinelle/janitor> spatch.opt -sp-file
checking_function_calls_directly1.cocci~/Projekte/Linux/next-patched/drivers/staging/ks7010/ks7010_sdio.cinit_defs_builtins:/usr/local/lib64/coccinelle/standard.h
minus: parse error:
File "checking_function_calls_directly1.cocci", line 10, column 15, charpos = 151
around = 'pl',
whole content = -retval = work(pl);
Quoted 1 line
Do I overlook anything in my SmPL script?
A parameter list is something that comes after the name of a function in the function header. Something like int x, int y, in foo (int x, int y) { ... }. Probably you want an expression list.
julia
[Cocci] Changing return value determination in if statements with SmPL
Quoted 3 lines
A parameter list is something that comes after the name of a function in the function header. Something like int x, int y, in foo (int x, int y) { ... }. Probably you want an expression list.
* How do you call the list usually that is used for the definition before the function body?
* Did I get inappropriate expectations from a description around a "parameter-list-declarator"?
http://en.cppreference.com/w/c/language/function_definition
* The following SmPL script variant seems to work better.
@checking_function_calls_directly@
identifier checker, retval, work;
expression list el;
statement is, es;
type rt;
@@
rt checker(...)
{
<+...
-retval = work(el);
if (
- retval
+ work(el)
)
is else
es
...+>
}
elfring at Sonne:~/Projekte/Coccinelle/janitor> spatch.opt -sp-file checking_function_calls_directly2.cocci ~/Projekte/Linux/next-patched/drivers/staging/ks7010/ks7010_sdio.cinit_defs_builtins: /usr/local/lib64/coccinelle/standard.h
HANDLING: /home/elfring/Projekte/Linux/next-patched/drivers/staging/ks7010/ks7010_sdio.c
tmp/cocci-output-1578-3a5e93-ks7010_sdio.c renamed from home/elfring/Projekte/Linux/next-patched/drivers/staging/ks7010/ks7010_sdio.c +1 -3
@@ -99,9 +99,7 @@ void ks_wlan_hw_sleep_doze_request(strucif (atomic_read (&priv->sleepstatus.status) ==0 ) { rw_data =GCR_B_DOZE ; - retval = -ks7010_sdio_write (priv,GCR_B , &rw_data,sizeof (rw_data)); -if (retval) { +if (ks7010_sdio_write (priv,GCR_B , &rw_data,sizeof (rw_data))) {DPRINTK (1 ," error : GCR_B=%02X\n" , rw_data); goto out; }
?
Regards,
Markus
[Cocci] Changing return value determination in if statements with SmPL
Quoted 6 lines · SF Markus Elfring
Quoted 3 lines
A parameter list is something that comes after the name of a function in the function header. Something like int x, int y, in foo (int x, int y) { ... }. Probably you want an expression list.
* How do you call the list usually that is used for the definition before the function body?
parameter list
Quoted 4 lines
* Did I get inappropriate expectations from a description around a "parameter-list-declarator"?
http://en.cppreference.com/w/c/language/function_definition
Apparently. A link from taht page quite clearly says:
parameter-list - either the single keyword void or a
comma-separated list of parameters, which may end with an ellipsis parameter
julia
Quoted 47 lines
* The following SmPL script variant seems to work better.
@checking_function_calls_directly@
identifier checker, retval, work;
expression list el;
statement is, es;
type rt;
@@
rt checker(...)
{
<+...(quoted diff) +1
-2-retval = work(el); if ( - retval + work(el) ) is else es ...+> }elfring at Sonne:~/Projekte/Coccinelle/janitor> spatch.opt -sp-file
checking_function_calls_directly2.cocci~/Projekte/Linux/next-patched/drivers/staging/ks7010/ks7010_sdio.cinit_defs_builtins:/usr/local/lib64/coccinelle/standard.h
HANDLING:/home/elfring/Projekte/Linux/next-patched/drivers/staging/ks7010/ks7010_sdio.c
diff =tmp/cocci-output-1578-3a5e93-ks7010_sdio.c renamed from home/elfring/Projekte/Linux/next-patched/drivers/staging/ks7010/ks7010_sdio.c +1
-3@@ -99,9 +99,7 @@ void ks_wlan_hw_sleep_doze_request(strucif (atomic_read (&priv->sleepstatus.status) ==0 ) { rw_data =GCR_B_DOZE ; - retval = -ks7010_sdio_write (priv,GCR_B , &rw_data,sizeof (rw_data)); -if (retval) { +if (ks7010_sdio_write (priv,GCR_B , &rw_data,sizeof (rw_data))) {DPRINTK (1 ," error : GCR_B=%02X\n" , rw_data); goto out; }?
Regards,
Markus
[Cocci] Better explanation for the usage of expression/parameter lists with SmPL?
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
A parameter list is something that comes after the name of a function in the function header. Something like int x, int y, in foo (int x, int y) { ... }. Probably you want an expression list.
* How do you call the list usually that is used for the definition before the function body?
parameter list
It seems that we have got the same understanding here.
Quoted 4 lines
Quoted 2 lines
* Did I get inappropriate expectations from a description around a "parameter-list-declarator"?
http://en.cppreference.com/w/c/language/function_definitionApparently.
I am surprised by this feedback.
Quoted 2 lines
parameter-list - either the single keyword void or a comma-separated list of parameters, which may end with an ellipsis parameter
How does this description fit to the term "expression list" in the semantic patch language?
Regards,
Markus
[Cocci] Better explanation for the usage of expression/parameter lists with SmPL?
Quoted 17 lines · SF Markus Elfring
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
A parameter list is something that comes after the name of a function in the function header. Something like int x, int y, in foo (int x, int y) { ... }. Probably you want an expression list.
* How do you call the list usually that is used for the definition before the function body?
parameter list
It seems that we have got the same understanding here.
Quoted 4 lines
Quoted 2 lines
* Did I get inappropriate expectations from a description around a "parameter-list-declarator"?
http://en.cppreference.com/w/c/language/function_definitionApparently.
Quoted 8 lines
I am surprised by this feedback.
Quoted 2 lines
parameter-list - either the single keyword void or a comma-separated list of parameters, which may end with an ellipsis parameter
How does this description fit to the term "expression list" in the semantic patch language?
Not at all.
int f(int x, int y) <---- parameter list
{
g(1, 2, 3, 4, 5): <---- expression list
}
julia
[Cocci] Better explanation for the usage of expression/parameter lists with SmPL?
Quoted 4 lines
int
f(int x, int y)<---- parameter list{ g(1, 2, 3, 4, 5): <---- expression list }
I'm sorry if I were confused too much about these places for a moment. Thanks for your quick help.
Regards,
Markus
Re: staging: ks7010: Delete unnecessary uses of the variable "retval"
In reply to Wolfram SangQuoted 4 lines
Quoted 2 lines
Can you follow expectations around the proposed refactoring of any function implementations?
I don't understand both questions. Maybe you need to give examples?
I suggest to try the following script (semantic patch for working with the Coccinelle software) out on the discussed source files.
@checking_function_calls_directly@
identifier checker, retval, work;
expression list el;
statement is, es;
type rt;
@@
rt checker(...)
{
<+...
-retval = work(el);
if (
- retval
+ work(el)
)
is else
es
...+>
}
Do you find such a source code transformation useful?
Regards,
Markus
Re: staging: ks7010: Delete unnecessary uses of the variable "retval"
Quoted 2 lines
Do you find such a source code transformation useful?
No. I already gave that answer by agreeing to Julia's viewpoint.
PATCH 6/9 staging: ks7010: Delete unnecessary braces
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 17 Jul 2016 18:39:03 +0200
Do not use curly brackets at some source code places where a single statement should be sufficient.
--- drivers/staging/ks7010/ks7010_sdio.c | 48 ++++++++++++------------------------ 1 file changed, 16 insertions(+), 32 deletions(-)
drivers/staging/ks7010/ks7010_sdio.c +16 -32
@@ -109,9 +109,8 @@ void ks_wlan_hw_sleep_doze_request(struct ks_wlan_private *priv)DPRINTK (3 ,"sleep_mode=SLP_SLEEP\n" );atomic_set (&priv->sleepstatus.status,1 ); priv->last_doze = jiffies; - }else { + }else DPRINTK (1 ,"sleep_mode=%d\n" , priv->sleep_mode); - } out: priv->sleep_mode =atomic_read (&priv->sleepstatus.status);
@@ -140,9 +139,8 @@ void ks_wlan_hw_sleep_wakeup_request(struct ks_wlan_private *priv)atomic_set (&priv->sleepstatus.status,0 ); priv->last_wakeup = jiffies; ++priv->wakeup_count; - }else { + }else DPRINTK (1 ,"sleep_mode=%d\n" , priv->sleep_mode); - } out: priv->sleep_mode =atomic_read (&priv->sleepstatus.status);
@@ -164,10 +162,9 @@ void ks_wlan_hw_wakeup_request(struct ks_wlan_private *priv)DPRINTK (4 ,"wake up : WAKEUP=%02X\n" , rw_data); priv->last_wakeup = jiffies; ++priv->wakeup_count; - }else { + }else DPRINTK (1 ,"psstatus=%d\n" ,atomic_read (&priv->psstatus.status)); - } }int _ks_wlan_hw_power_save (struct ks_wlan_private *priv)
@@ -380,10 +377,9 @@ int ks_wlan_hw_tx(struct ks_wlan_private *priv, void *p, unsigned long size, result =enqueue_txdev (priv, p, size, complete_handler, arg1, arg2);spin_unlock (&priv->tx_dev.tx_dev_lock); -if (cnt_txqbody (priv) >0 ) { +if (cnt_txqbody (priv) >0 )queue_delayed_work (priv->ks_wlan_hw.ks7010sdio_wq, &priv->ks_wlan_hw.rw_wq,0 ); - }return result; }
@@ -399,9 +395,8 @@ static void rx_event_task(unsigned long dev)hostif_receive (priv, rp->data, rp->size);inc_rxqhead (priv); -if (cnt_rxqbody (priv) >0 ) { +if (cnt_rxqbody (priv) >0 )tasklet_schedule (&priv->ks_wlan_hw.rx_bh_task); - } }return ;
@@ -463,12 +458,11 @@ static void ks_wlan_hw_rx(void *dev, uint16_t size)DPRINTK (1 ," error : READ_STATUS=%02X\n" , read_status);DPRINTK (4 ,"READ_STATUS=%02X\n" , read_status); -if (atomic_read (&priv->psstatus.confirm_wait)) { +if (atomic_read (&priv->psstatus.confirm_wait))if (IS_HIF_CONF (event)) {DPRINTK (4 ,"IS_HIF_CONF true !!\n" );atomic_dec (&priv->psstatus.confirm_wait); } - }/* rx_event_task((void *)priv); */ tasklet_schedule (&priv->ks_wlan_hw.rx_bh_task);
@@ -537,13 +531,11 @@ static void ks7010_rw_function(struct work_struct *work) }DPRINTK (4 ,"WSTATUS_RSIZE=%02X\n" , rw_data); -if (rw_data &RSIZE_MASK ) {/* Read schedule */ +if (rw_data &RSIZE_MASK )/* Read schedule */ ks_wlan_hw_rx ((void *)priv, (uint16_t ) (((rw_data &RSIZE_MASK ) <<4 ))); - } -if ((rw_data &WSTATUS_MASK )) { +if (rw_data &WSTATUS_MASK )tx_device_task ((void *)priv); - }_ks_wlan_hw_power_save (priv); release_host:sdio_release_host (priv->ks_wlan_hw.sdio_card->func);
@@ -611,10 +603,9 @@ static void ks_sdio_interrupt(struct sdio_func *func) }DPRINTK (4 ,"WSTATUS_RSIZE=%02X\n" , rw_data); rsize = rw_data &RSIZE_MASK ; -if (rsize) {/* Read schedule */ +if (rsize)/* Read schedule */ ks_wlan_hw_rx ((void *)priv, (uint16_t ) (((rsize) <<4 ))); - }if (rw_data &WSTATUS_MASK ) {#if 0 if (status & INT_WRITE_STATUS
@@ -625,11 +616,10 @@ static void ks_sdio_interrupt(struct sdio_func *func)ks7010_sdio_write (priv,DATA_WINDOW , &rw_data,sizeof (rw_data)); -if (retval) { +if (retval)DPRINTK (1 ,"write DATA_WINDOW Failed!!(%d)\n" , retval); - } status &= ~INT_WRITE_STATUS; }else {#endif
@@ -870,13 +860,11 @@ static void ks7010_card_init(struct ks_wlan_private *priv)DPRINTK (5 ,"hostif_sme_enqueu()\n" );if (!wait_for_completion_interruptible_timeout - (&priv->confirm_wait,5 *HZ )) { + (&priv->confirm_wait,5 *HZ ))DPRINTK (1 ,"wait time out!! SME_START\n" ); - } -if (priv->mac_address_valid && priv->version_size) { +if (priv->mac_address_valid && priv->version_size) priv->dev_state =DEVICE_STATE_PREINIT ; - }hostif_sme_enqueue (priv,SME_GET_EEPROM_CKSUM );
@@ -898,16 +886,14 @@ static void ks7010_card_init(struct ks_wlan_private *priv)hostif_sme_enqueue (priv,SME_START_REQUEST );if (!wait_for_completion_interruptible_timeout - (&priv->confirm_wait,5 *HZ )) { + (&priv->confirm_wait,5 *HZ ))DPRINTK (1 ,"wait time out!! wireless parameter set\n" ); - }if (priv->dev_state >=DEVICE_STATE_PREINIT ) {DPRINTK (1 ,"DEVICE READY!!\n" ); priv->dev_state =DEVICE_STATE_READY ; - }else { + }else DPRINTK (1 ,"dev_state=%d\n" , priv->dev_state); - } }static void ks7010_init_defaults (struct ks_wlan_private *priv)
@@ -1057,9 +1043,8 @@ static int ks7010_sdio_probe(struct sdio_func *func,sdio_claim_host (func); ret =ks7010_sdio_write (priv,INT_PENDING , &rw_data,sizeof (rw_data));sdio_release_host (func); -if (ret) { +if (ret)DPRINTK (1 ," error : INT_PENDING=%02X\n" , rw_data); - }DPRINTK (4 ," clear Interrupt : INT_PENDING=%02X\n" , rw_data);/* enable ks7010sdio interrupt (INT_GCR_B|INT_READ_STATUS|INT_WRITE_STATUS) */
@@ -1067,9 +1052,8 @@ static int ks7010_sdio_probe(struct sdio_func *func,sdio_claim_host (func); ret =ks7010_sdio_write (priv,INT_ENABLE , &rw_data,sizeof (rw_data));sdio_release_host (func); -if (ret) { +if (ret)DPRINTK (1 ," error : INT_ENABLE=%02X\n" , rw_data); - }DPRINTK (4 ," enable Interrupt : INT_ENABLE=%02X\n" , rw_data); priv->dev_state =DEVICE_STATE_BOOT ;
Signature · 1 line
2.9.1
Re: [PATCH 6/9] staging: ks7010: Delete unnecessary braces
Quoted 16 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 17 Jul 2016 18:39:03 +0200Do not use curly brackets at some source code places where a single statement should be sufficient.
Signed-off-by Markus Elfring <[email protected]>--- drivers/staging/ks7010/ks7010_sdio.c | 48 ++++++++++++------------------------ 1 file changed, 16 insertions(+), 32 deletions(-)drivers/staging/ks7010/ks7010_sdio.c +0
-0
drivers/staging/ks7010/ks7010_sdio.c void ks_wlan_hw_sleep_doze_request(struct ks_wlan_private *priv) · line 114
Quoted 7 lines
drivers/staging/ks7010/ks7010_sdio.c +1
-2@@ -109,9 +109,8 @@ void ks_wlan_hw_sleep_doze_request(struct ks_wlan_private *priv)DPRINTK (3 ,"sleep_mode=SLP_SLEEP\n" );atomic_set (&priv->sleepstatus.status,1 ); priv->last_doze = jiffies; - }else { + }else DPRINTK (1 ,"sleep_mode=%d\n" , priv->sleep_mode); - }
This is a violation of CodingStyle:
This does not apply if only one branch of a conditional statement is a single
statement; in the latter case use braces in both branches:
if (condition) {
do_this();
do_that();
} else {
otherwise();
}julia
Quoted 169 lines
drivers/staging/ks7010/ks7010_sdio.c +15
-31out: priv->sleep_mode =atomic_read (&priv->sleepstatus.status);@@ -140,9 +139,8 @@ void ks_wlan_hw_sleep_wakeup_request(struct ks_wlan_private *priv)atomic_set (&priv->sleepstatus.status,0 ); priv->last_wakeup = jiffies; ++priv->wakeup_count; - }else { + }else DPRINTK (1 ,"sleep_mode=%d\n" , priv->sleep_mode); - } out: priv->sleep_mode =atomic_read (&priv->sleepstatus.status);@@ -164,10 +162,9 @@ void ks_wlan_hw_wakeup_request(struct ks_wlan_private *priv)DPRINTK (4 ,"wake up : WAKEUP=%02X\n" , rw_data); priv->last_wakeup = jiffies; ++priv->wakeup_count; - }else { + }else DPRINTK (1 ,"psstatus=%d\n" ,atomic_read (&priv->psstatus.status)); - } }int _ks_wlan_hw_power_save (struct ks_wlan_private *priv)@@ -380,10 +377,9 @@ int ks_wlan_hw_tx(struct ks_wlan_private *priv, void *p, unsigned long size, result =enqueue_txdev (priv, p, size, complete_handler, arg1, arg2);spin_unlock (&priv->tx_dev.tx_dev_lock); -if (cnt_txqbody (priv) >0 ) { +if (cnt_txqbody (priv) >0 )queue_delayed_work (priv->ks_wlan_hw.ks7010sdio_wq, &priv->ks_wlan_hw.rw_wq,0 ); - }return result; }@@ -399,9 +395,8 @@ static void rx_event_task(unsigned long dev)hostif_receive (priv, rp->data, rp->size);inc_rxqhead (priv); -if (cnt_rxqbody (priv) >0 ) { +if (cnt_rxqbody (priv) >0 )tasklet_schedule (&priv->ks_wlan_hw.rx_bh_task); - } }return ;@@ -463,12 +458,11 @@ static void ks_wlan_hw_rx(void *dev, uint16_t size)DPRINTK (1 ," error : READ_STATUS=%02X\n" , read_status);DPRINTK (4 ,"READ_STATUS=%02X\n" , read_status); -if (atomic_read (&priv->psstatus.confirm_wait)) { +if (atomic_read (&priv->psstatus.confirm_wait))if (IS_HIF_CONF (event)) {DPRINTK (4 ,"IS_HIF_CONF true !!\n" );atomic_dec (&priv->psstatus.confirm_wait); } - }/* rx_event_task((void *)priv); */ tasklet_schedule (&priv->ks_wlan_hw.rx_bh_task);@@ -537,13 +531,11 @@ static void ks7010_rw_function(struct work_struct *work) }DPRINTK (4 ,"WSTATUS_RSIZE=%02X\n" , rw_data); -if (rw_data &RSIZE_MASK ) {/* Read schedule */ +if (rw_data &RSIZE_MASK )/* Read schedule */ ks_wlan_hw_rx ((void *)priv, (uint16_t ) (((rw_data &RSIZE_MASK ) <<4 ))); - } -if ((rw_data &WSTATUS_MASK )) { +if (rw_data &WSTATUS_MASK )tx_device_task ((void *)priv); - }_ks_wlan_hw_power_save (priv); release_host:sdio_release_host (priv->ks_wlan_hw.sdio_card->func);@@ -611,10 +603,9 @@ static void ks_sdio_interrupt(struct sdio_func *func) }DPRINTK (4 ,"WSTATUS_RSIZE=%02X\n" , rw_data); rsize = rw_data &RSIZE_MASK ; -if (rsize) {/* Read schedule */ +if (rsize)/* Read schedule */ ks_wlan_hw_rx ((void *)priv, (uint16_t ) (((rsize) <<4 ))); - }if (rw_data &WSTATUS_MASK ) {#if 0 if (status & INT_WRITE_STATUS@@ -625,11 +616,10 @@ static void ks_sdio_interrupt(struct sdio_func *func)ks7010_sdio_write (priv,DATA_WINDOW , &rw_data,sizeof (rw_data)); -if (retval) { +if (retval)DPRINTK (1 ,"write DATA_WINDOW Failed!!(%d)\n" , retval); - } status &= ~INT_WRITE_STATUS; }else {#endif @@ -870,13 +860,11 @@ static void ks7010_card_init(struct ks_wlan_private *priv)DPRINTK (5 ,"hostif_sme_enqueu()\n" );if (!wait_for_completion_interruptible_timeout - (&priv->confirm_wait,5 *HZ )) { + (&priv->confirm_wait,5 *HZ ))DPRINTK (1 ,"wait time out!! SME_START\n" ); - } -if (priv->mac_address_valid && priv->version_size) { +if (priv->mac_address_valid && priv->version_size) priv->dev_state =DEVICE_STATE_PREINIT ; - }hostif_sme_enqueue (priv,SME_GET_EEPROM_CKSUM );@@ -898,16 +886,14 @@ static void ks7010_card_init(struct ks_wlan_private *priv)hostif_sme_enqueue (priv,SME_START_REQUEST );if (!wait_for_completion_interruptible_timeout - (&priv->confirm_wait,5 *HZ )) { + (&priv->confirm_wait,5 *HZ ))DPRINTK (1 ,"wait time out!! wireless parameter set\n" ); - }if (priv->dev_state >=DEVICE_STATE_PREINIT ) {DPRINTK (1 ,"DEVICE READY!!\n" ); priv->dev_state =DEVICE_STATE_READY ; - }else { + }else DPRINTK (1 ,"dev_state=%d\n" , priv->dev_state); - } }static void ks7010_init_defaults (struct ks_wlan_private *priv)@@ -1057,9 +1043,8 @@ static int ks7010_sdio_probe(struct sdio_func *func,sdio_claim_host (func); ret =ks7010_sdio_write (priv,INT_PENDING , &rw_data,sizeof (rw_data));sdio_release_host (func); -if (ret) { +if (ret)DPRINTK (1 ," error : INT_PENDING=%02X\n" , rw_data); - }DPRINTK (4 ," clear Interrupt : INT_PENDING=%02X\n" , rw_data);/* enable ks7010sdio interrupt (INT_GCR_B|INT_READ_STATUS|INT_WRITE_STATUS) */ @@ -1067,9 +1052,8 @@ static int ks7010_sdio_probe(struct sdio_func *func,sdio_claim_host (func); ret =ks7010_sdio_write (priv,INT_ENABLE , &rw_data,sizeof (rw_data));sdio_release_host (func); -if (ret) { +if (ret)DPRINTK (1 ," error : INT_ENABLE=%02X\n" , rw_data); - }DPRINTK (4 ," enable Interrupt : INT_ENABLE=%02X\n" , rw_data); priv->dev_state =DEVICE_STATE_BOOT ; --2.9.1
--
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 6/9] staging: ks7010: Delete unnecessary braces
Quoted 15 lines · Julia Lawall
Quoted 11 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 17 Jul 2016 18:39:03 +0200Do not use curly brackets at some source code places where a single statement should be sufficient.
Signed-off-by Markus Elfring <[email protected]>--- drivers/staging/ks7010/ks7010_sdio.c | 48 ++++++++++++------------------------ 1 file changed, 16 insertions(+), 32 deletions(-)
Quoted 14 lines
drivers/staging/ks7010/ks7010_sdio.c void ks_wlan_hw_sleep_doze_request(struct ks_wlan_private *priv) · line 114
Quoted 12 lines
drivers/staging/ks7010/ks7010_sdio.c +1
-2@@ -109,9 +109,8 @@ void ks_wlan_hw_sleep_doze_request(struct ks_wlan_private *priv)DPRINTK (3 ,"sleep_mode=SLP_SLEEP\n" );atomic_set (&priv->sleepstatus.status,1 ); priv->last_doze = jiffies; - }else { + }else DPRINTK (1 ,"sleep_mode=%d\n" , priv->sleep_mode); - }This is a violation of CodingStyle:
Julia is right again, I agree.
PATCH 7/9 staging: ks7010: Replace three printk() calls by pr_err()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 17 Jul 2016 19:12:27 +0200
Prefer usage of the macro "pr_err" over the interface "printk". Fix a typo in an error message.
--- drivers/staging/ks7010/ks7010_sdio.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/staging/ks7010/ks7010_sdio.c +3 -4
@@ -987,11 +987,11 @@ static int ks7010_sdio_probe(struct sdio_func *func,/* private memory allocate */ netdev =alloc_etherdev (sizeof (*priv));if (netdev =NULL ) { -printk (KERN_ERR "ks7010 : Unable to alloc new net device\n" ); +pr_err ("ks7010: Unable to alloc new net device\n" ); goto release_irq; }if (dev_alloc_name (netdev,"wlan%d" ) <0 ) { -printk (KERN_ERR "ks7010 : Couldn't get name!\n" ); +pr_err ("ks7010: Couldn't get name!\n" ); goto free_dev; }
@@ -1031,8 +1031,7 @@ static int ks7010_sdio_probe(struct sdio_func *func,/* Upload firmware */ ret =ks7010_upload_firmware (priv, card);/* firmware load */ if (ret) { -printk (KERN_ERR -"ks7010: firmware load failed !! retern code = %d\n" , +pr_err ("ks7010: firmware load failed! return code = %d\n" , ret); goto free_buf; }
Signature · 1 line
2.9.1
Re: [PATCH 7/9] staging: ks7010: Replace three printk() calls by pr_err()
Quoted 5 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 17 Jul 2016 19:12:27 +0200Prefer usage of the macro "
pr_err" over the interface "printk". Fix a typo in an error message.
Please and and use pr_fmt
Re: [PATCH 7/9] staging: ks7010: Replace three printk() calls by pr_err()
Quoted 8 lines · Joe Perches
Quoted 5 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 17 Jul 2016 19:12:27 +0200Prefer usage of the macro "
pr_err" over the interface "printk". Fix a typo in an error message.Please and and use
pr_fmt
Can't we use dev_* on the SDIO device?
Re: staging: ks7010: Replace three printk() calls by pr_err()
Quoted 3 lines
Quoted 1 line
Please and and use
pr_fmtCan't we use dev_* on the SDIO device?
How should a connection be constructed from the data structure "sdio_device_id" to the corresponding device information for such an use case?
Regards,
Markus
Re: staging: ks7010: Replace three printk() calls by pr_err()
Quoted 6 lines · SF Markus Elfring
Quoted 3 lines
Quoted 1 line
Please and and use
pr_fmtCan't we use dev_* on the SDIO device?
How should a connection be constructed from the data structure "
sdio_device_id" to the corresponding device information for such an use case?
What did you try so far?
Re: staging: ks7010: Replace three printk() calls by pr_err()
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Can't we use dev_* on the SDIO device?
How should a connection be constructed from the data structure "
sdio_device_id" to the corresponding device information for such an use case?What did you try so far?
Nothing what I would find noteworthy for increasing the usage of a function like "dev_err".
Are you on "a mission" to improve software around logging calls a bit more?
Regards,
Markus
Re: staging: ks7010: Replace three printk() calls by pr_err()
Quoted 5 lines
Nothing what I would find noteworthy for increasing the usage of a function like "
dev_err".Are you on "a mission" to improve software around logging calls a bit more?
I have two of those cards and I would like to know which one caused an error. dev_err helps with exactly that.
PATCH 1/1 staging: ks7010: Adjust dev_err() calls in ks7010_sdio_probe()
In reply to Wolfram SangFrom: Markus Elfring <[email protected]>
Date: Tue, 11 Apr 2017 14:54:35 +0200
The use of the logging function "dev_err" was introduced here on 2016-09-26.
I find the following implementation details worth for another look.
* Reduce expressions for the first input parameter "dev".
* Omit an extra module prefix in passed error messages because the device name will be displayed by the function "__dev_printk".
--- drivers/staging/ks7010/ks7010_sdio.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/staging/ks7010/ks7010_sdio.c +5 -6
@@ -955,12 +955,11 @@ static int ks7010_sdio_probe(struct sdio_func *func,/* private memory allocate */ netdev =alloc_etherdev (sizeof (*priv));if (!netdev) { -dev_err (&card->func->dev,"ks7010 : Unable to alloc new net device\n" ); +dev_err (&func->dev,"Unable to alloc new net device\n" ); goto err_release_irq; }if (dev_alloc_name (netdev,"wlan%d" ) <0 ) { -dev_err (&card->func->dev, -"ks7010 : Couldn't get name!\n" ); +dev_err (&func->dev,"Couldn't get name!\n" ); goto err_free_netdev; }
@@ -1000,9 +999,9 @@ static int ks7010_sdio_probe(struct sdio_func *func,/* Upload firmware */ ret =ks7010_upload_firmware (priv, card);/* firmware load */ if (ret) { -dev_err (&card->func->dev, -"ks7010: firmware load failed !! return code = %d\n" , - ret); +dev_err (&func->dev, +"firmware load failed! return code = %d\n" , + ret); goto err_free_read_buf; }
Signature · 1 line
2.12.2
Re: [PATCH] staging: ks7010: Adjust dev_err() calls in ks7010_sdio_probe()
Quoted 39 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Tue, 11 Apr 2017 14:54:35 +0200The use of the logging function "
dev_err" was introduced here on 2016-09-26.I find the following implementation details worth for another look.
* Reduce expressions for the first input parameter "dev".* Omit an extra module prefix in passed error messages because the device name will be displayed by the function "
__dev_printk".Fixes 9887b5e51fafaf919601ccb8bdae1e0ad749032f ("staging: ks7010: Fix warnings on printk() usage")Signed-off-by Markus Elfring <[email protected]>--- drivers/staging/ks7010/ks7010_sdio.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)drivers/staging/ks7010/ks7010_sdio.c +2
-3@@ -955,12 +955,11 @@ static int ks7010_sdio_probe(struct sdio_func *func,/* private memory allocate */ netdev =alloc_etherdev (sizeof (*priv));if (!netdev) { -dev_err (&card->func->dev,"ks7010 : Unable to alloc new net device\n" ); +dev_err (&func->dev,"Unable to alloc new net device\n" ); goto err_release_irq; }if (dev_alloc_name (netdev,"wlan%d" ) <0 ) { -dev_err (&card->func->dev, -"ks7010 : Couldn't get name!\n" ); +dev_err (&func->dev,"Couldn't get name!\n" ); goto err_free_netdev; }@@ -1000,9 +999,9 @@ static int ks7010_sdio_probe(struct sdio_func *func,/* Upload firmware */
drivers/staging/ks7010/ks7010_sdio.c static int ks7010_sdio_probe(struct sdio_func *func, · line 1006
Quoted 10 lines
drivers/staging/ks7010/ks7010_sdio.c +3
-3ret =ks7010_upload_firmware (priv, card);/* firmware load */ if (ret) { -dev_err (&card->func->dev, -"ks7010: firmware load failed !! return code = %d\n" , - ret); +dev_err (&func->dev, +"firmware load failed! return code = %d\n" , + ret); goto err_free_read_buf; }
This patch does not apply to Greg's staging-testing branch. Sorry Markus a patch was merged the same day you submitted this one that refactored this code.
The patch was good though, good spotting.
Good luck,
Tobin.
Re: staging: ks7010: Adjust dev_err() calls in ks7010_sdio_probe()
Quoted 1 line
This patch does not apply to Greg's staging-testing branch.
Could the proposed changes be applied with a bit of “fuzz” for the implementation of the function “ks7010_sdio_probe”?
Quoted 2 lines
Markus a patch was merged the same day you submitted this one that refactored this code.
Do you refer to your contributions from 2017-04-10 here which seem to touch only other functions?
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git/log/?h=staging-testing&qt=author&q=Tobin+C.+Harding
Quoted 1 line
The patch was good though, good spotting.
Will there any more approaches be needed for a corresponding editing conflict resolution?
Which day would be better to dare a resend for my small update suggestion?
Regards,
Markus
Greg Kroah-Hartman
maintainerRe: [PATCH] staging: ks7010: Adjust dev_err() calls in ks7010_sdio_probe()
In reply to Tobin C. HardingQuoted 38 lines · Tobin C. Harding
Quoted 37 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Tue, 11 Apr 2017 14:54:35 +0200The use of the logging function "
dev_err" was introduced here on 2016-09-26.I find the following implementation details worth for another look.
* Reduce expressions for the first input parameter "dev".* Omit an extra module prefix in passed error messages because the device name will be displayed by the function "
__dev_printk".Fixes 9887b5e51fafaf919601ccb8bdae1e0ad749032f ("staging: ks7010: Fix warnings on printk() usage")Signed-off-by Markus Elfring <[email protected]>--- drivers/staging/ks7010/ks7010_sdio.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)drivers/staging/ks7010/ks7010_sdio.c +2
-3@@ -955,12 +955,11 @@ static int ks7010_sdio_probe(struct sdio_func *func,/* private memory allocate */ netdev =alloc_etherdev (sizeof (*priv));if (!netdev) { -dev_err (&card->func->dev,"ks7010 : Unable to alloc new net device\n" ); +dev_err (&func->dev,"Unable to alloc new net device\n" ); goto err_release_irq; }if (dev_alloc_name (netdev,"wlan%d" ) <0 ) { -dev_err (&card->func->dev, -"ks7010 : Couldn't get name!\n" ); +dev_err (&func->dev,"Couldn't get name!\n" ); goto err_free_netdev; }
Quoted 16 lines
drivers/staging/ks7010/ks7010_sdio.c static int ks7010_sdio_probe(struct sdio_func *func, · line 1006
Quoted 12 lines
drivers/staging/ks7010/ks7010_sdio.c +3
-3@@ -1000,9 +999,9 @@ static int ks7010_sdio_probe(struct sdio_func *func,/* Upload firmware */ ret =ks7010_upload_firmware (priv, card);/* firmware load */ if (ret) { -dev_err (&card->func->dev, -"ks7010: firmware load failed !! return code = %d\n" , - ret); +dev_err (&func->dev, +"firmware load failed! return code = %d\n" , + ret); goto err_free_read_buf; }This patch does not apply to Greg's staging-testing branch. Sorry Markus a patch was merged the same day you submitted this one that refactored this code.
Note, Markus is in almost all maintainers kill-file, so we don't even see their emails, and I'd recommend you not even worry about them either.
thanks,
greg k-h
Re: [PATCH] staging: ks7010: Adjust dev_err() calls in ks7010_sdio_probe()
Quoted 56 lines · Greg Kroah-Hartman
Quoted 38 lines · Tobin C. Harding
Quoted 37 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Tue, 11 Apr 2017 14:54:35 +0200The use of the logging function "
dev_err" was introduced here on 2016-09-26.I find the following implementation details worth for another look.
* Reduce expressions for the first input parameter "dev".* Omit an extra module prefix in passed error messages because the device name will be displayed by the function "
__dev_printk".Fixes 9887b5e51fafaf919601ccb8bdae1e0ad749032f ("staging: ks7010: Fix warnings on printk() usage")Signed-off-by Markus Elfring <[email protected]>--- drivers/staging/ks7010/ks7010_sdio.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)drivers/staging/ks7010/ks7010_sdio.c +2
-3@@ -955,12 +955,11 @@ static int ks7010_sdio_probe(struct sdio_func *func,/* private memory allocate */ netdev =alloc_etherdev (sizeof (*priv));if (!netdev) { -dev_err (&card->func->dev,"ks7010 : Unable to alloc new net device\n" ); +dev_err (&func->dev,"Unable to alloc new net device\n" ); goto err_release_irq; }if (dev_alloc_name (netdev,"wlan%d" ) <0 ) { -dev_err (&card->func->dev, -"ks7010 : Couldn't get name!\n" ); +dev_err (&func->dev,"Couldn't get name!\n" ); goto err_free_netdev; }Quoted 16 lines
drivers/staging/ks7010/ks7010_sdio.c static int ks7010_sdio_probe(struct sdio_func *func, · line 1006
Quoted 12 lines
drivers/staging/ks7010/ks7010_sdio.c +3
-3@@ -1000,9 +999,9 @@ static int ks7010_sdio_probe(struct sdio_func *func,/* Upload firmware */ ret =ks7010_upload_firmware (priv, card);/* firmware load */ if (ret) { -dev_err (&card->func->dev, -"ks7010: firmware load failed !! return code = %d\n" , - ret); +dev_err (&func->dev, +"firmware load failed! return code = %d\n" , + ret); goto err_free_read_buf; }This patch does not apply to Greg's staging-testing branch. Sorry Markus a patch was merged the same day you submitted this one that refactored this code.
Quoted 3 lines
Note, Markus is in almost all maintainers kill-file, so we don't even see their emails, and I'd recommend you not even worry about them either.
I've never heard of a kill-file, it sounds awesome. I hope to some day have one of those myself. I settled for a incoming mail rule deleting his email.
thanks for the tip,
Tobin.
Greg Kroah-Hartman
maintainerRe: [PATCH] staging: ks7010: Adjust dev_err() calls in ks7010_sdio_probe()
Quoted 57 lines · Tobin C. Harding
Quoted 56 lines · Greg Kroah-Hartman
Quoted 54 lines · Tobin C. Harding
Quoted 39 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Tue, 11 Apr 2017 14:54:35 +0200The use of the logging function "
dev_err" was introduced here on 2016-09-26.I find the following implementation details worth for another look.
* Reduce expressions for the first input parameter "dev".* Omit an extra module prefix in passed error messages because the device name will be displayed by the function "
__dev_printk".Fixes 9887b5e51fafaf919601ccb8bdae1e0ad749032f ("staging: ks7010: Fix warnings on printk() usage")Signed-off-by Markus Elfring <[email protected]>--- drivers/staging/ks7010/ks7010_sdio.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)drivers/staging/ks7010/ks7010_sdio.c +2
-3@@ -955,12 +955,11 @@ static int ks7010_sdio_probe(struct sdio_func *func,/* private memory allocate */ netdev =alloc_etherdev (sizeof (*priv));if (!netdev) { -dev_err (&card->func->dev,"ks7010 : Unable to alloc new net device\n" ); +dev_err (&func->dev,"Unable to alloc new net device\n" ); goto err_release_irq; }if (dev_alloc_name (netdev,"wlan%d" ) <0 ) { -dev_err (&card->func->dev, -"ks7010 : Couldn't get name!\n" ); +dev_err (&func->dev,"Couldn't get name!\n" ); goto err_free_netdev; }@@ -1000,9 +999,9 @@ static int ks7010_sdio_probe(struct sdio_func *func,/* Upload firmware */ drivers/staging/ks7010/ks7010_sdio.c static int ks7010_sdio_probe(struct sdio_func *func, · line 1006
Quoted 10 lines
drivers/staging/ks7010/ks7010_sdio.c +3
-3ret =ks7010_upload_firmware (priv, card);/* firmware load */ if (ret) { -dev_err (&card->func->dev, -"ks7010: firmware load failed !! return code = %d\n" , - ret); +dev_err (&func->dev, +"firmware load failed! return code = %d\n" , + ret); goto err_free_read_buf; }This patch does not apply to Greg's staging-testing branch. Sorry Markus a patch was merged the same day you submitted this one that refactored this code.
Quoted 7 lines
Quoted 3 lines
Note, Markus is in almost all maintainers kill-file, so we don't even see their emails, and I'd recommend you not even worry about them either.
I've never heard of a kill-file, it sounds awesome. I hope to some day have one of those myself. I settled for a incoming mail rule deleting his email.
Ah, you now have implemented your own, nice work!
PATCH 8/9 staging: ks7010: Delete a variable in write_to_device()
In reply to SF Markus ElfringFrom 01291121668ccb54f1a784765a8d2b5811afa75a Mon Sep 17 00:00:00 2001
From: Markus Elfring <[email protected]>
Date: Sun, 17 Jul 2016 19:26:15 +0200
Subject: [PATCH 8/9] staging: ks7010: Delete a variable in write_to_device()
The local variable "rc" was assigned a zero at one place. But it was not read within this function. Thus delete it.
--- drivers/staging/ks7010/ks7010_sdio.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/ks7010/ks7010_sdio.c +1 -2
@@ -291,11 +291,10 @@ static int enqueue_txdev(struct ks_wlan_private *priv, unsigned char *p,static int write_to_device (struct ks_wlan_private *priv,unsigned char *buffer,unsigned long size) { -int rc, retval; +int retval;unsigned char rw_data;struct hostif_hdr *hdr; hdr = (struct hostif_hdr *)buffer; - rc =0 ;DPRINTK (4 ,"size=%d\n" , hdr->size);if (hdr->event <HIF_DATA_REQ ||HIF_REQ_MAX < hdr->event) {
Signature · 1 line
2.9.1
Re: [PATCH 8/9] staging: ks7010: Delete a variable in write_to_device()
Quoted 9 lines · SF Markus Elfring
From
01291121668ccb54f1a784765a8d2b5811afa75aMon Sep 17 00:00:00 2001
From: Markus Elfring <[email protected]>
Date: Sun, 17 Jul 2016 19:26:15 +0200
Subject: [PATCH 8/9] staging: ks7010: Delete a variable inwrite_to_device()The local variable "rc" was assigned a zero at one place. But it was not read within this function. Thus delete it.
Signed-off-by Markus Elfring <[email protected]>
PATCH 9/9 staging: ks7010: Delete three unnecessary variable initialisations
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 17 Jul 2016 19:40:47 +0200
Three variables will be set to an appropriate value a bit later. Thus omit the explicit initialisation at the beginning.
--- drivers/staging/ks7010/ks7010_sdio.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/staging/ks7010/ks7010_sdio.c +4 -4
@@ -323,14 +323,14 @@ static void tx_device_task(void *dev) {struct ks_wlan_private *priv = (struct ks_wlan_private *)dev;struct tx_device_buffer *sp; -int rc =0 ;DPRINTK (4 ,"\n" );if (cnt_txqbody (priv) >0 &&atomic_read (&priv->psstatus.status) !=PS_SNOOZE ) { sp = &priv->tx_dev.tx_dev_buff[priv->tx_dev.qhead];if (priv->dev_state >=DEVICE_STATE_BOOT ) { - rc =write_to_device (priv, sp->sendp, sp->size); +int rc =write_to_device (priv, sp->sendp, sp->size); +if (rc) {DPRINTK (1 ,"write_to_device error !!(%d)\n" , rc);
@@ -358,7 +358,7 @@ int ks_wlan_hw_tx(struct ks_wlan_private *priv, void *p, unsigned long size,void (*complete_handler) (void *arg1,void *arg2), void *arg1, void *arg2) { - int result = 0; + int result;struct hostif_hdr *hdr; hdr = (struct hostif_hdr *)p;
@@ -737,7 +737,7 @@ free_buf:static int ks7010_upload_firmware (struct ks_wlan_private *priv,struct ks_sdio_card *card) { -unsigned int size, offset, n =0 ; +unsigned int size, offset, n;unsigned char *rom_buf;unsigned char rw_data =0 ;int retval, rc =0 ;
Signature · 1 line
2.9.1
Re: [PATCH 9/9] staging: ks7010: Delete three unnecessary variable initialisations
Quoted 18 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 17 Jul 2016 19:40:47 +0200Three variables will be set to an appropriate value a bit later. Thus omit the explicit initialisation at the beginning.
Signed-off-by Markus Elfring <[email protected]>--- drivers/staging/ks7010/ks7010_sdio.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/staging/ks7010/ks7010_sdio.c +0
-0@@ -323,14 +323,14 @@ static void tx_device_task(void *dev) {struct ks_wlan_private *priv = (struct ks_wlan_private *)dev;
drivers/staging/ks7010/ks7010_sdio.c static void tx_device_task(void *dev) · line 332
Quoted 10 lines
drivers/staging/ks7010/ks7010_sdio.c +1
-2struct tx_device_buffer *sp; -int rc =0 ;DPRINTK (4 ,"\n" );if (cnt_txqbody (priv) >0 &&atomic_read (&priv->psstatus.status) !=PS_SNOOZE ) { sp = &priv->tx_dev.tx_dev_buff[priv->tx_dev.qhead];if (priv->dev_state >=DEVICE_STATE_BOOT ) { - rc =write_to_device (priv, sp->sendp, sp->size); +int rc =write_to_device (priv, sp->sendp, sp->size);
This does not look appealing to me, neither the declaration in the middle of the function, nor the intiialization to the result of a complex expression, nor the separation of the call and the error checking code by a blank line. There is nothing wrong with having the rc variable be declared at the the top of the function, in its normal place.
julia
Quoted 30 lines
drivers/staging/ks7010/ks7010_sdio.c +3
-3+if (rc) {DPRINTK (1 ,"write_to_device error !!(%d)\n" , rc);@@ -358,7 +358,7 @@ int ks_wlan_hw_tx(struct ks_wlan_private *priv, void *p, unsigned long size,void (*complete_handler) (void *arg1,void *arg2), void *arg1, void *arg2) { - int result = 0; + int result;struct hostif_hdr *hdr; hdr = (struct hostif_hdr *)p;@@ -737,7 +737,7 @@ free_buf:static int ks7010_upload_firmware (struct ks_wlan_private *priv,struct ks_sdio_card *card) { -unsigned int size, offset, n =0 ; +unsigned int size, offset, n;unsigned char *rom_buf;unsigned char rw_data =0 ;int retval, rc =0 ; --2.9.1
--
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 9/9] staging: ks7010: Delete three unnecessary variable initialisations
Quoted 25 lines · Julia Lawall
Quoted 21 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 17 Jul 2016 19:40:47 +0200Three variables will be set to an appropriate value a bit later. Thus omit the explicit initialisation at the beginning.
Signed-off-by Markus Elfring <[email protected]>--- drivers/staging/ks7010/ks7010_sdio.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/staging/ks7010/ks7010_sdio.c +0
-1@@ -323,14 +323,14 @@ static void tx_device_task(void *dev) {struct ks_wlan_private *priv = (struct ks_wlan_private *)dev;struct tx_device_buffer *sp; -int rc =0 ;
Quoted 13 lines
drivers/staging/ks7010/ks7010_sdio.c static void tx_device_task(void *dev) · line 332
Quoted 7 lines
drivers/staging/ks7010/ks7010_sdio.c +1
-1DPRINTK (4 ,"\n" );if (cnt_txqbody (priv) >0 &&atomic_read (&priv->psstatus.status) !=PS_SNOOZE ) { sp = &priv->tx_dev.tx_dev_buff[priv->tx_dev.qhead];if (priv->dev_state >=DEVICE_STATE_BOOT ) { - rc =write_to_device (priv, sp->sendp, sp->size); +int rc =write_to_device (priv, sp->sendp, sp->size);This does not look appealing to me, neither the declaration in the middle of the function, nor the intiialization to the result of a complex expression, nor the separation of the call and the error checking code by a blank line. There is nothing wrong with having the rc variable be declared at the the top of the function, in its normal place.
+1
Re: [PATCH 9/9] staging: ks7010: Delete three unnecessary variable initialisations
In reply to Julia LawallQuoted 6 lines
Quoted 6 lines
drivers/staging/ks7010/ks7010_sdio.c +0
-1@@ -323,14 +323,14 @@ static void tx_device_task(void *dev) {struct ks_wlan_private *priv = (struct ks_wlan_private *)dev;struct tx_device_buffer *sp; -int rc =0 ;
Quoted 13 lines
drivers/staging/ks7010/ks7010_sdio.c static void tx_device_task(void *dev) · line 332
Quoted 7 lines
drivers/staging/ks7010/ks7010_sdio.c +1
-1DPRINTK (4 ,"\n" );if (cnt_txqbody (priv) >0 &&atomic_read (&priv->psstatus.status) !=PS_SNOOZE ) { sp = &priv->tx_dev.tx_dev_buff[priv->tx_dev.qhead];if (priv->dev_state >=DEVICE_STATE_BOOT ) { - rc =write_to_device (priv, sp->sendp, sp->size); +int rc =write_to_device (priv, sp->sendp, sp->size);This does not look appealing to me, neither the declaration in the middle of the function, nor the intiialization to the result of a complex expression, nor the separation of the call and the error checking code by a blank line. There is nothing wrong with having the rc variable be declared at the the top of the function, in its normal place.
* Do you occasionally care for a refactoring like "Reduce scope of variable"?
http://refactoring.com/catalog/reduceScopeOfVariable.html
* How do you think about to remove the extra assignment at the beginning of this function implementation?
Regards,
Markus
Re: [PATCH 9/9] staging: ks7010: Delete three unnecessary variable initialisations
Quoted 20 lines · SF Markus Elfring
Quoted 6 lines
Quoted 6 lines
drivers/staging/ks7010/ks7010_sdio.c +0
-1@@ -323,14 +323,14 @@ static void tx_device_task(void *dev) {struct ks_wlan_private *priv = (struct ks_wlan_private *)dev;struct tx_device_buffer *sp; -int rc =0 ;Quoted 13 lines
drivers/staging/ks7010/ks7010_sdio.c static void tx_device_task(void *dev) · line 332
Quoted 7 lines
drivers/staging/ks7010/ks7010_sdio.c +1
-1DPRINTK (4 ,"\n" );if (cnt_txqbody (priv) >0 &&atomic_read (&priv->psstatus.status) !=PS_SNOOZE ) { sp = &priv->tx_dev.tx_dev_buff[priv->tx_dev.qhead];if (priv->dev_state >=DEVICE_STATE_BOOT ) { - rc =write_to_device (priv, sp->sendp, sp->size); +int rc =write_to_device (priv, sp->sendp, sp->size);This does not look appealing to me, neither the declaration in the middle of the function, nor the intiialization to the result of a complex expression, nor the separation of the call and the error checking code by a blank line. There is nothing wrong with having the rc variable be declared at the the top of the function, in its normal place.
Quoted 3 lines
* Do you occasionally care for a refactoring like "Reduce scope of variable"?
Probably not. Certainly not in this case.
Quoted 2 lines
* How do you think about to remove the extra assignment at the beginning of this function implementation?
If the value is not useful, then it can go.
julia
Quoted 7 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: staging: ks7010: Delete three unnecessary variable initialisations
Quoted 5 lines
Quoted 3 lines
* Do you occasionally care for a refactoring like "Reduce scope of variable"?
Probably not. Certainly not in this case.
In which use cases would the suggested change pattern be more interesting for you?
Regards,
Markus
v2 cover staging: ks7010: Fine-tuning for a SDIO card driver
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 (10):
Delete unnecessary checks before the function call "kfree" Delete unnecessary assignments for buffer variables Return directly after a failed kmalloc()
Rename jump labels
Delete unnecessary uses of the variable "retval" Delete unnecessary braces
Add the macro "pr_fmt"
Replace three printk() calls by pr_err()
Delete a variable in write_to_device()
Delete three unnecessary variable initialisations
drivers/staging/ks7010/ks7010_sdio.c | 184 ++++++++++++++--------------------- 1 file changed, 73 insertions(+), 111 deletions(-)
Signature · 1 line
2.9.2
PATCH v2 1/10 staging: ks7010: Delete unnecessary checks before the function call "kfree"
From: Markus Elfring <[email protected]>
Date: Wed, 10 Aug 2016 17:15:15 +0200
The kfree() function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/staging/ks7010/ks7010_sdio.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
drivers/staging/ks7010/ks7010_sdio.c +4 -9
@@ -732,8 +732,7 @@ static int ks7010_sdio_update_index(struct ks_wlan_private *priv, u32 index) goto error_out; } error_out: -if (data_buf) -kfree (data_buf); +kfree (data_buf);return rc; }
@@ -763,8 +762,7 @@ static int ks7010_sdio_data_compare(struct ks_wlan_private *priv, u32 address, goto error_out; } error_out: -if (read_buf) -kfree (read_buf); +kfree (read_buf);return rc; }
@@ -879,8 +877,7 @@ static int ks7010_upload_firmware(struct ks_wlan_private *priv,release_firmware (fw_entry); error_out0:sdio_release_host (card->func); -if (rom_buf) -kfree (rom_buf); +kfree (rom_buf);return rc; }
@@ -1199,9 +1196,7 @@ static void ks7010_sdio_remove(struct sdio_func *func)unregister_netdev (netdev);trx_device_exit (priv); -if (priv->ks_wlan_hw.read_buf) { -kfree (priv->ks_wlan_hw.read_buf); - } +kfree (priv->ks_wlan_hw.read_buf);free_netdev (priv->net_dev); card->priv =NULL ; }
Signature · 1 line
2.9.2
PATCH v2 2/10 staging: ks7010: Delete unnecessary assignments for buffer variables
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 10 Aug 2016 17:26:01 +0200
A few variables were assigned a null pointer despite of the detail that they were immediately reassigned by the following statement. Thus remove such unnecessary assignments.
---
v2: Rebased on the source files from Linux next-20160809.
drivers/staging/ks7010/ks7010_sdio.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/staging/ks7010/ks7010_sdio.c +1 -4
@@ -711,7 +711,6 @@ static int ks7010_sdio_update_index(struct ks_wlan_private *priv, u32 index)int rc =0 ;int retval;unsigned char *data_buf; - data_buf =NULL ; data_buf =kmalloc (sizeof (u32),GFP_KERNEL );if (!data_buf) {
@@ -743,7 +742,7 @@ static int ks7010_sdio_data_compare(struct ks_wlan_private *priv, u32 address,int rc =0 ;int retval;unsigned char *read_buf; - read_buf =NULL ; + read_buf =kmalloc (ROM_BUFF_SIZE ,GFP_KERNEL );if (!read_buf) { rc =1 ;
@@ -776,8 +775,6 @@ static int ks7010_upload_firmware(struct ks_wlan_private *priv,int length;const struct firmware *fw_entry =NULL ; - rom_buf =NULL ; -/* buffer allocate */ rom_buf =kmalloc (ROM_BUFF_SIZE ,GFP_KERNEL );if (!rom_buf) {
Signature · 1 line
2.9.2
PATCH v2 3/10 staging: ks7010: Return directly after a failed kmalloc()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 10 Aug 2016 17:34:12 +0200
Return directly after a memory allocation failed at the beginning.
---
v2: Rebased on the source files from Linux next-20160809.
drivers/staging/ks7010/ks7010_sdio.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-)
drivers/staging/ks7010/ks7010_sdio.c +7 -12
@@ -713,10 +713,8 @@ static int ks7010_sdio_update_index(struct ks_wlan_private *priv, u32 index)unsigned char *data_buf; data_buf =kmalloc (sizeof (u32),GFP_KERNEL ); -if (!data_buf) { - rc =1 ; - goto error_out; - } +if (!data_buf) +return 1 ;memcpy (data_buf, &index,sizeof (index)); retval =ks7010_sdio_write (priv,WRITE_INDEX , data_buf,sizeof (index));
@@ -744,10 +742,9 @@ static int ks7010_sdio_data_compare(struct ks_wlan_private *priv, u32 address,unsigned char *read_buf; read_buf =kmalloc (ROM_BUFF_SIZE ,GFP_KERNEL ); -if (!read_buf) { - rc =1 ; - goto error_out; - } +if (!read_buf) +return 1 ; + retval =ks7010_sdio_read (priv, address, read_buf, size);if (retval) { rc =2 ;
@@ -777,10 +774,8 @@ static int ks7010_upload_firmware(struct ks_wlan_private *priv,/* buffer allocate */ rom_buf =kmalloc (ROM_BUFF_SIZE ,GFP_KERNEL ); -if (!rom_buf) { - rc =3 ; - goto error_out0; - } +if (!rom_buf) +return 3 ;sdio_claim_host (card->func);
Signature · 1 line
2.9.2
PATCH v2 4/10 staging: ks7010: Rename jump labels
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 10 Aug 2016 17:57:50 +0200
Adjust jump targets according to the Linux coding style convention.
---
v2: Rebased on the source files from Linux next-20160809.
Touched four source code places less.
drivers/staging/ks7010/ks7010_sdio.c | 73 +++++++++++++++++------------------- 1 file changed, 34 insertions(+), 39 deletions(-)
drivers/staging/ks7010/ks7010_sdio.c +34 -39
@@ -523,18 +523,18 @@ static void ks7010_rw_function(struct work_struct *work)queue_delayed_work (priv->ks_wlan_hw.ks7010sdio_wq, &priv->ks_wlan_hw.rw_wq,1 ); } - goto err_out; + goto release_host; }/* sleep mode doze */ if (atomic_read (&priv->sleepstatus.doze_request) =1 ) {ks_wlan_hw_sleep_doze_request (priv); - goto err_out; + goto release_host; }/* sleep mode wakeup */ if (atomic_read (&priv->sleepstatus.wakeup_request) =1 ) {ks_wlan_hw_sleep_wakeup_request (priv); - goto err_out; + goto release_host; }/* read (WriteStatus/ReadDataSize FN1:00_0014) */
@@ -543,7 +543,7 @@ static void ks7010_rw_function(struct work_struct *work)if (retval) {DPRINTK (1 ," error : WSTATUS_RSIZE=%02X psstatus=%d\n" , rw_data,atomic_read (&priv->psstatus.status)); - goto err_out; + goto release_host; }DPRINTK (4 ,"WSTATUS_RSIZE=%02X\n" , rw_data);
@@ -555,8 +555,7 @@ static void ks7010_rw_function(struct work_struct *work)tx_device_task ((void *)priv); }_ks_wlan_hw_power_save (priv); - - err_out: + release_host:sdio_release_host (priv->ks_wlan_hw.sdio_card->func);return ;
@@ -720,15 +719,13 @@ static int ks7010_sdio_update_index(struct ks_wlan_private *priv, u32 index) retval =ks7010_sdio_write (priv,WRITE_INDEX , data_buf,sizeof (index));if (retval) { rc =2 ; - goto error_out; + goto free_buf; } retval =ks7010_sdio_write (priv,READ_INDEX , data_buf,sizeof (index)); -if (retval) { +if (retval) rc =3 ; - goto error_out; - } - error_out: + free_buf:kfree (data_buf);return rc; }
@@ -748,16 +745,15 @@ static int ks7010_sdio_data_compare(struct ks_wlan_private *priv, u32 address, retval =ks7010_sdio_read (priv, address, read_buf, size);if (retval) { rc =2 ; - goto error_out; + goto free_buf; } retval =memcmp (data, read_buf, size);if (retval) {DPRINTK (0 ,"data compare error (%d) \n" , retval); rc =3 ; - goto error_out; } - error_out: + free_buf:kfree (read_buf);return rc; }
@@ -784,7 +780,7 @@ static int ks7010_upload_firmware(struct ks_wlan_private *priv,if (rw_data =GCR_A_RUN ) {DPRINTK (0 ,"MAC firmware running ...\n" ); rc =0 ; - goto error_out0; + goto release_host; } retval =request_firmware (&fw_entry,ROM_FILE , &priv->ks_wlan_hw.sdio_card->func->dev);
@@ -814,14 +810,14 @@ static int ks7010_upload_firmware(struct ks_wlan_private *priv, KS7010_IRAM_ADDRESS + offset);if (retval) { rc =6 ; - goto error_out1; + goto release_fw; }/* Write data */ retval =ks7010_sdio_write (priv,DATA_WINDOW , rom_buf, size);if (retval) { rc =8 ; - goto error_out1; + goto release_fw; }/* compare */
@@ -829,7 +825,7 @@ static int ks7010_upload_firmware(struct ks_wlan_private *priv,ks7010_sdio_data_compare (priv,DATA_WINDOW , rom_buf, size);if (retval) { rc =9 ; - goto error_out1; + goto release_fw; } n += size;
@@ -840,7 +836,7 @@ static int ks7010_upload_firmware(struct ks_wlan_private *priv, retval =ks7010_sdio_write (priv,GCR_A , &rw_data,sizeof (rw_data));if (retval) { rc =11 ; - goto error_out1; + goto release_fw; }DPRINTK (4 ," REMAP Request : GCR_A=%02X\n" , rw_data);
@@ -851,7 +847,7 @@ static int ks7010_upload_firmware(struct ks_wlan_private *priv,ks7010_sdio_read (priv,GCR_A , &rw_data,sizeof (rw_data));if (retval) { rc =11 ; - goto error_out1; + goto release_fw; }if (rw_data =GCR_A_RUN )break ;
@@ -860,14 +856,13 @@ static int ks7010_upload_firmware(struct ks_wlan_private *priv,if ((50 ) <= n) {DPRINTK (1 ,"firmware can't start\n" ); rc =12 ; - goto error_out1; + goto release_fw; } rc =0 ; - - error_out1: + release_fw:release_firmware (fw_entry); - error_out0: + release_host:sdio_release_host (card->func);kfree (rom_buf);return rc;
@@ -994,20 +989,20 @@ static int ks7010_sdio_probe(struct sdio_func *func, ret =sdio_enable_func (func);DPRINTK (5 ,"sdio_enable_func() %d\n" , ret);if (ret) - goto error_free_card; + goto free_card;/* interrupt disable */ sdio_writeb (func,0 ,INT_ENABLE , &ret);if (ret) - goto error_free_card; + goto free_card;sdio_writeb (func,0xff ,INT_PENDING , &ret);if (ret) - goto error_disable_func; + goto disable_func;/* setup interrupt handler */ ret =sdio_claim_irq (func, ks_sdio_interrupt);if (ret) - goto error_disable_func; + goto disable_func;sdio_release_host (func);
@@ -1020,11 +1015,11 @@ static int ks7010_sdio_probe(struct sdio_func *func, netdev =alloc_etherdev (sizeof (*priv));if (netdev =NULL ) {printk (KERN_ERR "ks7010 : Unable to alloc new net device\n" ); - goto error_release_irq; + goto release_irq; }if (dev_alloc_name (netdev,"wlan%d" ) <0 ) {printk (KERN_ERR "ks7010 : Couldn't get name!\n" ); - goto error_free_netdev; + goto free_dev; } priv =netdev_priv (netdev);
@@ -1038,7 +1033,7 @@ static int ks7010_sdio_probe(struct sdio_func *func, priv->ks_wlan_hw.read_buf =NULL ; priv->ks_wlan_hw.read_buf =kmalloc (RX_DATA_SIZE ,GFP_KERNEL );if (!priv->ks_wlan_hw.read_buf) { - goto error_free_netdev; + goto free_dev; } priv->dev_state =DEVICE_STATE_PREBOOT ; priv->net_dev = netdev;
@@ -1066,7 +1061,7 @@ static int ks7010_sdio_probe(struct sdio_func *func,printk (KERN_ERR "ks7010: firmware load failed !! retern code = %d\n" , ret); - goto error_free_read_buf; + goto free_buf; }/* interrupt setting */
@@ -1094,7 +1089,7 @@ static int ks7010_sdio_probe(struct sdio_func *func, priv->ks_wlan_hw.ks7010sdio_wq =create_workqueue ("ks7010sdio_wq" );if (!priv->ks_wlan_hw.ks7010sdio_wq) {DPRINTK (1 ,"create_workqueue failed !!\n" ); - goto error_free_read_buf; + goto free_buf; }INIT_DELAYED_WORK (&priv->ks_wlan_hw.rw_wq, ks7010_rw_function);
@@ -1102,22 +1097,22 @@ static int ks7010_sdio_probe(struct sdio_func *func, ret =register_netdev (priv->net_dev);if (ret) - goto error_free_read_buf; + goto free_buf;return 0 ; - error_free_read_buf: + free_buf:kfree (priv->ks_wlan_hw.read_buf); priv->ks_wlan_hw.read_buf =NULL ; - error_free_netdev: + free_dev:free_netdev (priv->net_dev); card->priv =NULL ; - error_release_irq: + release_irq:sdio_claim_host (func);sdio_release_irq (func); - error_disable_func: + disable_func:sdio_disable_func (func); - error_free_card: + free_card:sdio_release_host (func);sdio_set_drvdata (func,NULL );kfree (card);
Signature · 1 line
2.9.2
PATCH v2 5/10 staging: ks7010: Delete unnecessary uses of the variable "retval"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 10 Aug 2016 18:56:31 +0200
A few return values can also be directly used for condition checks. Thus remove a local variable for intermediate assignments.
---
v2: Rebased on the source files from Linux next-20160809.
Touched less source code places.
drivers/staging/ks7010/ks7010_sdio.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/staging/ks7010/ks7010_sdio.c +3 -8
@@ -489,7 +489,6 @@ static void ks7010_rw_function(struct work_struct *work)struct hw_info_t *hw;struct ks_wlan_private *priv;unsigned char rw_data; -int retval; hw = container_of(work, struct hw_info_t, rw_wq.work); priv = container_of(hw, struct ks_wlan_private, ks_wlan_hw);
@@ -538,9 +537,7 @@ static void ks7010_rw_function(struct work_struct *work) }/* read (WriteStatus/ReadDataSize FN1:00_0014) */ - retval -ks7010_sdio_read (priv,WSTATUS_RSIZE , &rw_data,sizeof (rw_data)); -if (retval) { +if (ks7010_sdio_read (priv,WSTATUS_RSIZE , &rw_data,sizeof (rw_data))) {DPRINTK (1 ," error : WSTATUS_RSIZE=%02X psstatus=%d\n" , rw_data,atomic_read (&priv->psstatus.status)); goto release_host;
@@ -708,7 +705,6 @@ static void trx_device_exit(struct ks_wlan_private *priv)static int ks7010_sdio_update_index (struct ks_wlan_private *priv,u32 index) {int rc =0 ; -int retval;unsigned char *data_buf; data_buf =kmalloc (sizeof (u32),GFP_KERNEL );
@@ -716,14 +712,12 @@ static int ks7010_sdio_update_index(struct ks_wlan_private *priv, u32 index)return 1 ;memcpy (data_buf, &index,sizeof (index)); - retval =ks7010_sdio_write (priv,WRITE_INDEX , data_buf,sizeof (index)); -if (retval) { +if (ks7010_sdio_write (priv,WRITE_INDEX , data_buf,sizeof (index))) { rc =2 ; goto free_buf; } - retval =ks7010_sdio_write (priv,READ_INDEX , data_buf,sizeof (index)); -if (retval) +if (ks7010_sdio_write (priv,READ_INDEX , data_buf,sizeof (index))) rc =3 ; free_buf:kfree (data_buf);
Signature · 1 line
2.9.2
PATCH v2 6/10 staging: ks7010: Delete unnecessary braces
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 10 Aug 2016 19:57:01 +0200
Do not use curly brackets at some source code places where a single statement should be sufficient.
---
v2: Rebased on the source files from Linux next-20160809.
Touched less source code places.
drivers/staging/ks7010/ks7010_sdio.c | 46 +++++++++++++----------------------- 1 file changed, 16 insertions(+), 30 deletions(-)
drivers/staging/ks7010/ks7010_sdio.c +16 -30
@@ -383,10 +383,9 @@ int ks_wlan_hw_tx(struct ks_wlan_private *priv, void *p, unsigned long size, result =enqueue_txdev (priv, p, size, complete_handler, arg1, arg2);spin_unlock (&priv->tx_dev.tx_dev_lock); -if (cnt_txqbody (priv) >0 ) { +if (cnt_txqbody (priv) >0 )queue_delayed_work (priv->ks_wlan_hw.ks7010sdio_wq, &priv->ks_wlan_hw.rw_wq,0 ); - }return result; }
@@ -402,9 +401,8 @@ static void rx_event_task(unsigned long dev)hostif_receive (priv, rp->data, rp->size);inc_rxqhead (priv); -if (cnt_rxqbody (priv) >0 ) { +if (cnt_rxqbody (priv) >0 )tasklet_schedule (&priv->ks_wlan_hw.rx_bh_task); - } }return ;
@@ -432,9 +430,8 @@ static void ks_wlan_hw_rx(void *dev, uint16_t size) retval ks7010_sdio_read(priv, DATA_WINDOW, &rx_buffer->data[0],hif_align_size (size )); -if (retval) { +if (retval) goto error_out; - }/* length check */ if (size >2046 || size =0 ) {
@@ -449,9 +446,8 @@ static void ks_wlan_hw_rx(void *dev, uint16_t size) retval ks7010_sdio_write(priv, READ_STATUS, &read_status, sizeof(read_status)); -if (retval) { +if (retval)DPRINTK (1 ," error : READ_STATUS=%02X\n" , read_status); - } goto error_out; }
@@ -470,12 +466,11 @@ static void ks_wlan_hw_rx(void *dev, uint16_t size) }DPRINTK (4 ,"READ_STATUS=%02X\n" , read_status); -if (atomic_read (&priv->psstatus.confirm_wait)) { +if (atomic_read (&priv->psstatus.confirm_wait))if (IS_HIF_CONF (event)) {DPRINTK (4 ,"IS_HIF_CONF true !!\n" );atomic_dec (&priv->psstatus.confirm_wait); } - }/* rx_event_task((void *)priv); */ tasklet_schedule (&priv->ks_wlan_hw.rx_bh_task);
@@ -544,13 +539,11 @@ static void ks7010_rw_function(struct work_struct *work) }DPRINTK (4 ,"WSTATUS_RSIZE=%02X\n" , rw_data); -if (rw_data &RSIZE_MASK ) {/* Read schedule */ +if (rw_data &RSIZE_MASK )/* Read schedule */ ks_wlan_hw_rx ((void *)priv, (uint16_t ) (((rw_data &RSIZE_MASK ) <<4 ))); - } -if ((rw_data &WSTATUS_MASK )) { +if (rw_data &WSTATUS_MASK )tx_device_task ((void *)priv); - }_ks_wlan_hw_power_save (priv); release_host:sdio_release_host (priv->ks_wlan_hw.sdio_card->func);
@@ -618,10 +611,9 @@ static void ks_sdio_interrupt(struct sdio_func *func) }DPRINTK (4 ,"WSTATUS_RSIZE=%02X\n" , rw_data); rsize = rw_data &RSIZE_MASK ; -if (rsize) {/* Read schedule */ +if (rsize)/* Read schedule */ ks_wlan_hw_rx ((void *)priv, (uint16_t ) (((rsize) <<4 ))); - }if (rw_data &WSTATUS_MASK ) {#if 0 if (status & INT_WRITE_STATUS
@@ -632,11 +624,10 @@ static void ks_sdio_interrupt(struct sdio_func *func)ks7010_sdio_write (priv,DATA_WINDOW , &rw_data,sizeof (rw_data)); -if (retval) { +if (retval)DPRINTK (1 ,"write DATA_WINDOW Failed!!(%d)\n" , retval); - } status &= ~INT_WRITE_STATUS; }else {#endif
@@ -877,13 +868,11 @@ static void ks7010_card_init(struct ks_wlan_private *priv)DPRINTK (5 ,"hostif_sme_enqueu()\n" );if (!wait_for_completion_interruptible_timeout - (&priv->confirm_wait,5 *HZ )) { + (&priv->confirm_wait,5 *HZ ))DPRINTK (1 ,"wait time out!! SME_START\n" ); - } -if (priv->mac_address_valid && priv->version_size) { +if (priv->mac_address_valid && priv->version_size) priv->dev_state =DEVICE_STATE_PREINIT ; - }hostif_sme_enqueue (priv,SME_GET_EEPROM_CKSUM );
@@ -905,9 +894,8 @@ static void ks7010_card_init(struct ks_wlan_private *priv)hostif_sme_enqueue (priv,SME_START_REQUEST );if (!wait_for_completion_interruptible_timeout - (&priv->confirm_wait,5 *HZ )) { + (&priv->confirm_wait,5 *HZ ))DPRINTK (1 ,"wait time out!! wireless parameter set\n" ); - }if (priv->dev_state >=DEVICE_STATE_PREINIT ) {DPRINTK (1 ,"DEVICE READY!!\n" );
@@ -1026,9 +1014,9 @@ static int ks7010_sdio_probe(struct sdio_func *func,init_completion (&priv->ks_wlan_hw.ks7010_sdio_wait); priv->ks_wlan_hw.read_buf =NULL ; priv->ks_wlan_hw.read_buf =kmalloc (RX_DATA_SIZE ,GFP_KERNEL ); -if (!priv->ks_wlan_hw.read_buf) { +if (!priv->ks_wlan_hw.read_buf) goto free_dev; - } + priv->dev_state =DEVICE_STATE_PREBOOT ; priv->net_dev = netdev; priv->firmware_version[0 ] ='\0' ;
@@ -1064,9 +1052,8 @@ static int ks7010_sdio_probe(struct sdio_func *func,sdio_claim_host (func); ret =ks7010_sdio_write (priv,INT_PENDING , &rw_data,sizeof (rw_data));sdio_release_host (func); -if (ret) { +if (ret)DPRINTK (1 ," error : INT_PENDING=%02X\n" , rw_data); - }DPRINTK (4 ," clear Interrupt : INT_PENDING=%02X\n" , rw_data);/* enable ks7010sdio interrupt (INT_GCR_B|INT_READ_STATUS|INT_WRITE_STATUS) */
@@ -1074,9 +1061,8 @@ static int ks7010_sdio_probe(struct sdio_func *func,sdio_claim_host (func); ret =ks7010_sdio_write (priv,INT_ENABLE , &rw_data,sizeof (rw_data));sdio_release_host (func); -if (ret) { +if (ret)DPRINTK (1 ," error : INT_ENABLE=%02X\n" , rw_data); - }DPRINTK (4 ," enable Interrupt : INT_ENABLE=%02X\n" , rw_data); priv->dev_state =DEVICE_STATE_BOOT ;
Signature · 1 line
2.9.2
PATCH v2 7/10 staging: ks7010: Add the macro "pr_fmt"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 10 Aug 2016 20:45:11 +0200
Add a definition for the macro "pr_fmt" so that its information can be used for consistent message output.
---
v2: Addition from source code review
drivers/staging/ks7010/ks7010_sdio.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/staging/ks7010/ks7010_sdio.c +2 -0
@@ -10,6 +10,8 @@* published by the Free Software Foundation. */ +#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt +#include <linux/firmware.h> #include <linux/mmc/card.h> #include <linux/mmc/sdio_func.h>
Signature · 1 line
2.9.2
PATCH v2 8/10 staging: ks7010: Replace three printk() calls by pr_err()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 10 Aug 2016 21:56:15 +0200
Prefer usage of the macro "pr_err" over the interface "printk". Fix a typo in an error message.
---
v2: Rebased on the source files from Linux next-20160809.
drivers/staging/ks7010/ks7010_sdio.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/staging/ks7010/ks7010_sdio.c +3 -4
@@ -998,11 +998,11 @@ static int ks7010_sdio_probe(struct sdio_func *func,/* private memory allocate */ netdev =alloc_etherdev (sizeof (*priv));if (netdev =NULL ) { -printk (KERN_ERR "ks7010 : Unable to alloc new net device\n" ); +pr_err (pr_fmt ("Unable to alloc new net device\n" )); goto release_irq; }if (dev_alloc_name (netdev,"wlan%d" ) <0 ) { -printk (KERN_ERR "ks7010 : Couldn't get name!\n" ); +pr_err (pr_fmt ("Couldn't get name!\n" )); goto free_dev; }
@@ -1042,8 +1042,7 @@ static int ks7010_sdio_probe(struct sdio_func *func,/* Upload firmware */ ret =ks7010_upload_firmware (priv, card);/* firmware load */ if (ret) { -printk (KERN_ERR -"ks7010: firmware load failed !! retern code = %d\n" , +pr_err (pr_fmt ("firmware load failed! return code = %d\n" ), ret); goto free_buf; }
Signature · 1 line
2.9.2
Re: [PATCH v2 08/10] staging: ks7010: Replace three printk() calls by pr_err()
Quoted 1 line · SF Markus Elfring
Prefer usage of the macro "
pr_err" over the interface "printk".
Not correct
drivers/staging/ks7010/ks7010_sdio.c
Quoted 1 line
drivers/staging/ks7010/ks7010_sdio.c +0
-0
[]
drivers/staging/ks7010/ks7010_sdio.c static int ks7010_sdio_probe(struct sdio_func *func, · line 1001
Quoted 6 lines
drivers/staging/ks7010/ks7010_sdio.c +1
-1@@ -998,11 +998,11 @@ static int ks7010_sdio_probe(struct sdio_func *func, /* private memory allocate */ netdev = alloc_etherdev(sizeof(*priv)); if (netdev = NULL) { -printk (KERN_ERR "ks7010 : Unable to alloc new net device\n" ); +pr_err (pr_fmt ("Unable to alloc new net device\n" ));
All of these pr_fmt uses are redundant as pr_err already does pr_fmt alloc_etherdev already does a dump_stack so the OOM isn't useful.
Quoted 15 lines
drivers/staging/ks7010/ks7010_sdio.c +1
-1goto release_irq; } if (dev_alloc_name(netdev, "wlan%d") < 0) { -printk (KERN_ERR "ks7010 : Couldn't get name!\n" ); +pr_err (pr_fmt ("Couldn't get name!\n" )); goto free_dev; }drivers/staging/ks7010/ks7010_sdio.c +0
-0@@ -1042,8 +1042,7 @@ static int ks7010_sdio_probe(struct sdio_func *func, /* Upload firmware */ret =
ks7010_upload_firmware(priv, card); /* firmware load */
if (ret) {drivers/staging/ks7010/ks7010_sdio.c +1
-2- printk(KERN_ERR - "ks7010: firmware load failed !! retern code = %d\n", + pr_err(pr_fmt("firmware load failed! return code = %d\n"),
Quoted 3 lines
ret);
gotofree_buf;
}
--
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: staging: ks7010: Replace three printk() calls by pr_err()
Quoted 2 lines
Quoted 1 line
Prefer usage of the macro "
pr_err" over the interface "printk".Not correct
A checkpatch warning like "PREFER_PR_LEVEL" can point additional possibilities out for this use case.
Would you like to introduce any of the higher level logging functions instead?
Quoted 10 lines
drivers/staging/ks7010/ks7010_sdio.c
Quoted 1 line
drivers/staging/ks7010/ks7010_sdio.c +0
-0[]
drivers/staging/ks7010/ks7010_sdio.c static int ks7010_sdio_probe(struct sdio_func *func, · line 1001
Quoted 6 lines
drivers/staging/ks7010/ks7010_sdio.c +1
-1@@ -998,11 +998,11 @@ static int ks7010_sdio_probe(struct sdio_func *func,/* private memory allocate */ netdev =alloc_etherdev (sizeof (*priv));if (netdev =NULL ) { -printk (KERN_ERR "ks7010 : Unable to alloc new net device\n" ); +pr_err (pr_fmt ("Unable to alloc new net device\n" ));All of these
pr_fmtuses are redundant aspr_erralready doespr_fmt
Thanks for your reminder.
Would you accept that another update will be appended to the discussed patch series?
Quoted 1 line
alloc_etherdevalready does adump_stackso the OOM isn't useful.
Does this information indicate that this printk() (or pr_err()) call should be deleted?
Regards,
Markus
Re: staging: ks7010: Replace three printk() calls by pr_err()
Quoted 5 lines · SF Markus Elfring
Quoted 2 lines
Quoted 1 line
Prefer usage of the macro "
pr_err" over the interface "printk".Not correct
A checkpatch warning like "
PREFER_PR_LEVEL" can point additional possibilities out for this use case.
Would you like to introduce any of the higher level logging functions instead?
I think pr_<level> is OK if reworking the code
to support dev_<level> is not easy.
Quoted 10 lines
Quoted 10 lines
drivers/staging/ks7010/ks7010_sdio.c
Quoted 1 line
drivers/staging/ks7010/ks7010_sdio.c +0
-0[]
drivers/staging/ks7010/ks7010_sdio.c static int ks7010_sdio_probe(struct sdio_func *func, · line 1001
Quoted 7 lines
drivers/staging/ks7010/ks7010_sdio.c +1
-1@@ -998,11 +998,11 @@ static int ks7010_sdio_probe(struct sdio_func *func, /* private memory allocate */ netdev = alloc_etherdev(sizeof(*priv)); if (netdev = NULL) { -printk (KERN_ERR "ks7010 : Unable to alloc new net device\n" ); +pr_err (pr_fmt ("Unable to alloc new net device\n" ));All of these
pr_fmtuses are redundant aspr_erralready doespr_fmt
Quoted 3 lines
Thanks for your reminder.
Would you accept that another update will be appended to the discussed patch series?
No. Patches should not knowingly introduce defects that are corrected in follow-on patches.
Quoted 3 lines
Quoted 1 line
alloc_etherdevalready does adump_stackso the OOM isn't useful.Does this information indicate that this
printk()(orpr_err()) call should be deleted?
Markus, I don't know if it's your lack of English comprehension or not, but it's fairly obvious from my reply that this line should be deleted, either in this patch or a follow-on.
--
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: staging: ks7010: Replace three printk() calls by pr_err()
Quoted 2 lines
I think pr_<level> is OK if reworking the code to support dev_<level> is not easy.
Thanks for this explanation. - It sounds more constructive than the previous short feedback "Not correct".
Quoted 4 lines
Quoted 1 line
Would you accept that another update will be appended to the discussed patch series?
No. Patches should not knowingly introduce defects that are corrected in follow-on patches.
This view is fine in principle.
I am just curious on the preferred sequence to fix the affected implementation details.
1. I imagine that my questionable update suggestion "[PATCH v2 08/10] staging: ks7010:
Replace three printk() calls by pr_err()" can be skipped and the remaining logging calls will be improved somehow a bit later.
Or:
2. Do you want a resend of this whole patch series?
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
alloc_etherdevalready does adump_stackso the OOM isn't useful.Does this information indicate that this
printk()(orpr_err()) call should be deleted?Markus, I don't know if it's your lack of English comprehension or not, but it's fairly obvious from my reply that this line should be deleted,
I was unsure if this view fits to a consensus also by other developers.
It might be that I can occasionally become picky to check if other contributors insist on the usage of a specific error message.
Quoted 1 line
either in this patch or a follow-on.
I would prefer another addition (or source code clean-up) later. Could it happen that so many error messages are update candidates (for deletion) so that no places remain where a pr_err() call would make sense in this software module?
Regards,
Markus
Re: staging: ks7010: Replace three printk() calls by pr_err()
Quoted 5 lines · SF Markus Elfring
Quoted 3 lines
I think
pr_is OK if reworking the code
to supportdev_is not easy.Thanks for this explanation. - It sounds more constructive than the previous short feedback "Not correct".
<frustration>
How do you need your food prepared?
Do others need to cut it for you to bite sized pieces? </frustration>
You might have noticed I also wrote in the same reply:
"All of these pr_fmt uses are redundant as pr_err already does pr_fmt"
Quoted 4 lines
Quoted 3 lines
Quoted 1 line
Would you accept that another update will be appended to the discussed patch series?
No. Patches should not knowingly introduce defects that are corrected in follow-on patches.
This view is fine in principle.
It is not just principle.
It is a fundamental for kernel patch submission.
Quoted 9 lines
I am just curious on the preferred sequence to fix the affected implementation details.
1. I imagine that my questionable update suggestion "[PATCH v2 08/10] staging: ks7010:
Replace threeprintk()calls bypr_err()" can be skipped and the remaining logging calls will be improved somehow a bit later.Or:
2. Do you want a resend of this whole patch series?
I am not an upstream path.
Greg KH generally serves that function here.
My suggestion would be to resend the entire patchset as V(n+1).
Quoted 2 lines
It might be that I can occasionally become picky to check if other contributors insist on the usage of a specific error message.
You can be prone to understatement.
--
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: staging: ks7010: Replace three printk() calls by pr_err()
Quoted 3 lines
You might have noticed I also wrote in the same reply:
"All of these
pr_fmtuses are redundant aspr_erralready doespr_fmt"
I admit that I made another software development mistake there. - It might not matter much when a final fix could be to get rid of the three affected logging calls for example.
Quoted 2 lines
It is not just principle.
It is a fundamental for kernel patch submission.
I hope that this view supports still the reordering for update steps after some discussion.
Quoted 3 lines
I am not an upstream path.
Greg KH generally serves that function here.
My suggestion would be to resend the entire patchset as V(n+1).
I am curious if it would make sense to reduce the mail traffic a bit by finding out which software changes can be accepted already.
Regards,
Markus
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: staging: ks7010: Replace three printk() calls by pr_err()
Quoted 1 line
Really now, this is basic fixes and cleanups,
I agree to this view to some degree.
Quoted 1 line
you have been asked many times in the past to move on beyond these,
It is more useful when more severe bugs or bigger software improvements can be found. Which source code clean-ups are picked better up by other contributors?
Quoted 2 lines
as you often times seem to end up wasting lots of people's times as they attempt to help you.
It can take a bit more time occasionally to achieve the desired consensus.
Quoted 1 line
Personally, I'm long past wishing to help you out here, sorry.
Other contributors will eventually continue the clarification of remaining open issues in the source file "ks7010_sdio.c".
Quoted 3 lines
I'll take "correct" patches, but that's it. No discussion of them, no arguing over theoreticals, and no telling you what I might, or might not, want to see done in the future, sorry.
I became aware about software development possibilities which can also matter here.
Yesterday Julia Lawall informed me about a presentation on the topic "Refactor strings – make everyone happy" by Wolfram Sang on 2016-07-14.
Is such a software evolution also interesting and acceptable for you?
Quoted 2 lines
And really, your patch quality stinks, I strongly suggest getting a lot more experience with C first before doing more kernel work please.
Can you accept any specific update steps while other software changes will evolve after a bit of discussion as usual?
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
PATCH v2 9/10 staging: ks7010: Delete a variable in write_to_device()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 10 Aug 2016 22:10:20 +0200
The local variable "rc" was assigned a zero at one place. But it was not read within this function. Thus delete it.
---
v2: Rebased on the source files from Linux next-20160809.
drivers/staging/ks7010/ks7010_sdio.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/ks7010/ks7010_sdio.c +1 -2
@@ -299,11 +299,10 @@ static int enqueue_txdev(struct ks_wlan_private *priv, unsigned char *p,static int write_to_device (struct ks_wlan_private *priv,unsigned char *buffer,unsigned long size) { -int rc, retval; +int retval;unsigned char rw_data;struct hostif_hdr *hdr; hdr = (struct hostif_hdr *)buffer; - rc =0 ;DPRINTK (4 ,"size=%d\n" , hdr->size);if (hdr->event <HIF_DATA_REQ ||HIF_REQ_MAX < hdr->event) {
Signature · 1 line
2.9.2
PATCH v2 10/10 staging: ks7010: Delete three unnecessary variable initialisations
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 10 Aug 2016 22:33:52 +0200
Three variables will be set to an appropriate value a bit later. Thus omit the explicit initialisation at the beginning.
---
v2: Rebased on the source files from Linux next-20160809.
It was omitted to reduce the scope for the variable "rc" in the function "tx_device_task".
drivers/staging/ks7010/ks7010_sdio.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/ks7010/ks7010_sdio.c +3 -3
@@ -331,7 +331,7 @@ static void tx_device_task(void *dev) {struct ks_wlan_private *priv = (struct ks_wlan_private *)dev;struct tx_device_buffer *sp; -int rc =0 ; +int rc;DPRINTK (4 ,"\n" ); if (cnt_txqbody(priv) > 0
@@ -366,7 +366,7 @@ int ks_wlan_hw_tx(struct ks_wlan_private *priv, void *p, unsigned long size,void (*complete_handler) (void *arg1,void *arg2), void *arg1, void *arg2) { - int result = 0; + int result;struct hostif_hdr *hdr; hdr = (struct hostif_hdr *)p;
@@ -747,7 +747,7 @@ static int ks7010_sdio_data_compare(struct ks_wlan_private *priv, u32 address,static int ks7010_upload_firmware (struct ks_wlan_private *priv,struct ks_sdio_card *card) { -unsigned int size, offset, n =0 ; +unsigned int size, offset, n;unsigned char *rom_buf;unsigned char rw_data =0 ;int retval, rc =0 ;
Signature · 1 line
2.9.2
Re: [PATCH v2 00/10] staging: ks7010: Fine-tuning for a SDIO card driver
In reply to SF Markus ElfringQuoted 3 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Further update suggestions were taken into account
Which ones? Please describe them to ease review.
Quoted 1 line
after a patch was applied from static source code analysis.
I added some Acked- and Reviewed-by tags last time. Did the patches change or why didn't you add them?
Re: [PATCH v2 00/10] staging: ks7010: Fine-tuning for a SDIO card driver
Quoted 1 line
I added some Acked- and Reviewed-by tags last time.
I noticed this of course.
Quoted 1 line
Did the patches change
Yes. - The amount of source code which I touched in this software module is different for the second series.
Quoted 1 line
or why didn't you add them?
I imagined that your acknowledgements to the previous approach might not fit to the current software development situation any more.
Regards,
Markus
PATCH 1/1 tw686x-kh: Delete an unnecessary check before the function call "video_unregister_device"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 17 Jul 2016 22:00:35 +0200
The video_unregister_device() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/staging/media/tw686x-kh/tw686x-kh-video.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/media/tw686x-kh/tw686x-kh-video.c +1 -2
@@ -643,8 +643,7 @@ void tw686x_kh_video_free(struct tw686x_dev *dev)struct tw686x_video_channel *vc = &dev->video_channels[ch];v4l2_ctrl_handler_free (&vc->ctrl_handler); -if (vc->device) -video_unregister_device (vc->device); +video_unregister_device (vc->device);vb2_dma_sg_cleanup_ctx (vc->alloc_ctx);for (n =0 ; n <2 ; n++) {struct dma_desc *descs = &vc->sg_tables[n];
Signature · 1 line
2.9.1
Re: [PATCH] [media] tw686x-kh: Delete an unnecessary check before the function call "video_unregister_device"
Quoted 8 lines · SF Markus Elfring
The
video_unregister_device()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/staging/media/tw686x-kh/tw686x-kh-video.c | 3 +--
Thanks.
Signature · 4 lines
Krzysztof Halasa Industrial Research Institute for Automation and Measurements PIAP Al. Jerozolimskie 202, 02-486 Warsaw, Poland
PATCH 1/1 cec: Delete an unnecessary check before the function call "rc_free_device"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 17 Jul 2016 22:52:49 +0200
The rc_free_device() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/staging/media/cec/cec-core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/media/cec/cec-core.c +1 -2
@@ -354,8 +354,7 @@ void cec_delete_adapter(struct cec_adapter *adap)if (adap->kthread_config)kthread_stop (adap->kthread_config);#if IS_ENABLED (CONFIG_RC_CORE ) -if (adap->rc) -rc_free_device (adap->rc); +rc_free_device (adap->rc);#endif kfree (adap); }
Signature · 1 line
2.9.1
PATCH 1/1 hwmon-ntc_thermistor: Delete an unnecessary check before the function call "iio_channel_release"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 18 Jul 2016 20:34:41 +0200
The iio_channel_release() function tests whether its argument 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/hwmon/ntc_thermistor.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/hwmon/ntc_thermistor.c +1 -2
@@ -361,8 +361,7 @@ ntc_thermistor_parse_dt(struct platform_device *pdev) }static void ntc_iio_channel_release (struct ntc_thermistor_platform_data *pdata) { -if (pdata->chan) -iio_channel_release (pdata->chan); +iio_channel_release (pdata->chan); }#else static struct ntc_thermistor_platform_data *
Signature · 1 line
2.9.2
Guenter Roeck
maintainerRe: [PATCH] hwmon-ntc_thermistor: Delete an unnecessary check before the function call "iio_channel_release"
Quoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Mon, 18 Jul 2016 20:34:41 +0200The
iio_channel_release()function tests whether its argument 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]>
A much better change would be to use devm_iio_channel_get() instead of iio_channel_get(), and to remove ntc_iio_channel_release() completely.
Guenter
PATCH 1/1 virtio-balloon: Delete an unnecessary check before the function call "iput"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 18 Jul 2016 21:17:18 +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.
--- drivers/virtio/virtio_balloon.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/virtio/virtio_balloon.c +1 -2
@@ -611,8 +611,7 @@ static void virtballoon_remove(struct virtio_device *vdev)cancel_work_sync (&vb->update_balloon_stats_work);remove_common (vb); -if (vb->vb_dev_info.inode) -iput (vb->vb_dev_info.inode); +iput (vb->vb_dev_info.inode);kfree (vb); }
Signature · 1 line
2.9.2
PATCH 1/1 virtio-balloon: Delete an unnecessary check before the function call "iput"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 18 Jul 2016 21:17:18 +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.
--- drivers/virtio/virtio_balloon.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/virtio/virtio_balloon.c +1 -2
@@ -611,8 +611,7 @@ static void virtballoon_remove(struct virtio_device *vdev)cancel_work_sync (&vb->update_balloon_stats_work);remove_common (vb); -if (vb->vb_dev_info.inode) -iput (vb->vb_dev_info.inode); +iput (vb->vb_dev_info.inode);kfree (vb); }
Signature · 1 line
2.9.2
PATCH 1/1 v4l2-common: Delete an unnecessary check before the function call "spi_unregister_device"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 19 Jul 2016 19:54:16 +0200
The spi_unregister_device() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/media/v4l2-core/v4l2-common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/v4l2-core/v4l2-common.c +1 -1
@@ -291,7 +291,7 @@ struct v4l2_subdev *v4l2_spi_new_subdev(struct v4l2_device *v4l2_dev, error:/* If we have a client but no subdev, then something went wrong and we must unregister the client. */ -if (spi && sd =NULL ) +if (!sd)spi_unregister_device (spi);return sd;
Signature · 1 line
2.9.2
Re: [PATCH] [media] v4l2-common: Delete an unnecessary check before the function call "spi_unregister_device"
Am 19.07.2016 20:02, schrieb SF Markus Elfring:
Quoted 18 lines
From: Markus Elfring <[email protected]>
Date: Tue, 19 Jul 2016 19:54:16 +0200The
spi_unregister_device()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/media/v4l2-core/v4l2-common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/media/v4l2-core/v4l2-common.c +0
-0
drivers/media/v4l2-core/v4l2-common.c struct v4l2_subdev *v4l2_spi_new_subdev(struct v4l2_device *v4l2_dev, · line 297
Quoted 8 lines
drivers/media/v4l2-core/v4l2-common.c +1
-1@@ -291,7 +291,7 @@ struct v4l2_subdev *v4l2_spi_new_subdev(struct v4l2_device *v4l2_dev, error:/* If we have a client but no subdev, then something went wrong and we must unregister the client. */ -if (spi && sd =NULL ) +if (!sd)spi_unregister_device (spi);return sd;
if i read the code correct sd is always NULL at this point. so this was wrong in the first place and you must remove sd also.
re,
wh
PATCH 1/1 tw686x: Delete an unnecessary check before the function call "video_unregister_device"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 19 Jul 2016 21:24:26 +0200
The video_unregister_device() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/media/pci/tw686x/tw686x-video.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/media/pci/tw686x/tw686x-video.c +1 -2
@@ -1093,8 +1093,7 @@ void tw686x_video_free(struct tw686x_dev *dev)for (ch =0 ; ch <max_channels (dev); ch++) {struct tw686x_video_channel *vc = &dev->video_channels[ch]; -if (vc->device) -video_unregister_device (vc->device); +video_unregister_device (vc->device);if (dev->dma_ops->free)for (pb =0 ; pb <2 ; pb++)
Signature · 1 line
2.9.2
PATCH 1/1 of: Delete an unnecessary check before the function call "of_node_put"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 19 Jul 2016 22:42:22 +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.
--- drivers/of/base.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/of/base.c +1 -2
@@ -1609,8 +1609,7 @@ static int __of_parse_phandle_with_args(const struct device_node *np,*/ err: -if (it.node) -of_node_put (it.node); +of_node_put (it.node);return rc; }
Signature · 1 line
2.9.2
Re: [PATCH] of: Delete an unnecessary check before the function call "of_node_put"
Quoted 7 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Tue, 19 Jul 2016 22:42:22 +0200The
of_node_put()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/of/base.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
Applied, thanks.
Rob
PATCH 1/1 cxl: Delete an unnecessary check before the function call "of_node_put"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 20 Jul 2016 15:10:32 +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.
--- drivers/misc/cxl/of.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/misc/cxl/of.c +1 -2
@@ -490,8 +490,7 @@ int cxl_of_probe(struct platform_device *pdev) adapter->slices =0 ; } -if (afu_np) -of_node_put (afu_np); +of_node_put (afu_np);return 0 ; }
Signature · 1 line
2.9.2
Re: [PATCH] cxl: Delete an unnecessary check before the function call "of_node_put"
Quoted 19 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 20 Jul 2016 15:10:32 +0200The
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/misc/cxl/of.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/misc/cxl/of.c +0
-0
drivers/misc/cxl/of.c int cxl_of_probe(struct platform_device *pdev) · line 495
Quoted 8 lines
drivers/misc/cxl/of.c +1
-2@@ -490,8 +490,7 @@ int cxl_of_probe(struct platform_device *pdev) adapter->slices =0 ; } -if (afu_np) -of_node_put (afu_np); +of_node_put (afu_np);return 0 ; }
I don't think that the call should be there at all. The loop only exits when afu_np is NULL. Furthermore, the loop should not be written as a for loop, but rather with for_each_child_of_node.
julia
Re: [PATCH] cxl: Delete an unnecessary check before the function call "of_node_put"
Quoted 3 lines · Julia Lawall
I don't think that the call should be there at all. The loop only exits when
afu_npis NULL. Furthermore, the loop should not be written as a for loop, but rather withfor_each_child_of_node.
Will send a patch to fix both issues shortly.
Signature · 2 lines
Andrew Donnellan OzLabs, ADL Canberra [email protected] IBM Australia Limited
PATCH 1/1 cxl: replace loop with for_each_child_of_node(), remove unneeded of_node_put()
Rewrite the cxl_guest_init_afu() loop in cxl_of_probe() to use for_each_child_of_node() rather than a hand-coded for loop.
Remove the useless of_node_put(afu_np) call after the loop, where it's guaranteed that afu_np = NULL.
---
Checked the of_node_put() with Fred, he thinks it was probably just left over from an earlier private version of the code and we can just get rid of it.
--- drivers/misc/cxl/of.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/misc/cxl/of.c +3 -5
@@ -460,7 +460,7 @@ int cxl_of_probe(struct platform_device *pdev)struct device_node *afu_np =NULL ;struct cxl *adapter =NULL ;int ret; -int slice, slice_ok; +int slice =0 , slice_ok =0 ;pr_devel ("in %s\n" , __func__);
@@ -476,13 +476,13 @@ int cxl_of_probe(struct platform_device *pdev) }/* init afu */ - slice_ok =0 ; -for (afu_np =NULL , slice =0 ; (afu_np =of_get_next_child (np, afu_np)); slice++) { +for_each_child_of_node (np, afu_np) {if ((ret =cxl_guest_init_afu (adapter, slice, afu_np)))dev_err (&pdev->dev,"AFU %i failed to initialise: %i\n" , slice, ret);else slice_ok++; + slice++; }if (slice_ok =0 ) {
@@ -490,8 +490,6 @@ int cxl_of_probe(struct platform_device *pdev) adapter->slices =0 ; } -if (afu_np) -of_node_put (afu_np);return 0 ; }
Signature · 2 lines
Andrew Donnellan OzLabs, ADL Canberra [email protected] IBM Australia Limited
Re: [PATCH] cxl: replace loop with for_each_child_of_node(), remove unneeded of_node_put()
Quoted 9 lines · Andrew Donnellan
Rewrite the
cxl_guest_init_afu()loop incxl_of_probe()to usefor_each_child_of_node()rather than a hand-coded for loop.Remove the useless
of_node_put(afu_np)call after the loop, where it's guaranteed thatafu_np= NULL.Reported-by SF Markus Elfring <[email protected]>Reported-by Julia Lawall <[email protected]>Signed-off-by Andrew Donnellan <[email protected]>
Thanks!
--
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] cxl: replace loop with for_each_child_of_node(), remove unneeded of_node_put()
In reply to Andrew DonnellanAm 29.07.2016 05:55, schrieb Andrew Donnellan:
Quoted 36 lines
Rewrite the
cxl_guest_init_afu()loop incxl_of_probe()to usefor_each_child_of_node()rather than a hand-coded for loop.Remove the useless
of_node_put(afu_np)call after the loop, where it's guaranteed thatafu_np= NULL.Reported-by SF Markus Elfring <[email protected]>Reported-by Julia Lawall <[email protected]>Signed-off-by Andrew Donnellan <[email protected]>---
Checked the
of_node_put()with Fred, he thinks it was probably just left over from an earlier private version of the code and we can just get rid of it.--- drivers/misc/cxl/of.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)drivers/misc/cxl/of.c +1
-1@@ -460,7 +460,7 @@ int cxl_of_probe(struct platform_device *pdev)struct device_node *afu_np =NULL ;struct cxl *adapter =NULL ;int ret; -int slice, slice_ok; +int slice =0 , slice_ok =0 ;pr_devel ("in %s\n" , __func__);@@ -476,13 +476,13 @@ int cxl_of_probe(struct platform_device *pdev) }/* init afu */
drivers/misc/cxl/of.c int cxl_of_probe(struct platform_device *pdev) · line 486
Quoted 10 lines
drivers/misc/cxl/of.c +2
-2- slice_ok =0 ; -for (afu_np =NULL , slice =0 ; (afu_np =of_get_next_child (np, afu_np)); slice++) { +for_each_child_of_node (np, afu_np) {if ((ret =cxl_guest_init_afu (adapter, slice, afu_np)))dev_err (&pdev->dev,"AFU %i failed to initialise: %i\n" , slice, ret);else slice_ok++; + slice++; }
while you are here ..
you could move the assign out of the condition..
ret = cxl_guest_init_afu(adapter, slice, afu_np);
if (ret) ....
just my 2 cents,
re,
wh
Quoted 11 lines
drivers/misc/cxl/of.c +0
-2if (slice_ok =0 ) {@@ -490,8 +490,6 @@ int cxl_of_probe(struct platform_device *pdev) adapter->slices =0 ; } -if (afu_np) -of_node_put (afu_np);return 0 ; }
Re: [PATCH] cxl: replace loop with for_each_child_of_node(), remove unneeded of_node_put()
Quoted 53 lines · walter harms
Am 29.07.2016 05:55, schrieb Andrew Donnellan:
Quoted 36 lines
Rewrite the
cxl_guest_init_afu()loop incxl_of_probe()to usefor_each_child_of_node()rather than a hand-coded for loop.Remove the useless
of_node_put(afu_np)call after the loop, where it's guaranteed thatafu_np== NULL.Reported-by SF Markus Elfring <[email protected]>Reported-by Julia Lawall <[email protected]>Signed-off-by Andrew Donnellan <[email protected]>---
Checked the
of_node_put()with Fred, he thinks it was probably just left over from an earlier private version of the code and we can just get rid of it.--- drivers/misc/cxl/of.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)drivers/misc/cxl/of.c +1
-1@@ -460,7 +460,7 @@ int cxl_of_probe(struct platform_device *pdev)struct device_node *afu_np =NULL ;struct cxl *adapter =NULL ;int ret; -int slice, slice_ok; +int slice =0 , slice_ok =0 ;pr_devel ("in %s\n" , __func__);@@ -476,13 +476,13 @@ int cxl_of_probe(struct platform_device *pdev) }/* init afu */ drivers/misc/cxl/of.c int cxl_of_probe(struct platform_device *pdev) · line 486
Quoted 10 lines
drivers/misc/cxl/of.c +2
-2- slice_ok =0 ; -for (afu_np =NULL , slice =0 ; (afu_np =of_get_next_child (np, afu_np)); slice++) { +for_each_child_of_node (np, afu_np) {if ((ret =cxl_guest_init_afu (adapter, slice, afu_np)))dev_err (&pdev->dev,"AFU %i failed to initialise: %i\n" , slice, ret);else slice_ok++; + slice++; }while you are here ..
you could move the assign out of the condition..
Quoted 2 lines
ret =
cxl_guest_init_afu(adapter, slice, afu_np);
if (ret) ....
Yes, please.
julia
Quoted 22 lines
just my 2 cents,
re,
whdrivers/misc/cxl/of.c int cxl_of_probe(struct platform_device *pdev) · line 495
Quoted 11 lines
drivers/misc/cxl/of.c +0
-2if (slice_ok ==0 ) {@@ -490,8 +490,6 @@ int cxl_of_probe(struct platform_device *pdev) adapter->slices =0 ; } -if (afu_np) -of_node_put (afu_np);return 0 ; }--
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
Michael Ellerman
reviewerRe: [PATCH] cxl: replace loop with for_each_child_of_node(), remove unneeded of_node_put()
In reply to Andrew DonnellanQuoted 10 lines · Andrew Donnellan
Rewrite the
cxl_guest_init_afu()loop incxl_of_probe()to usefor_each_child_of_node()rather than a hand-coded for loop.Remove the useless
of_node_put(afu_np)call after the loop, where it's guaranteed thatafu_np= NULL.Reported-by SF Markus Elfring <[email protected]>Reported-by Julia Lawall <[email protected]>Signed-off-by Andrew Donnellan <[email protected]>
Quoted 5 lines
---
Checked the
of_node_put()with Fred, he thinks it was probably just left over from an earlier private version of the code and we can just get rid of it.
But who does keep a reference on the device_node? I can't see it anywhere. Which means in theory the device_node can be freed out from under you.
You have a reference for afu_np as part of for_each_child_of_node(), but it's dropped as soon as you go around the loop.
The typical pattern would be that cxl_guest_init_afu() takes an additional reference once it's done all its setup and can't fail.
That way at the end of the loop when the loop construct has dropped all references, the nodes you actually init'ed have their reference count incremented by 1.
cheers
Re: [PATCH] cxl: replace loop with for_each_child_of_node(), remove unneeded of_node_put()
Quoted 6 lines · Michael Ellerman
But who does keep a reference on the
device_node? I can't see it anywhere. Which means in theory thedevice_nodecan be freed out from under you.You have a reference for
afu_npas part offor_each_child_of_node(), but it's dropped as soon as you go around the loop.
Quoted 6 lines
The typical pattern would be that
cxl_guest_init_afu()takes an additional reference once it's done all its setup and can't fail.That way at the end of the loop when the loop construct has dropped all references, the nodes you actually init'ed have their reference count incremented by 1.
We don't keep a reference on the AFU device_node. Once we've read the config of the AFU, the AFU device_node is never accessed again. So I guess it's possible (though unexpected) that it's freed from under us, but it should not affect the driver.
The AFU is really dependent on the adapter itself, which is one level up in the device tree, and for which we create a device through of_platform_device_create(). The properties under the AFU device node are read directly from the PCI config space in the bare-metal case, where the cxl adapter is a PCI device.
Do we really have a problem here?
Fred
--
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
Michael Ellerman
AppliedRe: cxl: replace loop with for_each_child_of_node(), remove unneeded of_node_put()
In reply to Andrew DonnellanQuoted 10 lines · Andrew Donnellan
Rewrite the
cxl_guest_init_afu()loop incxl_of_probe()to usefor_each_child_of_node()rather than a hand-coded for loop.Remove the useless
of_node_put(afu_np)call after the loop, where it's guaranteed thatafu_np= NULL.Reported-by SF Markus Elfring <[email protected]>Reported-by Julia Lawall <[email protected]>Signed-off-by Andrew Donnellan <[email protected]>Reviewed-by Frederic Barrat <[email protected]>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/735840b44bcc998e2574faf63d1aaa
cheers
PATCH 1/1 GPU-DRM-sun4i: Delete an unnecessary check before drm_fbdev_cma_hotplug_event()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 20 Jul 2016 18:32:34 +0200
The drm_fbdev_cma_hotplug_event() function tests whether its argument 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/sun4i/sun4i_framebuffer.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/sun4i/sun4i_framebuffer.c +1 -2
@@ -20,8 +20,7 @@ static void sun4i_de_output_poll_changed(struct drm_device *drm) {struct sun4i_drv *drv = drm->dev_private; -if (drv->fbdev) -drm_fbdev_cma_hotplug_event (drv->fbdev); +drm_fbdev_cma_hotplug_event (drv->fbdev); }static const struct drm_mode_config_funcs sun4i_de_mode_config_funcs = {
Signature · 1 line
2.9.2
Daniel Vetter
AppliedRe: [PATCH] GPU-DRM-sun4i: Delete an unnecessary check before drm_fbdev_cma_hotplug_event()
Quoted 10 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 20 Jul 2016 18:32:34 +0200The
drm_fbdev_cma_hotplug_event()function tests whether its argument 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 to drm-misc, thanks.
-Daniel
Quoted 21 lines
--- drivers/gpu/drm/sun4i/sun4i_framebuffer.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/gpu/drm/sun4i/sun4i_framebuffer.c +1
-2@@ -20,8 +20,7 @@ static void sun4i_de_output_poll_changed(struct drm_device *drm) {struct sun4i_drv *drv = drm->dev_private; -if (drv->fbdev) -drm_fbdev_cma_hotplug_event (drv->fbdev); +drm_fbdev_cma_hotplug_event (drv->fbdev); }static const struct drm_mode_config_funcs sun4i_de_mode_config_funcs = {Signature · 1 line
2.9.2
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
PATCH 1/1 drm/mgag200: Delete an unnecessary check before drm_gem_object_unreference_unlocked()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 11:20:27 +0200
The drm_gem_object_unreference_unlocked() function tests whether its argument 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/mgag200/mgag200_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/mgag200/mgag200_main.c +2 -2
@@ -17,8 +17,8 @@static void mga_user_framebuffer_destroy (struct drm_framebuffer *fb) {struct mga_framebuffer *mga_fb =to_mga_framebuffer (fb); -if (mga_fb->obj) -drm_gem_object_unreference_unlocked (mga_fb->obj); + +drm_gem_object_unreference_unlocked (mga_fb->obj);drm_framebuffer_cleanup (fb);kfree (fb); }
Signature · 1 line
2.9.2
Sean Paul
AppliedRe: [PATCH] drm/mgag200: Delete an unnecessary check before drm_gem_object_unreference_unlocked()
Quoted 10 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 11:20:27 +0200The
drm_gem_object_unreference_unlocked()function tests whether its argument 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 to drm-misc
Quoted 26 lines
--- drivers/gpu/drm/mgag200/mgag200_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/mgag200/mgag200_main.c +2
-3@@ -17,8 +17,8 @@static void mga_user_framebuffer_destroy (struct drm_framebuffer *fb) {struct mga_framebuffer *mga_fb =to_mga_framebuffer (fb); -if (mga_fb->obj) -drm_gem_object_unreference_unlocked (mga_fb->obj); + +drm_gem_object_unreference_unlocked (mga_fb->obj);drm_framebuffer_cleanup (fb);kfree (fb); } --2.9.2
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
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: Fri, 22 Jul 2016 12:48:12 +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/mediatek/mtk_drm_crtc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/mediatek/mtk_drm_crtc.c +1 -3
@@ -112,9 +112,7 @@ static void mtk_drm_crtc_reset(struct drm_crtc *crtc)struct mtk_crtc_state *state;if (crtc->state) { -if (crtc->state->mode_blob) -drm_property_unreference_blob (crtc->state->mode_blob); - +drm_property_unreference_blob (crtc->state->mode_blob); state =to_mtk_crtc_state (crtc->state);memset (state,0 ,sizeof (*state)); }else {
Signature · 1 line
2.9.2
Re: [PATCH] GPU-DRM: Delete an unnecessary check before drm_property_unreference_blob()
Quoted 7 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 12:48:12 +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 7 lines
This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
Quoted 16 lines
drivers/gpu/drm/mediatek/mtk_drm_crtc.c +1
-3@@ -112,9 +112,7 @@ static void mtk_drm_crtc_reset(struct drm_crtc *crtc)struct mtk_crtc_state *state;if (crtc->state) { -if (crtc->state->mode_blob) -drm_property_unreference_blob (crtc->state->mode_blob); - +drm_property_unreference_blob (crtc->state->mode_blob); state =to_mtk_crtc_state (crtc->state);memset (state,0 ,sizeof (*state)); }else {
PATCH 1/1 drm/qxl: Delete an unnecessary check before drm_gem_object_unreference_unlocked()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 14:14:54 +0200
The drm_gem_object_unreference_unlocked() function tests whether its argument 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/qxl/qxl_display.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/qxl/qxl_display.c +1 -2
@@ -468,8 +468,7 @@ void qxl_user_framebuffer_destroy(struct drm_framebuffer *fb) {struct qxl_framebuffer *qxl_fb =to_qxl_framebuffer (fb); -if (qxl_fb->obj) -drm_gem_object_unreference_unlocked (qxl_fb->obj); +drm_gem_object_unreference_unlocked (qxl_fb->obj);drm_framebuffer_cleanup (fb);kfree (qxl_fb); }
Signature · 1 line
2.9.2
Sean Paul
AppliedRe: [PATCH] drm/qxl: Delete an unnecessary check before drm_gem_object_unreference_unlocked()
Quoted 10 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 14:14:54 +0200The
drm_gem_object_unreference_unlocked()function tests whether its argument 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 to drm-misc
Quoted 25 lines
--- drivers/gpu/drm/qxl/qxl_display.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/gpu/drm/qxl/qxl_display.c +1
-3@@ -468,8 +468,7 @@ void qxl_user_framebuffer_destroy(struct drm_framebuffer *fb) {struct qxl_framebuffer *qxl_fb =to_qxl_framebuffer (fb); -if (qxl_fb->obj) -drm_gem_object_unreference_unlocked (qxl_fb->obj); +drm_gem_object_unreference_unlocked (qxl_fb->obj);drm_framebuffer_cleanup (fb);kfree (qxl_fb); } --2.9.2
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
cover GPU-DRM-Etnaviv: Fine-tuning for a few functions
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 17:34:32 +0200
Further update suggestions were taken into account after a patch was applied from static source code analysis.
Markus Elfring (4):
Delete unnecessary checks before two function calls Delete unnecessary if statement in __etnaviv_gem_new() Rename jump labels
Optimize error handling in etnaviv_gem_new_userptr()
drivers/gpu/drm/etnaviv/etnaviv_gem.c | 36 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 23 deletions(-)
Signature · 1 line
2.9.2
PATCH 1/4 GPU-DRM-Etnaviv: Delete unnecessary checks before two function calls
From: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 15:56:15 +0200
The functions drm_gem_object_unreference_unlocked() and vunmap() perform also input parameter validation.
Thus the tests around their calls are not needed.
This issue was detected by using the Coccinelle software.
--- drivers/gpu/drm/etnaviv/etnaviv_gem.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/gpu/drm/etnaviv/etnaviv_gem.c +2 -5
@@ -535,8 +535,7 @@ void etnaviv_gem_describe_objects(struct etnaviv_drm_private *priv,static void etnaviv_gem_shmem_release (struct etnaviv_gem_object *etnaviv_obj) { -if (etnaviv_obj->vaddr) -vunmap (etnaviv_obj->vaddr); +vunmap (etnaviv_obj->vaddr);put_pages (etnaviv_obj); }
@@ -670,9 +669,7 @@ static struct drm_gem_object *__etnaviv_gem_new(struct drm_device *dev,return obj; fail: -if (obj) -drm_gem_object_unreference_unlocked (obj); - +drm_gem_object_unreference_unlocked (obj);return ERR_PTR (ret); }
Signature · 1 line
2.9.2
Sean Paul
AppliedRe: [PATCH 1/4] GPU-DRM-Etnaviv: Delete unnecessary checks before two function calls
Quoted 10 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 15:56:15 +0200The functions
drm_gem_object_unreference_unlocked()andvunmap()perform also input parameter validation.
Thus the tests around their calls are not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Applied to drm-misc. In the future, could you please format your subjects starting with "drm/<driver>"? I've fixed this one and the next, but it'd be nice not to have to do that going forward.
Quoted 36 lines
--- drivers/gpu/drm/etnaviv/etnaviv_gem.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)drivers/gpu/drm/etnaviv/etnaviv_gem.c +2
-6@@ -535,8 +535,7 @@ void etnaviv_gem_describe_objects(struct etnaviv_drm_private *priv,static void etnaviv_gem_shmem_release (struct etnaviv_gem_object *etnaviv_obj) { -if (etnaviv_obj->vaddr) -vunmap (etnaviv_obj->vaddr); +vunmap (etnaviv_obj->vaddr);put_pages (etnaviv_obj); }@@ -670,9 +669,7 @@ static struct drm_gem_object *__etnaviv_gem_new(struct drm_device *dev,return obj; fail: -if (obj) -drm_gem_object_unreference_unlocked (obj); - +drm_gem_object_unreference_unlocked (obj);return ERR_PTR (ret); } --2.9.2
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 2/4 GPU-DRM-Etnaviv: Delete unnecessary if statement in __etnaviv_gem_new()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 16:45:22 +0200
Move a return statement into a block for successful function execution. Omit a duplicate check for the local variable "ret" then at the end.
--- drivers/gpu/drm/etnaviv/etnaviv_gem.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/gpu/drm/etnaviv/etnaviv_gem.c +1 -5
@@ -661,13 +661,9 @@ static struct drm_gem_object *__etnaviv_gem_new(struct drm_device *dev,*/ mapping = obj->filp->f_mapping;mapping_set_gfp_mask (mapping,GFP_HIGHUSER ); +return obj; } -if (ret) - goto fail; - -return obj; - fail:drm_gem_object_unreference_unlocked (obj);return ERR_PTR (ret);
Signature · 1 line
2.9.2
Re: [PATCH 2/4] GPU-DRM-Etnaviv: Delete unnecessary if statement in __etnaviv_gem_new()
Am 22.07.2016 17:48, schrieb SF Markus Elfring:
Quoted 32 lines
From: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 16:45:22 +0200Move a return statement into a block for successful function execution. Omit a duplicate check for the local variable "ret" then at the end.
Signed-off-by Markus Elfring <[email protected]>--- drivers/gpu/drm/etnaviv/etnaviv_gem.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)drivers/gpu/drm/etnaviv/etnaviv_gem.c +1
-5@@ -661,13 +661,9 @@ static struct drm_gem_object *__etnaviv_gem_new(struct drm_device *dev,*/ mapping = obj->filp->f_mapping;mapping_set_gfp_mask (mapping,GFP_HIGHUSER ); +return obj; } -if (ret) - goto fail; - -return obj; - fail:drm_gem_object_unreference_unlocked (obj);return ERR_PTR (ret);
Quoted 1 line
From the program flow an readability it would be more nice the branch on error
ret = drm_gem_object_init(dev, obj, size);
if (ret)
goto fail;
just m 2 cents
re,
wh
PATCH 1/1 drm/etnaviv: Improve readability in __etnaviv_gem_new
Move things around a little in __etnaviv_gem_new() to make it more readable.
--- drivers/gpu/drm/etnaviv/etnaviv_gem.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-)
drivers/gpu/drm/etnaviv/etnaviv_gem.c +11 -14
@@ -640,6 +640,7 @@ static struct drm_gem_object *__etnaviv_gem_new(struct drm_device *dev, u32 size, u32 flags) {struct drm_gem_object *obj =NULL ; +struct address_space *mapping;int ret; size =PAGE_ALIGN (size);
@@ -650,23 +651,19 @@ static struct drm_gem_object *__etnaviv_gem_new(struct drm_device *dev, goto fail; ret =drm_gem_object_init (dev, obj, size); -if (ret ==0 ) { -struct address_space *mapping; - -/* -* Our buffers are kept pinned, so allocating them -* from the MOVABLE zone is a really bad idea, and -* conflicts with CMA. See coments above new_inode() -* why this is required _and_ expected if you're -* going to pin these pages. -*/ - mapping =file_inode (obj->filp)->i_mapping; -mapping_set_gfp_mask (mapping,GFP_HIGHUSER ); - } -if (ret) goto fail; +/* +* Our buffers are kept pinned, so allocating them +* from the MOVABLE zone is a really bad idea, and +* conflicts with CMA. See coments above new_inode() +* why this is required _and_ expected if you're +* going to pin these pages. +*/ + mapping =file_inode (obj->filp)->i_mapping; +mapping_set_gfp_mask (mapping,GFP_HIGHUSER ); +return obj; fail:
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 3/4 GPU-DRM-Etnaviv: Rename jump labels
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 16:51:00 +0200
Adjust jump targets according to the Linux coding style convention.
--- drivers/gpu/drm/etnaviv/etnaviv_gem.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/gpu/drm/etnaviv/etnaviv_gem.c +7 -7
@@ -308,17 +308,17 @@ struct etnaviv_vram_mapping *etnaviv_gem_mapping_get( mapping =NULL ;mutex_unlock (&gpu->mmu->lock);if (mapping) - goto out; + goto unlock; }else { mapping->use +=1 ; - goto out; + goto unlock; } } pages =etnaviv_gem_get_pages (etnaviv_obj);if (IS_ERR (pages)) { ret =PTR_ERR (pages); - goto out; + goto unlock; }/*
@@ -330,7 +330,7 @@ struct etnaviv_vram_mapping *etnaviv_gem_mapping_get( mapping =kzalloc (sizeof (*mapping),GFP_KERNEL );if (!mapping) { ret = -ENOMEM ; - goto out; + goto unlock; }INIT_LIST_HEAD (&mapping->scan_node);
@@ -349,7 +349,7 @@ struct etnaviv_vram_mapping *etnaviv_gem_mapping_get(else list_add_tail (&mapping->obj_node, &etnaviv_obj->vram_list); -out: +unlock:mutex_unlock (&etnaviv_obj->lock);if (ret)
@@ -646,7 +646,7 @@ static struct drm_gem_object *__etnaviv_gem_new(struct drm_device *dev, ret =etnaviv_gem_new_impl (dev, size, flags,NULL , &etnaviv_gem_shmem_ops, &obj);if (ret) - goto fail; + goto unreference; ret =drm_gem_object_init (dev, obj, size);if (ret ==0 ) {
@@ -664,7 +664,7 @@ static struct drm_gem_object *__etnaviv_gem_new(struct drm_device *dev,return obj; } -fail: +unreference:drm_gem_object_unreference_unlocked (obj);return ERR_PTR (ret); }
Signature · 1 line
2.9.2
Re: [PATCH 3/4] GPU-DRM-Etnaviv: Rename jump labels
Quoted 5 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 16:51:00 +0200Adjust jump targets according to the Linux coding style convention.
I'm not convinced the old labels are really that bad, tbh.
Sean
Quoted 73 lines
Signed-off-by Markus Elfring <[email protected]>--- drivers/gpu/drm/etnaviv/etnaviv_gem.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)drivers/gpu/drm/etnaviv/etnaviv_gem.c +7
-8@@ -308,17 +308,17 @@ struct etnaviv_vram_mapping *etnaviv_gem_mapping_get( mapping =NULL ;mutex_unlock (&gpu->mmu->lock);if (mapping) - goto out; + goto unlock; }else { mapping->use +=1 ; - goto out; + goto unlock; } } pages =etnaviv_gem_get_pages (etnaviv_obj);if (IS_ERR (pages)) { ret =PTR_ERR (pages); - goto out; + goto unlock; }/* @@ -330,7 +330,7 @@ struct etnaviv_vram_mapping *etnaviv_gem_mapping_get( mapping =kzalloc (sizeof (*mapping),GFP_KERNEL );if (!mapping) { ret = -ENOMEM ; - goto out; + goto unlock; }INIT_LIST_HEAD (&mapping->scan_node);@@ -349,7 +349,7 @@ struct etnaviv_vram_mapping *etnaviv_gem_mapping_get(else list_add_tail (&mapping->obj_node, &etnaviv_obj->vram_list); -out: +unlock:mutex_unlock (&etnaviv_obj->lock);if (ret)@@ -646,7 +646,7 @@ static struct drm_gem_object *__etnaviv_gem_new(struct drm_device *dev, ret =etnaviv_gem_new_impl (dev, size, flags,NULL , &etnaviv_gem_shmem_ops, &obj);if (ret) - goto fail; + goto unreference; ret =drm_gem_object_init (dev, obj, size);if (ret =0 ) {@@ -664,7 +664,7 @@ static struct drm_gem_object *__etnaviv_gem_new(struct drm_device *dev,return obj; } -fail: +unreference:drm_gem_object_unreference_unlocked (obj);return ERR_PTR (ret); } --2.9.2
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 4/4 GPU-DRM-Etnaviv: Optimize error handling in etnaviv_gem_new_userptr()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 17:17:48 +0200
Refactor this function implementation so that the drm_gem_object_unreference_unlocked() function will only be called once in case of a failure according to the Linux coding style recommendation for centralized exiting of functions.
--- drivers/gpu/drm/etnaviv/etnaviv_gem.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/gpu/drm/etnaviv/etnaviv_gem.c +3 -6
@@ -909,15 +909,12 @@ int etnaviv_gem_new_userptr(struct drm_device *dev, struct drm_file *file,get_task_struct (current); ret =etnaviv_gem_obj_add (dev, &etnaviv_obj->base); -if (ret) { -drm_gem_object_unreference_unlocked (&etnaviv_obj->base); -return ret; - } +if (ret) + goto unreference; ret =drm_gem_handle_create (file, &etnaviv_obj->base, handle); - +unreference:/* drop reference from allocate - handle holds it now */ drm_gem_object_unreference_unlocked (&etnaviv_obj->base); -return ret; }
Signature · 1 line
2.9.2
Sean Paul
AppliedRe: [PATCH 4/4] GPU-DRM-Etnaviv: Optimize error handling in etnaviv_gem_new_userptr()
Quoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 17:17:48 +0200Refactor this function implementation so that the
drm_gem_object_unreference_unlocked()function will only be called once in case of a failure according to the Linux coding style recommendation for centralized exiting of functions.Signed-off-by Markus Elfring <[email protected]>
Applied to drm-misc. In the future, could you please format your subjects starting with "drm/<driver>"? I've fixed this one and the first, but it'd be nice not to have to do that going forward.
Sean
Quoted 34 lines
--- drivers/gpu/drm/etnaviv/etnaviv_gem.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)drivers/gpu/drm/etnaviv/etnaviv_gem.c +3
-7@@ -909,15 +909,12 @@ int etnaviv_gem_new_userptr(struct drm_device *dev, struct drm_file *file,get_task_struct (current); ret =etnaviv_gem_obj_add (dev, &etnaviv_obj->base); -if (ret) { -drm_gem_object_unreference_unlocked (&etnaviv_obj->base); -return ret; - } +if (ret) + goto unreference; ret =drm_gem_handle_create (file, &etnaviv_obj->base, handle); - +unreference:/* drop reference from allocate - handle holds it now */ drm_gem_object_unreference_unlocked (&etnaviv_obj->base); -return ret; } --2.9.2
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 1/1 ASoC: Intel: Skylake: Delete an unnecessary check before the function call "release_firmware"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 18:58:14 +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.
--- sound/soc/intel/skylake/skl.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
sound/soc/intel/skylake/skl.c +1 -2
@@ -781,8 +781,7 @@ static void skl_remove(struct pci_dev *pci)struct hdac_ext_bus *ebus =pci_get_drvdata (pci);struct skl *skl =ebus_to_skl (ebus); -if (skl->tplg) -release_firmware (skl->tplg); +release_firmware (skl->tplg);if (pci_dev_run_wake (pci))pm_runtime_get_noresume (&pci->dev);
Signature · 1 line
2.9.2
Mark Brown
maintainerApplied "ASoC: Intel: Skylake: Delete an unnecessary check before the function call "release_firmware"" to the asoc tree
The patch
ASoC: Intel: Skylake: Delete an unnecessary check before the function call "release_firmware"
has been applied to the asoc tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
1b00126cb3de017274e899ac559a744d4e3dbd61Mon Sep 17 00:00:00 2001
From: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 18:58:14 +0200
Subject: [PATCH] ASoC: Intel: Skylake: Delete an unnecessary check before the
function call "release_firmware"
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.
--- sound/soc/intel/skylake/skl.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
sound/soc/intel/skylake/skl.c +1 -2
@@ -781,8 +781,7 @@ static void skl_remove(struct pci_dev *pci)struct hdac_ext_bus *ebus =pci_get_drvdata (pci);struct skl *skl =ebus_to_skl (ebus); -if (skl->tplg) -release_firmware (skl->tplg); +release_firmware (skl->tplg);if (pci_dev_run_wake (pci))pm_runtime_get_noresume (&pci->dev);
Signature · 1 line
2.8.1
PATCH 1/1 zsmalloc: Delete an unnecessary check before the function call "iput"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 19:54:20 +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.
--- mm/zsmalloc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
mm/zsmalloc.c +1 -2
@@ -2181,8 +2181,7 @@ static int zs_register_migration(struct zs_pool *pool)static void zs_unregister_migration (struct zs_pool *pool) {flush_work (&pool->free_work); -if (pool->inode) -iput (pool->inode); +iput (pool->inode); }/*
Signature · 1 line
2.9.2
Re: [PATCH] zsmalloc: Delete an unnecessary check before the function call "iput"
Quoted 4 lines · SF Markus Elfring
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.
there is no issue; the change is just cosmetic.
Quoted 1 line
Signed-off-by Markus Elfring <[email protected]>
alloc_anon_inode() returns ERR_PTR, so I'd probably rather change iput() to do IS_ERR_OR_NULL instead of !NULL.
inode = alloc_anon_inode();
if (IS_ERR(inode)) {
inode = NULL;
^^^^^^^^^^^^^
}
...
iput(inode);this NULL assignment on error path is a bit fragile.
IOW, something like this
---
fs/inode.c +1 -1
@@ -1497,7 +1497,7 @@ static void iput_final(struct inode *inode)*/ void iput (struct inode *inode) { -if (!inode) +if (IS_ERR_OR_NULL (inode))return ;BUG_ON (inode->i_state &I_CLEAR ); retry:
---
-ss
Quoted 21 lines
--- mm/zsmalloc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)mm/zsmalloc.c +1
-2@@ -2181,8 +2181,7 @@ static int zs_register_migration(struct zs_pool *pool)static void zs_unregister_migration (struct zs_pool *pool) {flush_work (&pool->free_work); -if (pool->inode) -iput (pool->inode); +iput (pool->inode); }/* Signature · 1 line
2.9.2
Re: [PATCH] zsmalloc: Delete an unnecessary check before the function call "iput"
In reply to SF Markus ElfringQuoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 19:54:20 +0200The
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]>
Thanks!
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 1/1 block: Delete an unnecessary check before the function call "kmem_cache_destroy"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 21:07:37 +0200
The kmem_cache_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.
--- block/elevator.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
block/elevator.c +1 -2
@@ -846,8 +846,7 @@ int elv_register(struct elevator_type *e)spin_lock (&elv_list_lock);if (elevator_find (e->elevator_name)) {spin_unlock (&elv_list_lock); -if (e->icq_cache) -kmem_cache_destroy (e->icq_cache); +kmem_cache_destroy (e->icq_cache);return -EBUSY ; }list_add_tail (&e->list, &elv_list);
Signature · 1 line
2.9.2
PATCH 1/1 block: Delete unnecessary checks before the function call "mempool_destroy"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 21:45:26 +0200
The mempool_destroy() function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.
This issue was detected by using the Coccinelle software.
--- block/bio-integrity.c | 7 ++----- block/bio.c | 8 ++------ block/blk-core.c | 3 +-- 3 files changed, 5 insertions(+), 13 deletions(-)
block/bio-integrity.c +2 -5
@@ -499,11 +499,8 @@ EXPORT_SYMBOL(bioset_integrity_create);void bioset_integrity_free (struct bio_set *bs) { -if (bs->bio_integrity_pool) -mempool_destroy (bs->bio_integrity_pool); - -if (bs->bvec_integrity_pool) -mempool_destroy (bs->bvec_integrity_pool); +mempool_destroy (bs->bio_integrity_pool); +mempool_destroy (bs->bvec_integrity_pool); }EXPORT_SYMBOL (bioset_integrity_free);
block/bio.c +2 -6
@@ -1843,12 +1843,8 @@ void bioset_free(struct bio_set *bs)if (bs->rescue_workqueue)destroy_workqueue (bs->rescue_workqueue); -if (bs->bio_pool) -mempool_destroy (bs->bio_pool); - -if (bs->bvec_pool) -mempool_destroy (bs->bvec_pool); - +mempool_destroy (bs->bio_pool); +mempool_destroy (bs->bvec_pool);bioset_integrity_free (bs);bio_put_slab (bs);
block/blk-core.c +1 -2
@@ -636,8 +636,7 @@ int blk_init_rl(struct request_list *rl, struct request_queue *q,void blk_exit_rl (struct request_list *rl) { -if (rl->rq_pool) -mempool_destroy (rl->rq_pool); +mempool_destroy (rl->rq_pool); }struct request_queue *blk_alloc_queue (gfp_t gfp_mask)
Signature · 1 line
2.9.2
PATCH 1/1 IB/hfi1: Delete an unnecessary check before the function call "sc_return_credits"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 23 Jul 2016 08:30:52 +0200
The sc_return_credits() function tests whether its argument 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/hw/hfi1/file_ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/hfi1/file_ops.c +1 -1
@@ -228,7 +228,7 @@ static long hfi1_file_ioctl(struct file *fp, unsigned int cmd, sizeof(struct hfi1_base_info));break ;case HFI1_IOCTL_CREDIT_UPD : -if (uctxt && uctxt->sc) +if (uctxt)sc_return_credits (uctxt->sc);break ;
Signature · 1 line
2.9.2
A message that is not in the archive (sent off-list or not yet received): cd93853f-c315-eceb-347d-3bbb5ac9fb82-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Doug Ledford
AppliedRe: [PATCH] IB/hfi1: Delete an unnecessary check before the function call "sc_return_credits"
Quoted 26 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 23 Jul 2016 08:30:52 +0200The
sc_return_credits()function tests whether its argument 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/hw/hfi1/file_ops.c | 2 +-1 file changed, 1 insertion(+), 1 deletion(-)drivers/infiniband/hw/hfi1/file_ops.c +0
-0@@ -228,7 +228,7 @@ static long hfi1_file_ioctl(struct file *fp, unsigned int cmd, sizeof(struct hfi1_base_info)); break;case
HFI1_IOCTL_CREDIT_UPD:drivers/infiniband/hw/hfi1/file_ops.c +1
-1-if (uctxt && uctxt->sc) +if (uctxt)
Quoted 3 lines
sc_return_credits(uctxt->sc); break;
Thanks, applied.
Signature · 2 lines
Doug Ledford <[email protected]> GPG KeyID: 0E572FDD
PATCH 1/1 power: generic-adc-battery: Delete unnecessary checks before the function call "iio_channel_release"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 23 Jul 2016 14:50:47 +0200
The iio_channel_release() function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/power/generic-adc-battery.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
drivers/power/generic-adc-battery.c +4 -9
@@ -350,10 +350,8 @@ err_gpio: gpio_req_fail:power_supply_unregister (adc_bat->psy); err_reg_fail: -for (chan =0 ; chan <ARRAY_SIZE (gab_chan_name); chan++) { -if (adc_bat->channel[chan]) -iio_channel_release (adc_bat->channel[chan]); - } +for (chan =0 ; chan <ARRAY_SIZE (gab_chan_name); chan++) +iio_channel_release (adc_bat->channel[chan]); second_mem_fail:kfree (psy_desc->properties); first_mem_fail:
@@ -373,11 +371,8 @@ static int gab_remove(struct platform_device *pdev)gpio_free (pdata->gpio_charge_finished); } -for (chan =0 ; chan <ARRAY_SIZE (gab_chan_name); chan++) { -if (adc_bat->channel[chan]) -iio_channel_release (adc_bat->channel[chan]); - } - +for (chan =0 ; chan <ARRAY_SIZE (gab_chan_name); chan++) +iio_channel_release (adc_bat->channel[chan]);kfree (adc_bat->psy_desc.properties);cancel_delayed_work (&adc_bat->bat_work);return 0 ;
Signature · 1 line
2.9.2
PATCH 1/1 memory: omap-gpmc: Delete an unnecessary check before the function call "gpiochip_free_own_desc"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 23 Jul 2016 18:54:02 +0200
The gpiochip_free_own_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.
--- drivers/memory/omap-gpmc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/memory/omap-gpmc.c +1 -3
@@ -2143,9 +2143,7 @@ err_child_fail: ret = -ENODEV ; err_cs: -if (waitpin_desc) -gpiochip_free_own_desc (waitpin_desc); - +gpiochip_free_own_desc (waitpin_desc); err:gpmc_cs_free (cs);
Signature · 1 line
2.9.2
Re: [PATCH] memory: omap-gpmc: Delete an unnecessary check before the function call "gpiochip_free_own_desc"
Hi Markus,
Quoted 19 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 23 Jul 2016 18:54:02 +0200The
gpiochip_free_own_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.
Signed-off-by Markus Elfring <[email protected]>--- drivers/memory/omap-gpmc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)drivers/memory/omap-gpmc.c +0
-0
drivers/memory/omap-gpmc.c err_child_fail: · line 2149
Quoted 10 lines
drivers/memory/omap-gpmc.c +1
-3@@ -2143,9 +2143,7 @@ err_child_fail: ret = -ENODEV ; err_cs: -if (waitpin_desc) -gpiochip_free_own_desc (waitpin_desc); - +gpiochip_free_own_desc (waitpin_desc); err:gpmc_cs_free (cs);
This looks good to me. I will queue this for v4.8. Thanks.
cheers,
-roger
PATCH 1/1 omapfb: panel-dsi-cm: Delete an unnecessary check before backlight_device_unregister()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 23 Jul 2016 19:29:28 +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/omapfb/displays/panel-dsi-cm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/video/fbdev/omap2/omapfb/displays/panel-dsi-cm.c +1 -2
@@ -1283,8 +1283,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.9.2
PATCH 1/1 coresight: tmc: Delete an unnecessary check before the function call "kfree"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 23 Jul 2016 20:04:09 +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/hwtracing/coresight/coresight-tmc-etf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwtracing/coresight/coresight-tmc-etf.c +1 -1
@@ -168,7 +168,7 @@ out:spin_unlock_irqrestore (&drvdata->spinlock, flags);/* Free memory outside the spinlock if need be */ -if (!used && buf) +if (!used)kfree (buf);if (!ret)
Signature · 1 line
2.9.2
Re: [PATCH] coresight: tmc: Delete an unnecessary check before the function call "kfree"
Quoted 27 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 23 Jul 2016 20:04:09 +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]>--- drivers/hwtracing/coresight/coresight-tmc-etf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/hwtracing/coresight/coresight-tmc-etf.c +1
-2@@ -168,7 +168,7 @@ out:spin_unlock_irqrestore (&drvdata->spinlock, flags);/* Free memory outside the spinlock if need be */ -if (!used && buf) +if (!used)kfree (buf);if (!ret) --
Quoted 2 lines
2.9.2
Applied - thanks.
Mathieu
PATCH 1/1 Input-rmi_bus: Delete an unnecessary check before the function call "of_node_put"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 24 Jul 2016 07:37:23 +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.
--- drivers/input/rmi4/rmi_bus.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/input/rmi4/rmi_bus.c +1 -4
@@ -232,10 +232,7 @@ err_put_device:void rmi_unregister_function (struct rmi_function *fn) {device_del (&fn->dev); - -if (fn->dev.of_node) -of_node_put (fn->dev.of_node); - +of_node_put (fn->dev.of_node);put_device (&fn->dev); }
Signature · 1 line
2.9.2
Re: [PATCH] Input-rmi_bus: Delete an unnecessary check before the function call "of_node_put"
Quoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 24 Jul 2016 07:37:23 +0200The
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]>
Applied, thank you.
Quoted 23 lines
--- drivers/input/rmi4/rmi_bus.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)drivers/input/rmi4/rmi_bus.c +1
-4@@ -232,10 +232,7 @@ err_put_device:void rmi_unregister_function (struct rmi_function *fn) {device_del (&fn->dev); - -if (fn->dev.of_node) -of_node_put (fn->dev.of_node); - +of_node_put (fn->dev.of_node);put_device (&fn->dev); }Signature · 1 line
2.9.2
Signature · 1 line
Dmitry
PATCH 1/1 firmware-gsmi: Delete an unnecessary check before the function call "dma_pool_destroy"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 24 Jul 2016 10:16:56 +0200
The dma_pool_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/firmware/google/gsmi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/firmware/google/gsmi.c +1 -2
@@ -910,8 +910,7 @@ out_err:gsmi_buf_free (gsmi_dev.param_buf);gsmi_buf_free (gsmi_dev.data_buf);gsmi_buf_free (gsmi_dev.name_buf); -if (gsmi_dev.dma_pool) -dma_pool_destroy (gsmi_dev.dma_pool); +dma_pool_destroy (gsmi_dev.dma_pool);platform_device_unregister (gsmi_dev.pdev);pr_info ("gsmi: failed to load: %d\n" , ret);return ret;
Signature · 1 line
2.9.2
Re: [PATCH] firmware-gsmi: Delete an unnecessary check before the function call "dma_pool_destroy"
Quoted 6 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 24 Jul 2016 10:16:56 +0200The
dma_pool_destroy()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/firmware/google/gsmi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
Looks fine to me. If Mike doesn't pick this up I'll take it through the EFI tree.
Re: [PATCH] firmware-gsmi: Delete an unnecessary check before the function call "dma_pool_destroy"
Quoted 10 lines · Matt Fleming
Quoted 8 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 24 Jul 2016 10:16:56 +0200The
dma_pool_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.
Quoted 7 lines
Quoted 4 lines
Signed-off-by Markus Elfring <[email protected]>--- drivers/firmware/google/gsmi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)Looks fine to me. If Mike doesn't pick this up I'll take it through the EFI tree.
Yes please do.
PATCH 1/1 libnvdimm-btt: Delete an unnecessary check before the function call "__nd_device_register"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 24 Jul 2016 11:05:34 +0200
The __nd_device_register() function tests whether its argument 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/nvdimm/btt_devs.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/nvdimm/btt_devs.c +1 -2
@@ -198,8 +198,7 @@ struct device *nd_btt_create(struct nd_region *nd_region) {struct device *dev =__nd_btt_create (nd_region,0 ,NULL ,NULL ); -if (dev) -__nd_device_register (dev); +__nd_device_register (dev);return dev; }
Signature · 1 line
2.9.2
Dan Williams
AppliedRe: [PATCH] libnvdimm-btt: Delete an unnecessary check before the function call "__nd_device_register"
Quoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 24 Jul 2016 11:05:34 +0200The
__nd_device_register()function tests whether its argument 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.
PATCH 1/1 scsi: Delete an unnecessary check before the function call "kfree"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 24 Jul 2016 14:20:21 +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/scsi/scsi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/scsi/scsi.c +1 -2
@@ -864,8 +864,7 @@ retry_pg83:rcu_assign_pointer (sdev->vpd_pg83, vpd_buf);mutex_unlock (&sdev->inquiry_mutex);synchronize_rcu (); -if (orig_vpd_buf) -kfree (orig_vpd_buf); +kfree (orig_vpd_buf); } }
Signature · 1 line
2.9.2
Re: [PATCH] scsi: Delete an unnecessary check before the function call "kfree"
----- Original Message -----
Quoted 37 lines
From: "SF Markus Elfring" <[email protected]>
To: [email protected], "Christoph Hellwig" <[email protected]>, "Hannes Reinecke" <[email protected]>, "James E. J. Bottomley" <[email protected]>, "Martin K. Petersen" <[email protected]>
Cc: "LKML" <[email protected]>, [email protected], "Julia Lawall" <[email protected]>
Sent: Sunday, July 24, 2016 8:30:35 AM
Subject: [PATCH] scsi: Delete an unnecessary check before the function call "kfree"From: Markus Elfring <[email protected]>
Date: Sun, 24 Jul 2016 14:20:21 +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]>--- drivers/scsi/scsi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/scsi/scsi.c +1
-3@@ -864,8 +864,7 @@ retry_pg83:rcu_assign_pointer (sdev->vpd_pg83, vpd_buf);mutex_unlock (&sdev->inquiry_mutex);synchronize_rcu (); -if (orig_vpd_buf) -kfree (orig_vpd_buf); +kfree (orig_vpd_buf); } } --2.9.2
Quoted 5 lines
--
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
Looks fine, small comment is that the function call prior to check in the fucntion sets up variables etc. So is more expensive than a simple NULL check prior.
[Cocci] Improvements for passing of big regular expressions in SmPL constraints?
In reply to SF Markus ElfringQuoted 4 lines
@Delete_unnecessary_checks@
expression x;
identifier release =~ "^(?x)
(?:
Quoted 9 lines
(?:kz?|slob_)free
|
(?:
# alternation/disjunction of 893 strings ...
)
)$";
@@
-if (x)
release(x);Would it be useful that the shown regular expression could be included from an other source file?
How do you think about an extension for the semantic patch language so that such a string could be assigned to a special metavariable with a type like "regex"? Can it be passed from a "virtual" parameter?
Regards,
Markus
[Cocci] Improvements for passing of big regular expressions in SmPL constraints?
Quoted 14 lines · SF Markus Elfring
Quoted 4 lines
@Delete_unnecessary_checks@
expression x;
identifier release =~ "^(?x)
(?:Quoted 9 lines
(?:kz?|slob_)free | (?: # alternation/disjunction of 893 strings ... ) )$"; @@ -if (x) release(x);
Quoted 5 lines
Would it be useful that the shown regular expression could be included from an other source file? How do you think about an extension for the semantic patch language so that such a string could be assigned to a special metavariable with a type like "regex"? Can it be passed from a "virtual" parameter?
A priori, I don't think regular expressions are a good idea at all. It reflects a lac of control over what is matched. Furthermore, Coccinelle doesn't do any optimizations based on regular expressions. If you put a regular expression match in your rule, Coccinelle is likely to have to try (parse etc) every file, because it doesn't know whether the regular expression matches or not. It would be better to use virtual identifiers. That way, if you also use some kind of indexing (glimpse or id-utils), then very little work will be done in most cases.
julia
[Cocci] Improvements for passing of big regular expressions in SmPL constraints?
Quoted 1 line
It would be better to use virtual identifiers.
Can this SmPL interface be marked and used in the way that an identifier does not contain "plain text" but should be handled as a long regular expression?
Regards,
Markus
[Cocci] Improvements for passing of big regular expressions in SmPL constraints?
Quoted 4 lines · SF Markus Elfring
Quoted 1 line
It would be better to use virtual identifiers.
Can this SmPL interface be marked and used in the way that an identifier does not contain "plain text" but should be handled as a long regular expression?
No.
julia
[Cocci] Determination of the number for named function parameters
In reply to SF Markus ElfringQuoted 2 lines
A source code search with the following pattern found 893 functions which check their single parameter.
I am also interested to generate statistics for the declaration of function parameters and their use.
Is it possible to analyse the function parameter list by interfaces from the semantic patch language? Can any useful numbers be extracted at this place?
Regards,
Markus
[Cocci] Determination of the number for named function parameters
Quoted 7 lines · SF Markus Elfring
Quoted 2 lines
A source code search with the following pattern found 893 functions which check their single parameter.
I am also interested to generate statistics for the declaration of function parameters and their use.
Is it possible to analyse the function parameter list by interfaces from the semantic patch language? Can any useful numbers be extracted at this place?
The question is not very precise. I don't know what you mean by analyse, nor what you mean by interfaces, nor what you mean by useful. You can write things like:
f(...,T i,...) { ... }
where T is a type and i is an identifier
or
f(...,p,...) { ... }
where p is a parameter
or
f(ps,p,...) { ... }
where ps is a parameter list and p is a parameter.
In declaratin a parameter list, you can also say;
parameter list[n] ps;
and then n is the number of parameters that are matched.
julia
[Cocci] Determination of the number for named function parameters
Quoted 5 lines
In declaratin a parameter list, you can also say;
parameter list[n] ps;
and then n is the number of parameters that are matched.
Thanks for your interesting details.
I find the use of the element "n" (the name in square brackets) not obvious from the Coccinelle manual so far.
But I would like to try more analysis with the data that is passed by the metavariable type "parameter list". I have started to look a bit into it by the function "pickle.dumps". This kind of display is not so useful for me yet. I am missing documentation for corresponding data structures I can depend on in further reports.
Regards,
Markus
[Cocci] Determination of the number for named function parameters
Quoted 2 lines
I am missing documentation for corresponding data structures I can depend on in further reports.
The display from the function "pprint.pformat" shows another implementation detail in my simple script.
http://docs.python.org/2/library/pprint.html
Would you like to clarify data analysis according to the current situation around "coccilib.elems.TermList instance"?
Regards,
Markus
[Cocci] Determination of the number for named function parameters
Quoted 9 lines · SF Markus Elfring
Quoted 2 lines
I am missing documentation for corresponding data structures I can depend on in further reports.
The display from the function "pprint.pformat" shows another implementation detail in my simple script.
http://docs.python.org/2/library/pprint.htmlWould you like to clarify data analysis according to the current situation around "coccilib.elems.TermList instance"?
I know nothing about this. Maybe look at the python code and see what it does. But I am not sure that using it is the best way to do whjat you want, although I also don't know what you want to do.
julia
[Cocci] Determination of the number for named function parameters
Quoted 4 lines
Quoted 2 lines
Would you like to clarify data analysis according to the current situation around "coccilib.elems.TermList instance"?
I know nothing about this.
I am surprised by this feedback.
I assume that a corresponding interface description would be nice if I look at "man 3cocci Coccilib". How are the chances to improve the mapping from the OCaml API to the Python binding?
Quoted 2 lines
But I am not sure that using it is the best way to do whjat you want, although I also don't know what you want to do.
The tool "spatch" counts all elements in a metavariable of the type "parameter list". I would like to treat list elements that have got the function parameter type "void" or no name differently.
- How can I assign the number "zero" (instead of "1") in this case?
- Should I generally exclude parameters without names from another report variant?
I am also interested a bit in run time optimisation. A passed list should be sufficient for further computations. I do not really need a count in another variable which was specified between square brackets of a SmPL rule.
Regards,
Markus
[Cocci] Determination of the number for named function parameters
Quoted 6 lines · SF Markus Elfring
Quoted 4 lines
Quoted 2 lines
Would you like to clarify data analysis according to the current situation around "coccilib.elems.TermList instance"?
I know nothing about this.
I am surprised by this feedback.
I didn't implement it, and I never use python. The thing you are citing was implemented by a masters student for his masters thesis project, and it contains whatever he found useful.
Quoted 3 lines
I assume that a corresponding interface description would be nice if I look at "man 3cocci Coccilib". How are the chances to improve the mapping from the OCaml API to the Python binding?
If you would like to have such a thing you are welcome to implement. In my experience the AST is very rarely useful.
Quoted 7 lines
Quoted 2 lines
But I am not sure that using it is the best way to do whjat you want, although I also don't know what you want to do.
The tool "spatch" counts all elements in a metavariable of the type "parameter list". I would like to treat list elements that have got the function parameter type "void" or no name differently.
- How can I assign the number "zero" (instead of "1") in this case?
Have a special rule for such functions and use position variables to prevent the rule that matches interesting parameter lists from matching functions that have satisfied this case:
@r@
position p;
identifier f;
@@
f at p(void} { ... }
@goodfunctions@
position p != r.p;
parameter list[n] ps;
identifier f;
@@
f at p(ps) { ... }
Or you can just use your python code to see if ps is just the string "void".
Quoted 3 lines
I am also interested a bit in run time optimisation. A passed list should be sufficient for further computations. I do not really need a count in another variable which was specified between square brackets of a SmPL rule.
It is hard to imagine why converting all the elements of a list to strings as is done in the interface to python would be more efficient than just passing a single number.
Anyway, the runtime cost is not here, in either case. The runtime cost will be that you have to parse every function of every file.
julia
[Cocci] Determination of the number for named function parameters
Quoted 1 line
I didn't implement it, and I never use python.
I would struggle with OCaml script development more so far.
Quoted 3 lines
Have a special rule for such functions and use position variables to prevent the rule that matches interesting parameter lists from matching functions that have satisfied this case:
Thanks for your SmPL pattern suggestion.
Quoted 7 lines
@r@
position p;
identifier f;
@@f at p(void} { ... }
Quoted 7 lines
@goodfunctions@
position p != r.p;
parameter list[n] ps;
identifier f;
@@f at p(ps) { ... }
I would prefer to specify a meaningful constraint for the metavariable "ps" somehow.
Quoted 2 lines
Or you can just use your python code to see if ps is just the string "void".
I thought also in a similar direction. But I would like to be sure about the passed data structures. I imagine that I would need to inspect the class "coccilib.elems.TermList" if the corresponding documentation is unclear.
Quoted 8 lines
Quoted 4 lines
I am also interested a bit in run time optimisation. A passed list should be sufficient for further computations. I do not really need a count in another variable which was specified between square brackets of a SmPL rule.
It is hard to imagine why converting all the elements of a list to strings as is done in the interface to python would be more efficient than just passing a single number.
I would like to try out two reports at least.
1. What is the maximum number of named function parameters in a source code base? I need only the value "n" (without the additional data from the related
metavariable).
2. Comparison for the incidence of unnamed function parameters to all of them The parameter count could be determined from the list of parameter names
alone, couldn't it?
Regards,
Markus
[Cocci] Determination of the number for named function parameters
Quoted 1 line
2. Comparison for the incidence of unnamed function parameters to all of them
I am trying out a bit more preparation with OCaml script development for this report variant.
@initialize:ocaml@
@@
module My_map = Map.Make(Int64)
let m = ref My_map.empty
let counting dir =
let d = Unix.opendir dir in
try while true do
let name = Unix.readdir d in
let length = Int64.of_int (String.length name) in
if My_map.mem length (! m) then
ignore (m := My_map.add length (Int64.add (My_map.find length (! m))
Int64.one) (! m))
else
ignore (m := My_map.add length Int64.one (! m))
done
with End_of_file -> Unix.closedir d@find@
identifier fu;
@@
*fu(...)
{ ... }
@script:ocaml collection@
area << virtual.folder;
@@
if area = "" then
counting "/"
else
counting area
@finalize:ocaml@
@@
if My_map.is_empty (! m) then
prerr_endline "No result for this analysis!"
else
let delimiter = '|' in
let output key count = Printf.printf "%Li%c%Li\r\n" key delimiter count in Printf.printf "length%cincidence\r\n" delimiter;
My_map.iter output (! m)
elfring@Sonne:~/Projekte/Coccinelle/janitor> spatch.opt --sp-file list_file_name_lengths1.cocci ../Probe/f-ptr-test1.cinit_defs_builtins: /usr/local/share/coccinelle/standard.h Using native version of ocamlc/ocamlopt/ocamldep ocamlopt.opt -shared -o /tmp/list_file_name_lengths1f3bae5.cmxs -g -I /usr/lib64/ocaml -I /usr/local/share/coccinelle/ocaml /tmp/list_file_name_lengths1f3bae5.ml
Compilation OK!
Loading ML code of the SP...
HANDLING: ../Probe/f-ptr-test1.c
...
No result for this analysis!
How do you think about such a semantic patch approach?
Regards,
Markus
[Cocci] Determination of the number for named function parameters
In reply to Julia LawallQuoted 3 lines
Have a special rule for such functions and use position variables to prevent the rule that matches interesting parameter lists from matching functions that have satisfied this case:
I have adjusted your suggestion a little bit here.
@no_input@
identifier fun;
position pos;
@@
fun at pos(void) { ... }
@input depends on no_input@
identifier fun;
parameter list [count] pl;
position pos != no_input.pos;
@@
fun at pos(pl) { ... }
@script:python collection depends on input@
fun << input.fun;
count << input.count;
places << input.pos;
@@store_positions(fun, count, places)
This pattern variant works as expected for a source code example that was already mentioned before.
elfring@Sonne:~/Projekte/Coccinelle/janitor> spatch.opt --sp-file list_function_parameters2.cocci ../Probe/f-ptr-test1.cinit_defs_builtins: /usr/local/share/coccinelle/standard.h
HANDLING: ../Probe/f-ptr-test1.c
function|"parameter count"|"source file"|line|column my_log|1|"../Probe/f-ptr-test1.c"|1|6
my_safe_log|1|"../Probe/f-ptr-test1.c"|6|5 my_addition|2|"../Probe/f-ptr-test1.c"|25|5
But I wonder about the processing for the following small source file.
void my_log(char const * format, ...)
{
/* Write something ... */
}
elfring at Sonne:~/Projekte/Coccinelle/janitor> spatch.opt --sp-file list_function_parameters2.cocci ../Probe/ellipsis-test1.cinit_defs_builtins: /usr/local/share/coccinelle/standard.h
HANDLING: ../Probe/ellipsis-test1.c
No result for this analysis!
I would appreciate your advices.
Regards,
Markus
[Cocci] Determination of the number for named function parameters
Quoted 12 lines · SF Markus Elfring
Quoted 3 lines
Have a special rule for such functions and use position variables to prevent the rule that matches interesting parameter lists from matching functions that have satisfied this case:
I have adjusted your suggestion a little bit here.
@no_input@
identifier fun;
position pos;
@@
fun at pos(void) { ... }
Quoted 8 lines
@input depends on no_input@
identifier fun;
parameter list [count] pl;
position pos != no_input.pos;
@@
fun at pos(pl) { ... }@script:python collection depends on input@
No need for depends on input. For a python rule, all metavariables have to be bound before anything happens.
Quoted 27 lines
fun << input.fun;
count << input.count;
places << input.pos;
@@store_positions(fun, count, places)This pattern variant works as expected for a source code example that was already mentioned before.
elfring at Sonne:~/Projekte/Coccinelle/janitor> spatch.opt --sp-file
list_function_parameters2.cocci../Probe/f-ptr-test1.cinit_defs_builtins:/usr/local/share/coccinelle/standard.h
HANDLING:../Probe/f-ptr-test1.c
function|"parameter count"|"source file"|line|column my_log|1|"../Probe/f-ptr-test1.c"|1|6my_safe_log|1|"../Probe/f-ptr-test1.c"|6|5 my_addition|2|"../Probe/f-ptr-test1.c"|25|5But I wonder about the processing for the following small source file.
void
my_log(char const * format, ...)
{
/* Write something ... */
}
Quoted 8 lines
elfring at Sonne:~/Projekte/Coccinelle/janitor> spatch.opt --sp-file
list_function_parameters2.cocci../Probe/ellipsis-test1.cinit_defs_builtins:/usr/local/share/coccinelle/standard.h
HANDLING:../Probe/ellipsis-test1.c
No result for this analysis!I would appreciate your advices.
I have no idea. I would have sort of expected that it would return a length of 2, but I guess it is reasonable, and even desirable, that it does not. What answer would you like?
julia
[Cocci] Determination of the number for named function parameters
Quoted 3 lines
I have no idea. I would have sort of expected that it would return a length of 2, but I guess it is reasonable, and even desirable, that it does not. What answer would you like?
I would expect that it will be treated by the SmPL pattern as a function with a single named parameter at least. I am unsure how the "ellipsis" should be counted and matched in the signature eventually.
Does this small source file indicate that there might be further difficulties for data analysis of variadic functions?
Regards,
Markus
[Cocci] Determination of the number for named function parameters
Quoted 10 lines · SF Markus Elfring
Quoted 3 lines
I have no idea. I would have sort of expected that it would return a length of 2, but I guess it is reasonable, and even desirable, that it does not. What answer would you like?
I would expect that it will be treated by the SmPL pattern as a function with a single named parameter at least. I am unsure how the "ellipsis" should be counted and matched in the signature eventually.
Does this small source file indicate that there might be further difficulties for data analysis of variadic functions?
Without knowing what you mean by "data analysis" it is impossible to tell. It is clear that there is some problem with ... matching a parameter-typed metavariable. This could be considered reasonable, because ... is not a (single) parameter.
julia
[Cocci] Determination of the number for named function parameters
Quoted 1 line
Without knowing what you mean by "data analysis" it is impossible to tell.
I mean the existence check for a parameter like "format" or extraction of a position for the function signature.
Quoted 1 line
It is clear that there is some problem with ... matching a parameter-typed metavariable.
Thanks that you agree to this detail. Would you like to test the handling of variadic macros and functions also in other situations?
Quoted 1 line
This could be considered reasonable, because ... is not a (single) parameter.
Is there any special mapping of the "ellipsis" at this place in the semantic patch language needed?
Regards,
Markus
[Cocci] Determination of the number for named function parameters
In reply to Julia LawallQuoted 3 lines
It is clear that there is some problem with ... matching a parameter-typed metavariable. This could be considered reasonable, because ... is not a (single) parameter.
How is the software support evolving for variadic macros and functions?
Does the OCaml scripting interface provide more information (besides the SmPL API) which can be useful in advanced source code analysis?
Regards,
Markus
[Cocci] Determination of the number for named function parameters
Quoted 5 lines · SF Markus Elfring
Quoted 3 lines
It is clear that there is some problem with ... matching a parameter-typed metavariable. This could be considered reasonable, because ... is not a (single) parameter.
How is the software support evolving for variadic macros and functions?
For functions, someone is working on it.
Quoted 2 lines
Does the OCaml scripting interface provide more information (besides the SmPL API) which can be useful in advanced source code analysis?
No.
julia
[Cocci] Determination of the number for named function parameters
Quoted 4 lines
Quoted 2 lines
Does the OCaml scripting interface provide more information (besides the SmPL API) which can be useful in advanced source code analysis?
No.
How is the status about an abstract syntax tree interface which was mentioned in a wiki article a while ago?
Regards,
Markus
[Cocci] Determination of the number for named function parameters
Quoted 7 lines · SF Markus Elfring
Quoted 4 lines
Quoted 2 lines
Does the OCaml scripting interface provide more information (besides the SmPL API) which can be useful in advanced source code analysis?
No.
How is the status about an abstract syntax tree interface which was mentioned in a wiki article a while ago?
No idea what you are referring to. In an ocaml script, if you declare a metavariable as:
(a,b) << r.e;
then b is the abstract syntax tree of e. You can eg process it using the visitors available visitor_c.ml.
julia
[Cocci] Determination of the number for named function parameters
Quoted 6 lines
In an ocaml script, if you declare a metavariable as:
(a,b) << r.e;
then b is the abstract syntax tree of e. You can eg process it using the visitors available visitor_c.ml.
I am looking for more descriptions around the following information from the manual.
"...
The file parsing_c/ast_c.ml in the Coccinelle implementation gives some information about the structure of the abstract syntax tree.
..."
Regards,
Markus
[Cocci] Determination of the number for named function parameters
Quoted 7 lines · SF Markus Elfring
Quoted 6 lines
In an ocaml script, if you declare a metavariable as:
(a,b) << r.e;
then b is the abstract syntax tree of e. You can eg process it using the visitors available visitor_c.ml.
Quoted 6 lines
I am looking for more descriptions around the following information from the manual.
"...
The file parsing_c/ast_c.ml in the Coccinelle implementation gives some information about the structure of the abstract syntax tree.
..."
That's all the information there is.
julia
[Cocci] Selection of class libraries ...?
In reply to Julia LawallQuoted 1 line
I didn't implement it, and I never use python.
Would you like to suggest any references for class libraries which work in OCaml with popular data structures in a way I am used to from other programming languages? Is the "convenience" and software speed similar there?
Regards,
Markus
[Cocci] Selection of class libraries ...?
Quoted 5 lines · SF Markus Elfring
Quoted 1 line
I didn't implement it, and I never use python.
Would you like to suggest any references for class libraries which work in OCaml with popular data structures in a way I am used to from other programming languages? Is the "convenience" and software speed similar there?
I have no idea what you are asking for.
julia
[Cocci] Selection of class libraries ...?
Quoted 5 lines
Quoted 3 lines
Would you like to suggest any references for class libraries which work in OCaml with popular data structures in a way I am used to from other programming languages? Is the "convenience" and software speed similar there?
I have no idea what you are asking for.
The programming language "OCaml" has got the property that values from standard data types are immutable. Now I am looking for a well-known OCaml class library which supports the modification of data structures like strings and lists in place. I would prefer to reuse an existing one instead of developing another variation for my experiments.
Regards,
Markus
[Cocci] Selection of class libraries ...?
Quoted 11 lines · SF Markus Elfring
Quoted 5 lines
Quoted 3 lines
Would you like to suggest any references for class libraries which work in OCaml with popular data structures in a way I am used to from other programming languages? Is the "convenience" and software speed similar there?
I have no idea what you are asking for.
The programming language "OCaml" has got the property that values from standard data types are immutable. Now I am looking for a well-known OCaml class library which supports the modification of data structures like strings and lists in place. I would prefer to reuse an existing one instead of developing another variation for my experiments.
Why do you want to do this? There is a String.set function that allows you to modify a character of a string. For a list, if you need to modify an element then it should be a list of reference cells. But I think that in practice it would be strange for either operation to be necessary.
julia
[Cocci] Selection of class libraries ...?
Quoted 4 lines
Why do you want to do this? There is a String.set function that allows you to modify a character of a string. For a list, if you need to modify an element then it should be a list of reference cells. But I think that in practice it would be strange for either operation to be necessary.
I would like to avoid unwanted run time behaviour because of unnecessary data copying when I will append text lines to a growing list.
http://ocaml.org/learn/tutorials/comparison_of_standard_containers.html#Listsimmutablesinglylinkedlists
I imagine that in-place modification will be a more efficient approach for my use case. Is a kind of list buffer available?
Regards,
Markus
[Cocci] Selection of class libraries ...?
Quoted 11 lines · SF Markus Elfring
Quoted 4 lines
Why do you want to do this? There is a String.set function that allows you to modify a character of a string. For a list, if you need to modify an element then it should be a list of reference cells. But I think that in practice it would be strange for either operation to be necessary.
I would like to avoid unwanted run time behaviour because of unnecessary data copying when I will append text lines to a growing list.
http://ocaml.org/learn/tutorials/comparison_of_standard_containers.html#ListsimmutablesinglylinkedlistsI imagine that in-place modification will be a more efficient approach for my use case. Is a kind of list buffer available?
You can just add information to the front of the list, and then reverse it at the end if that is needed.
julia
[Cocci] Selection of class libraries ...?
Quoted 2 lines
You can just add information to the front of the list, and then reverse it at the end if that is needed.
I would like to avoid even insertion at some list heads and a corresponding element reordering because of software efficiency considerations. Is a data structure available for OCaml which is similar to a standard buffer?
http://ocaml.org/learn/tutorials/comparison_of_standard_containers.html#Bufferextensiblestrings
Regards,
Markus
[Cocci] Clarification for OCaml scripts in SmPL
In reply to Julia LawallQuoted 5 lines
Quoted 2 lines
I imagine that in-place modification will be a more efficient approach for my use case. Is a kind of list buffer available?
You can just add information to the front of the list, and then reverse it at the end if that is needed.
I am trying to convert Python statements into similar OCaml functionality for one of my semantic patch examples.
@initialize:ocaml@
@@
let result = Queue.create ()
let current_function = ref ""
let current_count = ref ""
let empty = ""
let delimiter = "|"
let quote = "\""
let quote2 = "\"\""
let mark text = String.concat empty [quote; text; quote]
let replace text =
let length = String.length text in
let part = Buffer.create length in
for x = 0 to length - 1 do
if text.[x] = '"' then
Buffer.add_string part quote2
else
Buffer.add_char part text.[x]
done;
Buffer.contents part
(* Add a source code position to an internal list. *) let append place =
Queue.add (String.concat delimiter [!current_function;
!current_count;
mark (replace place.file);
string_of_int place.line;
string_of_int (place.column + 1)]) resultlet store_positions fun count places =
current_function := fun;
current_count := string_of_int count;
List.iter append places@no_input@
identifier fun;
position pos;
@@
fun at pos(void) { ... }
@input depends on no_input@
identifier fun;
parameter list [count] pl;
position pos != no_input.pos;
@@
fun at pos(pl) { ... }
@script:ocaml collection@
fun << input.fun;
count << input.count;
places << input.pos;
@@store_positions fun count places
@finalize:ocaml@
@@
if Queue.is_empty result then
Printf.eprintf "No result for this analysis!\n"
else
let output text = Printf.printf "%s\r\n" text in
Printf.printf "%s\r\n" (String.concat delimiter ["function";
"\"parameter count\"";
"\"source file\"";
"line";
"column"]);Queue.iter output result
The source code from this SmPL finalisation rule works as expected in a OCaml command line interface. Now I wonder about the following error message.
elfring@Sonne:~/Projekte/Coccinelle/janitor> spatch.opt --sp-file list_function_parameters3.cocci ../Probe/f-ptr-test1.cinit_defs_builtins: /usr/local/share/coccinelle/standard.h
File "list_function_parameters3.cocci", line 69, column 27, charpos = 1914
around = '', whole content = Queue.iter output result
Fatal error: exception Failure("lexing: empty token")
I would appreciate your advices.
Regards,
Markus
[Cocci] Clarification for OCaml scripts in SmPL
Quoted 2 lines
let
store_positionsfun count places =current_function := fun;
Does OCaml not like my name selection here?
Do I accidentally stumble on another software development "surprise" with reserved key words?
http://ocaml.org/learn/faq.html
let store_positions fu count places =
current_fu := fu;
current_count := string_of_int count;
List.iter append placesRegards,
Markus
[Cocci] Clarification for OCaml scripts in SmPL
Quoted 6 lines · SF Markus Elfring
Quoted 2 lines
let
store_positionsfun count places =current_function := fun;Does OCaml not like my name selection here?
Do I accidentally stumble on another software development "surprise" with reserved key words?
Well, it is not really a surprise. Fun is indeed a reserved keyword in ocaml.
julia
Quoted 14 lines
http://ocaml.org/learn/faq.html
let store_positions fu count places = current_fu := fu; current_count := string_of_int count; List.iter append placesRegards,
Markus
_______________________________________________
Cocci mailing list
Cocci at systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci
[Cocci] Clarification for OCaml scripts in SmPL
In reply to SF Markus ElfringQuoted 1 line
let output text = Printf.printf "%s\r\n" text in
It's not related to the problem, but I'm not sure to understand "let output text = ..." Normally the left hand side of a let has only one variable.
julia
[Cocci] Clarification for OCaml scripts in SmPL
Quoted 5 lines · Julia Lawall
Quoted 1 line
let output text = Printf.printf "%s\r\n" text in
It's not related to the problem, but I'm not sure to understand "let output text = ..." Normally the left hand side of a let has only one variable.
I'm sorry. That was a stupid comment :) It is the definition fo a function.
julia
[Cocci] Clarification for OCaml scripts in SmPL
In reply to SF Markus ElfringI think that the problem is in the use of \" and perhaps especially '"'. I'm not sure that what you are doing is the normal ocaml way to do what you want to do. Could you explain in words what replace is supposed to do, for example? I never use either for loops or Buffers.
julia
[Cocci] Clarification for OCaml scripts in SmPL
Quoted 1 line
Could you explain in words what replace is supposed to do, for example?
Yes, of course.
It should replace each quotation mark in a string by two of this character. (Quotes should become duplicated.)
Quoted 1 line
I never use either for loops or Buffers.
Which elements would you prefer to reuse from the programming language "OCaml" for the shown use case?
Regards,
Markus
[Cocci] Clarification for OCaml scripts in SmPL
Quoted 6 lines · SF Markus Elfring
Quoted 1 line
Could you explain in words what replace is supposed to do, for example?
Yes, of course.
It should replace each quotation mark in a string by two of this character. (Quotes should become duplicated.)
The string in question is the file name from a position variable. A file name does not contain a quote character. When you print a string, it appears as eg "foo", but the only characters in the string are f o and o. If you want to put a quote character before and after, The simplest would
be: Printf.sprintf "\"%s\"" place.file.
julia
[Cocci] Clarification for OCaml scripts in SmPL
Quoted 2 lines
The string in question is the file name from a position variable. A file name does not contain a quote character.
I would prefer to handle also the general case that such strings contain quotation marks eventually.
It depends on the analysis area if corresponding safety checks for special characters will matter, doesn't it?
Other example:
https://github.com/coccinelle/coccinelle/issues/5
Regards,
Markus
[Cocci] Clarification for OCaml scripts in SmPL
Quoted 5 lines · SF Markus Elfring
Quoted 2 lines
The string in question is the file name from a position variable. A file name does not contain a quote character.
I would prefer to handle also the general case that such strings contain quotation marks eventually.
Why would a file name contain a quote character. And if it does, what good will adding exxtra ones do you. If the name is
foo\"bar
you will have
"foo\""bar"
and your string will be misparsed by your database.
julia
Quoted 9 lines
It depends on the analysis area if corresponding safety checks for special characters will matter, doesn't it?
Other example:
https://github.com/coccinelle/coccinelle/issues/5Regards,
Markus
[Cocci] Clarification for OCaml scripts in SmPL
Quoted 1 line
Why would a file name contain a quote character.
I do not really know how often this case happens in the world of detailed data processing.
Quoted 1 line
And if it does, what good will adding exxtra ones do you.
I hope to ensure constraints for the used data formats.
Quoted 1 line
... and your string will be misparsed by your database.
I do not think so. I try to achieve quoting by the discussed function implementation so that a column/field in a CSV file will be generally treated as a text string.
Regards,
Markus
[Cocci] Determination of the number for named function parameters
In reply to SF Markus ElfringQuoted 10 lines · SF Markus Elfring
Quoted 5 lines
In declaratin a parameter list, you can also say;
parameter list[n] ps;
and then n is the number of parameters that are matched.
Thanks for your interesting details.
I find the use of the element "n" (the name in square brackets) not obvious from the Coccinelle manual so far.
It is the number of elements that have been matched. You can use it in python code (as a string, I think), in ocaml code (as an integer), or inherit it into another list-typed metavariable.
Quoted 5 lines
But I would like to try more analysis with the data that is passed by the metavariable type "parameter list". I have started to look a bit into it by the function "pickle.dumps". This kind of display is not so useful for me yet. I am missing documentation for corresponding data structures I can depend on in further reports.
What analysis do you want to do? If you write an ocaml script, you can have access to the comple abstract syntax trees. Python code only receives a string representation.
julia
[Cocci] Determination of the number for named function parameters
Quoted 4 lines
Quoted 2 lines
I find the use of the element "n" (the name in square brackets) not obvious from the Coccinelle manual so far.
It is the number of elements that have been matched.
A part of my difficulty with interpretation of the grammar for the semantic patch language came from this notation.
"metadecl ::= ...
| parameter [list] ids ;
| parameter list [ id ] ids ;..."
Do square brackets indicate in one line that an information is optional while in the other line they should be used as literals?
Quoted 1 line
What analysis do you want to do?
If I try out the following script ...
@initialize:python@
@@
import sys
result = []
mark = ['"', '', '"']
delimiter = '|'
def store_positions(fun, count, places):
"""Add source code positions to an internal list.""" for place in places:
fields = []
fields.append(fun)
fields.append(count)
mark[1] = place.file.replace('"', '""')
fields.append(''.join(mark))
fields.append(place.line)
fields.append(str(int(place.column) + 1))
result.append(delimiter.join(fields))
@skeleton@
identifier fun;
parameter list [count] pl;
position pos;
@@
fun at pos(pl)
{
...
}
@script:python collection depends on skeleton@
fun << skeleton.fun;
count << skeleton.count;
places << skeleton.pos;
@@store_positions(fun, count, places)
@finalize:python@
@@
if result:
result.insert(0, delimiter.join(("function", '"parameter count"', '"source
file"', "line", "column")))
print("\r\n".join(result))
else:
sys.stderr.write("No result for this analysis!\n")
... on this source code example, ...
void my_log(char const * text)
{
/* Write something ... */
}
int my_safe_log(char const * text)
{
if (!text)
return 1;
my_log(text);
return 0;
}
char const * const my_message(void)
{
return "Surprise!";
}
int my_status(void)
{
return 1;
}
int my_addition(char a, char b)
{
return a + b;
}
int main(void)
{
struct my_operations
{
void (*log)(char const * t);
int (*safe_log)(char const * t);
char const * const (*get_message)(void);
int (*is_ready)(void);
int (*add)(char a, char b); } mo = {my_log, my_safe_log, my_message, my_status, my_addition}, * mop = &mo;
char const * const x = mo.get_message();
int y = mop->is_ready();
y = mop->add(1, 2);
y = mo.add(3, 4);
mo.log(mo.get_message());
mo.is_ready();
my_safe_log(0);
mo.safe_log(0);
mop->safe_log(0);
}
... I get a result that is a bit interesting.
elfring at Sonne:~/Projekte/Coccinelle/janitor> spatch --sp-file list_function_parameters2.cocci ../Probe/f-ptr-test1.cinit_defs_builtins: /usr/local/share/coccinelle/standard.h
HANDLING: ../Probe/f-ptr-test1.c
function|"parameter count"|"source file"|line|column main|1|"../Probe/f-ptr-test1.c"|30|5 my_log|1|"../Probe/f-ptr-test1.c"|1|6 my_message|1|"../Probe/f-ptr-test1.c"|15|20
my_safe_log|1|"../Probe/f-ptr-test1.c"|6|5 my_status|1|"../Probe/f-ptr-test1.c"|20|5 my_addition|2|"../Probe/f-ptr-test1.c"|25|5
I guess that I want to exclude matches for my use case where where the parameter type is "void". I would like to show the distribution of parameter numbers in a source code base.
Regards,
Markus
[Cocci] Determination of the number for named function parameters
Quoted 8 lines · SF Markus Elfring
Quoted 4 lines
Quoted 2 lines
I find the use of the element "n" (the name in square brackets) not obvious from the Coccinelle manual so far.
It is the number of elements that have been matched.
A part of my difficulty with interpretation of the grammar for the semantic patch language came from this notation.
Quoted 8 lines
"metadecl ::= ...
| parameter [list] ids ; | parameter list [ id ] ids ;..."
Do square brackets indicate in one line that an information is optional while in the other line they should be used as literals?
Yes. The spaces around the [ ] means that they are tokens.
julia
[Cocci] Improvements for the SmPL grammar description?
Quoted 1 line
The spaces around the [ ] means that they are tokens.
I would appreciate if the distinction will become easier for such characters.
Regards,
Markus
[Cocci] Branch layout for if statements with SmPL disjunctions
In reply to Julia LawallQuoted 6 lines
Quoted 4 lines
( if (input) is
| if (likely(input)) is
)
else esThis is not allowed. Inside a disjunction you need to have complete terms.
I imagine that it would be nice if parts from an if statement could be written in the shown way. Would such an extension be useful for the semantic patch language?
I can easily adjust my simple pattern here because each if branch will be matched by a metavariable. I hope that the corresponding repetition of bigger subpatterns can be avoided in the future.
Regards,
Markus
[Cocci] Branch layout for if statements with SmPL disjunctions
Quoted 10 lines · SF Markus Elfring
Quoted 6 lines
Quoted 4 lines
( if (input) is
| if (likely(input)) is
)
else esThis is not allowed. Inside a disjunction you need to have complete terms.
I imagine that it would be nice if parts from an if statement could be written in the shown way. Would such an extension be useful for the semantic patch language?
No, I think that simple rules are better. Always use complete terms is a simple rule.
julia
Quoted 7 lines
I can easily adjust my simple pattern here because each if branch will be matched by a metavariable. I hope that the corresponding repetition of bigger subpatterns can be avoided in the future.
Regards,
Markus
Quoted 2 lines
Something goes wrong with the switch pattern. I would have to look into why.
Do you know about any progress on the involved implementation details?
Regards,
Markus
[Cocci] How to exclude volatile data accesses in expressions with SmPL?
In reply to Julia LawallQuoted 3 lines
Not sure what you mean by extended. There are indeed some other functions in Linux that perform NULL tests before doing anything, and thus they don't really need a null test around them.
I have got another concern for a corresponding implementation detail. How can a constraint be specified for the filter in the semantic patch so that the expression refers only to non-volatile data?
Is it a software development challenge to exclude accesses on volatile data elements eventually from the suggested deletion of condition checks?
https://en.wikipedia.org/wiki/Volatile_variable#In_C_and_C.2B.2B
Regards,
Markus
[Cocci] How to exclude volatile data accesses in expressions with SmPL?
Quoted 10 lines · SF Markus Elfring
Quoted 3 lines
Not sure what you mean by extended. There are indeed some other functions in Linux that perform NULL tests before doing anything, and thus they don't really need a null test around them.
I have got another concern for a corresponding implementation detail. How can a constraint be specified for the filter in the semantic patch so that the expression refers only to non-volatile data?
Is it a software development challenge to exclude accesses on volatile data elements eventually from the suggested deletion of condition checks?
https://en.wikipedia.org/wiki/Volatile_variable#In_C_and_C.2B.2B
Perhaps it is possible to write:
@@
volatile x;
@@
* x == NULL
Or maybe
@@
type T;
volatile T x;
@@
* x == NULL
Or at worst:
@@
type T;
identifier i;
@@
volatile T i;
...
*i == NULL
I don't know if this would find much. Intuitively, one might expect such problems to be detected easily by testing or developers to know better in thw first place, but who knows.
julia
[Cocci] How to exclude volatile data accesses in expressions with SmPL?
Quoted 3 lines
I don't know if this would find much. Intuitively, one might expect such problems to be detected easily by testing or developers to know better in thw first place, but who knows.
I see the software development challenge in the analysis of the expression which is used in a condition check. Such an expression could be constructed out of several elements.
I am still unsure on how a data type property like "volatile" can be safely determined by the semantic patch language for each used element. I would be able to specify a filter for a single element as you suggest. But is the combination of some elements more interesting for the general use case?
Regards,
Markus
[Cocci] How to exclude volatile data accesses in expressions with SmPL?
Quoted 4 lines · SF Markus Elfring
Quoted 3 lines
I don't know if this would find much. Intuitively, one might expect such problems to be detected easily by testing or developers to know better in thw first place, but who knows.
Quoted 8 lines
I see the software development challenge in the analysis of the expression which is used in a condition check. Such an expression could be constructed out of several elements.
I am still unsure on how a data type property like "volatile" can be safely determined by the semantic patch language for each used element. I would be able to specify a filter for a single element as you suggest. But is the combination of some elements more interesting for the general use case?
Coccinelle makes an effort to infer types. YOu may need to use eg --recursive-includes and --relax-include-path to get the most possible type information.
julia
[Cocci] How to exclude volatile data accesses in expressions with SmPL?
Quoted 3 lines
Coccinelle makes an effort to infer types. YOu may need to use eg --recursive-includes and --relax-include-path to get the most possible type information.
It is nice when a simple filter pattern works in principle. A filter pattern which needs the knowledge about all data type details to consider relevant constraints will need more time for the data analysis. I hope that the corresponding execution speed can also be improved.
Regards,
Markus
[Cocci] How to exclude volatile data accesses in expressions with SmPL?
In reply to Julia LawallQuoted 3 lines
Coccinelle makes an effort to infer types. YOu may need to use eg --recursive-includes and --relax-include-path to get the most possible type information.
How do you think about to make it possible to check attributes for expressions in SmPL constraints?
Regards,
Markus
[Cocci] How to exclude volatile data accesses in expressions with SmPL?
Quoted 6 lines · SF Markus Elfring
Quoted 3 lines
Coccinelle makes an effort to infer types. YOu may need to use eg --recursive-includes and --relax-include-path to get the most possible type information.
How do you think about to make it possible to check attributes for expressions in SmPL constraints?
I tried to do this at one point, but it introduced a lot of parsing problems, because attributes can appear in a variety of places. The benefit didn't seem to be worth the risk.
julia
[Cocci] How to exclude volatile data accesses in expressions with SmPL?
Quoted 5 lines
Quoted 2 lines
How do you think about to make it possible to check attributes for expressions in SmPL constraints?
I tried to do this at one point, but it introduced a lot of parsing problems, because attributes can appear in a variety of places.
Which kind of syntax had you got in mind for such a functionality?
Is there a need to distinguish property checks from support for extensions from a popular compiler implementation?
http://gcc.gnu.org/onlinedocs/gcc-4.8.2/gcc/Type-Attributes.html
Quoted 1 line
The benefit didn't seem to be worth the risk.
Can we clarify your concerns a bit more here?
Regards,
Markus
[Cocci] How to exclude volatile data accesses in expressions with SmPL?
Quoted 8 lines · SF Markus Elfring
Quoted 5 lines
Quoted 2 lines
How do you think about to make it possible to check attributes for expressions in SmPL constraints?
I tried to do this at one point, but it introduced a lot of parsing problems, because attributes can appear in a variety of places.
Which kind of syntax had you got in mind for such a functionality?
Quoted 8 lines
Is there a need to distinguish property checks from support for extensions from a popular compiler implementation?
http://gcc.gnu.org/onlinedocs/gcc-4.8.2/gcc/Type-Attributes.htmlQuoted 1 line
The benefit didn't seem to be worth the risk.
Can we clarify your concerns a bit more here?
To my recollection, there were problems of ambiguity in the parser. Also, I think it made the abstract syntax tree unwieldy, because attributes had to be taken into account in many positions.
julia
[Cocci] How to exclude volatile data accesses in expressions with SmPL?
Quoted 3 lines
To my recollection, there were problems of ambiguity in the parser. Also, I think it made the abstract syntax tree unwieldy, because attributes had to be taken into account in many positions.
Would you like to give it another try?
Regards,
Markus