Source code review around jump label usage
Subsystems (101)
Re: mfd: smsc-ece1099: Fine-tuning for smsc_i2c_probe()
In reply to Lee JonesQuoted 5 lines
Quoted 3 lines
Do you request that I should resend my four update suggestions for different components as a single patch series for the software area "
drivers/mfd"?You have to make that decision yourself.
I chose on 2015-12-29 to send them in the combination you see.
Quoted 1 line
What I'm saying is, if the cover letter says there are 2 patches
These refer to the component "smsc-ece1099".
Quoted 1 line
in the set, that's what we should expect.
Can changes for the components "dm355evm_msp" and "twl-core" be clarified independently?
Regards,
Markus
Re: mfd: smsc-ece1099: Fine-tuning for smsc_i2c_probe()
Quoted 7 lines · SF Markus Elfring
Quoted 5 lines
Quoted 3 lines
Do you request that I should resend my four update suggestions for different components as a single patch series for the software area "
drivers/mfd"?You have to make that decision yourself.
I chose on 2015-12-29 to send them in the combination you see.
That was not a good choice.
Quoted 3 lines
Quoted 1 line
What I'm saying is, if the cover letter says there are 2 patches
These refer to the component "smsc-ece1099".
That's fine. Then there should have been 2 patches in the set. But then to attach 2 unrelated patches to the set is not fine. They should have either been submitted as part of the set i.e. 0/4 or completely separately.
Quoted 4 lines
Quoted 1 line
in the set, that's what we should expect.
Can changes for the components "
dm355evm_msp" and "twl-core" be clarified independently?
Yes, or together would have also been fine. The only think that is not okay is to submit a set of 2 patches, then to "bolt-on" another 2 for some reason.
Signature · 8 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog -- To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 1/1 mfd: twl-core: One function call less in add_numbered_child() after error detection
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 29 Dec 2015 19:29:08 +0100
The platform_device_put() function was called in one case by the add_numbered_child() function during error handling even if the passed variable "pdev" contained a null pointer.
Implementation details could be improved by the adjustment of jump targets according to the Linux coding style convention.
This issue was detected by using the Coccinelle software.
--- drivers/mfd/twl-core.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-)
drivers/mfd/twl-core.c +10 -11
@@ -625,7 +625,7 @@ add_numbered_child(unsigned mod_no, const char *name, int num,if (!pdev) {dev_dbg (&twl->client->dev,"can't alloc dev\n" ); status = -ENOMEM ; - goto err; + goto report_failure; } pdev->dev.parent = &twl->client->dev;
@@ -634,7 +634,7 @@ add_numbered_child(unsigned mod_no, const char *name, int num, status =platform_device_add_data (pdev, pdata, pdata_len);if (status <0 ) {dev_dbg (&pdev->dev,"can't add platform_data\n" ); - goto err; + goto put_device; } }
@@ -647,21 +647,20 @@ add_numbered_child(unsigned mod_no, const char *name, int num, status =platform_device_add_resources (pdev, r, irq1 ?2 :1 );if (status <0 ) {dev_dbg (&pdev->dev,"can't add irqs\n" ); - goto err; + goto put_device; } } status =platform_device_add (pdev); -if (status =0 ) +if (!status) {device_init_wakeup (&pdev->dev, can_wakeup); - -err: -if (status <0 ) { -platform_device_put (pdev); -dev_err (&twl->client->dev,"can't add %s dev\n" , name); -return ERR_PTR (status); +return &pdev->dev; } -return &pdev->dev; +put_device: +platform_device_put (pdev); +report_failure: +dev_err (&twl->client->dev,"can't add %s dev\n" , name); +return ERR_PTR (status); } static inline struct device *add_child(unsigned mod_no, const char *name,
Signature · 1 line
2.6.3
Re: [PATCH] mfd: twl-core: One function call less in add_numbered_child() after error detection
Quoted 22 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Tue, 29 Dec 2015 19:29:08 +0100The
platform_device_put()function was called in one case by theadd_numbered_child()function during error handling even if the passed variable "pdev" contained a null pointer.Implementation details could be improved by the adjustment of jump targets according to the Linux coding style convention.
This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/mfd/twl-core.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-)drivers/mfd/twl-core.c +0
-0
drivers/mfd/twl-core.c add_numbered_child(unsigned mod_no, const char *name, int num, · line 626
Quoted 2 lines
drivers/mfd/twl-core.c +0
-0@@ -625,7 +625,7 @@ add_numbered_child(unsigned mod_no, const char *name, int num,if (!pdev) {dev_dbg (&twl->client->dev,"can't alloc dev\n" );
Change this to be dev_err()
drivers/mfd/twl-core.c add_numbered_child(unsigned mod_no, const char *name, int num, · line 628
Quoted 3 lines
drivers/mfd/twl-core.c +1
-1status = -ENOMEM ; - goto err; + goto report_failure;
... and just return status from here.
Quoted 14 lines
drivers/mfd/twl-core.c +1
-1} pdev->dev.parent = &twl->client->dev;@@ -634,7 +634,7 @@ add_numbered_child(unsigned mod_no, const char *name, int num, status =platform_device_add_data (pdev, pdata, pdata_len);if (status <0 ) {dev_dbg (&pdev->dev,"can't add platform_data\n" ); - goto err; + goto put_device; } }@@ -647,21 +647,20 @@ add_numbered_child(unsigned mod_no, const char *name, int num, status =platform_device_add_resources (pdev, r, irq1 ?2 :1 );
drivers/mfd/twl-core.c add_numbered_child(unsigned mod_no, const char *name, int num, · line 655
Quoted 10 lines
drivers/mfd/twl-core.c +2
-2if (status <0 ) {dev_dbg (&pdev->dev,"can't add irqs\n" ); - goto err; + goto put_device; } } status =platform_device_add (pdev); -if (status =0 ) +if (!status) {
You've changed the way you handle errors from this point. To be more consistent it would be better if you checked for status, then jump to put_device in the case of a failure, as you do above.
Quoted 18 lines
drivers/mfd/twl-core.c +6
-7device_init_wakeup (&pdev->dev, can_wakeup); - -err: -if (status <0 ) { -platform_device_put (pdev); -dev_err (&twl->client->dev,"can't add %s dev\n" , name); -return ERR_PTR (status); +return &pdev->dev; } -return &pdev->dev; +put_device: +platform_device_put (pdev); +report_failure: +dev_err (&twl->client->dev,"can't add %s dev\n" , name); +return ERR_PTR (status); } static inline struct device *add_child(unsigned mod_no, const char *name,
Signature · 8 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog -- To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
cover mfd: twl-core: Fine-tuning for add_numbered_child()
From: Markus Elfring <[email protected]>
Date: Sun, 15 May 2016 19:55:30 +0200
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (2):
Return directly after a failed platform_device_alloc() in add_numbered_child() Refactoring for add_numbered_child()
drivers/mfd/twl-core.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-)
Signature · 1 line
2.8.2
PATCH 1/2 mfd: twl-core: Return directly after a failed platform_device_alloc() in add_numbered_child()
From: Markus Elfring <[email protected]>
Date: Sun, 15 May 2016 19:20:28 +0200
The platform_device_put() function was called in one case by the add_numbered_child() function during error handling even if the passed variable "pdev" contained a null pointer.
* Change an error message.
* Return directly in this case.
This issue was detected by using the Coccinelle software.
--- drivers/mfd/twl-core.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/mfd/twl-core.c +4 -3
@@ -623,9 +623,10 @@ add_numbered_child(unsigned mod_no, const char *name, int num, pdev =platform_device_alloc (name, num);if (!pdev) { -dev_dbg (&twl->client->dev,"can't alloc dev\n" ); - status = -ENOMEM ; - goto err; +dev_err (&twl->client->dev, +"Allocation failed for device: %s\n" , + name); +return ERR_PTR (-ENOMEM ); } pdev->dev.parent = &twl->client->dev;
Signature · 1 line
2.8.2
Re: [PATCH 1/2] mfd: twl-core: Return directly after a failed platform_device_alloc() in add_numbered_child()
Quoted 8 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 15 May 2016 19:20:28 +0200The
platform_device_put()function was called in one case by theadd_numbered_child()function during error handling even if the passed variable "pdev" contained a null pointer.* Change an error message.
Why? Is dev_err needed? Doesn't it already print out the device name?
In any case, the only source of failure is failure of a kzalloc in platform_device_alloc, which means that a complete backtrace would be generated, so it is not clear that any message is needed at all.
julia
Quoted 36 lines
* Return directly in this case.
This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/mfd/twl-core.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/mfd/twl-core.c +4
-3@@ -623,9 +623,10 @@ add_numbered_child(unsigned mod_no, const char *name, int num, pdev =platform_device_alloc (name, num);if (!pdev) { -dev_dbg (&twl->client->dev,"can't alloc dev\n" ); - status = -ENOMEM ; - goto err; +dev_err (&twl->client->dev, +"Allocation failed for device: %s\n" , + name); +return ERR_PTR (-ENOMEM ); } pdev->dev.parent = &twl->client->dev;Signature · 6 lines
2.8.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: mfd: twl-core: Return directly after a failed platform_device_alloc() in add_numbered_child()
Quoted 3 lines
Quoted 1 line
* Change an error message.
Why? Is
dev_errneeded?
I interpreted Lee's response in this way.
https://lkml.org/lkml/2016/1/11/104
Regards,
Markus
Re: mfd: twl-core: Return directly after a failed platform_device_alloc() in add_numbered_child()
Quoted 6 lines · SF Markus Elfring
Quoted 3 lines
Quoted 1 line
* Change an error message.
Why? Is
dev_errneeded?I interpreted Lee's response in this way.
https://lkml.org/lkml/2016/1/11/104
OK. He didn't ask for the message to be changed though. It's a bit unfortunate that it now takes up multiple lines. And I believe it also prints redundant information. Perhaps he will have some further thoughts on the matter.
julia
Re: mfd: twl-core: Return directly after a failed platform_device_alloc() in add_numbered_child()
Quoted 6 lines · Julia Lawall
Quoted 4 lines · SF Markus Elfring
Quoted 3 lines
Quoted 1 line
* Change an error message.
Why? Is
dev_errneeded?
Quoted 7 lines
Quoted 2 lines
I interpreted Lee's response in this way.
https://lkml.org/lkml/2016/1/11/104OK. He didn't ask for the message to be changed though. It's a bit unfortunate that it now takes up multiple lines. And I believe it also prints redundant information. Perhaps he will have some further thoughts on the matter.
Yes, Julia is right. We normally don't print anything for OOM errors since Linux reports on them already.
Please remove the print altogether.
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Re: mfd: twl-core: Return directly after a failed platform_device_alloc() in add_numbered_child()
Quoted 1 line
Please remove the print altogether.
Would you like to omit any extra logging statements at more source code places?
Regards,
Markus
PATCH 2/2 mfd: twl-core: Refactoring for add_numbered_child()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 15 May 2016 19:50:55 +0200
Adjust jump targets according to the Linux coding style convention. Another check for the variable "status" can be omitted then at the end.
--- drivers/mfd/twl-core.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
drivers/mfd/twl-core.c +9 -10
@@ -635,7 +635,7 @@ add_numbered_child(unsigned mod_no, const char *name, int num, status =platform_device_add_data (pdev, pdata, pdata_len);if (status <0 ) {dev_dbg (&pdev->dev,"can't add platform_data\n" ); - goto err; + goto put_device; } }
@@ -648,21 +648,20 @@ add_numbered_child(unsigned mod_no, const char *name, int num, status =platform_device_add_resources (pdev, r, irq1 ?2 :1 );if (status <0 ) {dev_dbg (&pdev->dev,"can't add irqs\n" ); - goto err; + goto put_device; } } status =platform_device_add (pdev); -if (status =0 ) -device_init_wakeup (&pdev->dev, can_wakeup); +if (status) + goto put_device; -err: -if (status <0 ) { -platform_device_put (pdev); -dev_err (&twl->client->dev,"can't add %s dev\n" , name); -return ERR_PTR (status); - } +device_init_wakeup (&pdev->dev, can_wakeup);return &pdev->dev; +put_device: +platform_device_put (pdev); +dev_err (&twl->client->dev,"can't add %s dev\n" , name); +return ERR_PTR (status); } static inline struct device *add_child(unsigned mod_no, const char *name,
Signature · 1 line
2.8.2
Re: [PATCH 2/2] mfd: twl-core: Refactoring for add_numbered_child()
Quoted 36 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 15 May 2016 19:50:55 +0200Adjust jump targets according to the Linux coding style convention. Another check for the variable "status" can be omitted then at the end.
Signed-off-by Markus Elfring <[email protected]>--- drivers/mfd/twl-core.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)drivers/mfd/twl-core.c +2
-4@@ -635,7 +635,7 @@ add_numbered_child(unsigned mod_no, const char *name, int num, status =platform_device_add_data (pdev, pdata, pdata_len);if (status <0 ) {dev_dbg (&pdev->dev,"can't add platform_data\n" ); - goto err; + goto put_device; } }@@ -648,21 +648,20 @@ add_numbered_child(unsigned mod_no, const char *name, int num, status =platform_device_add_resources (pdev, r, irq1 ?2 :1 );if (status <0 ) {dev_dbg (&pdev->dev,"can't add irqs\n" ); - goto err; + goto put_device; } } status =platform_device_add (pdev); -if (status ==0 ) -device_init_wakeup (&pdev->dev, can_wakeup);
drivers/mfd/twl-core.c add_numbered_child(unsigned mod_no, const char *name, int num, · line 659
Quoted 10 lines
drivers/mfd/twl-core.c +3
-6+if (status) + goto put_device; -err: -if (status <0 ) { -platform_device_put (pdev); -dev_err (&twl->client->dev,"can't add %s dev\n" , name); -return ERR_PTR (status); - } +device_init_wakeup (&pdev->dev, can_wakeup);
Nit: Place a '\n' here.
drivers/mfd/twl-core.c add_numbered_child(unsigned mod_no, const char *name, int num, · line 660
Quoted 1 line
drivers/mfd/twl-core.c +0
-0return &pdev->dev;
Nit: Place a '\n' here.
drivers/mfd/twl-core.c add_numbered_child(unsigned mod_no, const char *name, int num, · line 663
Quoted 3 lines
drivers/mfd/twl-core.c +3
-0+put_device: +platform_device_put (pdev); +dev_err (&twl->client->dev,"can't add %s dev\n" , name);
Nit: "failed to add device %s\n"
drivers/mfd/twl-core.c add_numbered_child(unsigned mod_no, const char *name, int num, · line 667
Quoted 4 lines
drivers/mfd/twl-core.c +1
-0+return ERR_PTR (status); } static inline struct device *add_child(unsigned mod_no, const char *name,
Once you've fixed those, please re-submit with my:
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
cover mfd: Fine-tuning for three function implementations
From: Markus Elfring <[email protected]>
Date: Sun, 26 Jun 2016 15:25:43 +0200
Several update suggestions were taken into account from static source code analysis.
Markus Elfring (6):
twl-core: Return directly after a failed platform_device_alloc()
in add_numbered_child()
twl-core: Refactoring for add_numbered_child()
dm355evm_msp: Return directly after a failed platform_device_alloc()
in add_child()
dm355evm_msp: Refactoring for add_child()
smsc-ece1099: Delete an unnecessary variable initialisation
in smsc_i2c_probe()
smsc-ece1099: Return directly after a function failure
in smsc_i2c_probe()drivers/mfd/dm355evm_msp.c | 25 ++++++++++++------------- drivers/mfd/smsc-ece1099.c | 11 ++++------- drivers/mfd/twl-core.c | 28 +++++++++++++--------------- 3 files changed, 29 insertions(+), 35 deletions(-)
Signature · 1 line
2.9.0
PATCH 1/6 mfd: twl-core: Return directly after a failed platform_device_alloc() in add_numbered_child()
From: Markus Elfring <[email protected]>
Date: Sun, 26 Jun 2016 12:25:36 +0200
The platform_device_put() function was called in one case by the add_numbered_child() function during error handling even if the passed variable "pdev" contained a null pointer.
Return directly in this case.
This issue was detected by using the Coccinelle software.
--- drivers/mfd/twl-core.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/mfd/twl-core.c +2 -5
@@ -622,11 +622,8 @@ add_numbered_child(unsigned mod_no, const char *name, int num, twl = &twl_priv->twl_modules[sid]; pdev =platform_device_alloc (name, num); -if (!pdev) { -dev_dbg (&twl->client->dev,"can't alloc dev\n" ); - status = -ENOMEM ; - goto err; - } +if (!pdev) +return ERR_PTR (-ENOMEM ); pdev->dev.parent = &twl->client->dev;
Signature · 1 line
2.9.0
Re: [PATCH 1/6] mfd: twl-core: Return directly after a failed platform_device_alloc() in add_numbered_child()
Quoted 2 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 26 Jun 2016 12:25:36 +0200
Please use git send-email when sending patches to the list.
Quoted 11 lines
The
platform_device_put()function was called in one case by theadd_numbered_child()function during error handling even if the passed variable "pdev" contained a null pointer.
Return directly in this case.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/mfd/twl-core.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
Applied though, thanks.
Quoted 18 lines
drivers/mfd/twl-core.c +2
-5@@ -622,11 +622,8 @@ add_numbered_child(unsigned mod_no, const char *name, int num, twl = &twl_priv->twl_modules[sid]; pdev =platform_device_alloc (name, num); -if (!pdev) { -dev_dbg (&twl->client->dev,"can't alloc dev\n" ); - status = -ENOMEM ; - goto err; - } +if (!pdev) +return ERR_PTR (-ENOMEM ); pdev->dev.parent = &twl->client->dev;
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
PATCH 2/6 mfd: twl-core: Refactoring for add_numbered_child()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 26 Jun 2016 13:03:59 +0200
Adjust jump targets according to the Linux coding style convention. Another check for the variable "status" can be omitted then at the end.
--- drivers/mfd/twl-core.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)
drivers/mfd/twl-core.c +11 -10
@@ -631,7 +631,7 @@ add_numbered_child(unsigned mod_no, const char *name, int num, status =platform_device_add_data (pdev, pdata, pdata_len);if (status <0 ) {dev_dbg (&pdev->dev,"can't add platform_data\n" ); - goto err; + goto put_device; } }
@@ -644,21 +644,22 @@ add_numbered_child(unsigned mod_no, const char *name, int num, status =platform_device_add_resources (pdev, r, irq1 ?2 :1 );if (status <0 ) {dev_dbg (&pdev->dev,"can't add irqs\n" ); - goto err; + goto put_device; } } status =platform_device_add (pdev); -if (status =0 ) -device_init_wakeup (&pdev->dev, can_wakeup); +if (status) + goto put_device; + +device_init_wakeup (&pdev->dev, can_wakeup); -err: -if (status <0 ) { -platform_device_put (pdev); -dev_err (&twl->client->dev,"can't add %s dev\n" , name); -return ERR_PTR (status); - }return &pdev->dev; + +put_device: +platform_device_put (pdev); +dev_err (&twl->client->dev,"failed to add device %s\n" , name); +return ERR_PTR (status); } static inline struct device *add_child(unsigned mod_no, const char *name,
Signature · 1 line
2.9.0
Lee Jones
AppliedRe: [PATCH 2/6] mfd: twl-core: Refactoring for add_numbered_child()
Quoted 11 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 26 Jun 2016 13:03:59 +0200Adjust jump targets according to the Linux coding style convention. Another check for the variable "status" can be omitted then at the end.
Signed-off-by Markus Elfring <[email protected]>Acked-by Lee Jones <[email protected]>--- drivers/mfd/twl-core.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)
Applied, thanks.
Quoted 45 lines
drivers/mfd/twl-core.c +11
-10@@ -631,7 +631,7 @@ add_numbered_child(unsigned mod_no, const char *name, int num, status =platform_device_add_data (pdev, pdata, pdata_len);if (status <0 ) {dev_dbg (&pdev->dev,"can't add platform_data\n" ); - goto err; + goto put_device; } }@@ -644,21 +644,22 @@ add_numbered_child(unsigned mod_no, const char *name, int num, status =platform_device_add_resources (pdev, r, irq1 ?2 :1 );if (status <0 ) {dev_dbg (&pdev->dev,"can't add irqs\n" ); - goto err; + goto put_device; } } status =platform_device_add (pdev); -if (status ==0 ) -device_init_wakeup (&pdev->dev, can_wakeup); +if (status) + goto put_device; + +device_init_wakeup (&pdev->dev, can_wakeup); -err: -if (status <0 ) { -platform_device_put (pdev); -dev_err (&twl->client->dev,"can't add %s dev\n" , name); -return ERR_PTR (status); - }return &pdev->dev; + +put_device: +platform_device_put (pdev); +dev_err (&twl->client->dev,"failed to add device %s\n" , name); +return ERR_PTR (status); } static inline struct device *add_child(unsigned mod_no, const char *name,
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
PATCH 3/6 mfd: dm355evm_msp: Return directly after a failed platform_device_alloc() in add_child()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 26 Jun 2016 13:40:35 +0200
The platform_device_put() function was called in one case by the add_child() function during error handling even if the passed variable "pdev" contained a null pointer.
Return directly in this case.
This issue was detected by using the Coccinelle software.
--- drivers/mfd/dm355evm_msp.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/mfd/dm355evm_msp.c +2 -5
@@ -199,11 +199,8 @@ static struct device *add_child(struct i2c_client *client, const char *name,int status; pdev =platform_device_alloc (name,-1 ); -if (!pdev) { -dev_dbg (&client->dev,"can't alloc dev\n" ); - status = -ENOMEM ; - goto err; - } +if (!pdev) +return ERR_PTR (-ENOMEM );device_init_wakeup (&pdev->dev, can_wakeup); pdev->dev.parent = &client->dev;
Signature · 1 line
2.9.0
Lee Jones
AppliedRe: [PATCH 3/6] mfd: dm355evm_msp: Return directly after a failed platform_device_alloc() in add_child()
Quoted 8 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 26 Jun 2016 13:40:35 +0200The
platform_device_put()function was called in one case by theadd_child()function during error handling even if the passed variable "pdev" contained a null pointer.
Return directly in this case.
Quoted 6 lines
This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/mfd/dm355evm_msp.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
Applied, thanks.
Quoted 18 lines
drivers/mfd/dm355evm_msp.c +2
-5@@ -199,11 +199,8 @@ static struct device *add_child(struct i2c_client *client, const char *name,int status; pdev =platform_device_alloc (name,-1 ); -if (!pdev) { -dev_dbg (&client->dev,"can't alloc dev\n" ); - status = -ENOMEM ; - goto err; - } +if (!pdev) +return ERR_PTR (-ENOMEM );device_init_wakeup (&pdev->dev, can_wakeup); pdev->dev.parent = &client->dev;
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
PATCH 4/6 mfd: dm355evm_msp: Refactoring for add_child()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 26 Jun 2016 13:56:58 +0200
Adjust jump targets according to the Linux coding style convention. Another check for the variable "status" can be omitted then at the end.
--- drivers/mfd/dm355evm_msp.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
drivers/mfd/dm355evm_msp.c +10 -8
@@ -209,7 +209,7 @@ static struct device *add_child(struct i2c_client *client, const char *name, status =platform_device_add_data (pdev, pdata, pdata_len);if (status <0 ) {dev_dbg (&pdev->dev,"can't add platform_data\n" ); - goto err; + goto put_device; } }
@@ -222,19 +222,21 @@ static struct device *add_child(struct i2c_client *client, const char *name, status =platform_device_add_resources (pdev, &r,1 );if (status <0 ) {dev_dbg (&pdev->dev,"can't add irq\n" ); - goto err; + goto put_device; } } status =platform_device_add (pdev); -err: -if (status <0 ) { -platform_device_put (pdev); -dev_err (&client->dev,"can't add %s dev\n" , name); -return ERR_PTR (status); - } +if (status) + goto put_device; +return &pdev->dev; + +put_device: +platform_device_put (pdev); +dev_err (&client->dev,"failed to add device %s\n" , name); +return ERR_PTR (status); }static int add_children (struct i2c_client *client)
Signature · 1 line
2.9.0
Re: [PATCH 4/6] mfd: dm355evm_msp: Refactoring for add_child()
Quoted 25 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 26 Jun 2016 13:56:58 +0200Adjust jump targets according to the Linux coding style convention. Another check for the variable "status" can be omitted then at the end.
Signed-off-by Markus Elfring <[email protected]>--- drivers/mfd/dm355evm_msp.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)drivers/mfd/dm355evm_msp.c +1
-1@@ -209,7 +209,7 @@ static struct device *add_child(struct i2c_client *client, const char *name, status =platform_device_add_data (pdev, pdata, pdata_len);if (status <0 ) {dev_dbg (&pdev->dev,"can't add platform_data\n" ); - goto err; + goto put_device; } }
drivers/mfd/dm355evm_msp.c static struct device *add_child(struct i2c_client *client, const char *name, · line 230
Quoted 10 lines
drivers/mfd/dm355evm_msp.c +1
-1@@ -222,19 +222,21 @@ static struct device *add_child(struct i2c_client *client, const char *name, status =platform_device_add_resources (pdev, &r,1 );if (status <0 ) {dev_dbg (&pdev->dev,"can't add irq\n" ); - goto err; + goto put_device; } } status =platform_device_add (pdev);
Remove this line too.
Quoted 18 lines
drivers/mfd/dm355evm_msp.c +8
-6-err: -if (status <0 ) { -platform_device_put (pdev); -dev_err (&client->dev,"can't add %s dev\n" , name); -return ERR_PTR (status); - } +if (status) + goto put_device; +return &pdev->dev; + +put_device: +platform_device_put (pdev); +dev_err (&client->dev,"failed to add device %s\n" , name); +return ERR_PTR (status); }static int add_children (struct i2c_client *client)
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Re: [PATCH 4/6] mfd: dm355evm_msp: Refactoring for add_child()
Quoted 9 lines
Quoted 9 lines
drivers/mfd/dm355evm_msp.c +1
-1@@ -222,19 +222,21 @@ static struct device *add_child(struct i2c_client *client, const char *name, status =platform_device_add_resources (pdev, &r,1 );if (status <0 ) {dev_dbg (&pdev->dev,"can't add irq\n" ); - goto err; + goto put_device; } }
Quoted 4 lines
drivers/mfd/dm355evm_msp.c static struct device *add_child(struct i2c_client *client, const char *name, · line 230
Quoted 2 lines
drivers/mfd/dm355evm_msp.c +0
-0status =platform_device_add (pdev);Remove this line too.
Do you propose the deletion of a blank line here?
Did you skip this update suggestion while the other patches were finally accepted?
Regards,
Markus
Re: [PATCH 4/6] mfd: dm355evm_msp: Refactoring for add_child()
Quoted 9 lines · SF Markus Elfring
Quoted 9 lines
Quoted 9 lines
drivers/mfd/dm355evm_msp.c +1
-1@@ -222,19 +222,21 @@ static struct device *add_child(struct i2c_client *client, const char *name, status =platform_device_add_resources (pdev, &r,1 );if (status <0 ) {dev_dbg (&pdev->dev,"can't add irq\n" ); - goto err; + goto put_device; } }
Quoted 6 lines
Quoted 4 lines
drivers/mfd/dm355evm_msp.c static struct device *add_child(struct i2c_client *client, const char *name, · line 230
Quoted 2 lines
drivers/mfd/dm355evm_msp.c +0
-0status =platform_device_add (pdev);Remove this line too.
Do you propose the deletion of a blank line here?
Yes.
Quoted 1 line
Did you skip this update suggestion while the other patches were finally accepted?
I don't know what this means.
The other patches in the set have been accepted. Please fix this one and send it again on its own.
Signature · 8 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog -- To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 1/1 mfd: dm355evm_msp: Refactoring for add_child()
From: Markus Elfring <[email protected]>
Date: Thu, 30 Jun 2016 21:54:51 +0200
Adjust jump targets according to the Linux coding style convention. Another check for the variable "status" can be omitted then at the end.
--- drivers/mfd/dm355evm_msp.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/mfd/dm355evm_msp.c +9 -8
@@ -209,7 +209,7 @@ static struct device *add_child(struct i2c_client *client, const char *name, status =platform_device_add_data (pdev, pdata, pdata_len);if (status <0 ) {dev_dbg (&pdev->dev,"can't add platform_data\n" ); - goto err; + goto put_device; } }
@@ -222,19 +222,20 @@ static struct device *add_child(struct i2c_client *client, const char *name, status =platform_device_add_resources (pdev, &r,1 );if (status <0 ) {dev_dbg (&pdev->dev,"can't add irq\n" ); - goto err; + goto put_device; } } status =platform_device_add (pdev); +if (status) + goto put_device; -err: -if (status <0 ) { -platform_device_put (pdev); -dev_err (&client->dev,"can't add %s dev\n" , name); -return ERR_PTR (status); - }return &pdev->dev; + +put_device: +platform_device_put (pdev); +dev_err (&client->dev,"failed to add device %s\n" , name); +return ERR_PTR (status); }static int add_children (struct i2c_client *client)
Signature · 1 line
2.9.0
Joe Perches
maintainerRe: [PATCH] mfd: dm355evm_msp: Refactoring for add_child()
Quoted 6 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Thu, 30 Jun 2016 21:54:51 +0200Adjust jump targets according to the Linux coding style convention. Another check for the variable "status" can be omitted then at the end.
Two headers in this email:
References: <[email protected]> <[email protected]> <20160111082922.GB14104@x1> <[email protected]> <[email protected]> <20160608111442.GB14888@dell> <[email protected]> <[email protected]> <20160628150725.GL24982@dell> <[email protected]> <20160628163146.GG29166@dell>
In-reply-to: <20160628163146.GG29166@dell>
Can you please fix your email client to _not_ send References:
and In-reply-to: headers when sending new patches? Thanks.
Even better would be to use git send-email for these patches.
--
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] mfd: dm355evm_msp: Refactoring for add_child()
Quoted 10 lines · Joe Perches
Quoted 6 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Thu, 30 Jun 2016 21:54:51 +0200Adjust jump targets according to the Linux coding style convention. Another check for the variable "status" can be omitted then at the end.
Two headers in this email:
Quoted 7 lines
References: <[email protected]> <[email protected]> <20160111082922.GB14104@x1> <[email protected]> <[email protected]> <20160608111442.GB14888@dell> <[email protected]> <[email protected]> <20160628150725.GL24982@dell> <[email protected]> <20160628163146.GG29166@dell>
In-reply-to: <20160628163146.GG29166@dell>Can you please fix your email client to _not_ send References:
and In-reply-to: headers when sending new patches? Thanks.Even better would be to use git send-email for these patches.
Yes, I've mentioned this before.
I now have a gargantuan threaded mess consisting of 53 mails in my inbox. Please submit patches using git send-email, not forgetting to increase your submission each time you submit i.e [PATCH v2] and send them independently i.e. not attached to previous submissions.
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Re: mfd: dm355evm_msp: Refactoring for add_child()
In reply to Joe PerchesQuoted 2 lines
Can you please fix your email client to _not_ send References:
and In-reply-to: headers when sending new patches?
I prefer to associate some patches with previous relevant discussion directly.
Quoted 1 line
Even better would be to use git send-email for these patches.
This command can also support a parameter like "--thread", can't it? Would you like point any more views out about communication styles?
Regards,
Markus
Joe Perches
maintainerRe: mfd: dm355evm_msp: Refactoring for add_child()
Quoted 10 lines · SF Markus Elfring
Quoted 3 lines
Can you please fix your email client to _not_ send References:
and In-reply-to: headers when sending new patches?I prefer to associate some patches with previous relevant discussion directly.
Quoted 2 lines
Even better would be to use git send-email for these patches.
This command can also support a parameter like "--thread", can't it?
yes, good to see you can read documentation.
Quoted 1 line
Would you like point any more views out about communication styles?
Actually, yes.
Just because you've submitted a similar patch, an independent patch like this one, doesn't need to refer to those patches you've previously submitted.
For instance, your "References:" for this email
imply some association to a patch series you submitted "[PATCH v3 0/3] gianfar: Fine-tuning for gfar_ethflow_to_filer_table()" for no obvious reason. What is this reason?
--
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] mfd: dm355evm_msp: Refactoring for add_child()
In reply to SF Markus ElfringQuoted 10 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Thu, 30 Jun 2016 21:54:51 +0200Adjust jump targets according to the Linux coding style convention. Another check for the variable "status" can be omitted then at the end.
Signed-off-by Markus Elfring <[email protected]>--- drivers/mfd/dm355evm_msp.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
FYI, code looks fine.
... but please take this opportunity to set-up your submission environment i.e. using git format-patch and git send-email. Once you've done that, please re-submit this patch with my:
Quoted 41 lines
drivers/mfd/dm355evm_msp.c +9
-8@@ -209,7 +209,7 @@ static struct device *add_child(struct i2c_client *client, const char *name, status =platform_device_add_data (pdev, pdata, pdata_len);if (status <0 ) {dev_dbg (&pdev->dev,"can't add platform_data\n" ); - goto err; + goto put_device; } }@@ -222,19 +222,20 @@ static struct device *add_child(struct i2c_client *client, const char *name, status =platform_device_add_resources (pdev, &r,1 );if (status <0 ) {dev_dbg (&pdev->dev,"can't add irq\n" ); - goto err; + goto put_device; } } status =platform_device_add (pdev); +if (status) + goto put_device; -err: -if (status <0 ) { -platform_device_put (pdev); -dev_err (&client->dev,"can't add %s dev\n" , name); -return ERR_PTR (status); - }return &pdev->dev; + +put_device: +platform_device_put (pdev); +dev_err (&client->dev,"failed to add device %s\n" , name); +return ERR_PTR (status); }static int add_children (struct i2c_client *client)
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Re: mfd: dm355evm_msp: Refactoring for add_child()
Quoted 1 line
FYI, code looks fine.
Thanks for your acknowledgement.
Quoted 2 lines
... but please take this opportunity to set-up your submission environment i.e. using
git format-patchandgit send-email.
Would you like to see any special settings to be mentioned in a section like "15) Explicit In-Reply-To headers" from the document "SubmittingPatches"?
Quoted 1 line
you've done that, please re-submit this patch with my:
Does the association of this patch with a bit relevant discussion really hinder the desired commit?
Regards,
Markus
Re: mfd: dm355evm_msp: Refactoring for add_child()
Quoted 15 lines · SF Markus Elfring
Quoted 1 line
FYI, code looks fine.
Thanks for your acknowledgement.
Quoted 2 lines
... but please take this opportunity to set-up your submission environment i.e. using
git format-patchandgit send-email.Would you like to see any special settings to be mentioned in a section like "15) Explicit In-Reply-To headers" from the document "SubmittingPatches"?
Quoted 4 lines
Quoted 1 line
you've done that, please re-submit this patch with my:
Does the association of this patch with a bit relevant discussion really hinder the desired commit?
I'm unsure if you're not re-submitting because you're waiting for an answer for me or not. If you are, here it is. And, don't do that. :)
Please submit your patch-set *not* connected to this, now very tangled web of submissions, complete with all the Acks you've accrued.
Signature · 8 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog -- To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: mfd: dm355evm_msp: Refactoring for add_child()
Quoted 2 lines
I'm unsure if you're not re-submitting because you're waiting for an answer for me or not.
I found your five commits (on 2016-06-29) for this patch series sufficient in principle.
https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/commit/?idÓ13cdde71ec9a5c327a515c37a0dca2cca00de5
Quoted 1 line
If you are, here it is. And, don't do that. :)
I find this feedback a bit strange.
Quoted 3 lines
Please submit your patch-set *not* connected to this, now very tangled web of submissions, complete with all the Acks you've accrued.
I would find it nice if another one of my update suggestions could be integrated after a bit of feedback evolved for a special source code search pattern.
https://patchwork.kernel.org/patch/9199519/
https://patchwork.kernel.org/patch/9208925/
https://patchwork.kernel.org/patch/9210291/
It seems to be harder to achieve acceptance similar to the others.
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: mfd: dm355evm_msp: Refactoring for add_child()
Quoted 21 lines · SF Markus Elfring
Quoted 2 lines
I'm unsure if you're not re-submitting because you're waiting for an answer for me or not.
I found your five commits (on 2016-06-29) for this patch series sufficient in principle.
https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/commit/?id=d313cdde71ec9a5c327a515c37a0dca2cca00de5Quoted 1 line
If you are, here it is. And, don't do that. :)
I find this feedback a bit strange.
Quoted 3 lines
Please submit your patch-set *not* connected to this, now very tangled web of submissions, complete with all the Acks you've accrued.
I would find it nice if another one of my update suggestions could be integrated after a bit of feedback evolved for a special source code search pattern.
Quoted 5 lines
https://patchwork.kernel.org/patch/9199519/
https://patchwork.kernel.org/patch/9208925/
https://patchwork.kernel.org/patch/9210291/It seems to be harder to achieve acceptance similar to the others.
I'm not entirely sure what you're trying to say.
Please rebase all of your unaccepted patches on v4.8-rc1. Apply any Acks that you've collected along the way and re-submit the set.
Please ensure, when you re-submit, you do so using git format-patch and git send-email. Also ensure you do not send them attached to any other patch that you've previously sent.
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Re: mfd: dm355evm_msp: Refactoring for add_child()
Quoted 1 line
Please rebase all of your unaccepted patches on v4.8-rc1.
Thanks for your suggestion. - Would you like to add any comments to my remaining update suggestions for Linux modules (besides "dm355evm_msp")?
I would like to clarify still a few implementation details then.
https://patchwork.kernel.org/patch/9210291/
Quoted 2 lines
Also ensure you do not send them attached to any other patch that you've previously sent.
I imagine that another patch can evolve as a reply to a constructive software development discussion, can't it?
Regards,
Markus
Re: mfd: dm355evm_msp: Refactoring for add_child()
Quoted 10 lines · SF Markus Elfring
Quoted 1 line
Please rebase all of your unaccepted patches on v4.8-rc1.
Thanks for your suggestion. - Would you like to add any comments to my remaining update suggestions for Linux modules (besides "
dm355evm_msp")?I would like to clarify still a few implementation details then.
https://patchwork.kernel.org/patch/9210291/
Quoted 5 lines
Quoted 2 lines
Also ensure you do not send them attached to any other patch that you've previously sent.
I imagine that another patch can evolve as a reply to a constructive software development discussion, can't it?
Yes, just don't send it attached (threaded -- using reply-to).
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
PATCH 5/6 mfd: smsc-ece1099: Delete an unnecessary variable initialisation in smsc_i2c_probe()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 26 Jun 2016 14:14:54 +0200
The variable "ret" will be set to an appropriate value a bit later. Thus omit the explicit initialisation at the beginning.
--- drivers/mfd/smsc-ece1099.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/smsc-ece1099.c +1 -1
@@ -36,7 +36,7 @@ static int smsc_i2c_probe(struct i2c_client *i2c, {struct smsc *smsc;int devid, rev, venid_l, venid_h; -int ret =0 ; +int ret; smsc =devm_kzalloc (&i2c->dev,sizeof (struct smsc ),GFP_KERNEL );
Signature · 1 line
2.9.0
Lee Jones
AppliedRe: [PATCH 5/6] mfd: smsc-ece1099: Delete an unnecessary variable initialisation in smsc_i2c_probe()
Quoted 10 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 26 Jun 2016 14:14:54 +0200The variable "ret" 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/mfd/smsc-ece1099.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Applied, thanks.
Quoted 13 lines
drivers/mfd/smsc-ece1099.c +1
-1@@ -36,7 +36,7 @@ static int smsc_i2c_probe(struct i2c_client *i2c, {struct smsc *smsc;int devid, rev, venid_l, venid_h; -int ret =0 ; +int ret; smsc =devm_kzalloc (&i2c->dev,sizeof (struct smsc ),GFP_KERNEL );
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
PATCH 6/6 mfd: smsc-ece1099: Return directly after a function failure in smsc_i2c_probe()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 26 Jun 2016 14:30:46 +0200
This issue was detected by using the Coccinelle software.
Return directly if a call of the function "devm_regmap_init_i2c" or "regmap_write" failed.
Delete the jump label "err" then.
--- drivers/mfd/smsc-ece1099.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/mfd/smsc-ece1099.c +3 -6
@@ -46,10 +46,8 @@ static int smsc_i2c_probe(struct i2c_client *i2c, } smsc->regmap =devm_regmap_init_i2c (i2c, &smsc_regmap_config); -if (IS_ERR (smsc->regmap)) { - ret =PTR_ERR (smsc->regmap); - goto err; - } +if (IS_ERR (smsc->regmap)) +return PTR_ERR (smsc->regmap);i2c_set_clientdata (i2c, smsc); smsc->dev = &i2c->dev;
@@ -68,7 +66,7 @@ static int smsc_i2c_probe(struct i2c_client *i2c, ret =regmap_write (smsc->regmap,SMSC_CLK_CTRL , smsc->clk);if (ret) - goto err; +return ret;#ifdef CONFIG_OF if (i2c->dev.of_node)
@@ -76,7 +74,6 @@ static int smsc_i2c_probe(struct i2c_client *i2c, NULL, NULL, &i2c->dev);#endif -err:return ret; }
Signature · 1 line
2.9.0
Lee Jones
AppliedRe: [PATCH 6/6] mfd: smsc-ece1099: Return directly after a function failure in smsc_i2c_probe()
Quoted 8 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 26 Jun 2016 14:30:46 +0200This issue was detected by using the Coccinelle software.
Return directly if a call of the function "
devm_regmap_init_i2c" or "regmap_write" failed.
Quoted 6 lines
Delete the jump label "err" then.
Signed-off-by Markus Elfring <[email protected]>--- drivers/mfd/smsc-ece1099.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
Applied, thanks.
Quoted 34 lines
drivers/mfd/smsc-ece1099.c +3
-6@@ -46,10 +46,8 @@ static int smsc_i2c_probe(struct i2c_client *i2c, } smsc->regmap =devm_regmap_init_i2c (i2c, &smsc_regmap_config); -if (IS_ERR (smsc->regmap)) { - ret =PTR_ERR (smsc->regmap); - goto err; - } +if (IS_ERR (smsc->regmap)) +return PTR_ERR (smsc->regmap);i2c_set_clientdata (i2c, smsc); smsc->dev = &i2c->dev;@@ -68,7 +66,7 @@ static int smsc_i2c_probe(struct i2c_client *i2c, ret =regmap_write (smsc->regmap,SMSC_CLK_CTRL , smsc->clk);if (ret) - goto err; +return ret;#ifdef CONFIG_OF if (i2c->dev.of_node)@@ -76,7 +74,6 @@ static int smsc_i2c_probe(struct i2c_client *i2c, NULL, NULL, &i2c->dev);#endif -err:return ret; }
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Re: [PATCH 0/6] mfd: Fine-tuning for three function implementations
In reply to SF Markus ElfringQuoted 14 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 26 Jun 2016 15:25:43 +0200Several update suggestions were taken into account from static source code analysis.
Markus Elfring (6):
twl-core: Return directly after a failedplatform_device_alloc()
inadd_numbered_child()
twl-core: Refactoring foradd_numbered_child()
dm355evm_msp: Return directly after a failedplatform_device_alloc()
inadd_child()
dm355evm_msp: Refactoring foradd_child()
smsc-ece1099: Delete an unnecessary variable initialisation
Quoted 8 lines
in smsc_i2c_probe() smsc-ece1099: Return directly after a function failure in smsc_i2c_probe()drivers/mfd/dm355evm_msp.c | 25 ++++++++++++------------- drivers/mfd/smsc-ece1099.c | 11 ++++------- drivers/mfd/twl-core.c | 28 +++++++++++++--------------- 3 files changed, 29 insertions(+), 35 deletions(-)
What is this set? A different but related one to the set you tagged it on to? Probably best not to do that. I now have a huge entangled thread in my inbox, which is going to become out of control rather quickly (if it isn't already).
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
PATCH 1/1 mmc-core: One check less in mmc_select_hs200() after error detection
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 29 Dec 2015 20:28:46 +0100
This issue was detected by using the Coccinelle software.
Move the jump label directly before the desired log statement so that the variable "err" will not be checked once more after it was determined that a call of the function "__mmc_set_signal_voltage" or "__mmc_switch" failed. Use the identifier "report_failure" instead of the label "err".
--- drivers/mmc/core/mmc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/mmc/core/mmc.c +5 -4
@@ -1256,7 +1256,7 @@ static int mmc_select_hs200(struct mmc_card *card)/* If fails try again during next card power cycle */ if (err) - goto err; + goto report_failure;mmc_select_driver_type (card);
@@ -1276,7 +1276,7 @@ static int mmc_select_hs200(struct mmc_card *card) card->ext_csd.generic_cmd6_time, true, send_status, true);if (err) - goto err; + goto report_failure; old_timing = host->ios.timing;mmc_set_timing (host,MMC_TIMING_MMC_HS200 );if (!send_status) {
@@ -1289,10 +1289,11 @@ static int mmc_select_hs200(struct mmc_card *card)mmc_set_timing (host, old_timing); } } -err: -if (err) +if (err) { +report_failure:pr_err ("%s: %s failed, error %d\n" ,mmc_hostname (card->host), __func__, err); + }return err; }
Signature · 1 line
2.6.3
Re: [PATCH] mmc-core: One check less in mmc_select_hs200() after error detection
Quoted 10 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Tue, 29 Dec 2015 20:28:46 +0100This issue was detected by using the Coccinelle software.
Move the jump label directly before the desired log statement so that the variable "err" will not be checked once more after it was determined that a call of the function "
__mmc_set_signal_voltage" or "__mmc_switch" failed. Use the identifier "report_failure" instead of the label "err".
I understand the report, but this unfortunate not the proper solution.
Instead, the "if (err)" check should be entirely removed from the err label.
To do that, mmc_select_hs200() should pre validate whether 4 or 8 -bit bus is supported which then prevents starting to switch to hs200 unless really supported. Moreover it means mmc_select_bus_width() shall return 0 to indicate success instead of as now, returning a positive value or 0.
Kind regards
Uffe
Quoted 45 lines
Signed-off-by Markus Elfring <[email protected]>--- drivers/mmc/core/mmc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)drivers/mmc/core/mmc.c +5
-5@@ -1256,7 +1256,7 @@ static int mmc_select_hs200(struct mmc_card *card)/* If fails try again during next card power cycle */ if (err) - goto err; + goto report_failure;mmc_select_driver_type (card);@@ -1276,7 +1276,7 @@ static int mmc_select_hs200(struct mmc_card *card) card->ext_csd.generic_cmd6_time, true, send_status, true);if (err) - goto err; + goto report_failure; old_timing = host->ios.timing;mmc_set_timing (host,MMC_TIMING_MMC_HS200 );if (!send_status) {@@ -1289,10 +1289,11 @@ static int mmc_select_hs200(struct mmc_card *card)mmc_set_timing (host, old_timing); } } -err: -if (err) +if (err) { +report_failure:pr_err ("%s: %s failed, error %d\n" ,mmc_hostname (card->host), __func__, err); + }return err; } --2.6.3
cover mmc-host: Fine-tuning for one function
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 29 Dec 2015 21:54:14 +0100
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (2):
Delete unnecessary variable initialisations in sdricoh_init_mmc() Less checks in sdricoh_init_mmc() after error detection
drivers/mmc/host/sdricoh_cs.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-)
Signature · 1 line
2.6.3
PATCH 1/2 mmc-sdricoh_cs: Delete unnecessary variable initialisations in sdricoh_init_mmc()
From: Markus Elfring <[email protected]>
Date: Tue, 29 Dec 2015 21:11:45 +0100
These variables will eventually be set to an appropriate value a bit later.
* host
* iobase
* result
Thus let us omit the explicit initialisation at the beginning.
--- drivers/mmc/host/sdricoh_cs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/mmc/host/sdricoh_cs.c +3 -3
@@ -398,10 +398,10 @@ static struct mmc_host_ops sdricoh_ops = {static int sdricoh_init_mmc (struct pci_dev *pci_dev,struct pcmcia_device *pcmcia_dev) { -int result =0 ; -void __iomem *iobase =NULL ; +int result; +void __iomem *iobase;struct mmc_host *mmc =NULL ; -struct sdricoh_host *host =NULL ; +struct sdricoh_host *host;struct device *dev = &pcmcia_dev->dev;/* map iomem */ if (pci_resource_len(pci_dev, SDRICOH_PCI_REGION) !--
2.6.3
Re: [PATCH 1/2] mmc-sdricoh_cs: Delete unnecessary variable initialisations in sdricoh_init_mmc()
Hello,
Am Tue, 29 Dec 2015 22:00:35 +0100
schrieb SF Markus Elfring <[email protected]>:
Quoted 9 lines
From: Markus Elfring <[email protected]>
Date: Tue, 29 Dec 2015 21:11:45 +0100These variables will eventually be set to an appropriate value a bit later.
* host
* iobase
* result
Quoted 3 lines
Thus let us omit the explicit initialisation at the beginning.
Signed-off-by Markus Elfring <[email protected]>
Best regards
Sascha
PATCH 2/2 mmc-sdricoh_cs: Less checks in sdricoh_init_mmc() after, error detection
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 29 Dec 2015 21:45:34 +0100
This issue was detected by using the Coccinelle software.
Two pointer checks could be repeated by the sdricoh_init_mmc() function during error handling even if the relevant properties can be determined for the involved variables before by source code analysis.
* This implementation detail could be improved by adjustments for jump targets according to the Linux coding style convention.
* Drop an unnecessary initialisation for the variable "mmc" then.
--- drivers/mmc/host/sdricoh_cs.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-)
drivers/mmc/host/sdricoh_cs.c +2 -2
@@ -400,7 +400,7 @@ static int sdricoh_init_mmc(struct pci_dev *pci_dev, {int result;void __iomem *iobase; -struct mmc_host *mmc =NULL ; +struct mmc_host *mmc;struct sdricoh_host *host;struct device *dev = &pcmcia_dev->dev;/* map iomem */
@@ -419,7 +419,7 @@ static int sdricoh_init_mmc(struct pci_dev *pci_dev,if (readl (iobase +R104_VERSION ) !=0x4000 ) {dev_dbg (dev,"no supported mmc controller found\n" ); result = -ENODEV ; - goto err; + goto unmap_io; }/* allocate privdata */ mmc = pcmcia_dev->priv @@ -427,7 +427,7 @@ static int sdricoh_init_mmc(struct pci_dev *pci_dev,
if (!mmc) {
dev_err(dev, "mmc_alloc_host failed\n"); result = -ENOMEM;
- goto err;
+ goto unmap_io;
}
host = mmc_priv(mmc);
@@ -451,8 +451,7 @@ static int sdricoh_init_mmc(struct pci_dev *pci_dev,
if (sdricoh_reset(host)) {
dev_dbg(dev, "could not reset\n");
result = -EIO;
- goto err;
-
+ goto free_host;
}
result = mmc_add_host(mmc);
@@ -461,13 +460,10 @@ static int sdricoh_init_mmc(struct pci_dev *pci_dev,
dev_dbg(dev, "mmc host registered\n");
return 0;
}
-
-err:
- if (iobase)
- pci_iounmap(pci_dev, iobase);
- if (mmc)
- mmc_free_host(mmc);
-
+free_host:
+ mmc_free_host(mmc);
+unmap_io:
+ pci_iounmap(pci_dev, iobase);
return result;
}
Signature · 1 line
2.6.3
Re: [PATCH 2/2] mmc-sdricoh_cs: Less checks in sdricoh_init_mmc() after, error detection
Hello,
Am Tue, 29 Dec 2015 22:02:37 +0100
schrieb SF Markus Elfring <[email protected]>:
Quoted 9 lines
From: Markus Elfring <[email protected]>
Date: Tue, 29 Dec 2015 21:45:34 +0100This issue was detected by using the Coccinelle software.
Two pointer checks could be repeated by the
sdricoh_init_mmc()function during error handling even if the relevant properties can be determined for the involved variables before by source code analysis.
Quoted 7 lines
* This implementation detail could be improved by adjustments for jump targets according to the Linux coding style convention.
* Drop an unnecessary initialisation for the variable "mmc" then.
Signed-off-by Markus Elfring <[email protected]>---
Best regards
Sascha
Ulf Hansson
AppliedRe: [PATCH 0/2] mmc-host: Fine-tuning for one function
In reply to SF Markus ElfringQuoted 10 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Tue, 29 Dec 2015 21:54:14 +0100A few update suggestions were taken into account
from static source code analysis.Markus Elfring (2):
Delete unnecessary variable initialisations insdricoh_init_mmc()Less checks insdricoh_init_mmc()after error detection
Quoted 6 lines
drivers/mmc/host/sdricoh_cs.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-)--
2.6.3
Thanks, applied for next - with some minor change to the prefix of the commit message header.
Kind regards
Uffe
cover mtd-rfd_ftl: Fine-tuning for two function implementations
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 31 Dec 2015 21:15:15 +0100
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (3):
Replace a variable initialisation by assignments Refactoring for move_block_contents() Refactoring for erase_block()
drivers/mtd/rfd_ftl.c | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-)
Signature · 1 line
2.6.3
PATCH 1/3 mtd-rfd_ftl: Replace a variable initialisation by assignments in move_block_contents()
From: Markus Elfring <[email protected]>
Date: Thu, 31 Dec 2015 20:34:51 +0100
Replace an explicit initialisation for the variable "rc" at the beginning by assignments that will only be performed if a memory allocation failed.
--- drivers/mtd/rfd_ftl.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/mtd/rfd_ftl.c +7 -3
@@ -359,17 +359,21 @@ static int move_block_contents(struct partition *part, int block_no, u_long *oldvoid *sector_data;u16 *map;size_t retlen; -int i, rc = -ENOMEM ; +int i, rc; part->is_reclaiming =1 ; sector_data =kmalloc (SECTOR_SIZE ,GFP_KERNEL ); -if (!sector_data) +if (!sector_data) { + rc = -ENOMEM ; goto err3; + } map =kmalloc (part->header_size,GFP_KERNEL ); -if (!map) +if (!map) { + rc = -ENOMEM ; goto err2; + } rc =mtd_read (part->mbd.mtd, part->blocks[block_no].offset, part->header_size, &retlen, (u_char *)map);
Signature · 1 line
2.6.3
PATCH 2/3 mtd-rfd_ftl: Refactoring for move_block_contents()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 31 Dec 2015 20:54:50 +0100
This issue was detected by using the Coccinelle software.
Rename jump labels according to the current Linux coding style convention.
--- drivers/mtd/rfd_ftl.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-)
drivers/mtd/rfd_ftl.c +8 -14
@@ -366,13 +366,13 @@ static int move_block_contents(struct partition *part, int block_no, u_long *old sector_data =kmalloc (SECTOR_SIZE ,GFP_KERNEL );if (!sector_data) { rc = -ENOMEM ; - goto err3; + goto reset_reclaim; } map =kmalloc (part->header_size,GFP_KERNEL );if (!map) { rc = -ENOMEM ; - goto err2; + goto free_sector; } rc = mtd_read(part->mbd.mtd, part->blocks[block_no].offset,
@@ -385,8 +385,7 @@ static int move_block_contents(struct partition *part, int block_no, u_long *old printk(KERN_ERR PREFIX "error reading '%s' at ""0x%lx\n" , part->mbd.mtd->name, part->blocks[block_no].offset); - - goto err; + goto free_map; }for (i=0 ; i<part->data_sectors_per_block; i++) {
@@ -417,7 +416,6 @@ static int move_block_contents(struct partition *part, int block_no, u_long *old } rc =mtd_read (part->mbd.mtd, addr,SECTOR_SIZE , &retlen, sector_data); -if (!rc && retlen !=SECTOR_SIZE ) rc = -EIO ;
@@ -425,24 +423,20 @@ static int move_block_contents(struct partition *part, int block_no, u_long *old printk(KERN_ERR PREFIX "'%s': Unable to ""read sector for relocation\n" , part->mbd.mtd->name); - - goto err; + goto free_map; } rc =rfd_ftl_writesect ((struct mtd_blktrans_dev *)part, entry, sector_data); -if (rc) - goto err; + goto free_map; } - -err: +free_map:kfree (map); -err2: +free_sector:kfree (sector_data); -err3: +reset_reclaim: part->is_reclaiming =0 ; -return rc; }
Signature · 1 line
2.6.3
PATCH 3/3 mtd-rfd_ftl: Refactoring for erase_block()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 31 Dec 2015 21:06:27 +0100
This issue was detected by using the Coccinelle software.
* Return directly if a memory allocation failed.
* Drop the explicit initialisation for the variable "rc" at the beginning then.
--- drivers/mtd/rfd_ftl.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/mtd/rfd_ftl.c +2 -4
@@ -326,11 +326,11 @@ static void erase_callback(struct erase_info *erase)static int erase_block (struct partition *part,int block) {struct erase_info *erase; -int rc = -ENOMEM ; +int rc; erase =kmalloc (sizeof (struct erase_info ),GFP_KERNEL );if (!erase) - goto err; +return -ENOMEM ; erase->mtd = part->mbd.mtd; erase->callback = erase_callback;
@@ -349,8 +349,6 @@ static int erase_block(struct partition *part, int block) (unsigned long long)erase->len, part->mbd.mtd->name);kfree (erase); } - -err:return rc; }
Signature · 1 line
2.6.3
Re: [PATCH 0/3] mtd-rfd_ftl: Fine-tuning for two function implementations
In reply to SF Markus ElfringQuoted 5 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Thu, 31 Dec 2015 21:15:15 +0100A few update suggestions were taken into account
from static source code analysis.
Are you fixing anything? Have you tested your work?
At the moment, I can't find any value in your patches.
Brian
PATCH 1/1 net-thunder: One check less in nicvf_register_interrupts() after error detection
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 31 Dec 2015 22:40:39 +0100
Adjust a jump target to eliminate a check before error logging. Use the identifier "report_failure" instead of "err".
--- drivers/net/ethernet/cavium/thunder/nicvf_main.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/net/ethernet/cavium/thunder/nicvf_main.c +7 -8
@@ -922,7 +922,7 @@ static int nicvf_register_interrupts(struct nicvf *nic) ret =request_irq (vector, nicvf_intr_handler,0 , nic->irq_name[irq], nic->napi[irq]);if (ret) - goto err; + goto report_failure; nic->irq_allocated[irq] = true; }
@@ -933,7 +933,7 @@ static int nicvf_register_interrupts(struct nicvf *nic) ret =request_irq (vector, nicvf_rbdr_intr_handler,0 , nic->irq_name[irq], nic);if (ret) - goto err; + goto report_failure; nic->irq_allocated[irq] = true; }
@@ -944,13 +944,12 @@ static int nicvf_register_interrupts(struct nicvf *nic) ret =request_irq (nic->msix_entries[irq].vector, nicvf_qs_err_intr_handler,0 , nic->irq_name[irq], nic); -if (!ret) +if (!ret) { nic->irq_allocated[irq] = true; - -err: -if (ret) -netdev_err (nic->netdev,"request_irq failed, vector %d\n" , irq); - +return 0 ; + } +report_failure: +netdev_err (nic->netdev,"request_irq failed, vector %d\n" , irq);return ret; }
Signature · 1 line
2.6.3
Re: [PATCH] net-thunder: One check less in nicvf_register_interrupts() after error detection
Quoted 5 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Thu, 31 Dec 2015 22:40:39 +0100Adjust a jump target to eliminate a check before error logging. Use the identifier "
report_failure" instead of "err".
I don't see much value in those changes. Using the 'err' label is ok as it is not misleading and common use. And, there is no need to optimize the check since this is not the fast path and will be compiler optimized anyway. So let's keep the code as it is with the flavor of the original author.
-Robert
Quoted 46 lines
Signed-off-by Markus Elfring <[email protected]>--- drivers/net/ethernet/cavium/thunder/nicvf_main.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)drivers/net/ethernet/cavium/thunder/nicvf_main.c +7
-8@@ -922,7 +922,7 @@ static int nicvf_register_interrupts(struct nicvf *nic) ret =request_irq (vector, nicvf_intr_handler,0 , nic->irq_name[irq], nic->napi[irq]);if (ret) - goto err; + goto report_failure; nic->irq_allocated[irq] = true; }@@ -933,7 +933,7 @@ static int nicvf_register_interrupts(struct nicvf *nic) ret =request_irq (vector, nicvf_rbdr_intr_handler,0 , nic->irq_name[irq], nic);if (ret) - goto err; + goto report_failure; nic->irq_allocated[irq] = true; }@@ -944,13 +944,12 @@ static int nicvf_register_interrupts(struct nicvf *nic) ret =request_irq (nic->msix_entries[irq].vector, nicvf_qs_err_intr_handler,0 , nic->irq_name[irq], nic); -if (!ret) +if (!ret) { nic->irq_allocated[irq] = true; - -err: -if (ret) -netdev_err (nic->netdev,"request_irq failed, vector %d\n" , irq); - +return 0 ; + } +report_failure: +netdev_err (nic->netdev,"request_irq failed, vector %d\n" , irq);return ret; }
Re: [PATCH] net-thunder: One check less in nicvf_register_interrupts() after error detection
Quoted 4 lines
Quoted 2 lines
Adjust a jump target to eliminate a check before error logging. Use the identifier "
report_failure" instead of "err".I don't see much value in those changes.
Thanks for your feedback.
Quoted 1 line
Using the 'err' label is ok as it is not misleading and common use.
Is such a short jump label enough explanation for the information "what" and "why"?
Quoted 1 line
And, there is no need to optimize the check since this is not the fast path
Really? - Is it a bit more efficient to avoid a double check for the variable "ret" at the end of the current implementation for the discussed function?
https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/drivers/net/ethernet/cavium/thunder/nicvf_main.c?id@fb5f8a60f33133d36afde35a9ad865d35e4423#n940
Quoted 1 line
and will be compiler optimized anyway.
How sure are you about automatic software optimisations?
Can it occasionally help to jump to the really intended source code location directly?
Quoted 18 lines
Quoted 18 lines
drivers/net/ethernet/cavium/thunder/nicvf_main.c +5
-6@@ -944,13 +944,12 @@ static int nicvf_register_interrupts(struct nicvf *nic) ret =request_irq (nic->msix_entries[irq].vector, nicvf_qs_err_intr_handler,0 , nic->irq_name[irq], nic); -if (!ret) +if (!ret) { nic->irq_allocated[irq] = true; - -err: -if (ret) -netdev_err (nic->netdev,"request_irq failed, vector %d\n" , irq); - +return 0 ; + } +report_failure: +netdev_err (nic->netdev,"request_irq failed, vector %d\n" , irq);return ret; }
Joe Perches
maintainerRe: [PATCH] net-thunder: One check less in nicvf_register_interrupts() after error detection
Quoted 7 lines · SF Markus Elfring
Quoted 3 lines
Quoted 2 lines
Adjust a jump target to eliminate a check before error logging. Use the identifier "
report_failure" instead of "err".I don't see much value in those changes
Thanks for your feedback.
Quoted 1 line
Using the 'err' label is ok as it is not misleading and common use.
Is such a short jump label enough explanation for the information "what" and "why"?
When there is only one type of error possible, yes.
Quoted 5 lines
Quoted 2 lines
And, there is no need to optimize the check since this is not the fast path
Really? - Is it a bit more efficient to avoid a double check for the variable "ret" at the end of the current implementation for the discussed function?
Before asking questions you could answer yourself, please look at object code produced by the compiler before and after your proposed changes.
Re: net-thunder: One check less in nicvf_register_interrupts() after error detection
Quoted 7 lines
Quoted 3 lines
Is it a bit more efficient to avoid a double check for the variable "ret" at the end of the current implementation for the discussed function?
Before asking questions you could answer yourself, please look at object code produced by the compiler before and after your proposed changes.
* Do any more source code reviewers wonder about the need for such a double check?
* Which object code representations would you find representative for a further constructive discussion around this software component?
Regards,
Markus
Joe Perches
maintainerRe: net-thunder: One check less in nicvf_register_interrupts() after error detection
Quoted 10 lines · SF Markus Elfring
Quoted 7 lines
Quoted 3 lines
Is it a bit more efficient to avoid a double check for the variable "ret" at the end of the current implementation for the discussed function?
Before asking questions you could answer yourself, please look at object code produced by the compiler before and after your proposed changes.
* Do any more source code reviewers wonder about the need for such a double check?
Given the feedback you've already received,
it seems so.
Quoted 3 lines
* Which object code representations would you find representative for a further constructive discussion around this software component?
Evidence of actual object code improvement when
with compiled with optimizations.
--
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: net-thunder: One check less in nicvf_register_interrupts() after error detection
Quoted 5 lines
Quoted 3 lines
* Which object code representations would you find representative for a further constructive discussion around this software component?
Evidence of actual object code improvement
How do you think about to provide a function implementation which looks a bit more efficient by default?
Quoted 1 line
when with compiled with optimizations.
Which combinations of hardware and software would you recommend for corresponding system checks?
Regards,
Markus
Joe Perches
maintainerRe: net-thunder: One check less in nicvf_register_interrupts() after error detection
Quoted 8 lines · SF Markus Elfring
Quoted 5 lines
Quoted 3 lines
* Which object code representations would you find representative for a further constructive discussion around this software component?
Evidence of actual object code improvement
How do you think about to provide a function implementation which looks a bit more efficient by default?
It's not a matter of "looks a bit more efficient". it's taste, style, and repetition for various functions.
Some prefer that source code be "templatized" regardless of the number of exit points that any particular use of a specific function type.
Some of your patches are converting these templatized functions to a different form for no added value.
These patches make the local source code inconsistent and generally goes against the authors preferred style.
--
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: net-thunder: One check less in nicvf_register_interrupts() after error detection
Quoted 3 lines
Some prefer that source code be "templatized" regardless of the number of exit points that any particular use of a specific function type.
This is another interesting view on involved implementation details.
Quoted 2 lines
Some of your patches are converting these templatized functions to a different form for no added value.
Would you like to distinguish a bit more between my evolving collection of update suggestions and the concrete proposal for the function "nicvf_register_interrupts"?
Quoted 2 lines
These patches make the local source code inconsistent and generally goes against the authors preferred style.
Which programming approach will be the leading one here finally?
Regards,
Markus
Joe Perches
maintainerRe: net-thunder: One check less in nicvf_register_interrupts() after error detection
Quoted 3 lines · SF Markus Elfring
Quoted 3 lines
Some prefer that source code be "templatized" regardless of the number of exit points that any particular use of a specific function type.
[]
Quoted 6 lines
Quoted 2 lines
Some of your patches are converting these templatized functions to a different form for no added value.
Would you like to distinguish a bit more between my evolving collection of update suggestions and the concrete proposal for the function "
nicvf_register_interrupts"?
No.
Quoted 4 lines
Quoted 2 lines
These patches make the local source code inconsistent and generally goes against the authors preferred style.
Which programming approach will be the leading one here finally?
Whatever the developer wants.
There is no _best_ or _only_ style for this.
PATCH 1/1 be2net: Delete an unnecessary check in two functions
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 1 Jan 2016 00:11:57 +0100
Remove two checks for null pointers which would be handled by usual error detection before.
--- drivers/net/ethernet/emulex/benet/be_cmds.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/net/ethernet/emulex/benet/be_cmds.c +2 -7
@@ -4366,9 +4366,7 @@ int be_cmd_get_profile_config(struct be_adapter *adapter,if (vf_res) res->vf_if_cap_flags = vf_res->cap_flags; err: -if (cmd.va) -dma_free_coherent (&adapter->pdev->dev, cmd.size, cmd.va, - cmd.dma); +dma_free_coherent (&adapter->pdev->dev, cmd.size, cmd.va, cmd.dma);return status; }
@@ -4398,10 +4396,7 @@ static int be_cmd_set_profile_config(struct be_adapter *adapter, void *desc,memcpy (req->desc, desc, size); status =be_cmd_notify_wait (adapter, &wrb); - -if (cmd.va) -dma_free_coherent (&adapter->pdev->dev, cmd.size, cmd.va, - cmd.dma); +dma_free_coherent (&adapter->pdev->dev, cmd.size, cmd.va, cmd.dma);return status; }
Signature · 1 line
2.6.3
Re: [PATCH] be2net: Delete an unnecessary check in two functions
Quoted 7 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 1 Jan 2016 00:11:57 +0100Remove two checks for null pointers which would be handled by usual error detection before.
Signed-off-by Markus Elfring <[email protected]>
This patch is suitable for the net-next tree. Thanks!
cover net-gianfar: Fine-tuning for gfar_ethflow_to_filer_table()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 1 Jan 2016 13:15:34 +0100
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (3):
Less function calls after error detection
Delete unnecessary variable initialisations
Extend an initialisation clause of a for loop
drivers/net/ethernet/freescale/gianfar_ethtool.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)
Signature · 1 line
2.6.3
PATCH 1/3 net-gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection
From: Markus Elfring <[email protected]>
Date: Fri, 1 Jan 2016 11:16:04 +0100
The kfree() function was called in one case by the gfar_ethflow_to_filer_table() function during error handling even if a passed variable contained a null pointer.
* Return directly if a memory allocation failed at the beginning.
* Adjust jump targets according to the Linux coding style convention.
This issue was detected by using the Coccinelle software.
--- drivers/net/ethernet/freescale/gianfar_ethtool.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/net/ethernet/freescale/gianfar_ethtool.c +8 -6
@@ -778,11 +778,13 @@ static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow, local_rqfpr =kmalloc_array (MAX_FILER_IDX +1 ,sizeof (unsigned int ),GFP_KERNEL ); +if (!local_rqfpr) +return 1 ; local_rqfcr =kmalloc_array (MAX_FILER_IDX +1 ,sizeof (unsigned int ),GFP_KERNEL ); -if (!local_rqfpr || !local_rqfcr) { +if (!local_rqfcr) { ret =0 ; - goto err; + goto free_fpr; }switch (class) {
@@ -802,7 +804,7 @@ static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow,netdev_err (priv->ndev,"Right now this class is not supported\n" ); ret =0 ; - goto err; + goto free_fcr; }for (i =0 ; i <MAX_FILER_IDX +1 ; i++) {
@@ -819,7 +821,7 @@ static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow,netdev_err (priv->ndev,"No parse rule found, can't create hash rules\n" ); ret =0 ; - goto err; + goto free_fcr; }/* If a match was found, then it begins the starting of a cluster rule
@@ -862,9 +864,9 @@ static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow,break ; priv->cur_filer_idx = priv->cur_filer_idx -1 ; } - -err: +free_fcr:kfree (local_rqfcr); +free_fpr:kfree (local_rqfpr);return ret; }
Signature · 1 line
2.6.3
Re: [PATCH 1/3] net-gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection
Quoted 23 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 1 Jan 2016 11:16:04 +0100The
kfree()function was called in one case by thegfar_ethflow_to_filer_table()function during error handling even if a passed variable contained a null pointer.* Return directly if a memory allocation failed at the beginning.
* Adjust jump targets according to the Linux coding style convention.
This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/net/ethernet/freescale/gianfar_ethtool.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)drivers/net/ethernet/freescale/gianfar_ethtool.c +0
-0
drivers/net/ethernet/freescale/gianfar_ethtool.c static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow, · line 782
Quoted 5 lines
drivers/net/ethernet/freescale/gianfar_ethtool.c +2
-0@@ -778,11 +778,13 @@ static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow, local_rqfpr =kmalloc_array (MAX_FILER_IDX +1 ,sizeof (unsigned int ),GFP_KERNEL ); +if (!local_rqfpr) +return 1 ;
Why return 1? Previously 0 was returned.
Normally, one returns -ENOMEM for this case, but it looks like this function is returning 0 on failure.
julia
Quoted 48 lines
drivers/net/ethernet/freescale/gianfar_ethtool.c +6
-6local_rqfcr =kmalloc_array (MAX_FILER_IDX +1 ,sizeof (unsigned int ),GFP_KERNEL ); -if (!local_rqfpr || !local_rqfcr) { +if (!local_rqfcr) { ret =0 ; - goto err; + goto free_fpr; }switch (class) {@@ -802,7 +804,7 @@ static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow,netdev_err (priv->ndev,"Right now this class is not supported\n" ); ret =0 ; - goto err; + goto free_fcr; }for (i =0 ; i <MAX_FILER_IDX +1 ; i++) {@@ -819,7 +821,7 @@ static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow,netdev_err (priv->ndev,"No parse rule found, can't create hash rules\n" ); ret =0 ; - goto err; + goto free_fcr; }/* If a match was found, then it begins the starting of a cluster rule @@ -862,9 +864,9 @@ static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow,break ; priv->cur_filer_idx = priv->cur_filer_idx -1 ; } - -err: +free_fcr:kfree (local_rqfcr); +free_fpr:kfree (local_rqfpr);return ret; }Signature · 6 lines
2.6.3 -- 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 1/3] net-gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection
Quoted 9 lines
drivers/net/ethernet/freescale/gianfar_ethtool.c static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow, · line 782
Quoted 7 lines
+++
b/drivers/net/ethernet/freescale/gianfar_ethtool.cdrivers/net/ethernet/freescale/gianfar_ethtool.c +2
-0@@ -778,11 +778,13 @@ static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow, local_rqfpr =kmalloc_array (MAX_FILER_IDX +1 ,sizeof (unsigned int ),GFP_KERNEL ); +if (!local_rqfpr) +return 1 ;Why return 1? Previously 0 was returned.
You are right. - Unfortunately, I made a mistake at this place of my update suggestion.
Quoted 2 lines
Normally, one returns
-ENOMEMfor this case, but it looks like this function is returning 0 on failure.
Should a symbol like "false" be used instead of such a special number?
Regards,
Markus
Re: [PATCH 1/3] net-gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection
Quoted 10 lines · SF Markus Elfring
Quoted 9 lines
drivers/net/ethernet/freescale/gianfar_ethtool.c static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow, · line 782
Quoted 7 lines
+++
b/drivers/net/ethernet/freescale/gianfar_ethtool.cdrivers/net/ethernet/freescale/gianfar_ethtool.c +2
-0@@ -778,11 +778,13 @@ static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow, local_rqfpr =kmalloc_array (MAX_FILER_IDX +1 ,sizeof (unsigned int ),GFP_KERNEL ); +if (!local_rqfpr) +return 1 ;Why return 1? Previously 0 was returned.
Quoted 8 lines
You are right. - Unfortunately, I made a mistake at this place of my update suggestion.
Quoted 2 lines
Normally, one returns
-ENOMEMfor this case, but it looks like this function is returning 0 on failure.Should a symbol like "false" be used instead of such a special number?
Maybe it's better than 0 and 1...
julia
Re: [PATCH 1/3] net-gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection
Julia Lawall <[email protected]> :
Quoted 1 line · SF Markus Elfring
[...]
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Normally, one returns
-ENOMEMfor this case, but it looks like this function is returning 0 on failure.Should a symbol like "false" be used instead of such a special number?
Maybe it's better than 0 and 1...
Your suggestion about -ENOMEM is consistent with the callchain. Nothing else is needed.
Btw:
1. kfree does not care about NULL parameter, especially in this hardly timing sensitive path.
2. kmalloc_array for small kernel controlled arrays of integers (see drivers/net/ethernet/freescale/gianfar.h), seriously ?
I'd suggest the janitor to introduce a dedicated struct to embed both gfar_private.ftp_rqf{p, c}r then use a single, plain kmalloc in gfar_ethflow_to_filer_table.
Happy tasteful 2016 :o)
Signature · 1 line
Ueimor
PATCH v2 1/3 net-gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection
In reply to Julia LawallFrom: Markus Elfring <[email protected]>
Date: Fri, 1 Jan 2016 13:56:09 +0100
The kfree() function was called in one case by the gfar_ethflow_to_filer_table() function during error handling even if a passed variable contained a null pointer.
* Return directly if a memory allocation failed at the beginning.
* Adjust jump targets according to the Linux coding style convention.
This issue was detected by using the Coccinelle software.
--- drivers/net/ethernet/freescale/gianfar_ethtool.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/net/ethernet/freescale/gianfar_ethtool.c +8 -6
@@ -778,11 +778,13 @@ static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow, local_rqfpr =kmalloc_array (MAX_FILER_IDX +1 ,sizeof (unsigned int ),GFP_KERNEL ); +if (!local_rqfpr) +return 0 ; local_rqfcr =kmalloc_array (MAX_FILER_IDX +1 ,sizeof (unsigned int ),GFP_KERNEL ); -if (!local_rqfpr || !local_rqfcr) { +if (!local_rqfcr) { ret =0 ; - goto err; + goto free_fpr; }switch (class) {
@@ -802,7 +804,7 @@ static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow,netdev_err (priv->ndev,"Right now this class is not supported\n" ); ret =0 ; - goto err; + goto free_fcr; }for (i =0 ; i <MAX_FILER_IDX +1 ; i++) {
@@ -819,7 +821,7 @@ static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow,netdev_err (priv->ndev,"No parse rule found, can't create hash rules\n" ); ret =0 ; - goto err; + goto free_fcr; }/* If a match was found, then it begins the starting of a cluster rule
@@ -862,9 +864,9 @@ static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow,break ; priv->cur_filer_idx = priv->cur_filer_idx -1 ; } - -err: +free_fcr:kfree (local_rqfcr); +free_fpr:kfree (local_rqfpr);return ret; }
Signature · 1 line
2.6.3
David Miller
maintainerRe: [PATCH v2 1/3] net-gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection
This is not the proper way to resubmit patches when you are asked to make changes to some portion of a multi-patch series.
You must always resubmit the entire series when this happens, not just the patch that changes.
And in the revised cover "0/N" posting you list the revisions that were made.
PATCH 2/3 net-gianfar: Delete unnecessary variable initialisations in gfar_ethflow_to_filer_table()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 1 Jan 2016 12:56:23 +0100
Omit explicit initialisation at the beginning for four local variables which are redefined before their first use.
--- drivers/net/ethernet/freescale/gianfar_ethtool.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/freescale/gianfar_ethtool.c +3 -3
@@ -768,12 +768,12 @@ static void ethflow_to_filer_rules (struct gfar_private *priv, u64 ethflow)static int gfar_ethflow_to_filer_table (struct gfar_private *priv,u64 ethflow,u64 class) { -unsigned int last_rule_idx = priv->cur_filer_idx; +unsigned int last_rule_idx;unsigned int cmp_rqfpr;unsigned int *local_rqfpr;unsigned int *local_rqfcr; -int i =0x0 , k =0x0 ; -int j =MAX_FILER_IDX , l =0x0 ; +int i, k, l; +int j =MAX_FILER_IDX ;int ret =1 ; local_rqfpr = kmalloc_array(MAX_FILER_IDX + 1, sizeof(unsigned int),
Signature · 1 line
2.6.3
PATCH 3/3 net-gianfar: Extend an initialisation clause of a for loop in gfar_ethflow_to_filer_table()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 1 Jan 2016 13:00:06 +0100
Move the assignment for the variable "j" from the beginning into an initialisation clause of a for loop.
--- drivers/net/ethernet/freescale/gianfar_ethtool.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/net/ethernet/freescale/gianfar_ethtool.c +2 -3
@@ -772,8 +772,7 @@ static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow,unsigned int cmp_rqfpr;unsigned int *local_rqfpr;unsigned int *local_rqfcr; -int i, k, l; -int j =MAX_FILER_IDX ; +int i, j, k, l;int ret =1 ; local_rqfpr = kmalloc_array(MAX_FILER_IDX + 1, sizeof(unsigned int),
@@ -807,7 +806,7 @@ static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow, goto free_fcr; } -for (i =0 ; i <MAX_FILER_IDX +1 ; i++) { +for (i =0 , j =MAX_FILER_IDX ; i <MAX_FILER_IDX +1 ; i++) { local_rqfpr[j] = priv->ftp_rqfpr[i]; local_rqfcr[j] = priv->ftp_rqfcr[i]; j--;
Signature · 1 line
2.6.3
v3 cover gianfar: Fine-tuning for gfar_ethflow_to_filer_table()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 15 Jan 2016 11:05:43 +0100
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (3):
Less function calls after error detection
Delete unnecessary variable initialisations
Extend an initialisation clause of a for loop
---
v3: Rebase proposed changes on the source files for the software
"Linux next-20160114".
v2: Unfortunately, an inappropriate return code was selected in the first
update step from this series.
Thus fix that.
drivers/net/ethernet/freescale/gianfar_ethtool.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)
Signature · 1 line
2.6.3
PATCH v3 1/3 gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection
From: Markus Elfring <[email protected]>
Date: Fri, 15 Jan 2016 10:30:37 +0100
The kfree() function was called in one case by the gfar_ethflow_to_filer_table() function during error handling even if a passed variable contained a null pointer.
* Return directly if a memory allocation failed at the beginning.
* Adjust jump targets according to the Linux coding style convention.
This issue was detected by using the Coccinelle software.
--- drivers/net/ethernet/freescale/gianfar_ethtool.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/net/ethernet/freescale/gianfar_ethtool.c +8 -6
@@ -778,11 +778,13 @@ static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow, local_rqfpr =kmalloc_array (MAX_FILER_IDX +1 ,sizeof (unsigned int ),GFP_KERNEL ); +if (!local_rqfpr) +return 0 ; local_rqfcr =kmalloc_array (MAX_FILER_IDX +1 ,sizeof (unsigned int ),GFP_KERNEL ); -if (!local_rqfpr || !local_rqfcr) { +if (!local_rqfcr) { ret =0 ; - goto err; + goto free_fpr; }switch (class) {
@@ -802,7 +804,7 @@ static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow,netdev_err (priv->ndev,"Right now this class is not supported\n" ); ret =0 ; - goto err; + goto free_fcr; }for (i =0 ; i <MAX_FILER_IDX +1 ; i++) {
@@ -819,7 +821,7 @@ static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow,netdev_err (priv->ndev,"No parse rule found, can't create hash rules\n" ); ret =0 ; - goto err; + goto free_fcr; }/* If a match was found, then it begins the starting of a cluster rule
@@ -862,9 +864,9 @@ static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow,break ; priv->cur_filer_idx = priv->cur_filer_idx -1 ; } - -err: +free_fcr:kfree (local_rqfcr); +free_fpr:kfree (local_rqfpr);return ret; }
Signature · 1 line
2.6.3
Joe Perches
maintainerRe: [PATCH v3 1/3] gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection
Quoted 9 lines · SF Markus Elfring
The
kfree()function was called in one case by thegfar_ethflow_to_filer_table()function during error handling even if a passed variable contained a null pointer.* Return directly if a memory allocation failed at the beginning.
* Adjust jump targets according to the Linux coding style convention.
This issue was detected by using the Coccinelle software.
Is this really better?
Perhaps this particular static analysis isn't too useful.
Why not just allocate once and assign a second pointer?
local_rqfpr = kmalloc_array(2 * (MAX_FILER_IDX + 1), sizeof(unsigned int), GFP_KERNEL); if (!local_rqfpr) goto err; local_rqfcr = &local_rqfpr[MAX_FILER_IDX + 1];
Perhaps this would be better removing the ret variable and using something like:
int gfar_ethflow_to_filer_table(...)
{
...
return 0;err:
kfree(local_rqfpt); return 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: gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection
Quoted 9 lines
Quoted 5 lines
* Return directly if a memory allocation failed at the beginning.
* Adjust jump targets according to the Linux coding style convention.
This issue was detected by using the Coccinelle software.
Is this really better?
Perhaps this particular static analysis isn't too useful.
The opinions are still evolving for such a kind of search pattern.
Quoted 8 lines
Why not just allocate once and assign a second pointer?
local_rqfpr = kmalloc_array(2 * (MAX_FILER_IDX + 1), sizeof(unsigned int), GFP_KERNEL); if (!local_rqfpr) goto err; local_rqfcr = &local_rqfpr[MAX_FILER_IDX + 1];
Do you suggest to use only one array (instead of two as before) here?
Regards,
Markus
Joe Perches
maintainerRe: gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection
Quoted 16 lines · SF Markus Elfring
Quoted 10 lines
Quoted 6 lines
* Return directly if a memory allocation failed at the beginning.
* Adjust jump targets according to the Linux coding style convention.
This issue was detected by using the Coccinelle software.
Is this really better?
Perhaps this particular static analysis isn't too useful.
The opinions are still evolving for such a kind of search pattern.
Quoted 2 lines
Why not just allocate once and assign a second pointer?
Quoted 8 lines
Quoted 6 lines
local_rqfpr = kmalloc_array(2 * (MAX_FILER_IDX + 1), sizeof(unsigned int), GFP_KERNEL); if (!local_rqfpr) goto err; local_rqfcr = &local_rqfpr[MAX_FILER_IDX + 1];Do you suggest to use only one array (instead of two as before) here?
That's a possibility.
If, as your title suggests, you really want fewer function calls, (which as far as I saw, you didn't do) that could be a mechanism to remove both an allocation and a free.
--
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: gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection
Quoted 10 lines
Quoted 8 lines
Quoted 6 lines
local_rqfpr = kmalloc_array(2 * (MAX_FILER_IDX + 1), sizeof(unsigned int), GFP_KERNEL); if (!local_rqfpr) goto err; local_rqfcr = &local_rqfpr[MAX_FILER_IDX + 1];Do you suggest to use only one array (instead of two as before) here?
That's a possibility.
Thanks for your clarification.
Quoted 1 line
If, as your title suggests, you really want fewer function calls,
I am unsure at the moment if more changes will make sense in this function implementation.
Quoted 1 line
(which as far as I saw, you didn't do)
Is my wording "after error detection" insufficient eventually?
Quoted 1 line
that could be a mechanism to remove both an allocation and a free.
Would any more software developers or source code reviewers like to share their opinions in such a direction?
Regards,
Markus
Claudiu Manoil
maintainerRE: gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection
Quoted 32 lines
-----Original Message-----
From: SF Markus Elfring [mailto:[email protected]]
Sent: Friday, January 15, 2016 7:33 PM
To: Joe Perches <[email protected]>; [email protected]
Cc: Claudiu Manoil <[email protected]>; LKML <linux- [email protected]>; [email protected]; Julia Lawall <[email protected]>
Subject: Re: gianfar: Less function calls ingfar_ethflow_to_filer_table()after error detectionQuoted 10 lines
Quoted 8 lines
Quoted 6 lines
local_rqfpr = kmalloc_array(2 * (MAX_FILER_IDX + 1), sizeof(unsigned int), GFP_KERNEL); if (!local_rqfpr) goto err; local_rqfcr = &local_rqfpr[MAX_FILER_IDX + 1];Do you suggest to use only one array (instead of two as before) here?
That's a possibility.
Thanks for your clarification.
Quoted 1 line
If, as your title suggests, you really want fewer function calls,
I am unsure at the moment if more changes will make sense in this function implementation.
Quoted 1 line
(which as far as I saw, you didn't do)
Quoted 8 lines
Is my wording "after error detection" insufficient eventually?
Quoted 1 line
that could be a mechanism to remove both an allocation and a free.
Would any more software developers or source code reviewers like to share their opinions in such a direction?
Hi,
This kind of fixes are net-next stuff at best, no need to push them into the net tree right now.
So please wait with these submissions until net-next re-opens at least. Thanks.
PATCH v3 2/3 gianfar: Delete unnecessary variable initialisations in gfar_ethflow_to_filer_table()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 15 Jan 2016 10:40:24 +0100
Omit explicit initialisation at the beginning for four local variables which are redefined before their first use.
--- drivers/net/ethernet/freescale/gianfar_ethtool.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/freescale/gianfar_ethtool.c +3 -3
@@ -768,12 +768,12 @@ static void ethflow_to_filer_rules (struct gfar_private *priv, u64 ethflow)static int gfar_ethflow_to_filer_table (struct gfar_private *priv,u64 ethflow,u64 class) { -unsigned int last_rule_idx = priv->cur_filer_idx; +unsigned int last_rule_idx;unsigned int cmp_rqfpr;unsigned int *local_rqfpr;unsigned int *local_rqfcr; -int i =0x0 , k =0x0 ; -int j =MAX_FILER_IDX , l =0x0 ; +int i, k, l; +int j =MAX_FILER_IDX ;int ret =1 ; local_rqfpr = kmalloc_array(MAX_FILER_IDX + 1, sizeof(unsigned int),
Signature · 1 line
2.6.3
Re: [PATCH v3 2/3] gianfar: Delete unnecessary variable initialisations in gfar_ethflow_to_filer_table()
Quoted 16 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 15 Jan 2016 10:40:24 +0100Omit explicit initialisation at the beginning for four local variables which are redefined before their first use.
Signed-off-by Markus Elfring <[email protected]>--- drivers/net/ethernet/freescale/gianfar_ethtool.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/net/ethernet/freescale/gianfar_ethtool.c +0
-0
drivers/net/ethernet/freescale/gianfar_ethtool.c static void ethflow_to_filer_rules (struct gfar_private *priv, u64 ethflow) · line 771
Quoted 5 lines
drivers/net/ethernet/freescale/gianfar_ethtool.c +1
-1@@ -768,12 +768,12 @@ static void ethflow_to_filer_rules (struct gfar_private *priv, u64 ethflow)static int gfar_ethflow_to_filer_table (struct gfar_private *priv,u64 ethflow,u64 class) { -unsigned int last_rule_idx = priv->cur_filer_idx; +unsigned int last_rule_idx;
This is a write only variable. We can just remove it.
regards,
dan carpenter
Re: [PATCH v3 2/3] gianfar: Delete unnecessary variable initialisations in gfar_ethflow_to_filer_table()
Quoted 9 lines
drivers/net/ethernet/freescale/gianfar_ethtool.c static void ethflow_to_filer_rules (struct gfar_private *priv, u64 ethflow) · line 771
Quoted 7 lines
+++
b/drivers/net/ethernet/freescale/gianfar_ethtool.cdrivers/net/ethernet/freescale/gianfar_ethtool.c +1
-1@@ -768,12 +768,12 @@ static void ethflow_to_filer_rules (struct gfar_private *priv, u64 ethflow)static int gfar_ethflow_to_filer_table (struct gfar_private *priv,u64 ethflow,u64 class) { -unsigned int last_rule_idx = priv->cur_filer_idx; +unsigned int last_rule_idx;This is a write only variable. We can just remove it.
Can a static source code analysis tool like the software "http://smatch.sourceforge.net/" detect that such a variable is not read by this function implementation so far?
https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/drivers/net/ethernet/freescale/gianfar_ethtool.c?id·5ec3af27bf011a760e2f44eb25a99b6fbb0fb3#n850
Does this place indicate an unwanted value assignment as a leftover, or are there any other actions missing?
Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 2/3] gianfar: Delete unnecessary variable initialisations in gfar_ethflow_to_filer_table()
Quoted 10 lines · SF Markus Elfring
Quoted 9 lines
drivers/net/ethernet/freescale/gianfar_ethtool.c static void ethflow_to_filer_rules (struct gfar_private *priv, u64 ethflow) · line 771
Quoted 7 lines
+++
b/drivers/net/ethernet/freescale/gianfar_ethtool.cdrivers/net/ethernet/freescale/gianfar_ethtool.c +1
-1@@ -768,12 +768,12 @@ static void ethflow_to_filer_rules (struct gfar_private *priv, u64 ethflow)static int gfar_ethflow_to_filer_table (struct gfar_private *priv,u64 ethflow,u64 class) { -unsigned int last_rule_idx = priv->cur_filer_idx; +unsigned int last_rule_idx;This is a write only variable. We can just remove it.
Quoted 2 lines
Can a static source code analysis tool like the software "http://smatch.sourceforge.net/" detect that such a variable is not read by this function implementation so far?
Yeah. That's a good idea. I will do that.
Quoted 4 lines
Does this place indicate an unwanted value assignment as a leftover, or are there any other actions missing?
I think it's just an extra variable and you can just delete it.
regards,
dan carpenter
--
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
David Miller
maintainerRe: [PATCH v3 2/3] gianfar: Delete unnecessary variable initialisations in gfar_ethflow_to_filer_table()
In reply to SF Markus ElfringFrom: SF Markus Elfring <[email protected]>
Date: Fri, 15 Jan 2016 12:34:33 +0100
Quoted 10 lines
Quoted 9 lines
drivers/net/ethernet/freescale/gianfar_ethtool.c static void ethflow_to_filer_rules (struct gfar_private *priv, u64 ethflow) · line 771
Quoted 7 lines
+++
b/drivers/net/ethernet/freescale/gianfar_ethtool.cdrivers/net/ethernet/freescale/gianfar_ethtool.c +1
-1@@ -768,12 +768,12 @@ static void ethflow_to_filer_rules (struct gfar_private *priv, u64 ethflow)static int gfar_ethflow_to_filer_table (struct gfar_private *priv,u64 ethflow,u64 class) { -unsigned int last_rule_idx = priv->cur_filer_idx; +unsigned int last_rule_idx;This is a write only variable. We can just remove it.
Quoted 2 lines
Can a static source code analysis tool like the software "http://smatch.sourceforge.net/" detect that such a variable is not read by this function implementation so far?
No, but a human can.
And a human should fully analyze any change he writes based upon static analysis tool results.
I am going to be honest, and say that I am completely ignoring most of your static checker patches. You don't put enough care and consideration into them, and I really don't have time to waste on looking at something like that.
Re: gianfar: Delete unnecessary variable initialisations in gfar_ethflow_to_filer_table()
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
This is a write only variable. We can just remove it.
Can a static source code analysis tool like the software "http://smatch.sourceforge.net/" detect that such a variable is not read by this function implementation so far?
No,
I imagine that there are a few tools available which can point such update candidates out. There are various software development challenges to consider.
Quoted 1 line
but a human can.
Some software developers and source code reviewers are struggling with mentioned implementation details as usual. Do they also wonder how the discussed variable assignment was left over in a specific function?
Quoted 2 lines
I am going to be honest, and say that I am completely ignoring most of your static checker patches.
I am curious if you would reconsider the affected source code places once more when you will be notified about related issues by other tools or persons.
Quoted 1 line
You don't put enough care and consideration into them,
Would you like to explain this impression a bit more?
Quoted 1 line
and I really don't have time to waste on looking at something like that.
Thanks for your feedback.
Various open issues are competing for our attention as usual.
Regards,
Markus
PATCH v3 3/3 gianfar: Extend an initialisation clause of a for loop in gfar_ethflow_to_filer_table()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 15 Jan 2016 10:50:34 +0100
Move the assignment for the variable "j" from the beginning into an initialisation clause of a for loop.
--- drivers/net/ethernet/freescale/gianfar_ethtool.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/net/ethernet/freescale/gianfar_ethtool.c +2 -3
@@ -772,8 +772,7 @@ static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow,unsigned int cmp_rqfpr;unsigned int *local_rqfpr;unsigned int *local_rqfcr; -int i, k, l; -int j =MAX_FILER_IDX ; +int i, j, k, l;int ret =1 ; local_rqfpr = kmalloc_array(MAX_FILER_IDX + 1, sizeof(unsigned int),
@@ -807,7 +806,7 @@ static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow, goto free_fcr; } -for (i =0 ; i <MAX_FILER_IDX +1 ; i++) { +for (i =0 , j =MAX_FILER_IDX ; i <MAX_FILER_IDX +1 ; i++) { local_rqfpr[j] = priv->ftp_rqfpr[i]; local_rqfcr[j] = priv->ftp_rqfcr[i]; j--;
Signature · 1 line
2.6.3
PATCH 1/1 net-i40e: Replace variable initialisations by assignments in i40e_vc_get_vf_resources_msg()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 1 Jan 2016 15:11:09 +0100
Replace explicit initialisations for four local variables at the beginning by assignments that will only be performed if the corresponding code will really be executed.
--- drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +9 -6
@@ -1172,16 +1172,18 @@ static int i40e_vc_get_version_msg(struct i40e_vf *vf, u8 *msg)**/ static int i40e_vc_get_vf_resources_msg (struct i40e_vf *vf,u8 *msg) { -struct i40e_virtchnl_vf_resource *vfres =NULL ; -struct i40e_pf *pf = vf->pf; -i40e_status aq_ret =0 ; +struct i40e_virtchnl_vf_resource *vfres; +struct i40e_pf *pf; +i40e_status aq_ret;struct i40e_vsi *vsi; -int i =0 , len =0 ; +int i =0 ;int num_vsis =1 ; -int ret; +int len, ret;if (!test_bit (I40E_VF_STAT_INIT , &vf->vf_states)) { aq_ret =I40E_ERR_PARAM ; + vfres =NULL ; + len =0 ; goto err; }
@@ -1202,6 +1204,7 @@ static int i40e_vc_get_vf_resources_msg(struct i40e_vf *vf, u8 *msg)I40E_VIRTCHNL_VF_OFFLOAD_VLAN ; vfres->vf_offload_flags =I40E_VIRTCHNL_VF_OFFLOAD_L2 ; + pf = vf->pf; vsi = pf->vsi[vf->lan_vsi_idx];if (!vsi->info.pvid) vfres->vf_offload_flags |=I40E_VIRTCHNL_VF_OFFLOAD_VLAN ;
@@ -1231,7 +1234,7 @@ static int i40e_vc_get_vf_resources_msg(struct i40e_vf *vf, u8 *msg) i++; }set_bit (I40E_VF_STAT_ACTIVE , &vf->vf_states); - + aq_ret =0 ; err:/* send the response back to the VF */ ret = i40e_vc_send_msg_to_vf(vf, I40E_VIRTCHNL_OP_GET_VF_RESOURCES,
Signature · 1 line
2.6.3
net-i40e: Reconsider further usage of variable "i" in i40e_vc_get_vf_resources_msg()
Hello,
I have taken another look at the implementation of the
function "i40e_vc_get_vf_resources_msg". I find the use of the variable "i" strange there. It seems that the value from the increment operation in an if branch is not reused so far.
I would appreciate a further clarification.
Can this variable be eventually deleted?
Regards,
Markus
RE: net-i40e: Reconsider further usage of variable "i" in i40e_vc_get_vf_resources_msg()
Quoted 11 lines
From: SF Markus Elfring [mailto:elfring at users.sourceforge.net]
Hello,
I have taken another look at the implementation of the function "
i40e_vc_get_vf_resources_msg". I find the use of the variable "i"
strange there. It seems that the value from the increment operation in an
if branch is not reused so far.
Quoted 2 lines
I would appreciate a further clarification.
Can this variable be eventually deleted?
Thanks for pointing this out. We've got an internal patch coming that will address this.
Cheers,
sln
RE: [PATCH] net-i40e: Replace variable initialisations by assignments in i40e_vc_get_vf_resources_msg()
In reply to SF Markus ElfringQuoted 6 lines
From: SF Markus Elfring [mailto:elfring at users.sourceforge.net]
Sent: Friday, January 01, 2016 6:33 AMFrom: Markus Elfring <[email protected]>
Date: Fri, 1 Jan 2016 15:11:09 +0100
Quoted 6 lines
Replace explicit initialisations for four local variables at the beginning by assignments that will only be performed if the corresponding code will really be executed.
Signed-off-by Markus Elfring <[email protected]>---
This seems to me to be unnecessary fussing with the code.
sln
Re: [PATCH] net-i40e: Replace variable initialisations by assignments in i40e_vc_get_vf_resources_msg()
In reply to SF Markus ElfringQuoted 8 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 1 Jan 2016 15:11:09 +0100Replace explicit initialisations for four local variables at the beginning
by assignments that will only be performed if the corresponding code will really be executed.
Quoted 5 lines
Signed-off-by Markus Elfring <[email protected]>---
?drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 15 +++++++++---
---
?1 file changed, 9 insertions(+), 6 deletions(-)
Dropping this patch based on feedback from Shannon.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://lists.osuosl.org/pipermail/intel-wired-lan/attachments/20160108/d5613803/attachment.asc>
PATCH 1/1 net-huawei_cdc_ncm: Delete an unnecessary variable initialisation in huawei_cdc_ncm_bind()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 1 Jan 2016 16:54:13 +0100
Omit explicit initialisation at the beginning for one local variable that is redefined before its first use.
--- drivers/net/usb/huawei_cdc_ncm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/usb/huawei_cdc_ncm.c +1 -1
@@ -71,7 +71,7 @@ static int huawei_cdc_ncm_bind(struct usbnet *usbnet_dev, {struct cdc_ncm_ctx *ctx;struct usb_driver *subdriver =ERR_PTR (-ENODEV ); -int ret = -ENODEV ; +int ret;struct huawei_cdc_ncm_state *drvstate = (void *)&usbnet_dev->data;int drvflags =0 ;
Signature · 1 line
2.6.3
cover net-qmi_wwan: Fine-tuning for two function implementations
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 1 Jan 2016 17:47:46 +0100
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (2):
Refactoring for qmi_wwan_bind()
Delete an unnecessary variable initialisation in qmi_wwan_register_subdriver()
drivers/net/usb/qmi_wwan.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
Signature · 1 line
2.6.3
PATCH 1/2 net-qmi_wwan: Refactoring for qmi_wwan_bind()
From: Markus Elfring <[email protected]>
Date: Fri, 1 Jan 2016 17:32:07 +0100
Reduce the scope for the local variable "desc" to one branch of an if statement.
--- drivers/net/usb/qmi_wwan.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/usb/qmi_wwan.c +2 -1
@@ -345,7 +345,6 @@ static int qmi_wwan_bind(struct usbnet *dev, struct usb_interface *intf)int status =-1 ;u8 *buf = intf->cur_altsetting->extra;int len = intf->cur_altsetting->extralen; -struct usb_interface_descriptor *desc = &intf->cur_altsetting->desc;struct usb_cdc_union_desc *cdc_union;struct usb_cdc_ether_desc *cdc_ether;struct usb_driver *driver =driver_of (intf);
@@ -366,6 +365,8 @@ static int qmi_wwan_bind(struct usbnet *dev, struct usb_interface *intf)/* Use separate control and data interfaces if we found a CDC Union */ if (cdc_union) { +struct usb_interface_descriptor *desc = &intf->cur_altsetting->desc; + info->data =usb_ifnum_to_if (dev->udev, cdc_union->bSlaveInterface0); if (desc->bInterfaceNumber != cdc_union->bMasterInterface0 ||
Signature · 1 line
2.6.3
Bjørn Mork
maintainerRe: [PATCH 1/2] net-qmi_wwan: Refactoring for qmi_wwan_bind()
Quoted 5 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 1 Jan 2016 17:32:07 +0100Reduce the scope for the local variable "desc" to one branch of an if statement.
This patch is harmless. But is also pointless.
You could at least try to explain why this must be changed. I'm not interested in why you think it is better this way - I might agree with that. what I am interested in is the advantage changing the code gives us. Some analysis of the risk and work involved would also be nice. Is this change really worth it?
Personally I am convinced that I wasted any time I used writing this, and you wasted any time you used reading it. Sorry.
Note: This patch would have been fine if it was a natural part of some *improvement* of the driver, i.e. a bugfix or feaure addition. As a standalone patch I see it as noise.
Please stop the noise and start writing something useful. I'm sure you can fix bugs instead. Wouldn't that be more interesting? More challenging? These mindless robotic code refactoring patches are really best left for robots.
Bjørn
--
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 2/2 net-qmi_wwan: Delete an unnecessary variable initialisation in qmi_wwan_register_subdriver()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 1 Jan 2016 17:35:03 +0100
Omit explicit initialisation at the beginning for one local variable that is redefined before its first use.
--- drivers/net/usb/qmi_wwan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/usb/qmi_wwan.c +1 -1
@@ -286,7 +286,7 @@ static int qmi_wwan_cdc_wdm_manage_power(struct usb_interface *intf, int on)static int qmi_wwan_register_subdriver (struct usbnet *dev) {int rv; -struct usb_driver *subdriver =NULL ; +struct usb_driver *subdriver;struct qmi_wwan_state *info = (void *)&dev->data;/* collect bulk endpoints */
Signature · 1 line
2.6.3
Bjørn Mork
maintainerRe: [PATCH 2/2] net-qmi_wwan: Delete an unnecessary variable initialisation in qmi_wwan_register_subdriver()
Quoted 5 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 1 Jan 2016 17:35:03 +0100Omit explicit initialisation at the beginning for one local variable that is redefined before its first use.
This patch is unnecessary. The variable initialisation is redundant. See the difference? Sending an unnecessary patch causes unnecessary load on reviewers and maintainers. Keeping redundant code has no measurable cost, and can save the same maintainers a lot of trouble later.
I'd like to keep this particular redundant initialisation as a safe guard against future code refactoring, causing for example the err label to move up. Yes, I do understand that any patch with such a bug should be rejected, but I do know what happens in the real world and how easy it is for something like that to slip through in a stream of unnecessary "cleanup" patches.
Reducing redundancy in the kernel is only making the code less robust. It is harmful. Please stop. Thanks.
Bjørn
--
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
David Miller
maintainerRe: [PATCH 2/2] net-qmi_wwan: Delete an unnecessary variable initialisation in qmi_wwan_register_subdriver()
From: Bjørn Mork <[email protected]>
Date: Sat, 02 Jan 2016 22:30:48 +0100
Quoted 9 lines
Quoted 5 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 1 Jan 2016 17:35:03 +0100Omit explicit initialisation at the beginning for one local variable that is redefined before its first use.
Quoted 5 lines
This patch is unnecessary. The variable initialisation is redundant. See the difference? Sending an unnecessary patch causes unnecessary load on reviewers and maintainers. Keeping redundant code has no measurable cost, and can save the same maintainers a lot of trouble later.
+1
I'm getting really tired of these changes. And a lot of them are coming in right now...
--
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
cover net-ath9k_htc: Fine-tuning for two function implementations
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 1 Jan 2016 19:16:05 +0100
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (2):
Delete an unnecessary variable initialisation in ath9k_hif_usb_rx_stream() Replace a variable initialisation by an assignment in ath9k_htc_set_channel()
drivers/net/wireless/ath/ath9k/hif_usb.c | 2 +- drivers/net/wireless/ath/ath9k/htc_drv_main.c | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-)
Signature · 1 line
2.6.3
PATCH 1/2 net-ath9k_htc: Delete an unnecessary variable initialisation in ath9k_hif_usb_rx_stream()
From: Markus Elfring <[email protected]>
Date: Fri, 1 Jan 2016 19:00:53 +0100
Omit explicit initialisation at the beginning for one local variable that is redefined before its first use.
--- drivers/net/wireless/ath/ath9k/hif_usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath9k/hif_usb.c +1 -1
@@ -525,7 +525,7 @@ static void ath9k_hif_usb_rx_stream(struct hif_device_usb *hif_dev, struct sk_buff *skb) {struct sk_buff *nskb, *skb_pool[MAX_PKT_NUM_IN_TRANSFER ]; -int index =0 , i =0 , len = skb->len; +int index =0 , i, len = skb->len;int rx_remain_len, rx_pkt_len;u16 pool_index =0 ;u8 *ptr;
Signature · 1 line
2.6.3
Re: [PATCH 1/2] net-ath9k_htc: Delete an unnecessary variable initialisation in ath9k_hif_usb_rx_stream()
Am 01.01.2016 um 19:23 schrieb SF Markus Elfring:
Quoted 17 lines
From: Markus Elfring <[email protected]>
Date: Fri, 1 Jan 2016 19:00:53 +0100Omit explicit initialisation at the beginning for one local variable that is redefined before its first use.
Signed-off-by Markus Elfring <[email protected]>--- drivers/net/wireless/ath/ath9k/hif_usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/wireless/ath/ath9k/hif_usb.c +0
-0
drivers/net/wireless/ath/ath9k/hif_usb.c static void ath9k_hif_usb_rx_stream(struct hif_device_usb *hif_dev, · line 531
Quoted 8 lines
drivers/net/wireless/ath/ath9k/hif_usb.c +1
-1@@ -525,7 +525,7 @@ static void ath9k_hif_usb_rx_stream(struct hif_device_usb *hif_dev, struct sk_buff *skb) {struct sk_buff *nskb, *skb_pool[MAX_PKT_NUM_IN_TRANSFER ]; -int index =0 , i =0 , len = skb->len; +int index =0 , i, len = skb->len;int rx_remain_len, rx_pkt_len;u16 pool_index =0 ;u8 *ptr;
Signature · 10 lines
Regards, Oleksij -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 213 bytes Desc: OpenPGP digital signature Url : http://lists.ath9k.org/pipermail/ath9k-devel/attachments/20160101/9f7764b8/attachment.pgp
PATCH 2/2 net-ath9k_htc: Replace a variable initialisation by an assignment in ath9k_htc_set_channel()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 1 Jan 2016 19:09:32 +0100
Replace an explicit initialisation for one local variable at the beginning by a conditional assignment.
--- drivers/net/wireless/ath/ath9k/htc_drv_main.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/net/wireless/ath/ath9k/htc_drv_main.c +2 -5
@@ -246,7 +246,7 @@ static int ath9k_htc_set_channel(struct ath9k_htc_priv *priv,struct ieee80211_conf *conf = &common->hw->conf;bool fastcc;struct ieee80211_channel *channel = hw->conf.chandef.chan; -struct ath9k_hw_cal_data *caldata =NULL ; +struct ath9k_hw_cal_data *caldata;enum htc_phymode mode;__be16 htc_mode;u8 cmd_rsp;
@@ -274,10 +274,7 @@ static int ath9k_htc_set_channel(struct ath9k_htc_priv *priv, priv->ah->curchan->channel, channel->center_freq,conf_is_ht (conf),conf_is_ht40 (conf), fastcc); - -if (!fastcc) - caldata = &priv->caldata; - + caldata = fastcc ?NULL : &priv->caldata; ret =ath9k_hw_reset (ah, hchan, caldata, fastcc);if (ret) { ath_err(common,
Signature · 1 line
2.6.3
Re: [PATCH 2/2] net-ath9k_htc: Replace a variable initialisation by an assignment in ath9k_htc_set_channel()
Am 01.01.2016 um 19:25 schrieb SF Markus Elfring:
Quoted 27 lines
From: Markus Elfring <[email protected]>
Date: Fri, 1 Jan 2016 19:09:32 +0100Replace an explicit initialisation for one local variable at the beginning by a conditional assignment.
Signed-off-by Markus Elfring <[email protected]>--- drivers/net/wireless/ath/ath9k/htc_drv_main.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)drivers/net/wireless/ath/ath9k/htc_drv_main.c +1
-1@@ -246,7 +246,7 @@ static int ath9k_htc_set_channel(struct ath9k_htc_priv *priv,struct ieee80211_conf *conf = &common->hw->conf;bool fastcc;struct ieee80211_channel *channel = hw->conf.chandef.chan; -struct ath9k_hw_cal_data *caldata =NULL ; +struct ath9k_hw_cal_data *caldata;enum htc_phymode mode;__be16 htc_mode;u8 cmd_rsp;@@ -274,10 +274,7 @@ static int ath9k_htc_set_channel(struct ath9k_htc_priv *priv, priv->ah->curchan->channel,
drivers/net/wireless/ath/ath9k/htc_drv_main.c static int ath9k_htc_set_channel(struct ath9k_htc_priv *priv, · line 280
Quoted 10 lines
drivers/net/wireless/ath/ath9k/htc_drv_main.c +1
-4channel->center_freq,conf_is_ht (conf),conf_is_ht40 (conf), fastcc); - -if (!fastcc) - caldata = &priv->caldata; - + caldata = fastcc ?NULL : &priv->caldata; ret =ath9k_hw_reset (ah, hchan, caldata, fastcc);if (ret) { ath_err(common,
Signature · 10 lines
Regards, Oleksij -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 213 bytes Desc: OpenPGP digital signature Url : http://lists.ath9k.org/pipermail/ath9k-devel/attachments/20160101/a7f6d86e/attachment.pgp
Re: [PATCH 2/2] net-ath9k_htc: Replace a variable initialisation by an assignment in ath9k_htc_set_channel()
In reply to SF Markus ElfringHi Kalle,
Quoted 7 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 1 Jan 2016 19:09:32 +0100Replace an explicit initialisation for one local variable at the beginning by a conditional assignment.
Signed-off-by Markus Elfring <[email protected]>
This looks sane to me.
Thanks,
Julian Calaby
Quoted 36 lines
--- drivers/net/wireless/ath/ath9k/htc_drv_main.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)drivers/net/wireless/ath/ath9k/htc_drv_main.c +2
-6@@ -246,7 +246,7 @@ static int ath9k_htc_set_channel(struct ath9k_htc_priv *priv,struct ieee80211_conf *conf = &common->hw->conf;bool fastcc;struct ieee80211_channel *channel = hw->conf.chandef.chan; -struct ath9k_hw_cal_data *caldata =NULL ; +struct ath9k_hw_cal_data *caldata;enum htc_phymode mode;__be16 htc_mode;u8 cmd_rsp;@@ -274,10 +274,7 @@ static int ath9k_htc_set_channel(struct ath9k_htc_priv *priv, priv->ah->curchan->channel, channel->center_freq,conf_is_ht (conf),conf_is_ht40 (conf), fastcc); - -if (!fastcc) - caldata = &priv->caldata; - + caldata = fastcc ?NULL : &priv->caldata; ret =ath9k_hw_reset (ah, hchan, caldata, fastcc);if (ret) { ath_err(common, --2.6.3
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 4 lines
Julian Calaby Email: julian.calaby at gmail.com Profile: http://www.google.com/profiles/julian.calaby/
Re: [PATCH 2/2] net-ath9k_htc: Replace a variable initialisation by an assignment in ath9k_htc_set_channel()
Quoted 7 lines · Julian Calaby
Hi Kalle,
Quoted 3 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 1 Jan 2016 19:09:32 +0100
Quoted 8 lines
Quoted 4 lines
Replace an explicit initialisation for one local variable at the beginning by a conditional assignment.
Signed-off-by Markus Elfring <[email protected]>This looks sane to me.
Reviewed-by Julian Calaby <[email protected]>
Before I commit I'll just change the commit title to:
ath9k_htc: Replace a variable initialisation by an assignment in ath9k_htc_set_channel()
Signature · 1 line
Kalle Valo
Re: [PATCH 2/2] net-ath9k_htc: Replace a variable initialisation by an assignment in ath9k_htc_set_channel()
Hi Kalle,
Quoted 14 lines · Kalle Valo
Quoted 12 lines · Julian Calaby
Hi Kalle,
Quoted 7 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 1 Jan 2016 19:09:32 +0100Replace an explicit initialisation for one local variable at the beginning by a conditional assignment.
Signed-off-by Markus Elfring <[email protected]>
Quoted 7 lines
Quoted 3 lines
This looks sane to me.
Reviewed-by Julian Calaby <[email protected]>Before I commit I'll just change the commit title to:
ath9k_htc: Replace a variable initialisation by an assignment inath9k_htc_set_channel()
Sounds good to me.
Thanks,
Signature · 4 lines
Julian Calaby Email: julian.calaby at gmail.com Profile: http://www.google.com/profiles/julian.calaby/
Kalle Valo
AppliedRe: [PATCH 2/2] net-ath9k_htc: Replace a variable initialisation by an assignment in ath9k_htc_set_channel()
In reply to Julian CalabyQuoted 5 lines · Julian Calaby
Quoted 3 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 1 Jan 2016 19:09:32 +0100
Quoted 8 lines
Quoted 4 lines
Replace an explicit initialisation for one local variable at the beginning by a conditional assignment.
Signed-off-by Markus Elfring <[email protected]>This looks sane to me.
Reviewed-by Julian Calaby <[email protected]>
Applied, thanks.
Signature · 1 line
Kalle Valo
PATCH 1/1 net-brcmfmac: Delete an unnecessary variable initialisation in brcmf_sdio_download_firmware()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 1 Jan 2016 20:20:15 +0100
Omit explicit initialisation at the beginning for one local variable that is redefined before its first use.
--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c +1 -1
@@ -3260,7 +3260,7 @@ static int brcmf_sdio_download_firmware(struct brcmf_sdio *bus,const struct firmware *fw, void *nvram, u32 nvlen) { - int bcmerror = -EFAULT; + int bcmerror;u32 rstvec;sdio_claim_host (bus->sdiodev->func[1 ]);
Signature · 1 line
2.6.3
Re: [PATCH] net-brcmfmac: Delete an unnecessary variable initialisation in brcmf_sdio_download_firmware()
Quoted 2 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 1 Jan 2016 20:20:15 +0100
I think it has been said over and over, but please use driver name only as prefix. I don't see value to prepend it with 'net-'.
Quoted 3 lines
Omit explicit initialisation at the beginning for one local variable that is redefined before its first use.
That being said here is my....
Quoted 19 lines
Signed-off-by Markus Elfring <[email protected]>--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c +1
-1@@ -3260,7 +3260,7 @@ static int brcmf_sdio_download_firmware(struct brcmf_sdio *bus,const struct firmware *fw, void *nvram, u32 nvlen) { - int bcmerror = -EFAULT; + int bcmerror;u32 rstvec;sdio_claim_host (bus->sdiodev->func[1 ]);
Re: [PATCH] net-brcmfmac: Delete an unnecessary variable initialisation in brcmf_sdio_download_firmware()
Quoted 6 lines · Arend van Spriel
Quoted 2 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 1 Jan 2016 20:20:15 +0100I think it has been said over and over, but please use driver name only as prefix. I don't see value to prepend it with 'net-'.
Yes, please use existing naming schemes. This time I can fix it before I commit the patch, but in the future please use correct prefixes. It's easy to check what has been used previously:
$ git log --oneline --no-merges --follow drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c | head -10 63ce3d5db093 brcmfmac: use msecs_to_jiffies() in macro definitions 4011fc499690 brcmfmac: change brcmf_sdio_wd_timer() prototype a7decc44a002 brcmfmac: fix waitqueue_active without memory barrier in brcmfmac driver 46d703a77539 brcmfmac: Unify methods to define and map firmware files. 64d66c30c37e brcmfmac: no retries on rxglom superframe errors 6866a64a0f9b brcmfmac: constify brcmf_bus_ops structures 05491d2ccf20 brcm80211: move under broadcom vendor directory ff4445a8502c brcmfmac: expose device memory to devcoredump subsystem a32be0177252 brcmfmac: include linux/atomic.h 9d6c1dc4f913 brcmfmac: add dedicated debug level for firmware console logging $
Signature · 1 line
Kalle Valo
cover net-iwlegacy: Fine-tuning for il_eeprom_init()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 1 Jan 2016 21:25:43 +0100
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (3):
Refactoring
One check less after error detection
Another refactoring
drivers/net/wireless/intel/iwlegacy/common.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
Signature · 1 line
2.6.3
PATCH 1/3 net-iwlegacy: Refactoring for il_eeprom_init()
From: Markus Elfring <[email protected]>
Date: Fri, 1 Jan 2016 20:54:25 +0100
Return directly if a memory allocation failed at the beginning.
--- drivers/net/wireless/intel/iwlegacy/common.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/net/wireless/intel/iwlegacy/common.c +3 -5
@@ -723,10 +723,9 @@ il_eeprom_init(struct il_priv *il) sz = il->cfg->eeprom_size;D_EEPROM ("NVM size = %d\n" , sz); il->eeprom =kzalloc (sz,GFP_KERNEL ); -if (!il->eeprom) { - ret = -ENOMEM ; - goto alloc_err; - } +if (!il->eeprom) +return -ENOMEM ; + e = (__le16 *) il->eeprom; il->ops->apm_init (il);
@@ -778,7 +777,6 @@ err:il_eeprom_free (il);/* Reset chip to save power until we load uCode during "up". */ il_apm_stop (il); -alloc_err:return ret; }EXPORT_SYMBOL (il_eeprom_init);
Signature · 1 line
2.6.3
Re: [PATCH 1/3] net-iwlegacy: Refactoring for il_eeprom_init()
Quoted 6 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 1 Jan 2016 20:54:25 +0100Return directly if a memory allocation failed at the beginning.
Signed-off-by Markus Elfring <[email protected]>
PATCH 2/3 net-iwlegacy: One check less in il_eeprom_init() after error detection
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 1 Jan 2016 21:12:29 +0100
This issue was detected by using the Coccinelle software.
Adjust a jump target to avoid a check repetition before the function call "il_eeprom_free".
--- drivers/net/wireless/intel/iwlegacy/common.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/net/wireless/intel/iwlegacy/common.c +6 -4
@@ -734,7 +734,7 @@ il_eeprom_init(struct il_priv *il)if (ret <0 ) {IL_ERR ("EEPROM not found, EEPROM_GP=0x%08x\n" , gp); ret = -ENOENT ; - goto err; + goto free_eeprom; }/* Make sure driver (instead of uCode) is allowed to read EEPROM */
@@ -742,7 +742,7 @@ il_eeprom_init(struct il_priv *il)if (ret <0 ) {IL_ERR ("Failed to acquire EEPROM semaphore.\n" ); ret = -ENOENT ; - goto err; + goto free_eeprom; }/* eeprom is an array of 16bit values */
@@ -772,9 +772,11 @@ il_eeprom_init(struct il_priv *il) done: il->ops->eeprom_release_semaphore (il); -err: -if (ret) +if (ret) { +free_eeprom:il_eeprom_free (il); + } +/* Reset chip to save power until we load uCode during "up". */ il_apm_stop (il);return ret;
Signature · 1 line
2.6.3
Re: [PATCH 2/3] net-iwlegacy: One check less in il_eeprom_init() after error detection
Hello.
Quoted 7 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 1 Jan 2016 21:12:29 +0100This issue was detected by using the Coccinelle software.
Adjust a jump target to avoid a check repetition before the function call "
il_eeprom_free".
One question: why?
Quoted 10 lines
Signed-off-by Markus Elfring <[email protected]>--- drivers/net/wireless/intel/iwlegacy/common.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)drivers/net/wireless/intel/iwlegacy/common.c +0
-0
[...]
drivers/net/wireless/intel/iwlegacy/common.c il_eeprom_init(struct il_priv *il) · line 776
Quoted 8 lines
drivers/net/wireless/intel/iwlegacy/common.c +2
-2@@ -772,9 +772,11 @@ il_eeprom_init(struct il_priv *il) done: il->ops->eeprom_release_semaphore (il); -err: -if (ret) +if (ret) { +free_eeprom:
This is ugly, I'd say.
[...]
MBR, Sergei
PATCH 3/3 net-iwlegacy: Another refactoring for il_eeprom_init()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 1 Jan 2016 21:16:01 +0100
Rename a jump label according to the current Linux coding style convention.
--- drivers/net/wireless/intel/iwlegacy/common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/intel/iwlegacy/common.c +2 -2
@@ -759,7 +759,7 @@ il_eeprom_init(struct il_priv *il) IL_EEPROM_ACCESS_TIMEOUT);if (ret <0 ) {IL_ERR ("Time out reading EEPROM[%d]\n" , addr); - goto done; + goto release_semaphore; } r =_il_rd (il,CSR_EEPROM_REG ); e[addr /2 ] =cpu_to_le16 (r >>16 );
@@ -769,7 +769,7 @@ il_eeprom_init(struct il_priv *il) il_eeprom_query16(il, EEPROM_VERSION)); ret =0 ; -done: +release_semaphore: il->ops->eeprom_release_semaphore (il);if (ret) {
Signature · 1 line
2.6.3
Re: [PATCH 3/3] net-iwlegacy: Another refactoring for il_eeprom_init()
Quoted 15 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 1 Jan 2016 21:16:01 +0100Rename a jump label according to the current Linux coding style convention.
Signed-off-by Markus Elfring <[email protected]>--- drivers/net/wireless/intel/iwlegacy/common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/net/wireless/intel/iwlegacy/common.c +0
-0
drivers/net/wireless/intel/iwlegacy/common.c il_eeprom_init(struct il_priv *il) · line 762
Quoted 5 lines
drivers/net/wireless/intel/iwlegacy/common.c +1
-1@@ -759,7 +759,7 @@ il_eeprom_init(struct il_priv *il) IL_EEPROM_ACCESS_TIMEOUT);if (ret <0 ) {IL_ERR ("Time out reading EEPROM[%d]\n" , addr); - goto done; + goto release_semaphore;
Current code looks good.
Quoted 15 lines
drivers/net/wireless/intel/iwlegacy/common.c +1
-2} r =_il_rd (il,CSR_EEPROM_REG ); e[addr /2 ] =cpu_to_le16 (r >>16 );@@ -769,7 +769,7 @@ il_eeprom_init(struct il_priv *il) il_eeprom_query16(il, EEPROM_VERSION)); ret =0 ; -done: +release_semaphore: il->ops->eeprom_release_semaphore (il);if (ret) { --2.6.3
Quoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
-Souptick
PATCH 1/1 net-libertas: Better exception handling in if_spi_host_to_card_worker()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 1 Jan 2016 22:27:20 +0100
This issue was detected by using the Coccinelle software.
Move the jump label directly before the desired log statement so that the variable "err" will not be checked once more after it was determined that a function call failed. Use the identifier "report_failure" instead of the label "err".
--- drivers/net/wireless/marvell/libertas/if_spi.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/net/wireless/marvell/libertas/if_spi.c +6 -5
@@ -880,18 +880,18 @@ static void if_spi_host_to_card_worker(struct work_struct *work) &hiStatus);if (err) {netdev_err (priv->dev,"I/O error\n" ); - goto err; + goto report_failure; }if (hiStatus &IF_SPI_HIST_CMD_UPLOAD_RDY ) { err =if_spi_c2h_cmd (card);if (err) - goto err; + goto report_failure; }if (hiStatus &IF_SPI_HIST_RX_UPLOAD_RDY ) { err =if_spi_c2h_data (card);if (err) - goto err; + goto report_failure; }/*
@@ -940,9 +940,10 @@ static void if_spi_host_to_card_worker(struct work_struct *work)if (hiStatus &IF_SPI_HIST_CARD_EVENT )if_spi_e2h (card); -err: -if (err) +if (err) { +report_failure:netdev_err (priv->dev,"%s: got error %d\n" , __func__, err); + }lbs_deb_leave (LBS_DEB_SPI ); }
Signature · 1 line
2.6.3
Re: [PATCH] net-libertas: Better exception handling in if_spi_host_to_card_worker()
Quoted 8 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 1 Jan 2016 22:27:20 +0100This issue was detected by using the Coccinelle software.
Move the jump label directly before the desired log statement so that the variable "err" will not be checked once more after it was determined that a function call failed.
Putting a label inside an if is ugly.
julia
Quoted 54 lines
Use the identifier "
report_failure" instead of the label "err".Signed-off-by Markus Elfring <[email protected]>--- drivers/net/wireless/marvell/libertas/if_spi.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)drivers/net/wireless/marvell/libertas/if_spi.c +6
-5@@ -880,18 +880,18 @@ static void if_spi_host_to_card_worker(struct work_struct *work) &hiStatus);if (err) {netdev_err (priv->dev,"I/O error\n" ); - goto err; + goto report_failure; }if (hiStatus &IF_SPI_HIST_CMD_UPLOAD_RDY ) { err =if_spi_c2h_cmd (card);if (err) - goto err; + goto report_failure; }if (hiStatus &IF_SPI_HIST_RX_UPLOAD_RDY ) { err =if_spi_c2h_data (card);if (err) - goto err; + goto report_failure; }/* @@ -940,9 +940,10 @@ static void if_spi_host_to_card_worker(struct work_struct *work)if (hiStatus &IF_SPI_HIST_CARD_EVENT )if_spi_e2h (card); -err: -if (err) +if (err) { +report_failure:netdev_err (priv->dev,"%s: got error %d\n" , __func__, err); + }lbs_deb_leave (LBS_DEB_SPI ); }Signature · 6 lines
2.6.3 -- 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] net-libertas: Better exception handling in if_spi_host_to_card_worker()
In reply to SF Markus ElfringHello
Quoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 1 Jan 2016 22:27:20 +0100This issue was detected by using the Coccinelle software.
Move the jump label directly before the desired log statement so that the variable "err" will not be checked once more after it was determined that a function call failed. Use the identifier "
report_failure" instead of the label "err".
Why? The code was smart enough and you're making it uglier that it needs
to be.
Quoted 1 line
Signed-off-by Markus Elfring <[email protected]>
MBR, Sergei
Re: [PATCH] net-libertas: Better exception handling in if_spi_host_to_card_worker()
Quoted 6 lines
Quoted 4 lines
Move the jump label directly before the desired log statement so that the variable "err" will not be checked once more after it was determined that a function call failed. Use the identifier "
report_failure" instead of the label "err".Why?
I suggest to reconsider the places with which such a jump label is connected.
Quoted 1 line
The code was smart enough
Which action should really be performed after a failure was detected and handled a bit already?
* Another condition check
* Just additional error logging
Quoted 1 line
and you're making it uglier that it needs to be.
I assume that a software development taste can evolve, can't it?
Regards,
Markus
Re: [PATCH] net-libertas: Better exception handling in if_spi_host_to_card_worker()
Quoted 16 lines · SF Markus Elfring
Quoted 6 lines
Quoted 4 lines
Move the jump label directly before the desired log statement so that the variable "err" will not be checked once more after it was determined that a function call failed. Use the identifier "
report_failure" instead of the label "err".Why?
I suggest to reconsider the places with which such a jump label is connected.
Quoted 1 line
The code was smart enough
Which action should really be performed after a failure was detected and handled a bit already?
Quoted 8 lines
* Another condition check
* Just additional error logging
Quoted 1 line
and you're making it uglier that it needs to be.
I assume that a software development taste can evolve, can't it?
So far, you have gotten several down votes for this kind of change, and no enthusiasm.
Admittedly, this is a trivial case, because there are no local variables, but do you actually know the semantics in C of a jump into a block? And if you do know, do you think that this semantics is common knowledge? And do you really think that introducing poorly understandable code is really worth saving an if test of a single variable on a non-critical path?
Most of the kernel code is not performance critical at the level of a single if test. So the goal should be for the code to be easy to understand and robust to change. The code that is performance critical, you should probably not touch, ever. The people who wrote it knew what was important and what was not.
julia
Re: net-libertas: Better exception handling in if_spi_host_to_card_worker()
Quoted 3 lines
Quoted 1 line
I assume that a software development taste can evolve, can't it?
So far, you have gotten several down votes for this kind of change,
I am curious when more contributors will share corresponding opinions.
Quoted 1 line
and no enthusiasm.
How many software designers and developers can become enthusiastic about better exception handling to some degree?
Quoted 1 line
The code that is performance critical, you should probably not touch, ever.
I imagine that technical evolution will result in further considerations so that "unchangeable" components can be adjusted once more.
Quoted 1 line
The people who wrote it knew what was important and what was not.
I might come along at some places where the affected knowledge will also evolve.
Regards,
Markus
Re: net-libertas: Better exception handling in if_spi_host_to_card_worker()
Quoted 5 lines · SF Markus Elfring
Quoted 3 lines
Quoted 1 line
I assume that a software development taste can evolve, can't it?
So far, you have gotten several down votes for this kind of change,
I am curious when more contributors will share corresponding opinions.
Let's burn some cycles on this while the holidays give me time to do so. "software development taste" is another term for "coding style". In every project battles are fought over this between friends and foes. I have never seen much evolution going on in this area.
Quoted 4 lines
Quoted 1 line
and no enthusiasm.
How many software designers and developers can become enthusiastic about better exception handling to some degree?
I had to take a look at this particular patch and I have to say that I don't see, using your favorite term, evolution at work. It looks more like the result of inbred. What the patch tries to do is avoid the extra 'if (err)'. Setting coding style aside, the question is whether there is a good metric for the patch. So does it really safe processing time? Did you look at the resulting assembly code for different target architectures?
You got pushed back on the change so you have to come up with solid arguments for your change instead of spewing ideas about evolution in software development. Running Coccinelle is one thing, but understanding the results and what you are ultimately proposing to be changed is more important.
Regards,
Arend
Quoted 17 lines
Quoted 1 line
The code that is performance critical, you should probably not touch, ever.
I imagine that technical evolution will result in further considerations so that "unchangeable" components can be adjusted once more.
Quoted 1 line
The people who wrote it knew what was important and what was not.
I might come along at some places where the affected knowledge will also evolve.
Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: net-libertas: Better exception handling in if_spi_host_to_card_worker()
Quoted 1 line
I have never seen much evolution going on in this area.
I can get an other impression from a specific document for example.
https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/log/Documentation/CodingStyle
Quoted 1 line
What the patch tries to do is avoid the extra 'if (err)'.
Yes. - I propose to look at related consequences together with the usage of a popular short jump label once more.
Quoted 2 lines
Setting coding style aside, the question is whether there is a good metric for the patch.
A software development challenge is to accept changes also around a topic like "error handling". My update suggestion for the source file "drivers/net/wireless/marvell/libertas/if_spi.c" should only improve exception handling. (I came along other source files where more improvements will eventually be possible.)
When will the run-time behaviour matter also for exceptional situations?
Quoted 1 line
Did you look at the resulting assembly code for different target architectures?
Not yet. - Which execution system variants would you recommend for further comparisons?
Regards,
Markus
Re: net-libertas: Better exception handling in if_spi_host_to_card_worker()
Quoted 10 lines · SF Markus Elfring
Quoted 1 line
I have never seen much evolution going on in this area.
I can get an other impression from a specific document for example.
https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/log/Documentation/CodingStyleQuoted 1 line
What the patch tries to do is avoid the extra 'if (err)'.
Yes. - I propose to look at related consequences together with the usage of a popular short jump label once more.
When I read a subject saying "Better exception handling" it sounds like a functional improvement. Your change does not change anything functionally and may or may not save a bit of execution time depending on how smart the compiler is. What you change does is confuse people reading the code. So please explain why your update improves exception handling here. I don't see it. The code is not making the driver more robust against failures in this function, which is what I think of reading "better exception handling".
Quoted 9 lines
Quoted 2 lines
Setting coding style aside, the question is whether there is a good metric for the patch.
A software development challenge is to accept changes also around a topic like "error handling". My update suggestion for the source file "
drivers/net/wireless/marvell/libertas/if_spi.c" should only improve exception handling. (I came along other source files where more improvements will eventually be possible.)
Quoted 7 lines
When will the run-time behaviour matter also for exceptional situations?
Quoted 1 line
Did you look at the resulting assembly code for different target architectures?
Not yet. - Which execution system variants would you recommend for further comparisons?
Guess x86{,_64} and arm would be good candidates, ie. CISC vs. RISC.
Regards,
Arend
Re: net-libertas: Better exception handling in if_spi_host_to_card_worker()
Quoted 9 lines
Quoted 4 lines
Quoted 1 line
What the patch tries to do is avoid the extra 'if (err)'.
Yes. - I propose to look at related consequences together with the usage of a popular short jump label once more.
When I read a subject saying "Better exception handling" it sounds like a functional improvement. Your change does not change anything functionally and may or may not save a bit of execution time depending on how smart the compiler is.
Can it eventually matter to skip another condition check in three cases?
Quoted 1 line
What you change does is confuse people reading the code.
A few software developers might find this proposal unusual.
Quoted 2 lines
So please explain why your update improves exception handling here. I don't see it.
How does this feedback fit to the mentioned check avoidance?
Quoted 1 line
The code is not making the driver more robust against failures
That's true for this update suggestion.
Quoted 1 line
in this function, which is what I think of reading "better exception handling".
Other implementation details are affected by the shown fine-tuning.
Regards,
Markus
Re: net-libertas: Better exception handling in if_spi_host_to_card_worker()
In reply to Arend van SprielQuoted 7 lines · Arend van Spriel
Quoted 4 lines · SF Markus Elfring
Quoted 1 line
Did you look at the resulting assembly code for different target architectures?
Not yet. - Which execution system variants would you recommend for further comparisons?
Guess x86{,_64} and arm would be good candidates, ie. CISC vs. RISC.
Oh, don't forget about MIPS with its fancy branches handling. You know about it, don't you?
I'm against this patch as well.
Signature · 5 lines
Rafał -- 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: net-libertas: Better exception handling in if_spi_host_to_card_worker()
Quoted 11 lines · Rafał Miłecki
Quoted 7 lines · Arend van Spriel
Quoted 4 lines · SF Markus Elfring
Quoted 1 line
Did you look at the resulting assembly code for different target architectures?
Not yet. - Which execution system variants would you recommend for further comparisons?
Guess x86{,_64} and arm would be good candidates, ie. CISC vs. RISC.
Oh, don't forget about MIPS with its fancy branches handling. You know about it, don't you?
You are asking me, right ;-) ? I have come across my share of MIPS platforms here at Broadcom, but I still try to avoid them as much as possible.
Quoted 1 line
I'm against this patch as well.
and counting... :-p
Regards,
Arend
Re: net-libertas: Better exception handling in if_spi_host_to_card_worker()
Quoted 8 lines · Arend van Spriel
Quoted 7 lines · Rafał Miłecki
Quoted 6 lines · Arend van Spriel
Quoted 4 lines · SF Markus Elfring
Quoted 1 line
Did you look at the resulting assembly code for different target architectures?
Not yet. - Which execution system variants would you recommend for further comparisons?
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Guess x86{,_64} and arm would be good candidates, ie. CISC vs. RISC.
Oh, don't forget about MIPS with its fancy branches handling. You know about it, don't you?
You are asking me, right ;-) ? I have come across my share of MIPS platforms here at Broadcom, but I still try to avoid them as much as possible.
I was more thinking about author on this patch. But it's indeed an interesting thing, just to know, how MIPS CPU handles branches ;)
Signature · 1 line
Rafał
Re: [PATCH] net-libertas: Better exception handling in if_spi_host_to_card_worker()
In reply to Julia LawallQuoted 36 lines · Julia Lawall
Quoted 16 lines · SF Markus Elfring
Quoted 6 lines
Quoted 4 lines
Move the jump label directly before the desired log statement so that the variable "err" will not be checked once more after it was determined that a function call failed. Use the identifier "
report_failure" instead of the label "err".Why?
I suggest to reconsider the places with which such a jump label is connected.
Quoted 1 line
The code was smart enough
Which action should really be performed after a failure was detected and handled a bit already?
Quoted 8 lines
* Another condition check
* Just additional error logging
Quoted 1 line
and you're making it uglier that it needs to be.
I assume that a software development taste can evolve, can't it?
So far, you have gotten several down votes for this kind of change, and no enthusiasm.
Admittedly, this is a trivial case, because there are no local variables, but do you actually know the semantics in C of a jump into a block? And if you do know, do you think that this semantics is common knowledge? And do you really think that introducing poorly understandable code is really worth saving an if test of a single variable on a non-critical path?
Quoted 5 lines
Most of the kernel code is not performance critical at the level of a single if test. So the goal should be for the code to be easy to understand and robust to change. The code that is performance critical, you should probably not touch, ever. The people who wrote it knew what was important and what was not.
Very well said! Only optimise something you can measure.
I'm dropping this patch.
Signature · 1 line
Kalle Valo
cover net-rsi: Fine-tuning for two function implementations
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 2 Jan 2016 15:36:25 +0100
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (3):
Delete unnecessary variable initialisations in rsi_send_mgmt_pkt() Delete unnecessary variable initialisations in rsi_send_data_pkt() Replace variable initialisations by assignments in rsi_send_data_pkt()
drivers/net/wireless/rsi/rsi_91x_pkt.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-)
Signature · 1 line
2.6.3
PATCH 1/3 rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt()
From: Markus Elfring <[email protected]>
Date: Sat, 2 Jan 2016 14:54:30 +0100
Omit explicit initialisation at the beginning for five local variables which are redefined before their first use.
--- drivers/net/wireless/rsi/rsi_91x_pkt.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/wireless/rsi/rsi_91x_pkt.c +5 -5
@@ -123,15 +123,15 @@ int rsi_send_mgmt_pkt(struct rsi_common *common, struct sk_buff *skb) {struct rsi_hw *adapter = common->priv; -struct ieee80211_hdr *wh =NULL ; +struct ieee80211_hdr *wh;struct ieee80211_tx_info *info; -struct ieee80211_bss_conf *bss =NULL ; +struct ieee80211_bss_conf *bss;struct ieee80211_hw *hw = adapter->hw;struct ieee80211_conf *conf = &hw->conf;struct skb_info *tx_params; -int status = -E2BIG ; -__le16 *msg =NULL ; -u8 extnd_size =0 ; +int status; +__le16 *msg; +u8 extnd_size;u8 vap_id =0 ; info =IEEE80211_SKB_CB (skb);
Signature · 1 line
2.6.3
net-rsi: Reconsider usage of variable "vap_id" in rsi_send_mgmt_pkt()
Hello,
I have taken another look at the implementation of the function "rsi_send_mgmt_pkt".
https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/drivers/net/wireless/rsi/rsi_91x_pkt.c?idèc58e7a5a106c3d557fccd01cd4d1128f9bab38#n114
I find the following statement combination interesting there.
…
u8 vap_id = 0; … msg[7] |= cpu_to_le16(vap_id << 8);
…
I would appreciate a further clarification.
Does a shift operation for a variable which contains zero indicate an open issue?
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
kbuild test robot
build botRe: [PATCH 1/3] rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt()
In reply to SF Markus Elfringreproduce:
Hi Markus,
[auto build test WARNING on wireless-drivers-next/master]
[also build test WARNING on v4.4-rc7 next-20151231]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]
url: https://github.com/0day-ci/linux/commits/SF-Markus-Elfring/net-rsi-Fine-tuning-for-two-function-implementations/20160102-224740 base: https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next.git master config: x86_64-randconfig-s2-01030012 (attached as .config) reproduce: # save the attached .config to linux build tree make ARCH=x86_64
Note: it may well be a FALSE warning. FWIW you are at least aware of it now.
http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings
All warnings (new ones prefixed by >>):
drivers/net/wireless/rsi/rsi_91x_pkt.c: In function 'rsi_send_mgmt_pkt':
>> drivers/net/wireless/rsi/rsi_91x_pkt.c:211:2: warning: 'status' may be used uninitialized in this function [-Wmaybe-uninitialized]
rsi_indicate_tx_status(common->priv, skb, status);
^vim +/status +211 drivers/net/wireless/rsi/rsi_91x_pkt.c
dad0d04f Fariya Fatima 2014-03-16 195 /* Indicate to firmware to give cfm */
dad0d04f Fariya Fatima 2014-03-16 196 if ((skb->data[16] == IEEE80211_STYPE_PROBE_REQ) && (!bss->assoc)) {
dad0d04f Fariya Fatima 2014-03-16 197 msg[1] |= cpu_to_le16(BIT(10));
dad0d04f Fariya Fatima 2014-03-16 198 msg[7] = cpu_to_le16(PROBEREQ_CONFIRM);
dad0d04f Fariya Fatima 2014-03-16 199 common->mgmt_q_block = true;
dad0d04f Fariya Fatima 2014-03-16 200 }
dad0d04f Fariya Fatima 2014-03-16 201
dad0d04f Fariya Fatima 2014-03-16 202 msg[7] |= cpu_to_le16(vap_id << 8);
dad0d04f Fariya Fatima 2014-03-16 203
dad0d04f Fariya Fatima 2014-03-16 204 status = adapter->host_intf_write_pkt(common->priv,
dad0d04f Fariya Fatima 2014-03-16 205 (u8 *)msg,
dad0d04f Fariya Fatima 2014-03-16 206 skb->len);
dad0d04f Fariya Fatima 2014-03-16 207 if (status)
dad0d04f Fariya Fatima 2014-03-16 208 rsi_dbg(ERR_ZONE, "%s: Failed to write the packet\n", __func__);
dad0d04f Fariya Fatima 2014-03-16 209
dad0d04f Fariya Fatima 2014-03-16 210 err:
dad0d04f Fariya Fatima 2014-03-16 @211 rsi_indicate_tx_status(common->priv, skb, status);
dad0d04f Fariya Fatima 2014-03-16 212 return status;
dad0d04f Fariya Fatima 2014-03-16 213 }:::::: The code at line 211 was first introduced by commit
:::::: dad0d04fa7ba41ce603a01e8e64967650303e9a2 rsi: Add RS9113 wireless driver
:::::: TO: Fariya Fatima <[email protected]> :::::: CC: John W. Linville <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
PATCH v2 1/3 rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt()
From: Markus Elfring <[email protected]>
Date: Sat, 2 Jan 2016 19:22:36 +0100
Omit explicit initialisation at the beginning for four local variables which are redefined before their first use.
--- drivers/net/wireless/rsi/rsi_91x_pkt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/wireless/rsi/rsi_91x_pkt.c +4 -4
@@ -123,15 +123,15 @@ int rsi_send_mgmt_pkt(struct rsi_common *common, struct sk_buff *skb) {struct rsi_hw *adapter = common->priv; -struct ieee80211_hdr *wh =NULL ; +struct ieee80211_hdr *wh;struct ieee80211_tx_info *info; -struct ieee80211_bss_conf *bss =NULL ; +struct ieee80211_bss_conf *bss;struct ieee80211_hw *hw = adapter->hw;struct ieee80211_conf *conf = &hw->conf;struct skb_info *tx_params;int status = -E2BIG ; -__le16 *msg =NULL ; -u8 extnd_size =0 ; +__le16 *msg; +u8 extnd_size;u8 vap_id =0 ; info =IEEE80211_SKB_CB (skb);
Signature · 1 line
2.6.3
Re: [PATCH 1/3] rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt()
In reply to SF Markus ElfringThese patches are labour intensive to review because you can't just do it in the email client. Also you were not able to review it properly yourself and introduced a bug.
I am often remove initializers but it's normally because I am changing something else which makes it worthwhile. This patch is the correct thing but it's not "worthwhile". It is not a good use of my time.
Please stop sending cleanup patches, Markus. Just send fixes.
regards,
dan carpenter
Re: [PATCH 1/3] rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt()
Btw, GCC misses a lot of uninitialized variable bugs. I have a Smatch check which sometimes catches the bugs that GCC misses but you should not rely on the tools here. These patches need to be reviewed manually.
And the "goto err" before the initialization makes everything more complicated (that's actually what caused the bug in this patch, in fact).
regards,
dan carpenter
Re: [PATCH 1/3] rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt()
In reply to Dan CarpenterQuoted 2 lines
These patches are labour intensive to review because you can't just do it in the email client.
Thanks for your general interest.
Quoted 2 lines
Also you were not able to review it properly yourself and introduced a bug.
I admit that it can happen during my software development that I overlook implementation details somehow.
Quoted 2 lines
I am often remove initializers but it's normally because I am changing something else which makes it worthwhile.
It is nice to hear that you are also occasionally looking for similar update candidates.
Quoted 1 line
This patch is the correct thing but it's not "worthwhile".
I find this view interesting.
Quoted 1 line
Please stop sending cleanup patches, Markus. Just send fixes.
How often will source code clean-up fix something?
May I resend a consistent patch series for the source file "drivers/net/wireless/rsi/rsi_91x_pkt.c" in the near future?
Regards,
Markus
Re: [PATCH 1/3] rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt()
Quoted 7 lines · SF Markus Elfring
Quoted 1 line
Please stop sending cleanup patches, Markus. Just send fixes.
How often will source code clean-up fix something?
May I resend a consistent patch series for the source file "
drivers/net/wireless/rsi/rsi_91x_pkt.c" in the near future?
If you were sending checkpatch.pl fixes that would be easier to deal with but you are sending hundreds of "controversial" cleanups. They are controversial in the sense that they don't fix anything against official kernel style and they go against the author's original intention. I tend to agree that useless initializers are bad and disable GCCs uninitialized variable warnings but just because I agree with you doesn't make it official kernel style. It's slightly rude to go against the author's intention.
regards,
dan carpenter
Re: rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt()
Quoted 4 lines
Quoted 2 lines
May I resend a consistent patch series for the source file "
drivers/net/wireless/rsi/rsi_91x_pkt.c" in the near future?If you were sending checkpatch.pl fixes that would be easier to deal with
Does this feedback mean that you would accept any more suggestions around source code updates which are derived from recommendations of this script?
Quoted 1 line
but you are sending hundreds of "controversial" cleanups.
It depends on the time range you look at for my proposals.
Quoted 2 lines
They are controversial in the sense that they don't fix anything against official kernel style
I find that I suggested also few changes that fit to this aspect.
Quoted 1 line
and they go against the author's original intention.
Can it occasionally help to reconsider the "first approach"?
Quoted 1 line
I tend to agree that useless initializers are bad
Would any more software developers like to share their opinions on this detail?
Quoted 1 line
and disable GCCs uninitialized variable warnings
I hope that this software area can be also improved.
Quoted 1 line
but just because I agree with you doesn't make it official kernel style.
That is fine. - Will it become useful to clarify any extensions to a document like "CodingStyle"?
Quoted 1 line
It's slightly rude to go against the author's intention.
I just dare to propose further special changes.
Regards,
Markus
Re: rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt()
Hi Markus,
Quoted 7 lines · SF Markus Elfring
Quoted 4 lines
Quoted 2 lines
May I resend a consistent patch series for the source file "
drivers/net/wireless/rsi/rsi_91x_pkt.c" in the near future?If you were sending checkpatch.pl fixes that would be easier to deal with
Does this feedback mean that you would accept any more suggestions around source code updates which are derived from recommendations of this script?
A good rule of thumb here would be that if people start complaining about a particular type of change, stop sending them.
Another good rule of thumb is to try to "rock the boat" on coding style and conventions as little as possible. Just because it's possible doesn't mean that people want to do it.
That said, if you figure out some change that produces significant reductions in code or binary size on multiple architectures without making things more complicated, less readable or making the code or binary size larger, then by all means propose it. "This makes things smaller" carries much more weight than "I think this is better". Almost all of the changes you've proposed that have seen any discussion whatsoever fall into the latter category.
Thanks,
Signature · 4 lines
Julian Calaby Email: [email protected] Profile: http://www.google.com/profiles/julian.calaby/
Re: rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt()
Quoted 4 lines
That said, if you figure out some change that produces significant reductions in code or binary size on multiple architectures without making things more complicated, less readable or making the code or binary size larger, then by all means propose it.
Are you looking also for "a proof" that such changes are worthwhile?
Quoted 2 lines
"This makes things smaller" carries much more weight than "I think this is better".
Can the discussed implementation of a function like "rsi_send_mgmt_pkt" become a bit smaller by the deletion of extra variable initialisations
Quoted 2 lines
Almost all of the changes you've proposed that have seen any discussion whatsoever fall into the latter category.
Thanks for your interesting feedback.
Can a further constructive dialogue evolve from the presented information?
Regards,
Markus
Re: rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt()
Hi Markus,
Quoted 6 lines · SF Markus Elfring
Quoted 4 lines
That said, if you figure out some change that produces significant reductions in code or binary size on multiple architectures without making things more complicated, less readable or making the code or binary size larger, then by all means propose it.
Are you looking also for "a proof" that such changes are worthwhile?
It'd be better than "I think doing things this way is better", which is the hallmark of most of your patch sets. (Admittedly not this one, but this one is where the discussion is now, so that's where we're discussing it.)
Quoted 5 lines
Quoted 2 lines
"This makes things smaller" carries much more weight than "I think this is better".
Can the discussed implementation of a function like "
rsi_send_mgmt_pkt" become a bit smaller by the deletion of extra variable initialisations
I'm talking in general.
In this case you're asking people to review a patch which requires a lot of careful review for a fairly minor improvement. I must also note that you haven't CC'd the people who wrote this driver, so it's possible that the only people who have reviewed it aren't experts in the code.
The patches you sent recently which moved labels into if statements were a clear case of "I think this is better" where any actual benefit from the changes was eclipsed by the style and readability issues they introduced.
Quoted 4 lines
Quoted 2 lines
Almost all of the changes you've proposed that have seen any discussion whatsoever fall into the latter category.
Thanks for your interesting feedback.
No problem.
Quoted 1 line
Can a further constructive dialogue evolve from the presented information?
Part of the issue here is that you don't seem to be listening to the discussion of your patches, or if you are, you're not significantly changing your approach or attitude in response.
Every time you send a set of patches, there are legitimate issues which people raise, and every time they are discussed, you assert that your patches improve things and seem to ignore the concerns people raise.
I've seen this same pattern of discussion here with these patches, with your patches to move labels into if statements, with the patches you sent late June last year, your patches to remove conditions before kfree() and friends, etc.
You need to change you attitude: just because you can see some benefit from your patches doesn't mean others do and it doesn't mean that they're willing to accept them.
Thanks,
Signature · 4 lines
Julian Calaby Email: [email protected] Profile: http://www.google.com/profiles/julian.calaby/
Re: rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt()
Quoted 1 line
Every time you send a set of patches,
I suggested some updates for Linux source files since October 2014.
Quoted 1 line
there are legitimate issues which people raise,
There was usual feedback.
Quoted 1 line
and every time they are discussed,
The discussion results were mixed between acceptance and usual disagreement.
Quoted 1 line
you assert that your patches improve things
I guess that should be the default intention of every patch, shouldn't it?
Quoted 1 line
and seem to ignore the concerns people raise.
I hope not. - But I can imagine that you might understand some responses from contributors in this way.
Are you waiting for another clarification on a specific issue?
Quoted 4 lines
I've seen this same pattern of discussion here with these patches, with your patches to move labels into if statements, with the patches you sent late June last year, your patches to remove conditions before
kfree()and friends, etc.
It seems that communication difficulties come partly from the fact that I chose search patterns from static source code analysis so far which belong to an error category that gets a lower priority.
Quoted 3 lines
You need to change you attitude: just because you can see some benefit from your patches doesn't mean others do and it doesn't mean that they're willing to accept them.
I understand your advice.
Further update suggestions with higher importance might follow for various software areas in the future.
Regards,
Markus
Bjørn Mork
maintainerRe: [PATCH 1/3] rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt()
In reply to Dan CarpenterQuoted 1 line · Dan Carpenter
Please stop sending cleanup patches, Markus. Just send fixes.
Thanks for your continued but unwarranted belief in AI.
Do you mind if I remind you of https://lkml.org/lkml/2014/11/3/162 ? I am sure there are lots and lots of other examples. There is no reason to believe this will ever stop. He just goes into Eliza mode.
Bjørn
--
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 1/3] rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt()
Quoted 6 lines · Bjørn Mork
Quoted 1 line · Dan Carpenter
Please stop sending cleanup patches, Markus. Just send fixes.
Thanks for your continued but unwarranted belief in AI.
I always tell people that I am very mechanical and you can rely on me to send predictable responses...
Quoted 3 lines
Do you mind if I remind you of https://lkml.org/lkml/2014/11/3/162 ? I am sure there are lots and lots of other examples. There is no reason to believe this will ever stop. He just goes into Eliza mode.
Yup.
I feel some sense of responsibility for any patches where kernel-janitors is on the CC but I'm having a hard time dealing with all of Markus's patches. Normally you just respond to the first patch and people change the later patches but, as you put it, Markus just goes into ELIZA mode.
regards,
dan carpenter
--
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
David Miller
maintainerRe: [PATCH 1/3] rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt()
In reply to Dan CarpenterFrom: Dan Carpenter <[email protected]>
Date: Mon, 4 Jan 2016 12:28:57 +0300
Quoted 1 line
Please stop sending cleanup patches, Markus. Just send fixes.
+1
PATCH 2/3 rsi: Delete unnecessary variable initialisations in rsi_send_data_pkt()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 2 Jan 2016 15:15:12 +0100
Omit explicit initialisation at the beginning for four local variables which are redefined before their first use.
--- drivers/net/wireless/rsi/rsi_91x_pkt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/wireless/rsi/rsi_91x_pkt.c +4 -4
@@ -27,15 +27,15 @@int rsi_send_data_pkt (struct rsi_common *common,struct sk_buff *skb) {struct rsi_hw *adapter = common->priv; -struct ieee80211_hdr *tmp_hdr =NULL ; +struct ieee80211_hdr *tmp_hdr;struct ieee80211_tx_info *info;struct skb_info *tx_params; -struct ieee80211_bss_conf *bss =NULL ; +struct ieee80211_bss_conf *bss;int status = -EINVAL ;u8 ieee80211_size =MIN_802_11_HDR_LEN ; -u8 extnd_size =0 ; +u8 extnd_size;__le16 *frame_desc; -u16 seq_num =0 ; +u16 seq_num; info =IEEE80211_SKB_CB (skb); bss = &info->control.vif->bss_conf;
Signature · 1 line
2.6.3
PATCH 3/3 rsi: Replace variable initialisations by assignments in rsi_send_data_pkt()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 2 Jan 2016 15:25:34 +0100
Replace explicit initialisation for two local variables at the beginning by assignments.
--- drivers/net/wireless/rsi/rsi_91x_pkt.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/net/wireless/rsi/rsi_91x_pkt.c +6 -4
@@ -26,12 +26,12 @@*/ int rsi_send_data_pkt (struct rsi_common *common,struct sk_buff *skb) { -struct rsi_hw *adapter = common->priv; +struct rsi_hw *adapter;struct ieee80211_hdr *tmp_hdr;struct ieee80211_tx_info *info;struct skb_info *tx_params;struct ieee80211_bss_conf *bss; -int status = -EINVAL ; +int status;u8 ieee80211_size =MIN_802_11_HDR_LEN ;u8 extnd_size;__le16 *frame_desc;
@@ -41,8 +41,10 @@ int rsi_send_data_pkt(struct rsi_common *common, struct sk_buff *skb) bss = &info->control.vif->bss_conf; tx_params = (struct skb_info *)info->driver_data; -if (!bss->assoc) +if (!bss->assoc) { + status = -EINVAL ; goto err; + } tmp_hdr = (struct ieee80211_hdr *)&skb->data[0 ]; seq_num = (le16_to_cpu (tmp_hdr->seq_ctrl) >>4 );
@@ -97,7 +99,7 @@ int rsi_send_data_pkt(struct rsi_common *common, struct sk_buff *skb) frame_desc[7 ] =cpu_to_le16 (((tx_params->tid &0xf ) <<4 ) | (skb->priority &0xf ) | (tx_params->sta_id <<8 )); - + adapter = common->priv; status = adapter->host_intf_write_pkt (common->priv, skb->data, skb->len);
Signature · 1 line
2.6.3
Re: [PATCH 3/3] rsi: Replace variable initialisations by assignments in rsi_send_data_pkt()
SF Markus Elfring <[email protected]> :
Quoted 5 lines
From: Markus Elfring <[email protected]>
Date: Sat, 2 Jan 2016 15:25:34 +0100Replace explicit initialisation for two local variables at the beginning by assignments.
It makes no sense for the 'adapter' variable.
Signature · 1 line
Ueimor
v3 cover net-rsi: Fine-tuning for two function implementations
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 15 Jan 2016 13:54:43 +0100
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (3):
Delete unnecessary variable initialisations in rsi_send_mgmt_pkt() Delete unnecessary variable initialisations in rsi_send_data_pkt() Replace variable initialisations by assignments in rsi_send_data_pkt()
drivers/net/wireless/rsi/rsi_91x_pkt.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-)
---
v3: Rebase proposed changes on the source files for the software
"Linux next-20160114".
v2: Unfortunately, the first update step from this series contained
an inappropriate suggestion.
Thus fix that.
Signature · 1 line
2.6.3
PATCH v3 1/3 rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt()
From: Markus Elfring <[email protected]>
Date: Fri, 15 Jan 2016 13:30:39 +0100
Omit explicit initialisation at the beginning for four local variables which are redefined before their first use.
--- drivers/net/wireless/rsi/rsi_91x_pkt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/wireless/rsi/rsi_91x_pkt.c +4 -4
@@ -123,15 +123,15 @@ int rsi_send_mgmt_pkt(struct rsi_common *common, struct sk_buff *skb) {struct rsi_hw *adapter = common->priv; -struct ieee80211_hdr *wh =NULL ; +struct ieee80211_hdr *wh;struct ieee80211_tx_info *info; -struct ieee80211_bss_conf *bss =NULL ; +struct ieee80211_bss_conf *bss;struct ieee80211_hw *hw = adapter->hw;struct ieee80211_conf *conf = &hw->conf;struct skb_info *tx_params;int status = -E2BIG ; -__le16 *msg =NULL ; -u8 extnd_size =0 ; +__le16 *msg; +u8 extnd_size;u8 vap_id =0 ; info =IEEE80211_SKB_CB (skb);
Signature · 1 line
2.6.3
PATCH v3 2/3 rsi: Delete unnecessary variable initialisations in rsi_send_data_pkt()
In reply to SF Markus ElfringFrom 017d1bb49f46266ffeb33178ddd3022d6b341d71 Mon Sep 17 00:00:00 2001
From: Markus Elfring <[email protected]>
Date: Fri, 15 Jan 2016 13:35:47 +0100
Subject: [PATCH 2/3] rsi: Delete unnecessary variable initialisations in
rsi_send_data_pkt()
Omit explicit initialisation at the beginning for four local variables which are redefined before their first use.
--- drivers/net/wireless/rsi/rsi_91x_pkt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/wireless/rsi/rsi_91x_pkt.c +4 -4
@@ -27,15 +27,15 @@int rsi_send_data_pkt (struct rsi_common *common,struct sk_buff *skb) {struct rsi_hw *adapter = common->priv; -struct ieee80211_hdr *tmp_hdr =NULL ; +struct ieee80211_hdr *tmp_hdr;struct ieee80211_tx_info *info;struct skb_info *tx_params; -struct ieee80211_bss_conf *bss =NULL ; +struct ieee80211_bss_conf *bss;int status = -EINVAL ;u8 ieee80211_size =MIN_802_11_HDR_LEN ; -u8 extnd_size =0 ; +u8 extnd_size;__le16 *frame_desc; -u16 seq_num =0 ; +u16 seq_num; info =IEEE80211_SKB_CB (skb); bss = &info->control.vif->bss_conf;
Signature · 1 line
2.6.3
PATCH v3 3/3 rsi: Replace variable initialisations by assignments in rsi_send_data_pkt()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 15 Jan 2016 13:40:22 +0100
Replace explicit initialisation for two local variables at the beginning by assignments.
--- drivers/net/wireless/rsi/rsi_91x_pkt.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/net/wireless/rsi/rsi_91x_pkt.c +6 -4
@@ -26,12 +26,12 @@*/ int rsi_send_data_pkt (struct rsi_common *common,struct sk_buff *skb) { -struct rsi_hw *adapter = common->priv; +struct rsi_hw *adapter;struct ieee80211_hdr *tmp_hdr;struct ieee80211_tx_info *info;struct skb_info *tx_params;struct ieee80211_bss_conf *bss; -int status = -EINVAL ; +int status;u8 ieee80211_size =MIN_802_11_HDR_LEN ;u8 extnd_size;__le16 *frame_desc;
@@ -41,8 +41,10 @@ int rsi_send_data_pkt(struct rsi_common *common, struct sk_buff *skb) bss = &info->control.vif->bss_conf; tx_params = (struct skb_info *)info->driver_data; -if (!bss->assoc) +if (!bss->assoc) { + status = -EINVAL ; goto err; + } tmp_hdr = (struct ieee80211_hdr *)&skb->data[0 ]; seq_num = (le16_to_cpu (tmp_hdr->seq_ctrl) >>4 );
@@ -97,7 +99,7 @@ int rsi_send_data_pkt(struct rsi_common *common, struct sk_buff *skb) frame_desc[7 ] =cpu_to_le16 (((tx_params->tid &0xf ) <<4 ) | (skb->priority &0xf ) | (tx_params->sta_id <<8 )); - + adapter = common->priv; status = adapter->host_intf_write_pkt (common->priv, skb->data, skb->len);
Signature · 1 line
2.6.3
Re: [PATCH v3 3/3] rsi: Replace variable initialisations by assignments in rsi_send_data_pkt()
Still makes no sense for adapter like Francois Romieu said.
regards,
dan carpenter
cover xen-netback: Fine-tuning for three function implementations
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 2 Jan 2016 18:46:45 +0100
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (5):
Delete an unnecessary assignment in connect_rings()
Delete an unnecessary goto statement in connect_rings()
Replace a variable initialisation by an assignment in read_xenbus_vif_flags() Replace a variable initialisation by an assignment in xen_register_watchers() Delete an unnecessary variable initialisation in xen_register_watchers()
drivers/net/xen-netback/xenbus.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
Signature · 1 line
2.6.3
PATCH 1/5 xen-netback: Delete an unnecessary assignment in connect_rings()
From: Markus Elfring <[email protected]>
Date: Sat, 2 Jan 2016 17:32:40 +0100
Remove the assignment for a local variable because its value is not changed compared to the one from a previous function call.
--- drivers/net/xen-netback/xenbus.c | 1 - 1 file changed, 1 deletion(-)
drivers/net/xen-netback/xenbus.c +0 -1
@@ -941,7 +941,6 @@ static int connect_rings(struct backend_info *be, struct xenvif_queue *queue) goto err; } - err =0 ; err:/* Regular return falls through with err = 0 */ kfree (xspath);return err;
Signature · 1 line
2.6.3
PATCH 1/5 xen-netback: Delete an unnecessary assignment in connect_rings()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 2 Jan 2016 17:32:40 +0100
Remove the assignment for a local variable because its value is not changed compared to the one from a previous function call.
--- drivers/net/xen-netback/xenbus.c | 1 - 1 file changed, 1 deletion(-)
drivers/net/xen-netback/xenbus.c +0 -1
@@ -941,7 +941,6 @@ static int connect_rings(struct backend_info *be, struct xenvif_queue *queue) goto err; } - err =0 ; err:/* Regular return falls through with err == 0 */ kfree (xspath);return err;
Signature · 1 line
2.6.3
PATCH 2/5 xen-netback: Delete an unnecessary goto statement in connect_rings()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 2 Jan 2016 17:50:21 +0100
One goto statement referred to a source code position directly behind it. Thus omit such an unnecessary jump.
--- drivers/net/xen-netback/xenbus.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/xen-netback/xenbus.c +1 -3
@@ -933,13 +933,11 @@ static int connect_rings(struct backend_info *be, struct xenvif_queue *queue)/* Map the shared frame, irq etc. */ err =xenvif_connect (queue, tx_ring_ref, rx_ring_ref, tx_evtchn, rx_evtchn); -if (err) { +if (err)xenbus_dev_fatal (dev, err,"mapping shared-frames %lu/%lu port tx %u rx %u" , tx_ring_ref, rx_ring_ref, tx_evtchn, rx_evtchn); - goto err; - } err:/* Regular return falls through with err = 0 */ kfree (xspath);
Signature · 1 line
2.6.3
PATCH 2/5 xen-netback: Delete an unnecessary goto statement in connect_rings()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 2 Jan 2016 17:50:21 +0100
One goto statement referred to a source code position directly behind it. Thus omit such an unnecessary jump.
--- drivers/net/xen-netback/xenbus.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/xen-netback/xenbus.c +1 -3
@@ -933,13 +933,11 @@ static int connect_rings(struct backend_info *be, struct xenvif_queue *queue)/* Map the shared frame, irq etc. */ err =xenvif_connect (queue, tx_ring_ref, rx_ring_ref, tx_evtchn, rx_evtchn); -if (err) { +if (err)xenbus_dev_fatal (dev, err,"mapping shared-frames %lu/%lu port tx %u rx %u" , tx_ring_ref, rx_ring_ref, tx_evtchn, rx_evtchn); - goto err; - } err:/* Regular return falls through with err == 0 */ kfree (xspath);
Signature · 1 line
2.6.3
PATCH 3/5 xen-netback: Replace a variable initialisation by an assignment in read_xenbus_vif_flags()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 2 Jan 2016 18:01:57 +0100
Replace an explicit initialisation for one local variable at the beginning by an assignment.
--- drivers/net/xen-netback/xenbus.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/xen-netback/xenbus.c +4 -3
@@ -946,7 +946,7 @@ err: /* Regular return falls through with err = 0 */static int read_xenbus_vif_flags (struct backend_info *be) { -struct xenvif *vif = be->vif; +struct xenvif *vif;struct xenbus_device *dev = be->dev;unsigned int rx_copy;int err, val;
@@ -968,13 +968,14 @@ static int read_xenbus_vif_flags(struct backend_info *be)if (xenbus_scanf (XBT_NIL , dev->otherend,"feature-rx-notify" ,"%d" , &val) <0 ) val =0 ; + vif = be->vif;if (!val) {/* - Reduce drain timeout to poll more frequently for * Rx requests. * - Disable Rx stall detection. */ - be->vif->drain_timeout =msecs_to_jiffies (30 ); - be->vif->stall_timeout =0 ; + vif->drain_timeout =msecs_to_jiffies (30 ); + vif->stall_timeout =0 ; } if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-sg",
Signature · 1 line
2.6.3
PATCH 3/5 xen-netback: Replace a variable initialisation by an assignment in read_xenbus_vif_flags()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 2 Jan 2016 18:01:57 +0100
Replace an explicit initialisation for one local variable at the beginning by an assignment.
--- drivers/net/xen-netback/xenbus.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/xen-netback/xenbus.c +4 -3
@@ -946,7 +946,7 @@ err: /* Regular return falls through with err == 0 */static int read_xenbus_vif_flags (struct backend_info *be) { -struct xenvif *vif = be->vif; +struct xenvif *vif;struct xenbus_device *dev = be->dev;unsigned int rx_copy;int err, val;
@@ -968,13 +968,14 @@ static int read_xenbus_vif_flags(struct backend_info *be)if (xenbus_scanf (XBT_NIL , dev->otherend,"feature-rx-notify" ,"%d" , &val) <0 ) val =0 ; + vif = be->vif;if (!val) {/* - Reduce drain timeout to poll more frequently for * Rx requests. * - Disable Rx stall detection. */ - be->vif->drain_timeout =msecs_to_jiffies (30 ); - be->vif->stall_timeout =0 ; + vif->drain_timeout =msecs_to_jiffies (30 ); + vif->stall_timeout =0 ; } if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-sg",
Signature · 1 line
2.6.3
PATCH 4/5 xen-netback: Replace a variable initialisation by an assignment in xen_register_watchers()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 2 Jan 2016 18:23:16 +0100
Replace an explicit initialisation for one local variable at the beginning by an assignment.
--- drivers/net/xen-netback/xenbus.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/xen-netback/xenbus.c +2 -1
@@ -687,11 +687,12 @@ static int xen_register_watchers(struct xenbus_device *dev, struct xenvif *vif) {int err =0 ;char *node; -unsigned maxlen =strlen (dev->nodename) +sizeof ("/rate" ); +unsigned maxlen;if (vif->credit_watch.node)return -EADDRINUSE ; + maxlen =strlen (dev->nodename) +sizeof ("/rate" ); node =kmalloc (maxlen,GFP_KERNEL );if (!node)return -ENOMEM ;
Signature · 1 line
2.6.3
PATCH 4/5 xen-netback: Replace a variable initialisation by an assignment in xen_register_watchers()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 2 Jan 2016 18:23:16 +0100
Replace an explicit initialisation for one local variable at the beginning by an assignment.
--- drivers/net/xen-netback/xenbus.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/xen-netback/xenbus.c +2 -1
@@ -687,11 +687,12 @@ static int xen_register_watchers(struct xenbus_device *dev, struct xenvif *vif) {int err =0 ;char *node; -unsigned maxlen =strlen (dev->nodename) +sizeof ("/rate" ); +unsigned maxlen;if (vif->credit_watch.node)return -EADDRINUSE ; + maxlen =strlen (dev->nodename) +sizeof ("/rate" ); node =kmalloc (maxlen,GFP_KERNEL );if (!node)return -ENOMEM ;
Signature · 1 line
2.6.3
PATCH 5/5 xen-netback: Delete an unnecessary variable initialisation in xen_register_watchers()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 2 Jan 2016 18:28:26 +0100
Omit explicit initialisation at the beginning for one local variable that is redefined before its first use.
--- drivers/net/xen-netback/xenbus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/xen-netback/xenbus.c +1 -1
@@ -685,7 +685,7 @@ static void xen_net_rate_changed(struct xenbus_watch *watch,static int xen_register_watchers (struct xenbus_device *dev,struct xenvif *vif) { -int err =0 ; +int err;char *node;unsigned maxlen;
Signature · 1 line
2.6.3
PATCH 5/5 xen-netback: Delete an unnecessary variable initialisation in xen_register_watchers()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 2 Jan 2016 18:28:26 +0100
Omit explicit initialisation at the beginning for one local variable that is redefined before its first use.
--- drivers/net/xen-netback/xenbus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/xen-netback/xenbus.c +1 -1
@@ -685,7 +685,7 @@ static void xen_net_rate_changed(struct xenbus_watch *watch,static int xen_register_watchers (struct xenbus_device *dev,struct xenvif *vif) { -int err =0 ; +int err;char *node;unsigned maxlen;
Signature · 1 line
2.6.3
Joe Perches
maintainerRe: [PATCH 0/5] xen-netback: Fine-tuning for three function implementations
In reply to SF Markus ElfringQuoted 2 lines · SF Markus Elfring
A few update suggestions were taken into account
from static source code analysis.
While static analysis can be useful, I don't think these specific conversions are generally useful.
Perhaps it would be more useful to convert the string duplication or snprintf logic to kstrdup/kasprintf
This:
if (num_queues = 1) {
xspath = kzalloc(strlen(dev->otherend) + 1, GFP_KERNEL);
if (!xspath) {
xenbus_dev_fatal(dev, -ENOMEM,
"reading ring references");
return -ENOMEM;
}
strcpy(xspath, dev->otherend);
} else {
xspathsize = strlen(dev->otherend) + xenstore_path_ext_size;
xspath = kzalloc(xspathsize, GFP_KERNEL);
if (!xspath) {
xenbus_dev_fatal(dev, -ENOMEM,
"reading ring references");
return -ENOMEM;
}
snprintf(xspath, xspathsize, "%s/queue-%u", dev->otherend,
queue->id);
}could be simplified to something like:
if (num_queues = 1) xspath = kstrdup(dev->otherend, GFP_KERNEL); else xspath = kasprintf(GFP_KERNEL, "%s/queue-%u", dev->otherend, queue->id); if (!xspath) etc...
--
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
Joe Perches
maintainerRe: [PATCH 0/5] xen-netback: Fine-tuning for three function implementations
In reply to SF Markus ElfringQuoted 2 lines · SF Markus Elfring
A few update suggestions were taken into account
from static source code analysis.
While static analysis can be useful, I don't think these specific conversions are generally useful.
Perhaps it would be more useful to convert the string duplication or snprintf logic to kstrdup/kasprintf
This:
if (num_queues == 1) {
xspath = kzalloc(strlen(dev->otherend) + 1, GFP_KERNEL);
if (!xspath) {
xenbus_dev_fatal(dev, -ENOMEM,
"reading ring references");
return -ENOMEM;
}
strcpy(xspath, dev->otherend);
} else {
xspathsize = strlen(dev->otherend) + xenstore_path_ext_size;
xspath = kzalloc(xspathsize, GFP_KERNEL);
if (!xspath) {
xenbus_dev_fatal(dev, -ENOMEM,
"reading ring references");
return -ENOMEM;
}
snprintf(xspath, xspathsize, "%s/queue-%u", dev->otherend,
queue->id);
}could be simplified to something like:
if (num_queues == 1) xspath = kstrdup(dev->otherend, GFP_KERNEL); else xspath = kasprintf(GFP_KERNEL, "%s/queue-%u", dev->otherend, queue->id); if (!xspath) etc...
Re: [PATCH 0/5] xen-netback: Fine-tuning for three function implementations
In reply to SF Markus ElfringThe original code is fine.
regards,
dan carpenter
Re: [PATCH 0/5] xen-netback: Fine-tuning for three function implementations
In reply to SF Markus ElfringThe original code is fine.
regards,
dan carpenter
Re: [PATCH 0/5] xen-netback: Fine-tuning for three function implementations
In reply to SF Markus ElfringI think the original code is fine.
Wei.
Re: [PATCH 0/5] xen-netback: Fine-tuning for three function implementations
In reply to SF Markus ElfringI think the original code is fine.
Wei.
cover xen-netback: Fine-tuning for three function implementations
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 2 Jan 2016 18:46:45 +0100
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (5):
Delete an unnecessary assignment in connect_rings()
Delete an unnecessary goto statement in connect_rings()
Replace a variable initialisation by an assignment in read_xenbus_vif_flags() Replace a variable initialisation by an assignment in xen_register_watchers() Delete an unnecessary variable initialisation in xen_register_watchers()
drivers/net/xen-netback/xenbus.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
Signature · 1 line
2.6.3
cover NFC-mei_phy: Fine-tuning for two function implementations
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 2 Jan 2016 21:47:30 +0100
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (3):
Refactoring for mei_nfc_connect()
Refactoring for mei_nfc_if_version()
Delete an unnecessary variable initialisation in mei_nfc_if_version()
drivers/nfc/mei_phy.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-)
Signature · 1 line
2.6.3
PATCH 1/3 NFC-mei_phy: Refactoring for mei_nfc_connect()
From: Markus Elfring <[email protected]>
Date: Sat, 2 Jan 2016 21:21:24 +0100
This issue was detected by using the Coccinelle software.
Adjust jump targets according to the current Linux coding style convention.
--- drivers/nfc/mei_phy.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/nfc/mei_phy.c +6 -7
@@ -173,8 +173,8 @@ static int mei_nfc_connect(struct nfc_mei_phy *phy) reply =kzalloc (connect_resp_length,GFP_KERNEL );if (!reply) { -kfree (cmd); -return -ENOMEM ; + r = -ENOMEM ; + goto free_cmd; } connect_resp = (struct mei_nfc_connect_resp *)reply->data;
@@ -189,7 +189,7 @@ static int mei_nfc_connect(struct nfc_mei_phy *phy) r =mei_cldev_send (phy->cldev, (u8 *)cmd, connect_length);if (r <0 ) {pr_err ("Could not send connect cmd %d\n" , r); - goto err; + goto free_reply; } bytes_recv = mei_cldev_recv(phy->cldev, (u8 *)reply,
@@ -197,7 +197,7 @@ static int mei_nfc_connect(struct nfc_mei_phy *phy)if (bytes_recv <0 ) { r = bytes_recv;pr_err ("Could not read connect response %d\n" , r); - goto err; + goto free_reply; }MEI_DUMP_NFC_HDR ("connect reply" , &reply->hdr);
@@ -210,11 +210,10 @@ static int mei_nfc_connect(struct nfc_mei_phy *phy) connect_resp->me_hotfix, connect_resp->me_build); r =0 ; - -err: +free_reply:kfree (reply); +free_cmd:kfree (cmd); -return r; }
Signature · 1 line
2.6.3
Re: [PATCH 1/3] NFC-mei_phy: Refactoring for mei_nfc_connect()
Hi Markus,
Quoted 46 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 2 Jan 2016 21:21:24 +0100This issue was detected by using the Coccinelle software.
Adjust jump targets according to the current Linux coding style convention.
Signed-off-by Markus Elfring <[email protected]>--- drivers/nfc/mei_phy.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)drivers/nfc/mei_phy.c +4
-4@@ -173,8 +173,8 @@ static int mei_nfc_connect(struct nfc_mei_phy *phy) reply =kzalloc (connect_resp_length,GFP_KERNEL );if (!reply) { -kfree (cmd); -return -ENOMEM ; + r = -ENOMEM ; + goto free_cmd; } connect_resp = (struct mei_nfc_connect_resp *)reply->data;@@ -189,7 +189,7 @@ static int mei_nfc_connect(struct nfc_mei_phy *phy) r =mei_cldev_send (phy->cldev, (u8 *)cmd, connect_length);if (r <0 ) {pr_err ("Could not send connect cmd %d\n" , r); - goto err; + goto free_reply; } bytes_recv = mei_cldev_recv(phy->cldev, (u8 *)reply,@@ -197,7 +197,7 @@ static int mei_nfc_connect(struct nfc_mei_phy *phy)if (bytes_recv <0 ) { r = bytes_recv;pr_err ("Could not read connect response %d\n" , r); - goto err; + goto free_reply; }MEI_DUMP_NFC_HDR ("connect reply" , &reply->hdr);
drivers/nfc/mei_phy.c static int mei_nfc_connect(struct nfc_mei_phy *phy) · line 217
Quoted 10 lines
drivers/nfc/mei_phy.c +2
-3@@ -210,11 +210,10 @@ static int mei_nfc_connect(struct nfc_mei_phy *phy) connect_resp->me_hotfix, connect_resp->me_build); r =0 ; - -err: +free_reply:kfree (reply); +free_cmd:kfree (cmd); -
Why are you deleting the two blank lines here?
Thanks,
Signature · 4 lines
Julian Calaby Email: [email protected] Profile: http://www.google.com/profiles/julian.calaby/
Re: [PATCH 1/3] NFC-mei_phy: Refactoring for mei_nfc_connect()
Quoted 10 lines
drivers/nfc/mei_phy.c static int mei_nfc_connect(struct nfc_mei_phy *phy) · line 217
Quoted 8 lines
r = 0;drivers/nfc/mei_phy.c +2
-3- -err: +free_reply:kfree (reply); +free_cmd:kfree (cmd); -Why are you deleting the two blank lines here?
Can they be unnecessary at this source code place
according to the Linux coding style convention?
Regards,
Markus
Joe Perches
maintainerRe: [PATCH 1/3] NFC-mei_phy: Refactoring for mei_nfc_connect()
Quoted 11 lines · SF Markus Elfring
Quoted 10 lines
Quoted 8 lines
r = 0;
drivers/nfc/mei_phy.c +1
-2- -err: +free_reply:kfree(reply);
+free_cmd:
kfree(cmd);
-Why are you deleting the two blank lines here?
Quoted 2 lines
Can they be unnecessary at this source code place
according to the Linux coding style convention?
As far as I know, there's no linux specific accepted convention for blank lines preceding labels.
My personal preference is for a blank line before a new block, but not before the second and subsequent labels in an error handling block.
--
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 2/3 NFC-mei_phy: Refactoring for mei_nfc_if_version()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 2 Jan 2016 21:33:04 +0100
Rename a jump label according to the current Linux coding style convention.
--- drivers/nfc/mei_phy.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/nfc/mei_phy.c +2 -3
@@ -136,7 +136,7 @@ static int mei_nfc_if_version(struct nfc_mei_phy *phy)if (bytes_recv <0 || bytes_recv <sizeof (struct mei_nfc_reply )) {pr_err ("Could not read IF version\n" ); r = -EIO ; - goto err; + goto free_reply; } version = (struct mei_nfc_if_version *)reply->data;
@@ -144,8 +144,7 @@ static int mei_nfc_if_version(struct nfc_mei_phy *phy) phy->fw_ivn = version->fw_ivn; phy->vendor_id = version->vendor_id; phy->radio_type = version->radio_type; - -err: +free_reply:kfree (reply);return r; }
Signature · 1 line
2.6.3
PATCH 3/3 NFC-mei_phy: Delete an unnecessary variable initialisation in mei_nfc_if_version()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 2 Jan 2016 21:40:10 +0100
Omit explicit initialisation at the beginning for one local variable that is redefined before its first use.
--- drivers/nfc/mei_phy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nfc/mei_phy.c +1 -1
@@ -105,7 +105,7 @@ static int mei_nfc_if_version(struct nfc_mei_phy *phy) {struct mei_nfc_cmd cmd; -struct mei_nfc_reply *reply =NULL ; +struct mei_nfc_reply *reply;struct mei_nfc_if_version *version;size_t if_version_length;int bytes_recv, r;
Signature · 1 line
2.6.3
cover rtc-ab-b5ze-s3: Fine-tuning for some function implementations
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 3 Jan 2016 09:37:34 +0100
Several update suggestions were taken into account from static source code analysis.
Markus Elfring (8):
Better exception handling in abb5zes3_probe()
Delete an unnecessary variable in abb5zes3_rtc_set_alarm()
Delete an unnecessary variable initialisation in _abb5zes3_rtc_set_timer() Replace a variable initialisation by an assignment in _abb5zes3_rtc_set_alarm() Replace a variable initialisation by an assignment in _abb5zes3_rtc_read_alarm() Delete an unnecessary variable in _abb5zes3_rtc_read_timer()
Delete an unnecessary variable in _abb5zes3_rtc_interrupt()
Delete an unnecessary variable in _abb5zes3_rtc_set_timer()
drivers/rtc/rtc-ab-b5ze-s3.c | 59 ++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 32 deletions(-)
Signature · 1 line
2.6.3
PATCH 1/8 rtc-ab-b5ze-s3: Better exception handling in abb5zes3_probe()
From: Markus Elfring <[email protected]>
Date: Sun, 3 Jan 2016 07:07:49 +0100
This issue was detected by using the Coccinelle software.
* Return directly before the data structure element "irq" was assigned.
* Drop the explicit initialisation for the variable "data" at the beginning then.
* Adjust jump targets according to the Linux coding style convention.
* Simplify a condition check at the end.
--- drivers/rtc/rtc-ab-b5ze-s3.c | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-)
drivers/rtc/rtc-ab-b5ze-s3.c +14 -18
@@ -889,35 +889,31 @@ static const struct regmap_config abb5zes3_rtc_regmap_config = {static int abb5zes3_probe (struct i2c_client *client,const struct i2c_device_id *id) { -struct abb5zes3_rtc_data *data =NULL ; +struct abb5zes3_rtc_data *data;struct device *dev = &client->dev;struct regmap *regmap;int ret;if (!i2c_check_functionality (client->adapter,I2C_FUNC_I2C |I2C_FUNC_SMBUS_BYTE_DATA | -I2C_FUNC_SMBUS_I2C_BLOCK )) { - ret = -ENODEV ; - goto err; - } +I2C_FUNC_SMBUS_I2C_BLOCK )) +return -ENODEV ; regmap =devm_regmap_init_i2c (client, &abb5zes3_rtc_regmap_config);if (IS_ERR (regmap)) { ret =PTR_ERR (regmap);dev_err (dev,"%s: regmap allocation failed: %d\n" , __func__, ret); - goto err; +return ret; } ret =abb5zes3_i2c_validate_chip (regmap);if (ret) - goto err; +return ret; data =devm_kzalloc (dev,sizeof (*data),GFP_KERNEL ); -if (!data) { - ret = -ENOMEM ; - goto err; - } +if (!data) +return -ENOMEM ;mutex_init (&data->lock); data->regmap = regmap;
@@ -925,7 +921,7 @@ static int abb5zes3_probe(struct i2c_client *client, ret =abb5zes3_rtc_check_setup (dev);if (ret) - goto err; +return ret;if (client->irq >0 ) { ret = devm_request_threaded_irq(dev, client->irq, NULL,
@@ -940,7 +936,7 @@ static int abb5zes3_probe(struct i2c_client *client, }else {dev_err (dev,"%s: irq %d unavailable (%d)\n" , __func__, client->irq, ret); - goto err; +return ret; } }
@@ -950,7 +946,7 @@ static int abb5zes3_probe(struct i2c_client *client,if (ret) {dev_err (dev,"%s: unable to register RTC device (%d)\n" , __func__, ret); - goto err; + goto check_irq; }/* Enable battery low detection interrupt if battery not already low */
@@ -959,12 +955,12 @@ static int abb5zes3_probe(struct i2c_client *client,if (ret) {dev_err (dev,"%s: enabling battery low interrupt " "generation failed (%d)\n" , __func__, ret); - goto err; + goto check_irq; } } - -err: -if (ret && data && data->irq) +return 0 ; +check_irq: +if (data->irq)device_init_wakeup (dev, false);return ret; }
Signature · 1 line
2.6.3
PATCH 2/8 rtc-ab-b5ze-s3: Delete an unnecessary variable in abb5zes3_rtc_set_alarm()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 3 Jan 2016 07:35:09 +0100
Pass the address of the data structure element "time" directly in a call of the function "rtc_tm_to_time" instead of an extra initialisation for one local variable at the beginning.
--- drivers/rtc/rtc-ab-b5ze-s3.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/rtc/rtc-ab-b5ze-s3.c +1 -2
@@ -596,7 +596,6 @@ err:static int abb5zes3_rtc_set_alarm (struct device *dev,struct rtc_wkalrm *alarm) {struct abb5zes3_rtc_data *data =dev_get_drvdata (dev); -struct rtc_time *alarm_tm = &alarm->time;unsigned long rtc_secs, alarm_secs;struct rtc_time rtc_tm;int ret;
@@ -610,7 +609,7 @@ static int abb5zes3_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)if (ret) goto err; - ret =rtc_tm_to_time (alarm_tm, &alarm_secs); + ret =rtc_tm_to_time (&alarm->time, &alarm_secs);if (ret) goto err;
Signature · 1 line
2.6.3
PATCH 3/8 rtc-ab-b5ze-s3: Delete an unnecessary variable initialisation in _abb5zes3_rtc_set_timer()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 3 Jan 2016 07:42:18 +0100
Omit explicit initialisation at the beginning for one local variable that is redefined before its first use.
--- drivers/rtc/rtc-ab-b5ze-s3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-ab-b5ze-s3.c +1 -1
@@ -560,7 +560,7 @@ static int _abb5zes3_rtc_set_timer(struct device *dev, struct rtc_wkalrm *alarm,struct abb5zes3_rtc_data *data =dev_get_drvdata (dev);u8 regs[ABB5ZES3_TIMA_SEC_LEN ];u8 mask =ABB5ZES3_REG_TIM_CLK_TAC0 |ABB5ZES3_REG_TIM_CLK_TAC1 ; -int ret =0 ; +int ret;/* Program given number of seconds to Timer A registers */ sec_to_timer_a (secs, ®s[0 ], ®s[1 ]);
Signature · 1 line
2.6.3
PATCH 4/8 rtc-ab-b5ze-s3: Replace a variable initialisation by an assignment in _abb5zes3_rtc_set_alarm()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 3 Jan 2016 07:51:49 +0100
Replace an explicit initialisation for one local variable at the beginning by an assignment.
--- drivers/rtc/rtc-ab-b5ze-s3.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/rtc/rtc-ab-b5ze-s3.c +2 -1
@@ -476,7 +476,7 @@ static int abb5zes3_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)static int _abb5zes3_rtc_set_alarm (struct device *dev,struct rtc_wkalrm *alarm) {struct abb5zes3_rtc_data *data =dev_get_drvdata (dev); -struct rtc_time *alarm_tm = &alarm->time; +struct rtc_time *alarm_tm;unsigned long rtc_secs, alarm_secs;u8 regs[ABB5ZES3_ALRM_SEC_LEN ];struct rtc_time rtc_tm;
@@ -490,6 +490,7 @@ static int _abb5zes3_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)if (ret) goto err; + alarm_tm = &alarm->time; ret =rtc_tm_to_time (alarm_tm, &alarm_secs);if (ret) goto err;
Signature · 1 line
2.6.3
PATCH 5/8 rtc-ab-b5ze-s3: Replace a variable initialisation by an assignment in _abb5zes3_rtc_read_alarm()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 3 Jan 2016 08:00:29 +0100
Replace an explicit initialisation for one local variable at the beginning by an assignment.
--- drivers/rtc/rtc-ab-b5ze-s3.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/rtc/rtc-ab-b5ze-s3.c +2 -1
@@ -382,7 +382,7 @@ static int _abb5zes3_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm) {struct abb5zes3_rtc_data *data =dev_get_drvdata (dev); -struct rtc_time rtc_tm, *alarm_tm = &alarm->time; +struct rtc_time rtc_tm, *alarm_tm;unsigned long rtc_secs, alarm_secs;u8 regs[ABB5ZES3_ALRM_SEC_LEN ];unsigned int reg;
@@ -396,6 +396,7 @@ static int _abb5zes3_rtc_read_alarm(struct device *dev, goto err; } + alarm_tm = &alarm->time; alarm_tm->tm_sec =0 ; alarm_tm->tm_min =bcd2bin (regs[0 ] &0x7f ); alarm_tm->tm_hour =bcd2bin (regs[1 ] &0x3f );
Signature · 1 line
2.6.3
PATCH 6/8 rtc-ab-b5ze-s3: Delete an unnecessary variable in _abb5zes3_rtc_read_timer()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 3 Jan 2016 08:46:50 +0100
Pass the address of the data structure element "time" directly in a call of the function "rtc_time_to_tm" instead of an extra initialisation for one local variable at the beginning.
--- drivers/rtc/rtc-ab-b5ze-s3.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/rtc/rtc-ab-b5ze-s3.c +2 -2
@@ -326,7 +326,7 @@ static int _abb5zes3_rtc_read_timer(struct device *dev, struct rtc_wkalrm *alarm) {struct abb5zes3_rtc_data *data =dev_get_drvdata (dev); -struct rtc_time rtc_tm, *alarm_tm = &alarm->time; +struct rtc_time rtc_tm;u8 regs[ABB5ZES3_TIMA_SEC_LEN +1 ];unsigned long rtc_secs;unsigned int reg;
@@ -362,7 +362,7 @@ static int _abb5zes3_rtc_read_timer(struct device *dev, goto err;/* ... and convert back. */ -rtc_time_to_tm (rtc_secs + timer_secs, alarm_tm); +rtc_time_to_tm (rtc_secs + timer_secs, &alarm->time); ret =regmap_read (data->regmap,ABB5ZES3_REG_CTRL2 , ®);if (ret) {
Signature · 1 line
2.6.3
PATCH 7/8 rtc-ab-b5ze-s3: Delete an unnecessary variable in _abb5zes3_rtc_interrupt()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 3 Jan 2016 09:00:30 +0100
Pass the address of the data structure element "time" directly in calls of the function "rtc_update_irq" instead of an extra initialisation for one local variable at the beginning.
--- drivers/rtc/rtc-ab-b5ze-s3.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/rtc/rtc-ab-b5ze-s3.c +2 -5
@@ -816,7 +816,6 @@ static irqreturn_t _abb5zes3_rtc_interrupt(int irq, void *data)struct i2c_client *client = data;struct device *dev = &client->dev;struct abb5zes3_rtc_data *rtc_data =dev_get_drvdata (dev); -struct rtc_device *rtc = rtc_data->rtc;u8 regs[ABB5ZES3_CTRL_SEC_LEN ];int ret, handled =IRQ_NONE ;
@@ -844,8 +843,7 @@ static irqreturn_t _abb5zes3_rtc_interrupt(int irq, void *data)/* Check alarm flag */ if (regs[ABB5ZES3_REG_CTRL2 ] &ABB5ZES3_REG_CTRL2_AF ) {dev_dbg (dev,"RTC alarm!\n" ); - -rtc_update_irq (rtc,1 ,RTC_IRQF |RTC_AF ); +rtc_update_irq (rtc_data->rtc,1 ,RTC_IRQF |RTC_AF );/* Acknowledge and disable the alarm */ _abb5zes3_rtc_clear_alarm (dev);
@@ -857,8 +855,7 @@ static irqreturn_t _abb5zes3_rtc_interrupt(int irq, void *data)/* Check watchdog Timer A flag */ if (regs[ABB5ZES3_REG_CTRL2 ] &ABB5ZES3_REG_CTRL2_WTAF ) {dev_dbg (dev,"RTC timer!\n" ); - -rtc_update_irq (rtc,1 ,RTC_IRQF |RTC_AF ); +rtc_update_irq (rtc_data->rtc,1 ,RTC_IRQF |RTC_AF );/* * Acknowledge and disable the alarm. Note: WTAF
Signature · 1 line
2.6.3
Re: [PATCH 7/8] rtc-ab-b5ze-s3: Delete an unnecessary variable in _abb5zes3_rtc_interrupt()
Quoted 6 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 3 Jan 2016 09:00:30 +0100Pass the address of the data structure element "time" directly in calls of the function "
rtc_update_irq" instead of an extra initialisation for one local variable at the beginning.
Why is it better?
julia
Quoted 41 lines
Signed-off-by Markus Elfring <[email protected]>--- drivers/rtc/rtc-ab-b5ze-s3.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)drivers/rtc/rtc-ab-b5ze-s3.c +2
-5@@ -816,7 +816,6 @@ static irqreturn_t _abb5zes3_rtc_interrupt(int irq, void *data)struct i2c_client *client = data;struct device *dev = &client->dev;struct abb5zes3_rtc_data *rtc_data =dev_get_drvdata (dev); -struct rtc_device *rtc = rtc_data->rtc;u8 regs[ABB5ZES3_CTRL_SEC_LEN ];int ret, handled =IRQ_NONE ;@@ -844,8 +843,7 @@ static irqreturn_t _abb5zes3_rtc_interrupt(int irq, void *data)/* Check alarm flag */ if (regs[ABB5ZES3_REG_CTRL2 ] &ABB5ZES3_REG_CTRL2_AF ) {dev_dbg (dev,"RTC alarm!\n" ); - -rtc_update_irq (rtc,1 ,RTC_IRQF |RTC_AF ); +rtc_update_irq (rtc_data->rtc,1 ,RTC_IRQF |RTC_AF );/* Acknowledge and disable the alarm */ _abb5zes3_rtc_clear_alarm (dev);@@ -857,8 +855,7 @@ static irqreturn_t _abb5zes3_rtc_interrupt(int irq, void *data)/* Check watchdog Timer A flag */ if (regs[ABB5ZES3_REG_CTRL2 ] &ABB5ZES3_REG_CTRL2_WTAF ) {dev_dbg (dev,"RTC timer!\n" ); - -rtc_update_irq (rtc,1 ,RTC_IRQF |RTC_AF ); +rtc_update_irq (rtc_data->rtc,1 ,RTC_IRQF |RTC_AF );/* * Acknowledge and disable the alarm. Note: WTAF Signature · 1 line
2.6.3
Re: [PATCH 7/8] rtc-ab-b5ze-s3: Delete an unnecessary variable in _abb5zes3_rtc_interrupt()
Quoted 5 lines
Quoted 3 lines
Pass the address of the data structure element "time" directly in calls of the function "
rtc_update_irq" instead of an extra initialisation for one local variable at the beginning.Why is it better?
I suggest to refer to the data item "rtc_data->rtc" directly because the variable "rtc" was read only in two if branches.
Does it make sense then to reduce the variable allocation?
Regards,
Markus
Re: [PATCH 7/8] rtc-ab-b5ze-s3: Delete an unnecessary variable in _abb5zes3_rtc_interrupt()
Quoted 9 lines · SF Markus Elfring
Quoted 5 lines
Quoted 3 lines
Pass the address of the data structure element "time" directly in calls of the function "
rtc_update_irq" instead of an extra initialisation for one local variable at the beginning.Why is it better?
I suggest to refer to the data item "
rtc_data->rtc" directly because the variable "rtc" was read only in two if branches.
Does it make sense then to reduce the variable allocation?
No. That is the job of the compiler. For a local variable whose address is never taken, the compiler can easily detect its live region, and place the initialization in an optimal way.
julia
Re: [PATCH 7/8] rtc-ab-b5ze-s3: Delete an unnecessary variable in _abb5zes3_rtc_interrupt()
In reply to SF Markus ElfringQuoted 6 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 3 Jan 2016 09:00:30 +0100Pass the address of the data structure element "time" directly in calls of the function "
rtc_update_irq" instead of an extra initialisation for one local variable at the beginning.
Also, I don't see anything related to time in this patch.
julia
Quoted 42 lines
Signed-off-by Markus Elfring <[email protected]>--- drivers/rtc/rtc-ab-b5ze-s3.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)drivers/rtc/rtc-ab-b5ze-s3.c +2
-5@@ -816,7 +816,6 @@ static irqreturn_t _abb5zes3_rtc_interrupt(int irq, void *data)struct i2c_client *client = data;struct device *dev = &client->dev;struct abb5zes3_rtc_data *rtc_data =dev_get_drvdata (dev); -struct rtc_device *rtc = rtc_data->rtc;u8 regs[ABB5ZES3_CTRL_SEC_LEN ];int ret, handled =IRQ_NONE ;@@ -844,8 +843,7 @@ static irqreturn_t _abb5zes3_rtc_interrupt(int irq, void *data)/* Check alarm flag */ if (regs[ABB5ZES3_REG_CTRL2 ] &ABB5ZES3_REG_CTRL2_AF ) {dev_dbg (dev,"RTC alarm!\n" ); - -rtc_update_irq (rtc,1 ,RTC_IRQF |RTC_AF ); +rtc_update_irq (rtc_data->rtc,1 ,RTC_IRQF |RTC_AF );/* Acknowledge and disable the alarm */ _abb5zes3_rtc_clear_alarm (dev);@@ -857,8 +855,7 @@ static irqreturn_t _abb5zes3_rtc_interrupt(int irq, void *data)/* Check watchdog Timer A flag */ if (regs[ABB5ZES3_REG_CTRL2 ] &ABB5ZES3_REG_CTRL2_WTAF ) {dev_dbg (dev,"RTC timer!\n" ); - -rtc_update_irq (rtc,1 ,RTC_IRQF |RTC_AF ); +rtc_update_irq (rtc_data->rtc,1 ,RTC_IRQF |RTC_AF );/* * Acknowledge and disable the alarm. Note: WTAF Signature · 1 line
2.6.3
Re: [PATCH 7/8] rtc-ab-b5ze-s3: Delete an unnecessary variable in _abb5zes3_rtc_interrupt()
Quoted 5 lines
Quoted 3 lines
Pass the address of the data structure element "time" directly in calls of the function "
rtc_update_irq" instead of an extra initialisation for one local variable at the beginning.Also, I don't see anything related to time in this patch.
I should have referred to the data structure element "rtc" here. Should I resend this patch series with a corrected commit message now?
Regards,
Markus
PATCH 8/8 rtc-ab-b5ze-s3: Delete an unnecessary variable in _abb5zes3_rtc_set_timer()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 3 Jan 2016 09:19:32 +0100
Pass a value directly in a call of the function "regmap_update_bits" instead of an extra initialisation for one local variable at the beginning.
--- drivers/rtc/rtc-ab-b5ze-s3.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/rtc/rtc-ab-b5ze-s3.c +3 -2
@@ -561,7 +561,6 @@ static int _abb5zes3_rtc_set_timer(struct device *dev, struct rtc_wkalrm *alarm, {struct abb5zes3_rtc_data *data =dev_get_drvdata (dev);u8 regs[ABB5ZES3_TIMA_SEC_LEN ]; -u8 mask =ABB5ZES3_REG_TIM_CLK_TAC0 |ABB5ZES3_REG_TIM_CLK_TAC1 ;int ret;/* Program given number of seconds to Timer A registers */
@@ -575,7 +574,9 @@ static int _abb5zes3_rtc_set_timer(struct device *dev, struct rtc_wkalrm *alarm,/* Configure Timer A as a watchdog timer */ ret =regmap_update_bits (data->regmap,ABB5ZES3_REG_TIM_CLK , - mask,ABB5ZES3_REG_TIM_CLK_TAC1 ); +ABB5ZES3_REG_TIM_CLK_TAC0 + |ABB5ZES3_REG_TIM_CLK_TAC1 , +ABB5ZES3_REG_TIM_CLK_TAC1 );if (ret)dev_err (dev,"%s: failed to update timer\n" , __func__);
Signature · 1 line
2.6.3
Re: [PATCH 8/8] rtc-ab-b5ze-s3: Delete an unnecessary variable in _abb5zes3_rtc_set_timer()
Quoted 24 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 3 Jan 2016 09:19:32 +0100Pass a value directly in a call of the function "
regmap_update_bits" instead of an extra initialisation for one local variable at the beginning.Signed-off-by Markus Elfring <[email protected]>--- drivers/rtc/rtc-ab-b5ze-s3.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/rtc/rtc-ab-b5ze-s3.c +0
-1@@ -561,7 +561,6 @@ static int _abb5zes3_rtc_set_timer(struct device *dev, struct rtc_wkalrm *alarm, {struct abb5zes3_rtc_data *data =dev_get_drvdata (dev);u8 regs[ABB5ZES3_TIMA_SEC_LEN ]; -u8 mask =ABB5ZES3_REG_TIM_CLK_TAC0 |ABB5ZES3_REG_TIM_CLK_TAC1 ;int ret;/* Program given number of seconds to Timer A registers */
drivers/rtc/rtc-ab-b5ze-s3.c static int _abb5zes3_rtc_set_timer(struct device *dev, struct rtc_wkalrm *alarm, · line 579
Quoted 7 lines
drivers/rtc/rtc-ab-b5ze-s3.c +3
-1@@ -575,7 +574,9 @@ static int _abb5zes3_rtc_set_timer(struct device *dev, struct rtc_wkalrm *alarm,/* Configure Timer A as a watchdog timer */ ret =regmap_update_bits (data->regmap,ABB5ZES3_REG_TIM_CLK , - mask,ABB5ZES3_REG_TIM_CLK_TAC1 ); +ABB5ZES3_REG_TIM_CLK_TAC0 + |ABB5ZES3_REG_TIM_CLK_TAC1 , +ABB5ZES3_REG_TIM_CLK_TAC1 );
This doesn't seem like an improvement. The concept (mask) has disappeared, the binary operation is strangely broken, and the function call has one more line of arguments, which all look sort of the same and thus are hard to understand.
Don't underestimate the value of naming things.
julia
Quoted 11 lines
drivers/rtc/rtc-ab-b5ze-s3.c +0
-0if (ret)dev_err (dev,"%s: failed to update timer\n" , __func__);Signature · 6 lines
2.6.3 -- 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 8/8] rtc-ab-b5ze-s3: Delete an unnecessary variable in _abb5zes3_rtc_set_timer()
Quoted 7 lines
drivers/rtc/rtc-ab-b5ze-s3.c static int _abb5zes3_rtc_set_timer(struct device *dev, struct rtc_wkalrm *alarm, · line 579
Quoted 5 lines
drivers/rtc/rtc-ab-b5ze-s3.c +3
-1ret =regmap_update_bits (data->regmap,ABB5ZES3_REG_TIM_CLK , - mask,ABB5ZES3_REG_TIM_CLK_TAC1 ); +ABB5ZES3_REG_TIM_CLK_TAC0 + |ABB5ZES3_REG_TIM_CLK_TAC1 , +ABB5ZES3_REG_TIM_CLK_TAC1 );This doesn't seem like an improvement.
Interesting …
Quoted 1 line
The concept (mask) has disappeared,
I suggest to drop another local variable.
Can the operator "Bitwise OR" be sufficient to indicate the concept "mask"?
Quoted 1 line
the binary operation is strangely broken,
Do you prefer an other source code formatting within the usual line length range?
Quoted 1 line
and the function call has one more line of arguments,
How should several long preprocessor symbols be combined together with indentation so that they will fit into the limit of 80 characters?
Quoted 1 line
which all look sort of the same and thus are hard to understand.
Is this an usual consequence from an ordinary name pattern?
Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 8/8] rtc-ab-b5ze-s3: Delete an unnecessary variable in _abb5zes3_rtc_set_timer()
Quoted 24 lines · SF Markus Elfring
Quoted 7 lines
drivers/rtc/rtc-ab-b5ze-s3.c static int _abb5zes3_rtc_set_timer(struct device *dev, struct rtc_wkalrm *alarm, · line 579
Quoted 5 lines
drivers/rtc/rtc-ab-b5ze-s3.c +3
-1ret =regmap_update_bits (data->regmap,ABB5ZES3_REG_TIM_CLK , - mask,ABB5ZES3_REG_TIM_CLK_TAC1 ); +ABB5ZES3_REG_TIM_CLK_TAC0 + |ABB5ZES3_REG_TIM_CLK_TAC1 , +ABB5ZES3_REG_TIM_CLK_TAC1 );This doesn't seem like an improvement.
Interesting …
Quoted 1 line
The concept (mask) has disappeared,
I suggest to drop another local variable.
Can the operator "Bitwise OR" be sufficient to indicate the concept "mask"?Quoted 1 line
the binary operation is strangely broken,
Do you prefer an other source code formatting within the usual line length range?
Quoted 1 line
and the function call has one more line of arguments,
Quoted 7 lines
How should several long preprocessor symbols be combined together with indentation so that they will fit into the limit of 80 characters?
Quoted 1 line
which all look sort of the same and thus are hard to understand.
Is this an usual consequence from an ordinary name pattern?
The original code was better. No 80 character problem, easy to distinguish one argument from another, moderately meaningful variable name, etc.
julia
cover 390/qeth: Fine-tuning for qeth_core_set_online()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 3 Jan 2016 10:56:45 +0100
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (2):
Delete an unnecessary variable initialisation
Refactoring
drivers/s390/net/qeth_core_main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
Signature · 1 line
2.6.3
PATCH 1/2 390/qeth: Delete an unnecessary variable initialisation in qeth_core_set_online()
From: Markus Elfring <[email protected]>
Date: Sun, 3 Jan 2016 10:48:05 +0100
Omit explicit initialisation at the beginning for one local variable that is redefined before its first use.
--- drivers/s390/net/qeth_core_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/s390/net/qeth_core_main.c +1 -1
@@ -5637,7 +5637,7 @@ static void qeth_core_remove_device(struct ccwgroup_device *gdev)static int qeth_core_set_online (struct ccwgroup_device *gdev) {struct qeth_card *card =dev_get_drvdata (&gdev->dev); -int rc =0 ; +int rc;int def_discipline;if (!card->discipline) {
Signature · 1 line
2.6.3
Re: [PATCH 1/2] 390/qeth: Delete an unnecessary variable initialisation in qeth_core_set_online()
Quoted 16 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 3 Jan 2016 10:48:05 +0100Omit explicit initialisation at the beginning for one local variable that is redefined before its first use.
Signed-off-by Markus Elfring <[email protected]>--- drivers/s390/net/qeth_core_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/s390/net/qeth_core_main.c +0
-0
drivers/s390/net/qeth_core_main.c static void qeth_core_remove_device(struct ccwgroup_device *gdev) · line 5641
Quoted 6 lines
drivers/s390/net/qeth_core_main.c +1
-1@@ -5637,7 +5637,7 @@ static void qeth_core_remove_device(struct ccwgroup_device *gdev)static int qeth_core_set_online (struct ccwgroup_device *gdev) {struct qeth_card *card =dev_get_drvdata (&gdev->dev); -int rc =0 ; +int rc;int def_discipline;
You can generate hundreds of patches like this one. There are even plenty more opportunities within this same file. I don't think we need this.
If at all then change all occurrences within a file at once, but that is Ursula's call.
Re: [PATCH 1/2] 390/qeth: Delete an unnecessary variable initialisation in qeth_core_set_online()
In reply to SF Markus ElfringQuoted 16 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 3 Jan 2016 10:48:05 +0100Omit explicit initialisation at the beginning for one local variable that is redefined before its first use.
Signed-off-by Markus Elfring <[email protected]>--- drivers/s390/net/qeth_core_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/s390/net/qeth_core_main.c +0
-0
drivers/s390/net/qeth_core_main.c static void qeth_core_remove_device(struct ccwgroup_device *gdev) · line 5643
Quoted 8 lines
drivers/s390/net/qeth_core_main.c +1
-1@@ -5637,7 +5637,7 @@ static void qeth_core_remove_device(struct ccwgroup_device *gdev)static int qeth_core_set_online (struct ccwgroup_device *gdev) {struct qeth_card *card =dev_get_drvdata (&gdev->dev); -int rc =0 ; +int rc;int def_discipline;if (!card->discipline) {
As Heiko already answered, you could propose a lot of this kind of changes with just minor benefit. I do not want to push them in single patches. Either there is a cleanup patch for explicit initialisation of local variables in the whole qeth driver, or we take care about such minor changes, once we touch the code anyway due to other reasons.
Re: 390/qeth: Delete an unnecessary variable initialisation in qeth_core_set_online()
Quoted 2 lines
As Heiko already answered, you could propose a lot of this kind of changes with just minor benefit. I do not want to push them in single patches.
Thanks for your clarification.
Quoted 2 lines
Either there is a cleanup patch for explicit initialisation of local variables in the whole qeth driver,
Is there any more fine-tuning cooking in the background?
Quoted 1 line
or we take care about such minor changes, once we touch the code anyway
How often will this really happen?
Quoted 1 line
due to other reasons.
I am curious which ones will trigger further related software improvements.
Regards,
Markus
Re: 390/qeth: Delete an unnecessary variable initialisation in qeth_core_set_online()
Quoted 10 lines · SF Markus Elfring
Quoted 2 lines
As Heiko already answered, you could propose a lot of this kind of changes with just minor benefit. I do not want to push them in single patches.
Thanks for your clarification.
Quoted 2 lines
Either there is a cleanup patch for explicit initialisation of local variables in the whole qeth driver,
Is there any more fine-tuning cooking in the background?
Not yet; qeth is an important driver for Linux on System z; there are lots of investigation ideas for improvements, which we will take care about according to their priorities. I regard your proposed fine-tuning code change as valid, but prioritize it as one with lowest benefit, since it does not really make a difference once compiled.
Quoted 5 lines
Quoted 3 lines
or we take care about such minor changes, once we touch the code anyway
How often will this really happen?
There is no general rule. Check our git history to answer this question.
Quoted 9 lines
Quoted 3 lines
due to other reasons.
I am curious which ones will trigger further related software improvements.
Regards,
Markus
Re: 390/qeth: Delete an unnecessary variable initialisation in qeth_core_set_online()
Quoted 2 lines
Quoted 1 line
Is there any more fine-tuning cooking in the background?
Not yet;
I am a bit surprised by this information.
Quoted 1 line
qeth is an important driver for Linux on System z;
Good to know …
Quoted 2 lines
there are lots of investigation ideas for improvements, which we will take care about according to their priorities.
Software development as usual …
Quoted 1 line
I regard your proposed fine-tuning code change as valid,
Thanks for a bit of positive feedback.
Quoted 1 line
but prioritize it as one with lowest benefit,
This is fine in principle.
Quoted 1 line
since it does not really make a difference once compiled.
Would you like to help in the determination if deletion of unnecessary variable initialisations (besides in the implementation of the function "qeth_core_set_online") will result in measurable effects?
Regards,
Markus
PATCH 2/2 390/qeth: Refactoring for qeth_core_set_online()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 3 Jan 2016 10:50:11 +0100
Reduce the scope for the local variable "def_discipline" to one branch of an if statement.
--- drivers/s390/net/qeth_core_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/s390/net/qeth_core_main.c +2 -1
@@ -5638,9 +5638,10 @@ static int qeth_core_set_online(struct ccwgroup_device *gdev) {struct qeth_card *card =dev_get_drvdata (&gdev->dev);int rc; -int def_discipline;if (!card->discipline) { +int def_discipline; +if (card->info.type =QETH_CARD_TYPE_IQD ) def_discipline =QETH_DISCIPLINE_LAYER3 ;else
Signature · 1 line
2.6.3
Re: [PATCH 2/2] 390/qeth: Refactoring for qeth_core_set_online()
Quoted 16 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 3 Jan 2016 10:50:11 +0100Reduce the scope for the local variable "
def_discipline" to one branch of an if statement.Signed-off-by Markus Elfring <[email protected]>--- drivers/s390/net/qeth_core_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/s390/net/qeth_core_main.c +0
-0
drivers/s390/net/qeth_core_main.c static int qeth_core_set_online(struct ccwgroup_device *gdev) · line 5646
Quoted 10 lines
drivers/s390/net/qeth_core_main.c +2
-1@@ -5638,9 +5638,10 @@ static int qeth_core_set_online(struct ccwgroup_device *gdev) {struct qeth_card *card =dev_get_drvdata (&gdev->dev);int rc; -int def_discipline;if (!card->discipline) { +int def_discipline; +if (card->info.type =QETH_CARD_TYPE_IQD ) def_discipline =QETH_DISCIPLINE_LAYER3 ;
Same here: I don't think we want to start with patches like this. This going to be a never ending story without much benefit.
Re: [PATCH 2/2] 390/qeth: Refactoring for qeth_core_set_online()
Quoted 7 lines
Quoted 7 lines
+++
b/drivers/s390/net/qeth_core_main.cdrivers/s390/net/qeth_core_main.c +0
-1@@ -5638,9 +5638,10 @@ static int qeth_core_set_online(struct ccwgroup_device *gdev) {struct qeth_card *card =dev_get_drvdata (&gdev->dev);int rc; -int def_discipline;
Quoted 7 lines
drivers/s390/net/qeth_core_main.c static int qeth_core_set_online(struct ccwgroup_device *gdev) · line 5646
Quoted 5 lines
drivers/s390/net/qeth_core_main.c +2
-0if (!card->discipline) { +int def_discipline; +if (card->info.type =QETH_CARD_TYPE_IQD ) def_discipline =QETH_DISCIPLINE_LAYER3 ;Same here: I don't think we want to start with patches like this.
Thanks for your feedback.
Quoted 1 line
This going to be a never ending story without much benefit.
Is the source code a bit clearer and safer if it will be expressed directly that the use of a specific variable is not intended for a complete function implementation but for the smaller scope of an if branch?
Regards,
Markus
Re: [PATCH 2/2] 390/qeth: Refactoring for qeth_core_set_online()
Quoted 18 lines · SF Markus Elfring
Quoted 7 lines
Quoted 7 lines
+++
b/drivers/s390/net/qeth_core_main.cdrivers/s390/net/qeth_core_main.c +0
-1@@ -5638,9 +5638,10 @@ static int qeth_core_set_online(struct ccwgroup_device *gdev) {struct qeth_card *card =dev_get_drvdata (&gdev->dev);int rc; -int def_discipline;Quoted 7 lines
drivers/s390/net/qeth_core_main.c static int qeth_core_set_online(struct ccwgroup_device *gdev) · line 5646
Quoted 5 lines
drivers/s390/net/qeth_core_main.c +2
-0if (!card->discipline) { +int def_discipline; +if (card->info.type =QETH_CARD_TYPE_IQD ) def_discipline =QETH_DISCIPLINE_LAYER3 ;Same here: I don't think we want to start with patches like this.
Thanks for your feedback.
Quoted 6 lines
Quoted 1 line
This going to be a never ending story without much benefit.
Is the source code a bit clearer and safer if it will be expressed directly that the use of a specific variable is not intended for a complete function implementation but for the smaller scope of an if branch?
This depends on the function and what the author prefers. In this case the function body is very small so I don't see any benefit at all.
Re: 390/qeth: Refactoring for qeth_core_set_online()
Quoted 2 lines
In this case the function body is very small
so I don't see any benefit at all.
Do you care for fine-tuning of variable placement occasionally?
Regards,
Markus
Re: 390/qeth: Refactoring for qeth_core_set_online()
Quoted 4 lines · SF Markus Elfring
Quoted 2 lines
In this case the function body is very small
so I don't see any benefit at all.Do you care for fine-tuning of variable placement occasionally?
No.
PATCH 1/1 staging-slicoss: Replace variable initialisations by assignments in slic_if_init()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 3 Jan 2016 17:25:59 +0100
Replace explicit initialisation for two local variables at the beginning by assignments.
--- drivers/staging/slicoss/slicoss.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/staging/slicoss/slicoss.c +4 -2
@@ -2301,9 +2301,9 @@ static int slic_adapter_allocresources(struct adapter *adapter,*/ static int slic_if_init (struct adapter *adapter,unsigned long *flags) { -struct sliccard *card = adapter->card; +struct sliccard *card;struct net_device *dev = adapter->netdev; -__iomem struct slic_regs *slic_regs = adapter->slic_regs; +__iomem struct slic_regs *slic_regs;struct slic_shmem *pshmem;int rc;
@@ -2348,6 +2348,7 @@ static int slic_if_init(struct adapter *adapter, unsigned long *flags) adapter->queues_initialized =1 ; } + slic_regs = adapter->slic_regs;slic_reg32_write (&slic_regs->slic_icr,ICR_INT_OFF ,FLUSH );mdelay (1 );
@@ -2374,6 +2375,7 @@ static int slic_if_init(struct adapter *adapter, unsigned long *flags) } adapter->state =ADAPT_UP ; + card = adapter->card;if (!card->loadtimerset) {setup_timer (&card->loadtimer, &slic_timer_load_check, (ulong )card);
Signature · 1 line
2.6.3
Re: [PATCH] staging-slicoss: Replace variable initialisations by assignments in slic_if_init()
Quoted 5 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 3 Jan 2016 17:25:59 +0100Replace explicit initialisation for two local variables at the beginning by assignments.
Why?
julia
Quoted 45 lines
Signed-off-by Markus Elfring <[email protected]>--- drivers/staging/slicoss/slicoss.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/staging/slicoss/slicoss.c +4
-2@@ -2301,9 +2301,9 @@ static int slic_adapter_allocresources(struct adapter *adapter,*/ static int slic_if_init (struct adapter *adapter,unsigned long *flags) { -struct sliccard *card = adapter->card; +struct sliccard *card;struct net_device *dev = adapter->netdev; -__iomem struct slic_regs *slic_regs = adapter->slic_regs; +__iomem struct slic_regs *slic_regs;struct slic_shmem *pshmem;int rc;@@ -2348,6 +2348,7 @@ static int slic_if_init(struct adapter *adapter, unsigned long *flags) adapter->queues_initialized =1 ; } + slic_regs = adapter->slic_regs;slic_reg32_write (&slic_regs->slic_icr,ICR_INT_OFF ,FLUSH );mdelay (1 );@@ -2374,6 +2375,7 @@ static int slic_if_init(struct adapter *adapter, unsigned long *flags) } adapter->state =ADAPT_UP ; + card = adapter->card;if (!card->loadtimerset) {setup_timer (&card->loadtimer, &slic_timer_load_check, (ulong )card);Signature · 6 lines
2.6.3 -- 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] staging-slicoss: Replace variable initialisations by assignments in slic_if_init()
Quoted 4 lines
Quoted 2 lines
Replace explicit initialisation for two local variables at the beginning by assignments.
Why?
I prefer that assignments for variables like "card" and "slic_regs" will only be performed immediately before the corresponding content will be read again (after a few condition checks were executed).
Another description could be this view:
I suggest to move the variable initialisation a bit.
Regards,
Markus
Greg Kroah-Hartman
maintainerRe: [PATCH] staging-slicoss: Replace variable initialisations by assignments in slic_if_init()
Quoted 11 lines · SF Markus Elfring
Quoted 4 lines
Quoted 2 lines
Replace explicit initialisation for two local variables at the beginning by assignments.
Why?
I prefer that assignments for variables like "card" and "
slic_regs" will only be performed immediately before the corresponding content will be read again (after a few condition checks were executed).Another description could be this view:
I suggest to move the variable initialisation a bit.
And like David Miller and others just said, please don't bother us with pointless patches such as this, if you keep it up, I'll have to add you to my killfile as patches like this are a waste of everyone's valuable time.
greg k-h
Re: [PATCH] staging-slicoss: Replace variable initialisations by assignments in slic_if_init()
Quoted 10 lines
Quoted 6 lines
I prefer that assignments for variables like "card" and "
slic_regs" will only be performed immediately before the corresponding content will be read again (after a few condition checks were executed).Another description could be this view:
I suggest to move the variable initialisation a bit.And like David Miller and others just said, please don't bother us with pointless patches such as this, if you keep it up, I'll have to add you to my killfile as patches like this are a waste of everyone's valuable time.
I am a bit surprised that you do not like such source code fine-tuning. Will related software improvements get another chance later (eventually together with other changes)?
Regards,
Markus
Greg Kroah-Hartman
maintainerRe: [PATCH] staging-slicoss: Replace variable initialisations by assignments in slic_if_init()
Quoted 4 lines · SF Markus Elfring
Quoted 4 lines
Quoted 4 lines
I prefer that assignments for variables like "card" and "
slic_regs" will only be performed immediately before the corresponding content will be read again (after a few condition checks were executed).
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Another description could be this view:
I suggest to move the variable initialisation a bit.And like David Miller and others just said, please don't bother us with pointless patches such as this, if you keep it up, I'll have to add you to my killfile as patches like this are a waste of everyone's valuable time.
I am a bit surprised that you do not like such source code fine-tuning.
It's moving stuff around for no real reason, why would I like it? Reading and reviewing and applying this type of stuff takes away from the time I have to spend reviewing and applying actual code fixes from other developers who are doing real and useful work.
Remember maintainer's time is our most limited resource right now. You are abusing that by wasting their time for no valid reason.
Quoted 2 lines
Will related software improvements get another chance later (eventually together with other changes)?
Define "improvements". Did you fix an obvious bug? Did you speed up the code in a measurable way? Did you make the code easier to understand somehow? For this patch you did none of these things.
Code in staging needs to be moved out of staging, and this patch does nothing toward achieving that goal and it wastes people's time reviewing it to see if it is correct or not. Please stop or again, you will end up in some killfiles, if you haven't already been placed there.
thanks,
greg k-h
Re: [PATCH] staging-slicoss: Replace variable initialisations by assignments in slic_if_init()
Quoted 3 lines
Quoted 1 line
I am a bit surprised that you do not like such source code fine-tuning.
It's moving stuff around for no real reason, why would I like it?
Can such fine-tuning result in positive effects for the run-time behaviour?
Quoted 3 lines
Reading and reviewing and applying this type of stuff takes away from the time I have to spend reviewing and applying actual code fixes from other developers who are doing real and useful work.
I am aware that a lot of open issues are competing for your precious software development attention.
Quoted 1 line
Remember maintainer's time is our most limited resource right now.
That is mostly usual.
Quoted 1 line
You are abusing that by wasting their time for no valid reason.
I find a couple of my update suggestions still valid. I agree that the importance of proposed changes is varying.
Quoted 4 lines
Quoted 2 lines
Will related software improvements get another chance later (eventually together with other changes)?
Define "improvements". Did you fix an obvious bug?
Maybe. - It depends on the error classes you are interested in at the moment.
Quoted 1 line
Did you speed up the code in a measurable way?
My suggestions can result in measurable differences.
Quoted 2 lines
Did you make the code easier to understand somehow? For this patch you did none of these things.
Thanks for your view on my approach.
Will it become acceptable to reduce the scope for any more variable definitions in further function implementations?
Quoted 3 lines
Code in staging needs to be moved out of staging, and this patch does nothing toward achieving that goal and it wastes people's time reviewing it to see if it is correct or not.
I am curious on the ways the discussed software can evolve further.
Regards,
Markus
Greg Kroah-Hartman
maintainerRe: [PATCH] staging-slicoss: Replace variable initialisations by assignments in slic_if_init()
Quoted 5 lines · SF Markus Elfring
Quoted 3 lines
Quoted 1 line
I am a bit surprised that you do not like such source code fine-tuning.
It's moving stuff around for no real reason, why would I like it?
Can such fine-tuning result in positive effects for the run-time behaviour?
If you can not benchmark and show the proof, don't even start to claim such a thing.
Quoted 3 lines
Quoted 1 line
Did you speed up the code in a measurable way?
My suggestions can result in measurable differences.
Show the proof please. That's the only way I will ever accept anything else from you like this.
Quoted 2 lines
Will it become acceptable to reduce the scope for any more variable definitions in further function implementations?
No.
Quoted 5 lines
Quoted 3 lines
Code in staging needs to be moved out of staging, and this patch does nothing toward achieving that goal and it wastes people's time reviewing it to see if it is correct or not.
I am curious on the ways the discussed software can evolve further.
That's nice, but that's not my concern.
greg k-h
Re: staging-slicoss: Replace variable initialisations by assignments in slic_if_init()
Quoted 4 lines
Quoted 1 line
Can such fine-tuning result in positive effects for the run-time behaviour?
If you can not benchmark and show the proof, don't even start to claim such a thing.
Which measurement results would you accept for further discussion?
Quoted 3 lines
Quoted 1 line
My suggestions can result in measurable differences.
Show the proof please.
Which information presentations would finally qualify for "the proof" you request now?
Which test systems will be representative for you?
Quoted 1 line
That's the only way I will ever accept anything else from you like this.
Are there any update suggestions remaining in the waiting queue which have a higher chance of acceptance because their value might be a bit more obvious?
Regards,
Markus
Greg Kroah-Hartman
maintainerRe: staging-slicoss: Replace variable initialisations by assignments in slic_if_init()
Quoted 6 lines · SF Markus Elfring
Quoted 4 lines
Quoted 1 line
Can such fine-tuning result in positive effects for the run-time behaviour?
If you can not benchmark and show the proof, don't even start to claim such a thing.
Which measurement results would you accept for further discussion?
If you don't know how to show your results, then this whole discussion is pointless.
*plonk*
Re: staging-slicoss: Replace variable initialisations by assignments in slic_if_init()
Quoted 4 lines
Quoted 1 line
Which measurement results would you accept for further discussion?
If you don't know how to show your results, then this whole discussion is pointless.
I could show test results. But it could happen that I would choose insufficient variations for execution environments.
I am unsure about the requested detail and size around test parameters.
Regards,
Markus
cover Input-at32psif: Fine-tuning for OOM handling in psif_probe()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 2 Jul 2016 20:50:09 +0200
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (2):
Return directly after a failed kzalloc()
Remove two OOM messages
drivers/input/serio/at32psif.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
Signature · 1 line
2.9.0
PATCH 1/2 Input-at32psif: Return directly after a failed kzalloc() in psif_probe()
From: Markus Elfring <[email protected]>
Date: Sat, 2 Jul 2016 18:34:43 +0200
Return directly after a memory allocation failed at the beginning.
This issue was detected by using the Coccinelle software.
--- drivers/input/serio/at32psif.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/input/serio/at32psif.c +1 -3
@@ -212,8 +212,7 @@ static int __init psif_probe(struct platform_device *pdev) psif =kzalloc (sizeof (struct psif ),GFP_KERNEL );if (!psif) {dev_dbg (&pdev->dev,"out of memory\n" ); - ret = -ENOMEM ; - goto out; +return -ENOMEM ; } psif->pdev = pdev;
@@ -297,7 +296,6 @@ out_free_io:kfree (io); out_free_psif:kfree (psif); -out:return ret; }
Signature · 1 line
2.9.0
PATCH 2/2 Input-at32psif: Remove OOM messages in psif_probe()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 2 Jul 2016 20:34:18 +0200
Delete two debug messages because Linux will usually provide an appropriate information for a memory allocation failure.
--- drivers/input/serio/at32psif.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/input/serio/at32psif.c +2 -4
@@ -210,15 +210,13 @@ static int __init psif_probe(struct platform_device *pdev)int ret; psif =kzalloc (sizeof (struct psif ),GFP_KERNEL ); -if (!psif) { -dev_dbg (&pdev->dev,"out of memory\n" ); +if (!psif)return -ENOMEM ; - } + psif->pdev = pdev; io =kzalloc (sizeof (struct serio ),GFP_KERNEL );if (!io) { -dev_dbg (&pdev->dev,"out of memory\n" ); ret = -ENOMEM ; goto out_free_psif; }
Signature · 1 line
2.9.0
Re: [PATCH 2/2] Input-at32psif: Remove OOM messages in psif_probe()
Quoted 16 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 2 Jul 2016 20:34:18 +0200Delete two debug messages because Linux will usually provide an appropriate information for a memory allocation failure.
Signed-off-by Markus Elfring <[email protected]>--- drivers/input/serio/at32psif.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)drivers/input/serio/at32psif.c +0
-0
drivers/input/serio/at32psif.c static int __init psif_probe(struct platform_device *pdev) · line 215
Quoted 9 lines
drivers/input/serio/at32psif.c +2
-3@@ -210,15 +210,13 @@ static int __init psif_probe(struct platform_device *pdev)int ret; psif =kzalloc (sizeof (struct psif ),GFP_KERNEL ); -if (!psif) { -dev_dbg (&pdev->dev,"out of memory\n" ); +if (!psif)return -ENOMEM ; - } +
Why add a blank line here?
Quoted 12 lines
drivers/input/serio/at32psif.c +0
-1psif->pdev = pdev; io =kzalloc (sizeof (struct serio ),GFP_KERNEL );if (!io) { -dev_dbg (&pdev->dev,"out of memory\n" ); ret = -ENOMEM ; goto out_free_psif; }Signature · 1 line
2.9.0
Joe Perches
maintainerRe: [PATCH 0/2] Input-at32psif: Fine-tuning for OOM handling in psif_probe()
In reply to SF Markus ElfringQuoted 6 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 2 Jul 2016 20:50:09 +0200A few update suggestions were taken into account
from static source code analysis.
Quoted 6 lines
Markus Elfring (2):
Return directly after a failedkzalloc()
Remove two OOM messagesdrivers/input/serio/at32psif.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
What possible rationale is there for including this "references" header? [email protected]
This message id is for your message:
"Source code review around jump label usage"
sent December 11, 2015!
Please stop adding unnecessary and useless email headers.
--
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 0/2] Input-at32psif: Fine-tuning for OOM handling in psif_probe()
Quoted 7 lines
Quoted 7 lines
A few update suggestions were taken into account
from static source code analysis.Markus Elfring (2):
Return directly after a failedkzalloc()
Remove two OOM messages
Quoted 5 lines
Quoted 2 lines
drivers/input/serio/at32psif.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)What possible rationale is there for including this "references" header? [email protected]
Do any more software developers dare to reconsider source code also around a jump label like "out"?
Quoted 3 lines
This message id is for your message:
"Source code review around jump label usage"
sent December 11, 2015!
Can such an association with a bit of background information be occasionally useful for clarification of corresponding implementation details?
Regards,
Markus
Dmitry Torokhov
maintainerRe: [PATCH 0/2] Input-at32psif: Fine-tuning for OOM handling in psif_probe()
In reply to SF Markus ElfringQuoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 2 Jul 2016 20:50:09 +0200A few update suggestions were taken into account
from static source code analysis.Markus Elfring (2):
Return directly after a failedkzalloc()
Remove two OOM messages
I do not see a compelling reason for taking these...
Thanks.
Signature · 1 line
Dmitry
cover block-cciss: Fine-tuning for two function implementations
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 18 Aug 2016 11:40:04 +0200
Some update suggestions were taken into account
from static source code analysis.
Markus Elfring (5):
Use memdup_user()
Less function calls after error detection
Delete unnecessary initialisations
Move an assignment for the variable "sg_used"
Replace three kzalloc() calls by kcalloc()
drivers/block/cciss.c | 66 ++++++++++++++++++++++++--------------------------- 1 file changed, 31 insertions(+), 35 deletions(-)
Signature · 1 line
2.9.3
PATCH 1/5 block-cciss: Use memdup_user() rather than duplicating its implementation
From: Markus Elfring <[email protected]>
Date: Wed, 17 Aug 2016 22:10:29 +0200
* Reuse existing functionality from memdup_user() instead of keeping duplicate source code.
This issue was detected by using the Coccinelle software.
* Return directly if this copy operation failed.
--- drivers/block/cciss.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/block/cciss.c +3 -9
@@ -1587,15 +1587,9 @@ static int cciss_bigpassthru(ctlr_info_t *h, void __user *argp)return -EINVAL ;if (!capable (CAP_SYS_RAWIO ))return -EPERM ; - ioc =kmalloc (sizeof (*ioc),GFP_KERNEL ); -if (!ioc) { - status = -ENOMEM ; - goto cleanup1; - } -if (copy_from_user (ioc, argp,sizeof (*ioc))) { - status = -EFAULT ; - goto cleanup1; - } + ioc =memdup_user (argp,sizeof (*ioc)); +if (IS_ERR (ioc)) +return PTR_ERR (ioc);if ((ioc->buf_size <1 ) && (ioc->Request.Type.Direction !=XFER_NONE )) { status = -EINVAL ;
Signature · 1 line
2.9.3
PATCH 2/5 block-cciss: Less function calls in cciss_bigpassthru() after error detection
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 17 Aug 2016 22:39:31 +0200
The kfree() function was called in a few cases by the cciss_bigpassthru() function during error handling even if a passed variable contained a null pointer.
Adjust jump targets according to the Linux coding style convention.
--- drivers/block/cciss.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-)
drivers/block/cciss.c +20 -20
@@ -1593,26 +1593,26 @@ static int cciss_bigpassthru(ctlr_info_t *h, void __user *argp)if ((ioc->buf_size <1 ) && (ioc->Request.Type.Direction !=XFER_NONE )) { status = -EINVAL ; - goto cleanup1; + goto free_ioc; }/* Check kmalloc limits using all SGs */ if (ioc->malloc_size >MAX_KMALLOC_SIZE ) { status = -EINVAL ; - goto cleanup1; + goto free_ioc; }if (ioc->buf_size > ioc->malloc_size *MAXSGENTRIES ) { status = -EINVAL ; - goto cleanup1; - } - buff =kzalloc (MAXSGENTRIES *sizeof (char *),GFP_KERNEL ); -if (!buff) { - status = -ENOMEM ; - goto cleanup1; + goto free_ioc; } buff_size =kmalloc (MAXSGENTRIES *sizeof (int ),GFP_KERNEL );if (!buff_size) { status = -ENOMEM ; - goto cleanup1; + goto free_ioc; + } + buff =kzalloc (MAXSGENTRIES *sizeof (char *),GFP_KERNEL ); +if (!buff) { + status = -ENOMEM ; + goto free_size; } left = ioc->buf_size; data_ptr = ioc->buf;
@@ -1622,12 +1622,12 @@ static int cciss_bigpassthru(ctlr_info_t *h, void __user *argp) buff[sg_used] =kmalloc (sz,GFP_KERNEL );if (buff[sg_used] =NULL ) { status = -ENOMEM ; - goto cleanup1; + goto free_buffer; }if (ioc->Request.Type.Direction =XFER_WRITE ) {if (copy_from_user (buff[sg_used], data_ptr, sz)) { status = -EFAULT ; - goto cleanup1; + goto free_buffer; } }else {memset (buff[sg_used],0 , sz);
@@ -1639,7 +1639,7 @@ static int cciss_bigpassthru(ctlr_info_t *h, void __user *argp) c =cmd_special_alloc (h);if (!c) { status = -ENOMEM ; - goto cleanup1; + goto free_buffer; } c->cmd_type =CMD_IOCTL_PEND ; c->Header.ReplyQueue =0 ;
@@ -1674,7 +1674,7 @@ static int cciss_bigpassthru(ctlr_info_t *h, void __user *argp)if (copy_to_user (argp, ioc,sizeof (*ioc))) {cmd_special_free (h, c); status = -EFAULT ; - goto cleanup1; + goto free_buffer; }if (ioc->Request.Type.Direction =XFER_READ ) {/* Copy the data out of the buffer we created */
@@ -1683,20 +1683,20 @@ static int cciss_bigpassthru(ctlr_info_t *h, void __user *argp)if (copy_to_user (ptr, buff[i], buff_size[i])) {cmd_special_free (h, c); status = -EFAULT ; - goto cleanup1; + goto free_buffer; } ptr += buff_size[i]; } }cmd_special_free (h, c); status =0 ; -cleanup1: -if (buff) { -for (i =0 ; i < sg_used; i++) -kfree (buff[i]); -kfree (buff); - } +free_buffer: +for (i =0 ; i < sg_used; i++) +kfree (buff[i]); +kfree (buff); +free_size:kfree (buff_size); +free_ioc:kfree (ioc);return status; }
Signature · 1 line
2.9.3
PATCH 3/5 block-cciss: Delete unnecessary initialisations in cciss_bigpassthru()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 17 Aug 2016 22:55:51 +0200
Three local variables will be set to an appropriate value a bit later. Thus omit the explicit initialisation at the beginning.
--- drivers/block/cciss.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/block/cciss.c +3 -3
@@ -1572,11 +1572,11 @@ static int cciss_bigpassthru(ctlr_info_t *h, void __user *argp) {BIG_IOCTL_Command_struct *ioc;CommandList_struct *c; -unsigned char **buff =NULL ; -int *buff_size =NULL ; +unsigned char **buff; +int *buff_size;u64bit temp64;BYTE sg_used =0 ; -int status =0 ; +int status;int i;DECLARE_COMPLETION_ONSTACK (wait);__u32 left;
Signature · 1 line
2.9.3
PATCH 4/5 block-cciss: Move an assignment for the variable "sg_used" in cciss_bigpassthru()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 17 Aug 2016 23:04:46 +0200
Move the assignment for the local variable "sg_used" behind the source code for some memory allocations by this function.
--- drivers/block/cciss.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/block/cciss.c +2 -1
@@ -1575,7 +1575,7 @@ static int cciss_bigpassthru(ctlr_info_t *h, void __user *argp)unsigned char **buff;int *buff_size;u64bit temp64; -BYTE sg_used =0 ; +BYTE sg_used;int status;int i;DECLARE_COMPLETION_ONSTACK (wait);
@@ -1616,6 +1616,7 @@ static int cciss_bigpassthru(ctlr_info_t *h, void __user *argp) } left = ioc->buf_size; data_ptr = ioc->buf; + sg_used =0 ;while (left) { sz = (left > ioc->malloc_size) ? ioc->malloc_size : left; buff_size[sg_used] = sz;
Signature · 1 line
2.9.3
PATCH 5/5 block-cciss: Replace three kzalloc() calls by kcalloc()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 18 Aug 2016 11:26:18 +0200
* The script "checkpatch.pl" can point information out like the following.
WARNING: Prefer kcalloc over kzalloc with multiply
Thus fix the affected source code places.
* Replace the specification of data structures by pointer dereferences to make the corresponding size determination a bit safer according to the Linux coding style convention.
--- drivers/block/cciss.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/block/cciss.c +5 -4
@@ -1604,12 +1604,12 @@ static int cciss_bigpassthru(ctlr_info_t *h, void __user *argp) status = -EINVAL ; goto free_ioc; } - buff_size =kmalloc (MAXSGENTRIES *sizeof (int ),GFP_KERNEL ); + buff_size =kcalloc (MAXSGENTRIES ,sizeof (*buff_size),GFP_KERNEL );if (!buff_size) { status = -ENOMEM ; goto free_ioc; } - buff =kzalloc (MAXSGENTRIES *sizeof (char *),GFP_KERNEL ); + buff =kcalloc (MAXSGENTRIES ,sizeof (*buff),GFP_KERNEL );if (!buff) { status = -ENOMEM ; goto free_size;
@@ -4838,8 +4838,9 @@ static int cciss_allocate_scatterlists(ctlr_info_t *h)int i;/* zero it, so that on free we need not know how many were alloc'ed */ - h->scatter_list =kzalloc (h->max_commands * -sizeof (struct scatterlist *),GFP_KERNEL ); + h->scatter_list =kcalloc (h->max_commands, +sizeof (*h->scatter_list), +GFP_KERNEL );if (!h->scatter_list)return -ENOMEM ;
Signature · 1 line
2.9.3
Re: [PATCH 0/5] block-cciss: Fine-tuning for two function implementations
In reply to SF Markus ElfringQuoted 12 lines
Date: Thu, 18 Aug 2016 11:40:04 +0200
Some update suggestions were taken into account
from static source code analysis.Markus Elfring (5):
Usememdup_user()
Less function calls after error detection
Delete unnecessary initialisations
Move an assignment for the variable "sg_used"
Replace threekzalloc()calls bykcalloc()
Quoted 2 lines
drivers/block/cciss.c | 66 ++++++++++++++++++++++++--------------------------- 1 file changed, 31 insertions(+), 35 deletions(-)
How will the clarification be continued for the shown change possibilities?
Regards,
Markus
cover GPU-DRM-Savage: Fine-tuning for savage_bci_cmdbuf()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 18 Aug 2016 21:38:37 +0200
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (2):
Use memdup_user() rather than duplicating its implementation Less function calls after error detection
drivers/gpu/drm/savage/savage_state.c | 42 +++++++++++++++-------------------- 1 file changed, 18 insertions(+), 24 deletions(-)
Signature · 1 line
2.9.3
PATCH 1/2 GPU-DRM-Savage: Use memdup_user() rather than duplicating
From: Markus Elfring <[email protected]>
Date: Thu, 18 Aug 2016 18:12:03 +0200
Reuse existing functionality from memdup_user() instead of keeping duplicate source code.
This issue was detected by using the Coccinelle software.
--- drivers/gpu/drm/savage/savage_state.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/gpu/drm/savage/savage_state.c +3 -9
@@ -1001,15 +1001,9 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_ cmdbuf->cmd_addr = kcmd_addr; }if (cmdbuf->vb_size) { - kvb_addr =kmalloc (cmdbuf->vb_size,GFP_KERNEL ); -if (kvb_addr =NULL ) { - ret = -ENOMEM ; - goto done; - } - -if (copy_from_user (kvb_addr, cmdbuf->vb_addr, - cmdbuf->vb_size)) { - ret = -EFAULT ; + kvb_addr =memdup_user (cmdbuf->vb_addr, cmdbuf->vb_size); +if (IS_ERR (kvb_addr)) { + ret =PTR_ERR (kvb_addr); goto done; } cmdbuf->vb_addr = kvb_addr;
Signature · 1 line
2.9.3
PATCH 2/2 GPU-DRM-Savage: Less function calls in savage_bci_cmdbuf() after error detection
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 18 Aug 2016 21:28:58 +0200
The kfree() function was called in a few cases by the savage_bci_cmdbuf() function during error handling even if a passed variable contained a null pointer.
Adjust jump targets according to the Linux coding style convention.
--- drivers/gpu/drm/savage/savage_state.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-)
drivers/gpu/drm/savage/savage_state.c +15 -15
@@ -1004,7 +1004,7 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_ kvb_addr =memdup_user (cmdbuf->vb_addr, cmdbuf->vb_size);if (IS_ERR (kvb_addr)) { ret =PTR_ERR (kvb_addr); - goto done; + goto free_cmd; } cmdbuf->vb_addr = kvb_addr; }
@@ -1013,13 +1013,13 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_ GFP_KERNEL);if (kbox_addr =NULL ) { ret = -ENOMEM ; - goto done; + goto free_vb; }if (copy_from_user (kbox_addr, cmdbuf->box_addr, cmdbuf->nbox *sizeof (struct drm_clip_rect ))) { ret = -EFAULT ; - goto done; + goto free_vb; } cmdbuf->box_addr = kbox_addr; }
@@ -1052,7 +1052,7 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_ "beyond end of command buffer\n");DMA_FLUSH (); ret = -EINVAL ; - goto done; + goto free_box; }/* fall through */ case SAVAGE_CMD_DMA_PRIM :
@@ -1071,7 +1071,7 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_ cmdbuf->vb_stride, cmdbuf->nbox, cmdbuf->box_addr);if (ret !=0 ) - goto done; + goto free_box; first_draw_cmd =NULL ; } }
@@ -1086,7 +1086,7 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_ "beyond end of command buffer\n");DMA_FLUSH (); ret = -EINVAL ; - goto done; + goto free_box; } ret =savage_dispatch_state (dev_priv, &cmd_header, (const uint32_t *)cmdbuf->cmd_addr);
@@ -1099,7 +1099,7 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_ "beyond end of command buffer\n");DMA_FLUSH (); ret = -EINVAL ; - goto done; + goto free_box; } ret = savage_dispatch_clear(dev_priv, &cmd_header, cmdbuf->cmd_addr,
@@ -1117,12 +1117,12 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_ cmd_header.cmd.cmd);DMA_FLUSH (); ret = -EINVAL ; - goto done; + goto free_box; }if (ret !=0 ) {DMA_FLUSH (); - goto done; + goto free_box; } }
@@ -1133,7 +1133,7 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_ cmdbuf->nbox, cmdbuf->box_addr);if (ret !=0 ) {DMA_FLUSH (); - goto done; + goto free_box; } }
@@ -1147,11 +1147,11 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_savage_freelist_put (dev, dmabuf); } -done: -/* If we didn't need to allocate them, these'll be NULL */ -kfree (kcmd_addr); -kfree (kvb_addr); +free_box:kfree (kbox_addr); - +free_vb: +kfree (kvb_addr); +free_cmd: +kfree (kcmd_addr);return ret; }
Signature · 1 line
2.9.3
Re: [PATCH 2/2] GPU-DRM-Savage: Less function calls in savage_bci_cmdbuf() after error detection
Quoted 10 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Thu, 18 Aug 2016 21:28:58 +0200The
kfree()function was called in a few cases by thesavage_bci_cmdbuf()function during error handling even if a passed variable contained a null pointer.Adjust jump targets according to the Linux coding style convention.
Signed-off-by Markus Elfring <[email protected]>
Not sure this is worth it, I'll pass. Patch 1 merged. Btw I consider cocci patches a good way to get started somewhere, but then it's much more useful to do a bit more involved things. We keep a list of small&big janitor tasks:
https://www.x.org/wiki/DRMJanitors/
Cleaning up all the cocci errors in drm isn't good since then the next person won't have something easy to get started, i.e. consider you're budget used up ;-)
-Daniel
Quoted 113 lines
--- drivers/gpu/drm/savage/savage_state.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-)drivers/gpu/drm/savage/savage_state.c +15
-15@@ -1004,7 +1004,7 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_ kvb_addr =memdup_user (cmdbuf->vb_addr, cmdbuf->vb_size);if (IS_ERR (kvb_addr)) { ret =PTR_ERR (kvb_addr); - goto done; + goto free_cmd; } cmdbuf->vb_addr = kvb_addr; }@@ -1013,13 +1013,13 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_ GFP_KERNEL);if (kbox_addr =NULL ) { ret = -ENOMEM ; - goto done; + goto free_vb; }if (copy_from_user (kbox_addr, cmdbuf->box_addr, cmdbuf->nbox *sizeof (struct drm_clip_rect ))) { ret = -EFAULT ; - goto done; + goto free_vb; } cmdbuf->box_addr = kbox_addr; }@@ -1052,7 +1052,7 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_ "beyond end of command buffer\n");DMA_FLUSH (); ret = -EINVAL ; - goto done; + goto free_box; }/* fall through */ case SAVAGE_CMD_DMA_PRIM :@@ -1071,7 +1071,7 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_ cmdbuf->vb_stride, cmdbuf->nbox, cmdbuf->box_addr);if (ret !=0 ) - goto done; + goto free_box; first_draw_cmd =NULL ; } }@@ -1086,7 +1086,7 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_ "beyond end of command buffer\n");DMA_FLUSH (); ret = -EINVAL ; - goto done; + goto free_box; } ret =savage_dispatch_state (dev_priv, &cmd_header, (const uint32_t *)cmdbuf->cmd_addr);@@ -1099,7 +1099,7 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_ "beyond end of command buffer\n");DMA_FLUSH (); ret = -EINVAL ; - goto done; + goto free_box; } ret = savage_dispatch_clear(dev_priv, &cmd_header, cmdbuf->cmd_addr,@@ -1117,12 +1117,12 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_ cmd_header.cmd.cmd);DMA_FLUSH (); ret = -EINVAL ; - goto done; + goto free_box; }if (ret !=0 ) {DMA_FLUSH (); - goto done; + goto free_box; } }@@ -1133,7 +1133,7 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_ cmdbuf->nbox, cmdbuf->box_addr);if (ret !=0 ) {DMA_FLUSH (); - goto done; + goto free_box; } }@@ -1147,11 +1147,11 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_savage_freelist_put (dev, dmabuf); } -done: -/* If we didn't need to allocate them, these'll be NULL */ -kfree (kcmd_addr); -kfree (kvb_addr); +free_box:kfree (kbox_addr); - +free_vb: +kfree (kvb_addr); +free_cmd: +kfree (kcmd_addr);return ret; }Signature · 1 line
2.9.3
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Re: GPU-DRM-Savage: Less function calls in savage_bci_cmdbuf() after error detection
Quoted 11 lines
Quoted 9 lines
Date: Thu, 18 Aug 2016 21:28:58 +0200
The
kfree()function was called in a few cases by thesavage_bci_cmdbuf()function during error handling even if a passed variable contained a null pointer.Adjust jump targets according to the Linux coding style convention.
Signed-off-by Markus Elfring <[email protected]>Not sure this is worth it, I'll pass. Patch 1 merged.
Unfortunately, it seems that this selection of only one update step from this small patch series has got unwanted consequences.
Will the update suggestion “[patch] drm/savage: dereferencing an error pointer” by Dan Carpenter (from today) trigger further software development discussions?
https://patchwork.kernel.org/patch/9372127/
https://lkml.kernel.org/r/<20161012062227.GU12841@mwanda>
Will an update step like “[PATCH 2/2] GPU-DRM-Savage: Less function calls in savage_bci_cmdbuf() after error detection” (from 2016-08-18) become worth for related consideratons once more?
https://patchwork.kernel.org/patch/9289183/
https://lkml.kernel.org/r/<[email protected]>
Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 0/2] GPU-DRM-Savage: Fine-tuning for savage_bci_cmdbuf()
In reply to SF Markus ElfringQuoted 5 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Thu, 18 Aug 2016 21:38:37 +0200A few update suggestions were taken into account
from static source code analysis.
savage is one of the dri1 legacy drivers, imo not really worth it to spend time on them. otoh no one will notice any breakage either ;-)
I guess I'll apply.
-Daniel
Quoted 11 lines
Markus Elfring (2):
Usememdup_user()rather than duplicating its implementation Less function calls after error detectiondrivers/gpu/drm/savage/savage_state.c | 42 +++++++++++++++-------------------- 1 file changed, 18 insertions(+), 24 deletions(-)Signature · 1 line
2.9.3
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
cover uvc_v4l2: Fine-tuning for uvc_ioctl_ctrl_map()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 19 Aug 2016 11:11:01 +0200
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (2):
Use memdup_user() rather than duplicating its implementation One function call less after error detection
drivers/media/usb/uvc/uvc_v4l2.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-)
Signature · 1 line
2.9.3
PATCH 1/2 uvc_v4l2: Use memdup_user() rather than duplicating its implementation
From: Markus Elfring <[email protected]>
Date: Fri, 19 Aug 2016 10:50:05 +0200
Reuse existing functionality from memdup_user() instead of keeping duplicate source code.
This issue was detected by using the Coccinelle software.
--- drivers/media/usb/uvc/uvc_v4l2.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)
drivers/media/usb/uvc/uvc_v4l2.c +3 -8
@@ -70,14 +70,9 @@ static int uvc_ioctl_ctrl_map(struct uvc_video_chain *chain, } size = xmap->menu_count *sizeof (*map->menu_info); - map->menu_info =kmalloc (size,GFP_KERNEL ); -if (map->menu_info =NULL ) { - ret = -ENOMEM ; - goto done; - } - -if (copy_from_user (map->menu_info, xmap->menu_info, size)) { - ret = -EFAULT ; + map->menu_info =memdup_user (xmap->menu_info, size); +if (IS_ERR (map->menu_info)) { + ret =PTR_ERR (map->menu_info); goto done; }
Signature · 1 line
2.9.3
Re: [PATCH 1/2] uvc_v4l2: Use memdup_user() rather than duplicating its implementation
Hi Markus,
Thank you for the patch.
Quoted 9 lines · On Friday 19 Aug 2016 11:23:18 SF Markus Elfring wrote:
From: Markus Elfring <[email protected]>
Date: Fri, 19 Aug 2016 10:50:05 +0200Reuse existing functionality from
memdup_user()instead of keeping duplicate source code.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
and applied to my tree.
Quoted 25 lines
--- drivers/media/usb/uvc/uvc_v4l2.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)(quoted diff) +0
-0
b/drivers/media/usb/uvc/uvc_v4l2.cindex 05eed4b..a7e12fd 100644drivers/media/usb/uvc/uvc_v4l2.c +3
-8@@ -70,14 +70,9 @@ static int uvc_ioctl_ctrl_map(struct uvc_video_chain *chain, } size = xmap->menu_count *sizeof (*map->menu_info); - map->menu_info =kmalloc (size,GFP_KERNEL ); -if (map->menu_info ==NULL ) { - ret = -ENOMEM ; - goto done; - } - -if (copy_from_user (map->menu_info, xmap->menu_info, size)) { - ret = -EFAULT ; + map->menu_info =memdup_user (xmap->menu_info, size); +if (IS_ERR (map->menu_info)) { + ret =PTR_ERR (map->menu_info); goto done; }
Signature · 3 lines
Regards, Laurent Pinchart
PATCH 2/2 uvc_v4l2: One function call less in uvc_ioctl_ctrl_map() after error detection
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 19 Aug 2016 11:00:38 +0200
The kfree() function was called in two cases by the uvc_ioctl_ctrl_map() function during error handling even if the passed data structure element contained a null pointer.
Adjust jump targets according to the Linux coding style convention.
--- drivers/media/usb/uvc/uvc_v4l2.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/media/usb/uvc/uvc_v4l2.c +4 -5
@@ -66,14 +66,14 @@ static int uvc_ioctl_ctrl_map(struct uvc_video_chain *chain,if (xmap->menu_count =0 || xmap->menu_count >UVC_MAX_CONTROL_MENU_ENTRIES ) { ret = -EINVAL ; - goto done; + goto free_map; } size = xmap->menu_count *sizeof (*map->menu_info); map->menu_info =memdup_user (xmap->menu_info, size);if (IS_ERR (map->menu_info)) { ret =PTR_ERR (map->menu_info); - goto done; + goto free_map; } map->menu_count = xmap->menu_count;
@@ -83,13 +83,12 @@ static int uvc_ioctl_ctrl_map(struct uvc_video_chain *chain,uvc_trace (UVC_TRACE_CONTROL ,"Unsupported V4L2 control type " "%u.\n" , xmap->v4l2_type); ret = -ENOTTY ; - goto done; + goto free_map; } ret =uvc_ctrl_add_mapping (chain, map); - -done:kfree (map->menu_info); +free_map:kfree (map);return ret;
Signature · 1 line
2.9.3
cover misc/mic/vop: Fine-tuning for vop_ioctl()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 19 Aug 2016 20:20:02 +0200
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (2):
Use memdup_user()
Rename jump labels
drivers/misc/mic/vop/vop_vringh.c | 43 ++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 26 deletions(-)
Signature · 1 line
2.9.3
PATCH 1/2 misc/mic/vop: Use memdup_user() rather than duplicating its implementation
From: Markus Elfring <[email protected]>
Date: Fri, 19 Aug 2016 19:48:45 +0200
Reuse existing functionality from memdup_user() instead of keeping duplicate source code.
This issue was detected by using the Coccinelle software.
--- drivers/misc/mic/vop/vop_vringh.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-)
drivers/misc/mic/vop/vop_vringh.c +6 -15
@@ -938,13 +938,9 @@ static long vop_ioctl(struct file *f, unsigned int cmd, unsigned long arg) dd.num_vq > MIC_MAX_VRINGS)return -EINVAL ; - dd_config =kzalloc (mic_desc_size (&dd),GFP_KERNEL ); -if (!dd_config) -return -ENOMEM ; -if (copy_from_user (dd_config, argp,mic_desc_size (&dd))) { - ret = -EFAULT ; - goto free_ret; - } + dd_config =memdup_user (argp,mic_desc_size (&dd)); +if (IS_ERR (dd_config)) +return PTR_ERR (dd_config);/* Ensure desc has not changed between the two reads */ if (memcmp (&dd, dd_config,sizeof (dd))) { ret = -EINVAL ;
@@ -996,17 +992,12 @@ _unlock_ret: ret =vop_vdev_inited (vdev);if (ret) goto __unlock_ret; - buf =kzalloc (vdev->dd->config_len,GFP_KERNEL ); -if (!buf) { - ret = -ENOMEM ; + buf =memdup_user (argp, vdev->dd->config_len); +if (IS_ERR (buf)) { + ret =PTR_ERR (buf); goto __unlock_ret; } -if (copy_from_user (buf, argp, vdev->dd->config_len)) { - ret = -EFAULT ; - goto done; - } ret =vop_virtio_config_change (vdev, buf); -done:kfree (buf); __unlock_ret:mutex_unlock (&vdev->vdev_mutex);
Signature · 1 line
2.9.3
PATCH 2/2 misc/mic/vop: Rename jump labels in vop_ioctl()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 19 Aug 2016 20:02:50 +0200
Adjust jump targets according to the Linux coding style convention.
--- drivers/misc/mic/vop/vop_vringh.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
drivers/misc/mic/vop/vop_vringh.c +11 -11
@@ -944,18 +944,18 @@ static long vop_ioctl(struct file *f, unsigned int cmd, unsigned long arg)/* Ensure desc has not changed between the two reads */ if (memcmp (&dd, dd_config,sizeof (dd))) { ret = -EINVAL ; - goto free_ret; + goto free_config; }mutex_lock (&vdev->vdev_mutex);mutex_lock (&vi->vop_mutex); ret =vop_virtio_add_device (vdev, dd_config);if (ret) - goto unlock_ret; + goto unlock_device_addition;list_add_tail (&vdev->list, &vi->vdev_list); -unlock_ret: +unlock_device_addition:mutex_unlock (&vi->vop_mutex);mutex_unlock (&vdev->vdev_mutex); -free_ret: +free_config:kfree (dd_config);return ret; }
@@ -966,21 +966,21 @@ free_ret:mutex_lock (&vdev->vdev_mutex); ret =vop_vdev_inited (vdev);if (ret) - goto _unlock_ret; + goto unlock_desc_copy;if (copy_from_user (©, argp,sizeof (copy))) { ret = -EFAULT ; - goto _unlock_ret; + goto unlock_desc_copy; } ret =vop_virtio_copy_desc (vdev, ©);if (ret <0 ) - goto _unlock_ret; + goto unlock_desc_copy;if (copy_to_user ( &((struct mic_copy_desc __user *)argp)->out_len, ©.out_len,sizeof (copy.out_len))) ret = -EFAULT ; -_unlock_ret: +unlock_desc_copy:mutex_unlock (&vdev->vdev_mutex);return ret; }
@@ -991,15 +991,15 @@ _unlock_ret:mutex_lock (&vdev->vdev_mutex); ret =vop_vdev_inited (vdev);if (ret) - goto __unlock_ret; + goto unlock_config_change; buf =memdup_user (argp, vdev->dd->config_len);if (IS_ERR (buf)) { ret =PTR_ERR (buf); - goto __unlock_ret; + goto unlock_config_change; } ret =vop_virtio_config_change (vdev, buf);kfree (buf); -__unlock_ret: +unlock_config_change:mutex_unlock (&vdev->vdev_mutex);return ret; }
Signature · 1 line
2.9.3
PATCH 1/1 VMCI: Use memdup_user() rather than duplicating its implementation
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 19 Aug 2016 21:12:41 +0200
Reuse existing functionality from memdup_user() instead of keeping duplicate source code.
This issue was detected by using the Coccinelle software.
--- drivers/misc/vmw_vmci/vmci_host.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-)
drivers/misc/vmw_vmci/vmci_host.c +4 -15
@@ -759,27 +759,16 @@ static int vmci_host_do_ctx_set_cpt_state(struct vmci_host_dev *vmci_host_dev,if (copy_from_user (&set_info, uptr,sizeof (set_info)))return -EFAULT ; - cpt_buf =kmalloc (set_info.buf_size,GFP_KERNEL ); -if (!cpt_buf) { -vmci_ioctl_err ( -"cannot allocate memory to set cpt state (type=%d)\n" , - set_info.cpt_type); -return -ENOMEM ; - } - -if (copy_from_user (cpt_buf, (void __user *)(uintptr_t )set_info.cpt_buf, - set_info.buf_size)) { - retval = -EFAULT ; - goto out; - } + cpt_buf =memdup_user ((void __user *)(uintptr_t )set_info.cpt_buf, + set_info.buf_size); +if (IS_ERR (cpt_buf)) +return PTR_ERR (cpt_buf); cid =vmci_ctx_get_id (vmci_host_dev->context); set_info.result =vmci_ctx_set_chkpt_state (cid, set_info.cpt_type, set_info.buf_size, cpt_buf); retval =copy_to_user (uptr, &set_info,sizeof (set_info)) ? -EFAULT :0 ; - -out:kfree (cpt_buf);return retval; }
Signature · 1 line
2.9.3
cover mmc-block: Fine-tuning for mmc_blk_ioctl_copy_from_user()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 19 Aug 2016 23:00:23 +0200
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (2):
Use memdup_user()
Rename jump labels
drivers/mmc/card/block.c | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-)
Signature · 1 line
2.9.3
PATCH 1/2 mmc-block: Use memdup_user() rather than duplicating its implementation
From: Markus Elfring <[email protected]>
Date: Fri, 19 Aug 2016 22:46:38 +0200
* Reuse existing functionality from memdup_user() instead of keeping duplicate source code.
This issue was detected by using the Coccinelle software.
* Delete the integer variable "err" then because the pointer variable "idata" should be sufficient to handle return values alone in this function.
--- drivers/mmc/card/block.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-)
drivers/mmc/card/block.c +9 -17
@@ -337,22 +337,21 @@ static struct mmc_blk_ioc_data *mmc_blk_ioctl_copy_from_user( struct mmc_ioc_cmd __user *user) {struct mmc_blk_ioc_data *idata; -int err; idata =kmalloc (sizeof (*idata),GFP_KERNEL );if (!idata) { - err = -ENOMEM ; + idata =ERR_PTR (-ENOMEM ); goto out; }if (copy_from_user (&idata->ic, user,sizeof (idata->ic))) { - err = -EFAULT ; + idata =ERR_PTR (-EFAULT ); goto idata_err; } idata->buf_bytes = (u64 ) idata->ic.blksz * idata->ic.blocks;if (idata->buf_bytes >MMC_IOC_MAX_BYTES ) { - err = -EOVERFLOW ; + idata =ERR_PTR (-EOVERFLOW ); goto idata_err; }
@@ -361,26 +360,19 @@ static struct mmc_blk_ioc_data *mmc_blk_ioctl_copy_from_user(return idata; } - idata->buf =kmalloc (idata->buf_bytes,GFP_KERNEL ); -if (!idata->buf) { - err = -ENOMEM ; + idata->buf =memdup_user ((void __user *)(unsigned long ) + idata->ic.data_ptr, + idata->buf_bytes); +if (IS_ERR (idata->buf)) { + idata = (void *) idata->buf; goto idata_err; } - -if (copy_from_user (idata->buf, (void __user *)(unsigned long ) - idata->ic.data_ptr, idata->buf_bytes)) { - err = -EFAULT ; - goto copy_err; - } -return idata; -copy_err: -kfree (idata->buf); idata_err:kfree (idata); out: -return ERR_PTR (err); +return idata; } static int mmc_blk_ioctl_copy_to_user(struct mmc_ioc_cmd __user *ic_ptr,
Signature · 1 line
2.9.3
Re: [PATCH 1/2] mmc-block: Use memdup_user() rather than duplicating its implementation
Am 19.08.2016 23:10, schrieb SF Markus Elfring:
Quoted 68 lines
From: Markus Elfring <[email protected]>
Date: Fri, 19 Aug 2016 22:46:38 +0200* Reuse existing functionality from
memdup_user()instead of keeping duplicate source code.This issue was detected by using the Coccinelle software.
* Delete the integer variable "err" then because the pointer variable "idata" should be sufficient to handle return values alone in this function.
Signed-off-by Markus Elfring <[email protected]>--- drivers/mmc/card/block.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-)drivers/mmc/card/block.c +8
-14@@ -337,22 +337,21 @@ static struct mmc_blk_ioc_data *mmc_blk_ioctl_copy_from_user( struct mmc_ioc_cmd __user *user) {struct mmc_blk_ioc_data *idata; -int err; idata =kmalloc (sizeof (*idata),GFP_KERNEL );if (!idata) { - err = -ENOMEM ; + idata =ERR_PTR (-ENOMEM ); goto out; }if (copy_from_user (&idata->ic, user,sizeof (idata->ic))) { - err = -EFAULT ; + idata =ERR_PTR (-EFAULT ); goto idata_err; } idata->buf_bytes = (u64 ) idata->ic.blksz * idata->ic.blocks;if (idata->buf_bytes >MMC_IOC_MAX_BYTES ) { - err = -EOVERFLOW ; + idata =ERR_PTR (-EOVERFLOW ); goto idata_err; }@@ -361,26 +360,19 @@ static struct mmc_blk_ioc_data *mmc_blk_ioctl_copy_from_user(return idata; } - idata->buf =kmalloc (idata->buf_bytes,GFP_KERNEL ); -if (!idata->buf) { - err = -ENOMEM ; + idata->buf =memdup_user ((void __user *)(unsigned long ) + idata->ic.data_ptr, + idata->buf_bytes); +if (IS_ERR (idata->buf)) { + idata = (void *) idata->buf; goto idata_err; } - -if (copy_from_user (idata->buf, (void __user *)(unsigned long ) - idata->ic.data_ptr, idata->buf_bytes)) { - err = -EFAULT ; - goto copy_err; - } -
drivers/mmc/card/block.c static struct mmc_blk_ioc_data *mmc_blk_ioctl_copy_from_user( · line 376
Quoted 10 lines
drivers/mmc/card/block.c +1
-3return idata; -copy_err: -kfree (idata->buf); idata_err:kfree (idata); out: -return ERR_PTR (err); +return idata; }
This looks strange, returning a freed pointer is a bad idea. I suggest a idata=NULL after kfree().
re,
wh
Quoted 2 lines
drivers/mmc/card/block.c +0
-0static int mmc_blk_ioctl_copy_to_user(struct mmc_ioc_cmd __user *ic_ptr,
PATCH 2/2 mmc-block: Rename jump labels in mmc_blk_ioctl_copy_from_user()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 19 Aug 2016 22:52:50 +0200
Adjust jump targets according to the Linux coding style convention.
--- drivers/mmc/card/block.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/mmc/card/block.c +4 -4
@@ -346,13 +346,13 @@ static struct mmc_blk_ioc_data *mmc_blk_ioctl_copy_from_user(if (copy_from_user (&idata->ic, user,sizeof (idata->ic))) { idata =ERR_PTR (-EFAULT ); - goto idata_err; + goto free_idata; } idata->buf_bytes = (u64 ) idata->ic.blksz * idata->ic.blocks;if (idata->buf_bytes >MMC_IOC_MAX_BYTES ) { idata =ERR_PTR (-EOVERFLOW ); - goto idata_err; + goto free_idata; }if (!idata->buf_bytes) {
@@ -365,11 +365,11 @@ static struct mmc_blk_ioc_data *mmc_blk_ioctl_copy_from_user( idata->buf_bytes);if (IS_ERR (idata->buf)) { idata = (void *) idata->buf; - goto idata_err; + goto free_idata; }return idata; -idata_err: +free_idata:kfree (idata); out:return idata;
Signature · 1 line
2.9.3
PATCH 1/1 mlx5/core: Use memdup_user() rather than duplicating its implementation
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 20 Aug 2016 07:50:09 +0200
* Reuse existing functionality from memdup_user() instead of keeping duplicate source code.
This issue was detected by using the Coccinelle software.
* Return directly if this copy operation failed.
--- drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/cmd.c +3 -14
@@ -1132,7 +1132,6 @@ static ssize_t data_write(struct file *filp, const char __user *buf,struct mlx5_core_dev *dev = filp->private_data;struct mlx5_cmd_debug *dbg = &dev->cmd.dbg;void *ptr; -int err;if (*pos !=0 )return -EINVAL ;
@@ -1140,25 +1139,15 @@ static ssize_t data_write(struct file *filp, const char __user *buf,kfree (dbg->in_msg); dbg->in_msg =NULL ; dbg->inlen =0 ; - - ptr =kzalloc (count,GFP_KERNEL ); -if (!ptr) -return -ENOMEM ; - -if (copy_from_user (ptr, buf, count)) { - err = -EFAULT ; - goto out; - } + ptr =memdup_user (buf, count); +if (IS_ERR (ptr)) +return PTR_ERR (ptr); dbg->in_msg = ptr; dbg->inlen = count; *pos = count;return count; - -out: -kfree (ptr); -return err; } static ssize_t data_read(struct file *filp, char __user *buf, size_t count,
Signature · 1 line
2.9.3
Re: [PATCH] mlx5/core: Use memdup_user() rather than duplicating its implementation
Am 20.08.2016 08:01, schrieb SF Markus Elfring:
Quoted 38 lines
From: Markus Elfring <[email protected]>
Date: Sat, 20 Aug 2016 07:50:09 +0200* Reuse existing functionality from
memdup_user()instead of keeping duplicate source code.This issue was detected by using the Coccinelle software.
* Return directly if this copy operation failed.
Signed-off-by Markus Elfring <[email protected]>--- drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-)drivers/net/ethernet/mellanox/mlx5/core/cmd.c +0
-8@@ -1132,7 +1132,6 @@ static ssize_t data_write(struct file *filp, const char __user *buf,struct mlx5_core_dev *dev = filp->private_data;struct mlx5_cmd_debug *dbg = &dev->cmd.dbg;void *ptr; -int err;if (*pos !=0 )return -EINVAL ;@@ -1140,25 +1139,15 @@ static ssize_t data_write(struct file *filp, const char __user *buf,kfree (dbg->in_msg); dbg->in_msg =NULL ; dbg->inlen =0 ; - - ptr =kzalloc (count,GFP_KERNEL ); -if (!ptr) -return -ENOMEM ; - -if (copy_from_user (ptr, buf, count)) { - err = -EFAULT ;
drivers/net/ethernet/mellanox/mlx5/core/cmd.c static ssize_t data_write(struct file *filp, const char __user *buf, · line 1149
Quoted 10 lines
drivers/net/ethernet/mellanox/mlx5/core/cmd.c +3
-2- goto out; - } + ptr =memdup_user (buf, count); +if (IS_ERR (ptr)) +return PTR_ERR (ptr); dbg->in_msg = ptr; dbg->inlen = count; *pos = count;
maybe i am missing something here but why do you need ptr ?
The use of count looks even more confusing it is stored in
dbg->inlen, *pos and is returned.
is that realy needed ?
re,
wh
Quoted 8 lines
drivers/net/ethernet/mellanox/mlx5/core/cmd.c +0
-4return count; - -out: -kfree (ptr); -return err; } static ssize_t data_read(struct file *filp, char __user *buf, size_t count,
Re: [PATCH] mlx5/core: Use memdup_user() rather than duplicating its implementation
In reply to SF Markus ElfringFrom: SF Markus Elfring <[email protected]>
Date: Sat, 20 Aug 2016 08:01:22 +0200
Quoted 11 lines
From: Markus Elfring <[email protected]>
Date: Sat, 20 Aug 2016 07:50:09 +0200* Reuse existing functionality from
memdup_user()instead of keeping duplicate source code.This issue was detected by using the Coccinelle software.
* Return directly if this copy operation failed.
Signed-off-by Markus Elfring <[email protected]>
Applied.
cover tun: Fine-tuning for update_filter()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 20 Aug 2016 09:16:16 +0200
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (2):
Use memdup_user()
Rename a jump label
drivers/net/tun.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-)
Signature · 1 line
2.9.3
PATCH 1/2 tun: Use memdup_user() rather than duplicating its implementation
From: Markus Elfring <[email protected]>
Date: Sat, 20 Aug 2016 08:54:15 +0200
Reuse existing functionality from memdup_user() instead of keeping duplicate source code.
This issue was detected by using the Coccinelle software.
--- drivers/net/tun.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)
drivers/net/tun.c +3 -8
@@ -731,14 +731,9 @@ static int update_filter(struct tap_filter *filter, void __user *arg) } alen =ETH_ALEN * uf.count; - addr =kmalloc (alen,GFP_KERNEL ); -if (!addr) -return -ENOMEM ; - -if (copy_from_user (addr, arg +sizeof (uf), alen)) { - err = -EFAULT ; - goto done; - } + addr =memdup_user (arg +sizeof (uf), alen); +if (IS_ERR (addr)) +return PTR_ERR (addr);/* The filter is updated without holding any locks. Which is * perfectly safe. We disable it first and in the worst
Signature · 1 line
2.9.3
Re: [PATCH 1/2] tun: Use memdup_user() rather than duplicating its implementation
Hi,
Quoted 9 lines · On Sat, 20 Aug 2016 09:34:56 +0200 SF Markus Elfring…
From: Markus Elfring <[email protected]>
Date: Sat, 20 Aug 2016 08:54:15 +0200Reuse existing functionality from
memdup_user()instead of keeping duplicate source code.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Re: [PATCH 1/2] tun: Use memdup_user() rather than duplicating its implementation
In reply to SF Markus ElfringQuoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 20 Aug 2016 08:54:15 +0200Reuse existing functionality from
memdup_user()instead of keeping duplicate source code.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Quoted 28 lines
--- drivers/net/tun.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)drivers/net/tun.c +3
-8@@ -731,14 +731,9 @@ static int update_filter(struct tap_filter *filter, void __user *arg) } alen =ETH_ALEN * uf.count; - addr =kmalloc (alen,GFP_KERNEL ); -if (!addr) -return -ENOMEM ; - -if (copy_from_user (addr, arg +sizeof (uf), alen)) { - err = -EFAULT ; - goto done; - } + addr =memdup_user (arg +sizeof (uf), alen); +if (IS_ERR (addr)) +return PTR_ERR (addr);/* The filter is updated without holding any locks. Which is * perfectly safe. We disable it first and in the worst Signature · 1 line
2.9.3
PATCH 2/2 tun: Rename a jump label in update_filter()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 20 Aug 2016 09:00:34 +0200
Adjust a jump target according to the Linux coding style convention.
--- drivers/net/tun.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/net/tun.c +2 -3
@@ -753,7 +753,7 @@ static int update_filter(struct tap_filter *filter, void __user *arg)for (; n < uf.count; n++) {if (!is_multicast_ether_addr (addr[n].u)) { err =0 ;/* no filter */ - goto done; + goto free_addr; }addr_hash_set (filter->mask, addr[n].u); }
@@ -769,8 +769,7 @@ static int update_filter(struct tap_filter *filter, void __user *arg)/* Return the number of exact filters */ err = nexact; - -done: +free_addr:kfree (addr);return err; }
Signature · 1 line
2.9.3
Michael S. Tsirkin
maintainerRe: [PATCH 2/2] tun: Rename a jump label in update_filter()
Quoted 6 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 20 Aug 2016 09:00:34 +0200Adjust a jump target according to the Linux coding style convention.
Signed-off-by Markus Elfring <[email protected]>
I don't have an opinion of this one. Which convention do you refer to?
Quoted 29 lines
--- drivers/net/tun.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/net/tun.c +2
-3@@ -753,7 +753,7 @@ static int update_filter(struct tap_filter *filter, void __user *arg)for (; n < uf.count; n++) {if (!is_multicast_ether_addr (addr[n].u)) { err =0 ;/* no filter */ - goto done; + goto free_addr; }addr_hash_set (filter->mask, addr[n].u); }@@ -769,8 +769,7 @@ static int update_filter(struct tap_filter *filter, void __user *arg)/* Return the number of exact filters */ err = nexact; - -done: +free_addr:kfree (addr);return err; }Signature · 1 line
2.9.3
Re: [PATCH 2/2] tun: Rename a jump label in update_filter()
Quoted 9 lines · Michael S. Tsirkin
Quoted 6 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 20 Aug 2016 09:00:34 +0200Adjust a jump target according to the Linux coding style convention.
Signed-off-by Markus Elfring <[email protected]>I don't have an opinion of this one. Which convention do you refer to?
Citing Documentation/CodingStyle:
Choose label names which say what the goto does or why the goto exists. An example of a good name could be "out_buffer:" if the goto frees "buffer". Avoid using GW-BASIC names like "err1:" and "err2:". Also don't name them after the goto location like "err_kmalloc_failed:"
Quoted 31 lines
Quoted 30 lines
--- drivers/net/tun.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/net/tun.c +2
-3@@ -753,7 +753,7 @@ static int update_filter(struct tap_filter *filter, void __user *arg)for (; n < uf.count; n++) {if (!is_multicast_ether_addr (addr[n].u)) { err =0 ;/* no filter */ - goto done; + goto free_addr; }addr_hash_set (filter->mask, addr[n].u); }@@ -769,8 +769,7 @@ static int update_filter(struct tap_filter *filter, void __user *arg)/* Return the number of exact filters */ err = nexact; - -done: +free_addr:kfree (addr);return err; }Signature · 1 line
2.9.3
David Miller
maintainerRe: [PATCH 0/2] tun: Fine-tuning for update_filter()
In reply to SF Markus ElfringFrom: SF Markus Elfring <[email protected]>
Date: Sat, 20 Aug 2016 09:27:39 +0200
Quoted 2 lines
A few update suggestions were taken into account
from static source code analysis.
Series applied.
cover hostap: Fine-tuning for a few functions
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 20 Aug 2016 18:35:43 +0200
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (3):
Use memdup_user()
Delete an unnecessary jump label
Delete unnecessary variable initialisations
.../net/wireless/intersil/hostap/hostap_ioctl.c | 36 ++++++++-------------- 1 file changed, 12 insertions(+), 24 deletions(-)
Signature · 1 line
2.9.3
PATCH 1/3 hostap: Use memdup_user() rather than duplicating its implementation
From: Markus Elfring <[email protected]>
Date: Sat, 20 Aug 2016 18:19:43 +0200
Reuse existing functionality from memdup_user() instead of keeping duplicate source code.
This issue was detected by using the Coccinelle software.
--- .../net/wireless/intersil/hostap/hostap_ioctl.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-)
drivers/net/wireless/intersil/hostap/hostap_ioctl.c +6 -16
@@ -3041,14 +3041,9 @@ static int prism2_ioctl_priv_download(local_info_t *local, struct iw_point *p) p->length > 1024 || !p->pointer)return -EINVAL ; - param =kmalloc (p->length,GFP_KERNEL ); -if (param =NULL ) -return -ENOMEM ; - -if (copy_from_user (param, p->pointer, p->length)) { - ret = -EFAULT ; - goto out; - } + param =memdup_user (p->pointer, p->length); +if (IS_ERR (param)) +return PTR_ERR (param);if (p->length <sizeof (struct prism2_download_param ) + param->num_areas *sizeof (struct prism2_download_area )) {
@@ -3803,14 +3798,9 @@ static int prism2_ioctl_priv_hostapd(local_info_t *local, struct iw_point *p) p->length > PRISM2_HOSTAPD_MAX_BUF_SIZE || !p->pointer)return -EINVAL ; - param =kmalloc (p->length,GFP_KERNEL ); -if (param =NULL ) -return -ENOMEM ; - -if (copy_from_user (param, p->pointer, p->length)) { - ret = -EFAULT ; - goto out; - } + param =memdup_user (p->pointer, p->length); +if (IS_ERR (param)) +return PTR_ERR (param);switch (param->cmd) {case PRISM2_SET_ENCRYPTION :
Signature · 1 line
2.9.3
Re: [1/3] hostap: Use memdup_user() rather than duplicating its implementation
Quoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 20 Aug 2016 18:19:43 +0200Reuse existing functionality from
memdup_user()instead of keeping duplicate source code.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Patch set to Rejected.
[1/3] hostap: Use memdup_user() rather than duplicating i... 2016-08-20 SF Markus El Rejected
Reason: A similar patch is already applied.
Applying: hostap: Use memdup_user() rather than duplicating its implementation Using index info to reconstruct a base tree...
Falling back to patching base and 3-way merge...
Auto-merging drivers/net/wireless/intersil/hostap/hostap_ioctl.c
CONFLICT (content): Merge conflict in drivers/net/wireless/intersil/hostap/hostap_ioctl.c Failed to merge in the changes.
Patch failed at 0001 hostap: Use memdup_user() rather than duplicating its implementation
Signature · 6 lines
https://patchwork.kernel.org/patch/9306999/ Documentation about submitting wireless patches and checking status from patchwork: https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
PATCH 2/3 hostap: Delete an unnecessary jump label in prism2_ioctl_priv_hostapd()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 20 Aug 2016 18:21:29 +0200
Remove a jump label which is unneeded in this function at the end.
--- drivers/net/wireless/intersil/hostap/hostap_ioctl.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/net/wireless/intersil/hostap/hostap_ioctl.c +2 -4
@@ -3835,14 +3835,12 @@ static int prism2_ioctl_priv_hostapd(local_info_t *local, struct iw_point *p) }if (ret =1 || !ap_ioctl) { -if (copy_to_user (p->pointer, param, p->length)) { +if (copy_to_user (p->pointer, param, p->length)) ret = -EFAULT ; - goto out; - }else if (ap_ioctl) +else if (ap_ioctl) ret =0 ; } - out:kfree (param);return ret; }
Signature · 1 line
2.9.3
Re: [PATCH 2/3] hostap: Delete an unnecessary jump label in prism2_ioctl_priv_hostapd()
Hi Marcus,
Quoted 18 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 20 Aug 2016 18:21:29 +0200Remove a jump label which is unneeded in this function at the end.
Signed-off-by Markus Elfring <[email protected]>--- drivers/net/wireless/intersil/hostap/hostap_ioctl.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)drivers/net/wireless/intersil/hostap/hostap_ioctl.c +0
-0@@ -3835,14 +3835,12 @@ static int prism2_ioctl_priv_hostapd(local_info_t *local, struct iw_point *p) }if (ret =1 || !ap_ioctl) {
drivers/net/wireless/intersil/hostap/hostap_ioctl.c static int prism2_ioctl_priv_hostapd(local_info_t *local, struct iw_point *p) · line 3845
Quoted 10 lines
drivers/net/wireless/intersil/hostap/hostap_ioctl.c +2
-4-if (copy_to_user (p->pointer, param, p->length)) { +if (copy_to_user (p->pointer, param, p->length)) ret = -EFAULT ; - goto out; - }else if (ap_ioctl) +else if (ap_ioctl) ret =0 ; } - out:
Does this change make any difference to the compiled code?
Thanks,
Signature · 4 lines
Julian Calaby Email: [email protected] Profile: http://www.google.com/profiles/julian.calaby/
Re: [2/3] hostap: Delete an unnecessary jump label in prism2_ioctl_priv_hostapd()
In reply to SF Markus ElfringQuoted 6 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 20 Aug 2016 18:21:29 +0200Remove a jump label which is unneeded in this function at the end.
Signed-off-by Markus Elfring <[email protected]>
2 patches set to Rejected.
9291771 [2/3] hostap: Delete an unnecessary jump label in prism2_ioctl_priv_hostapd() 9291775 [3/3] hostap: Delete unnecessary initialisations for the variable "ret"
Reason: The benefit is not clear.
Signature · 6 lines
https://patchwork.kernel.org/patch/9291771/ Documentation about submitting wireless patches and checking status from patchwork: https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: hostap: Delete an unnecessary jump label in prism2_ioctl_priv_hostapd()
Quoted 4 lines
9291771 [2/3] hostap: Delete an unnecessary jump label in
prism2_ioctl_priv_hostapd()9291775 [3/3] hostap: Delete unnecessary initialisations for the variable "ret"Reason: The benefit is not clear.
How do you think about to reduce the source code a bit at these places?
Regards,
Markus
Re: hostap: Delete an unnecessary jump label in prism2_ioctl_priv_hostapd()
Quoted 6 lines · SF Markus Elfring
Quoted 4 lines
9291771 [2/3] hostap: Delete an unnecessary jump label in
prism2_ioctl_priv_hostapd()9291775 [3/3] hostap: Delete unnecessary initialisations for the variable "ret"Reason: The benefit is not clear.
How do you think about to reduce the source code a bit at these places?
hostap is an obsolete driver, it's waste of time doing style fixes to it as nobody maintains it anymore.
Signature · 1 line
Kalle Valo
Re: hostap: Delete an unnecessary jump label in prism2_ioctl_priv_hostapd()
Quoted 2 lines
hostap is an obsolete driver, it's waste of time doing style fixes to it as nobody maintains it anymore.
Thanks for another bit of your software development attention and this information.
Is it easier to understand than the previous response "Reason: The benefit is not clear."?
Regards,
Markus
Joe Perches
maintainerRe: hostap: Delete an unnecessary jump label in prism2_ioctl_priv_hostapd()
In reply to Kalle ValoQuoted 2 lines · Kalle Valo
hostap is an obsolete driver, it's waste of time doing style fixes to it as nobody maintains it anymore.
Dunno know if Jouni is still maintaining this at all but maybe a MAINTAINERS update to mark it obsolete so checkpatch warns on unnecessary changes.
--- MAINTAINERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
MAINTAINERS +1 -1
@@ -5722,7 +5722,7 @@ M: Jouni Malinen L: [email protected] (subscribers-only) L: [email protected] W: http://hostap.epitest.fi/ -S: Maintained +S: Maintained / Obsolete F: drivers/net/wireless/intersil/hostap/ HP COMPAQ TC1100 TABLET WMI EXTRAS DRIVER
Re: hostap: Delete an unnecessary jump label in prism2_ioctl_priv_hostapd()
Quoted 16 lines · Joe Perches
Quoted 2 lines · Kalle Valo
hostap is an obsolete driver, it's waste of time doing style fixes to it as nobody maintains it anymore.
Dunno know if Jouni is still maintaining this at all but maybe a
MAINTAINERSupdate to mark it obsolete so checkpatch warns on unnecessary changes.--- MAINTAINERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)MAINTAINERS +0
-0
MAINTAINERS M: Jouni Malinen · line 5726
Quoted 6 lines
MAINTAINERS +1
-1@@ -5722,7 +5722,7 @@ M: Jouni Malinen L: [email protected] (subscribers-only) L: [email protected] W: http://hostap.epitest.fi/ -S: Maintained +S: Maintained / Obsolete F: drivers/net/wireless/intersil/hostap/
I talked with Jouni and we concluded marking this fully obsolete is the best (so removing the "Maintained" part completely). Also the shmoo list is not used anymore, that can be removed.
Signature · 1 line
Kalle Valo
Joe Perches
maintainerRe: hostap: Delete an unnecessary jump label in prism2_ioctl_priv_hostapd()
Quoted 3 lines · Kalle Valo
I talked with Jouni and we concluded marking this fully obsolete is the best (so removing the "Maintained" part completelo the shmoo list is not used anymore, that can be removed.
Well, it would be best if Jouni submitted something.