Remove unnecessary null pointer checks?
Subsystems (270)
Re: [PATCH] net: sched: One function call less in em_meta_change() after error detection
In reply to SF Markus ElfringHi,
Quoted 68 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 31 Jan 2015 17:18:48 +0100The
meta_delete()function could be called in four cases by theem_meta_change()function during error handling even if the passed variable "meta" contained still a null pointer.* This implementation detail could be improved by adjustments for jump labels.
* Let us return immediately after the first failed function call according to the current Linux coding style convention.
* Let us delete also unnecessary checks for the variables "err" and "meta" there.
Signed-off-by Markus Elfring <[email protected]>--- net/sched/em_meta.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)net/sched/em_meta.c +6
-6@@ -866,23 +866,23 @@ static int em_meta_change(struct net *net, void *data, int len, err =nla_parse (tb,TCA_EM_META_MAX , data, len, meta_policy);if (err <0 ) - goto errout; +return err; err = -EINVAL ;if (tb[TCA_EM_META_HDR ] =NULL ) - goto errout; + goto exit; hdr =nla_data (tb[TCA_EM_META_HDR ]);if (TCF_META_TYPE (hdr->left.kind) !=TCF_META_TYPE (hdr->right.kind) ||TCF_META_TYPE (hdr->left.kind) >TCF_META_TYPE_MAX ||TCF_META_ID (hdr->left.kind) >TCF_META_ID_MAX ||TCF_META_ID (hdr->right.kind) >TCF_META_ID_MAX ) - goto errout; + goto exit; meta =kzalloc (sizeof (*meta),GFP_KERNEL );if (meta =NULL ) { err = -ENOMEM ; - goto errout; + goto exit; }memcpy (&meta->lvalue.hdr, &hdr->left,sizeof (hdr->left));@@ -891,20 +891,20 @@ static int em_meta_change(struct net *net, void *data, int len,if (!meta_is_supported (&meta->lvalue) || !meta_is_supported (&meta->rvalue)) { err = -EOPNOTSUPP ; - goto errout; + goto delete_meta; }if (meta_change_data (&meta->lvalue, tb[TCA_EM_META_LVALUE ]) <0 ||meta_change_data (&meta->rvalue, tb[TCA_EM_META_RVALUE ]) <0 ) - goto errout; + goto delete_meta; m->datalen =sizeof (*meta); m->data = (unsigned long ) meta;
net/sched/em_meta.c static int em_meta_change(struct net *net, void *data, int len, · line 909
Quoted 10 lines
net/sched/em_meta.c +4
-4- err =0 ; -errout: -if (err && meta) -meta_delete (meta); +return 0 ; +delete_meta: +meta_delete (meta); +exit:return err; }
Why do you use that exit label if it does nothing more than returning the error value? Also if nla_parse fails you dont use it but return the error directly. While using a label which is used only to return an error may be a matter of taste, its at least inconsistent to do both in a function, use such a label in one case and return immediately in another, isnt it?
Regards,
Lino
Re: [PATCH] net: sched: One function call less in em_meta_change() after error detection
Quoted 10 lines
net/sched/em_meta.c static int em_meta_change(struct net *net, void *data, int len, · line 909
Quoted 3 lines
net/sched/em_meta.c +1
-0+exit:return err; }Why do you use that exit label if it does nothing more than returning the error value? Also if
nla_parsefails you dont use it but return the error directly. While using a label which is used only to return an error may be a matter of taste, its at least inconsistent to do both in a function, use such a label in one case and return immediately in another, isnt it?
I find that all these cases correspond to the current Linux coding style documentation, doesn't it?
Regards,
Markus
Re: [PATCH] net: sched: One function call less in em_meta_change() after error detection
Quoted 4 lines · SF Markus Elfring
I find that all these cases correspond to the current Linux coding style documentation, doesn't it?
Sure, I think it does. But it was not coding style violation what I was reffering to.
Regards,
Lino
Re: [PATCH] net: sched: One function call less in em_meta_change() after error detection
Quoted 4 lines
Quoted 2 lines
I find that all these cases correspond to the current Linux coding style documentation, doesn't it?
Sure, I think it does.
Thanks for your acknowledgement.
Quoted 1 line
But it was not coding style violation what I was reffering to.
Do you suggest any fine-tuning for the affected documentation so that I would tweak my update suggestion once more?
Regards,
Markus
Re: [PATCH] net: sched: One function call less in em_meta_change() after error detection
Quoted 5 lines · SF Markus Elfring
Quoted 4 lines
Quoted 2 lines
I find that all these cases correspond to the current Linux coding style documentation, doesn't it?
Sure, I think it does.
Quoted 8 lines
Thanks for your acknowledgement.
Quoted 1 line
But it was not coding style violation what I was reffering to.
Do you suggest any fine-tuning for the affected documentation so that I would tweak my update suggestion once more?
No I dont think that any documentation has to be adjusted. If you agree with me you should adjust the patch accordingly and resend it. Otherwise keep it as it is.
Regards,
Lino
Re: [PATCH] net: sched: One function call less in em_meta_change() after error detection
In reply to SF Markus Elfringnet/sched/em_meta.c static int em_meta_change(struct net *net, void *data, int len, · line 907
Quoted 3 lines · SF Markus Elfring
net/sched/em_meta.c +0
-3-errout: -if (err && meta) -meta_delete (meta);
Since this patch seems to be about optimization and cleanup you should probably also remove the now unnecessary initialization of "meta" with NULL at the beginning of the function...
Regards,
Lino
Re: [PATCH] net: sched: One function call less in em_meta_change() after error detection
Quoted 7 lines
net/sched/em_meta.c static int em_meta_change(struct net *net, void *data, int len, · line 907
Quoted 3 lines
net/sched/em_meta.c +0
-3-errout: -if (err && meta) -meta_delete (meta);Since this patch seems to be about optimization and cleanup you should probably also remove the now unnecessary initialization of "meta" with NULL at the beginning of the function...
Will the optimiser of the C compiler drop any remaining unnecessary variable initialisations?
Do you want another update step here?
Regards,
Markus
Re: [PATCH] net: sched: One function call less in em_meta_change() after error detection
Quoted 11 lines · SF Markus Elfring
Quoted 7 lines
net/sched/em_meta.c static int em_meta_change(struct net *net, void *data, int len, · line 907
Quoted 3 lines
net/sched/em_meta.c +0
-3-errout: -if (err && meta) -meta_delete (meta);Since this patch seems to be about optimization and cleanup you should probably also remove the now unnecessary initialization of "meta" with NULL at the beginning of the function...
Will the optimiser of the C compiler drop any remaining unnecessary variable initialisations?
I dont know if that matters, since the code is not only used by compilers but also read by humans.
Quoted 2 lines
Do you want another update step here?
I am not the one who decides if this patch is acceptable or not. But I vote for a removal of that assignment (as a part of the same patch).
Regards,
Lino
David Miller
maintainerRe: [PATCH] net: sched: One function call less in em_meta_change() after error detection
In reply to SF Markus ElfringFrom: SF Markus Elfring <[email protected]>
Date: Sat, 31 Jan 2015 17:34:54 +0100
Quoted 9 lines
From: Markus Elfring <[email protected]>
Date: Sat, 31 Jan 2015 17:18:48 +0100The
meta_delete()function could be called in four cases by theem_meta_change()function during error handling even if the passed variable "meta" contained still a null pointer.* This implementation detail could be improved by adjustments for jump labels.
Quoted 7 lines
* Let us return immediately after the first failed function call according to the current Linux coding style convention.
* Let us delete also unnecessary checks for the variables "err" and "meta" there.
Signed-off-by Markus Elfring <[email protected]>
I kind of like the way the code is now, branching to the end of the function even when cleanups are not necessary.
Inter-function return statements make code harder to audit, for locking errors, resource leaks, etc.
Re: [PATCH] net: sched: One function call less in em_meta_change() after error detection
Quoted 6 lines
Quoted 6 lines
The
meta_delete()function could be called in four cases by theem_meta_change()function during error handling even if the passed variable "meta" contained still a null pointer.* This implementation detail could be improved by adjustments for jump labels.
Quoted 8 lines
Quoted 5 lines
* Let us return immediately after the first failed function call according to the current Linux coding style convention.
* Let us delete also unnecessary checks for the variables "err" and "meta" there.
I kind of like the way the code is now, branching to the end of the function even when cleanups are not necessary.
I would appreciate if the affected exception handling can become also a bit more efficient.
Regards,
Markus
PATCH 1/1 net: sctp: Deletion of an unnecessary check before the function call "kfree"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 31 Jan 2015 18:10:03 +0100
The kfree() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- net/sctp/associola.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
net/sctp/associola.c +1 -2
@@ -391,8 +391,7 @@ void sctp_association_free(struct sctp_association *asoc)sctp_asconf_queue_teardown (asoc);/* Free pending address space being deleted */ -if (asoc->asconf_addr_del_pending !=NULL ) -kfree (asoc->asconf_addr_del_pending); +kfree (asoc->asconf_addr_del_pending);/* AUTH - Free the endpoint shared keys */ sctp_auth_destroy_keys (&asoc->endpoint_shared_keys);
Signature · 1 line
2.2.2
Re: [PATCH] net: sctp: Deletion of an unnecessary check before the function call "kfree"
Quoted 31 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 31 Jan 2015 18:10:03 +0100The
kfree()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- net/sctp/associola.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)net/sctp/associola.c +1
-2@@ -391,8 +391,7 @@ void sctp_association_free(struct sctp_association *asoc)sctp_asconf_queue_teardown (asoc);/* Free pending address space being deleted */ -if (asoc->asconf_addr_del_pending !=NULL ) -kfree (asoc->asconf_addr_del_pending); +kfree (asoc->asconf_addr_del_pending);/* AUTH - Free the endpoint shared keys */ sctp_auth_destroy_keys (&asoc->endpoint_shared_keys);Signature · 1 line
2.2.2
Sure, seems reasonable
Re: [PATCH] net: sctp: Deletion of an unnecessary check before the function call "kfree"
In reply to SF Markus ElfringFrom: SF Markus Elfring <[email protected]>
Date: Sat, 31 Jan 2015 18:15:59 +0100
Quoted 9 lines
From: Markus Elfring <[email protected]>
Date: Sat, 31 Jan 2015 18:10:03 +0100The
kfree()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Applied to net-next, thanks.
cover netlabel: Deletion of a few unnecessary checks
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 31 Jan 2015 22:00:14 +0100
Further update suggestions were taken into account after patches were applied from static source code analysis.
Markus Elfring (3):
Deletion of an unnecessary check before the function call "cipso_v4_doi_putdef" Deletion of an unnecessary check before the function call "cipso_v4_doi_free" Less function calls in netlbl_mgmt_add_common() after error detection
net/netlabel/netlabel_cipso_v4.c | 3 +-- net/netlabel/netlabel_mgmt.c | 47 ++++++++++++++++++++-------------------- 2 files changed, 24 insertions(+), 26 deletions(-)
Signature · 1 line
2.2.2
PATCH 1/3 netlabel: Deletion of an unnecessary check before the function call "cipso_v4_doi_putdef"
From: Markus Elfring <[email protected]>
Date: Sat, 31 Jan 2015 19:09:50 +0100
The cipso_v4_doi_putdef() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- net/netlabel/netlabel_mgmt.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
net/netlabel/netlabel_mgmt.c +1 -2
@@ -242,8 +242,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info,return 0 ; add_failure: -if (cipsov4) -cipso_v4_doi_putdef (cipsov4); +cipso_v4_doi_putdef (cipsov4);if (entry)kfree (entry->domain);kfree (addrmap);
Signature · 1 line
2.2.2
Re: [PATCH 1/3] netlabel: Deletion of an unnecessary check before the function call "cipso_v4_doi_putdef"
Quoted 6 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 31 Jan 2015 19:09:50 +0100The
cipso_v4_doi_putdef()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
Quoted 6 lines
This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- net/netlabel/netlabel_mgmt.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
Quoted 17 lines
net/netlabel/netlabel_mgmt.c +1
-3@@ -242,8 +242,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info,return 0 ; add_failure: -if (cipsov4) -cipso_v4_doi_putdef (cipsov4); +cipso_v4_doi_putdef (cipsov4);if (entry)kfree (entry->domain);kfree (addrmap); --2.2.2
Signature · 2 lines
paul moore www.paul-moore.com
PATCH 2/3 netlabel: Deletion of an unnecessary check before the function call "cipso_v4_doi_free"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 31 Jan 2015 19:35:59 +0100
The cipso_v4_doi_free() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- net/netlabel/netlabel_cipso_v4.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
net/netlabel/netlabel_cipso_v4.c +1 -2
@@ -324,8 +324,7 @@ static int netlbl_cipsov4_add_std(struct genl_info *info,return 0 ; add_std_failure: -if (doi_def) -cipso_v4_doi_free (doi_def); +cipso_v4_doi_free (doi_def);return ret_val; }
Signature · 1 line
2.2.2
Re: [PATCH 2/3] netlabel: Deletion of an unnecessary check before the function call "cipso_v4_doi_free"
Quoted 6 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 31 Jan 2015 19:35:59 +0100The
cipso_v4_doi_free()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
Quoted 6 lines
This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- net/netlabel/netlabel_cipso_v4.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
Quoted 17 lines
net/netlabel/netlabel_cipso_v4.c +1
-3@@ -324,8 +324,7 @@ static int netlbl_cipsov4_add_std(struct genl_info *info,return 0 ; add_std_failure: -if (doi_def) -cipso_v4_doi_free (doi_def); +cipso_v4_doi_free (doi_def);return ret_val; } --2.2.2
Signature · 2 lines
paul moore www.paul-moore.com
PATCH 3/3 netlabel: Less function calls in netlbl_mgmt_add_common() after error detection
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 31 Jan 2015 21:55:48 +0100
The functions "cipso_v4_doi_putdef" and "kfree" could be called in some cases by the netlbl_mgmt_add_common() function during error handling even if the passed variables contained still a null pointer.
* This implementation detail could be improved by adjustments for jump labels.
* Let us return immediately after the first failed function call according to the current Linux coding style convention.
* Let us delete also an unnecessary check for the variable "entry" there.
--- net/netlabel/netlabel_mgmt.c | 46 ++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 23 deletions(-)
net/netlabel/netlabel_mgmt.c +23 -23
@@ -99,17 +99,15 @@ static int netlbl_mgmt_add_common(struct genl_info *info,u32 tmp_val; entry =kzalloc (sizeof (*entry),GFP_KERNEL ); -if (entry =NULL ) { - ret_val = -ENOMEM ; - goto add_failure; - } +if (!entry) +return -ENOMEM ; entry->def.type =nla_get_u32 (info->attrs[NLBL_MGMT_A_PROTOCOL ]);if (info->attrs[NLBL_MGMT_A_DOMAIN ]) {size_t tmp_size =nla_len (info->attrs[NLBL_MGMT_A_DOMAIN ]); entry->domain =kmalloc (tmp_size,GFP_KERNEL );if (entry->domain =NULL ) { ret_val = -ENOMEM ; - goto add_failure; + goto free_entry; }nla_strlcpy (entry->domain, info->attrs[NLBL_MGMT_A_DOMAIN ], tmp_size);
@@ -125,16 +123,16 @@ static int netlbl_mgmt_add_common(struct genl_info *info,break ;case NETLBL_NLTYPE_CIPSOV4 :if (!info->attrs[NLBL_MGMT_A_CV4DOI ]) - goto add_failure; + goto free_domain; tmp_val =nla_get_u32 (info->attrs[NLBL_MGMT_A_CV4DOI ]); cipsov4 =cipso_v4_doi_getdef (tmp_val);if (cipsov4 =NULL ) - goto add_failure; + goto free_domain; entry->def.cipso = cipsov4;break ;default : - goto add_failure; + goto free_domain; }if (info->attrs[NLBL_MGMT_A_IPV4ADDR ]) {
@@ -145,7 +143,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info, addrmap =kzalloc (sizeof (*addrmap),GFP_KERNEL );if (addrmap =NULL ) { ret_val = -ENOMEM ; - goto add_failure; + goto doi_put_def; }INIT_LIST_HEAD (&addrmap->list4);INIT_LIST_HEAD (&addrmap->list6);
@@ -153,12 +151,12 @@ static int netlbl_mgmt_add_common(struct genl_info *info, if (nla_len(info->attrs[NLBL_MGMT_A_IPV4ADDR]) ! sizeof(struct in_addr)) { ret_val = -EINVAL ; - goto add_failure; + goto free_address_map; } if (nla_len(info->attrs[NLBL_MGMT_A_IPV4MASK]) ! sizeof(struct in_addr)) { ret_val = -EINVAL ; - goto add_failure; + goto free_address_map; } addr =nla_data (info->attrs[NLBL_MGMT_A_IPV4ADDR ]); mask =nla_data (info->attrs[NLBL_MGMT_A_IPV4MASK ]);
@@ -166,7 +164,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info, map =kzalloc (sizeof (*map),GFP_KERNEL );if (map =NULL ) { ret_val = -ENOMEM ; - goto add_failure; + goto free_address_map; } map->list.addr = addr->s_addr & mask->s_addr; map->list.mask = mask->s_addr;
@@ -178,7 +176,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info, ret_val =netlbl_af4list_add (&map->list, &addrmap->list4);if (ret_val !=0 ) {kfree (map); - goto add_failure; + goto free_address_map; } entry->def.type =NETLBL_NLTYPE_ADDRSELECT ;
@@ -192,7 +190,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info, addrmap =kzalloc (sizeof (*addrmap),GFP_KERNEL );if (addrmap =NULL ) { ret_val = -ENOMEM ; - goto add_failure; + goto doi_put_def; }INIT_LIST_HEAD (&addrmap->list4);INIT_LIST_HEAD (&addrmap->list6);
@@ -200,12 +198,12 @@ static int netlbl_mgmt_add_common(struct genl_info *info, if (nla_len(info->attrs[NLBL_MGMT_A_IPV6ADDR]) ! sizeof(struct in6_addr)) { ret_val = -EINVAL ; - goto add_failure; + goto free_address_map; } if (nla_len(info->attrs[NLBL_MGMT_A_IPV6MASK]) ! sizeof(struct in6_addr)) { ret_val = -EINVAL ; - goto add_failure; + goto free_address_map; } addr =nla_data (info->attrs[NLBL_MGMT_A_IPV6ADDR ]); mask =nla_data (info->attrs[NLBL_MGMT_A_IPV6MASK ]);
@@ -213,7 +211,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info, map =kzalloc (sizeof (*map),GFP_KERNEL );if (map =NULL ) { ret_val = -ENOMEM ; - goto add_failure; + goto free_address_map; } map->list.addr = *addr; map->list.addr.s6_addr32[0 ] &= mask->s6_addr32[0 ];
@@ -227,7 +225,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info, ret_val =netlbl_af6list_add (&map->list, &addrmap->list6);if (ret_val !=0 ) {kfree (map); - goto add_failure; + goto free_address_map; } entry->def.type =NETLBL_NLTYPE_ADDRSELECT ;
@@ -237,15 +235,17 @@ static int netlbl_mgmt_add_common(struct genl_info *info, ret_val =netlbl_domhsh_add (entry, audit_info);if (ret_val !=0 ) - goto add_failure; + goto free_address_map;return 0 ; -add_failure: -cipso_v4_doi_putdef (cipsov4); -if (entry) -kfree (entry->domain); +free_address_map:kfree (addrmap); +doi_put_def: +cipso_v4_doi_putdef (cipsov4); +free_domain: +kfree (entry->domain); +free_entry:kfree (entry);return ret_val; }
Signature · 1 line
2.2.2
Paul Moore
maintainerRe: [PATCH 3/3] netlabel: Less function calls in netlbl_mgmt_add_common() after error detection
Quoted 23 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 31 Jan 2015 21:55:48 +0100The functions "
cipso_v4_doi_putdef" and "kfree" could be called in some cases by thenetlbl_mgmt_add_common()function during error handling even if the passed variables contained still a null pointer.* This implementation detail could be improved by adjustments for jump labels.
* Let us return immediately after the first failed function call according to the current Linux coding style convention.
* Let us delete also an unnecessary check for the variable "entry" there.
Signed-off-by Markus Elfring <[email protected]>--- net/netlabel/netlabel_mgmt.c | 46 ++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 23 deletions(-)net/netlabel/netlabel_mgmt.c +0
-0
...
Quoted 13 lines
net/netlabel/netlabel_mgmt.c +1
-5@@ -237,15 +235,17 @@ static int netlbl_mgmt_add_common(struct genl_info *info, ret_val =netlbl_domhsh_add (entry, audit_info);if (ret_val !=0 ) - goto add_failure; + goto free_address_map;return 0 ; -add_failure: -cipso_v4_doi_putdef (cipsov4); -if (entry) -kfree (entry->domain);
net/netlabel/netlabel_mgmt.c static int netlbl_mgmt_add_common(struct genl_info *info, · line 251
Quoted 10 lines
net/netlabel/netlabel_mgmt.c +6
-0+free_address_map:kfree (addrmap); +doi_put_def: +cipso_v4_doi_putdef (cipsov4); +free_domain: +kfree (entry->domain); +free_entry:kfree (entry);return ret_val; }
It would be nice if you could stick with the goto label naming style in the rest of the file, e.g. "add_free_addrmap"/"add_put_doi_def"/"add_free_domain"/"add_free_entry".
Signature · 2 lines
paul moore www.paul-moore.com
PATCH v2 3/3 netlabel: Less function calls in netlbl_mgmt_add_common() after error detection
From: Markus Elfring <[email protected]>
Date: Sun, 1 Feb 2015 11:11:29 +0100
The functions "cipso_v4_doi_putdef" and "kfree" could be called in some cases by the netlbl_mgmt_add_common() function during error handling even if the passed variables contained still a null pointer.
* This implementation detail could be improved by adjustments for jump labels.
* Let us return immediately after the first failed function call according to the current Linux coding style convention.
* Let us delete also an unnecessary check for the variable "entry" there.
--- net/netlabel/netlabel_mgmt.c | 49 ++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 25 deletions(-)
net/netlabel/netlabel_mgmt.c +24 -25
@@ -93,23 +93,20 @@ static int netlbl_mgmt_add_common(struct genl_info *info, struct netlbl_audit *audit_info) {int ret_val = -EINVAL ; -struct netlbl_dom_map *entry =NULL ;struct netlbl_domaddr_map *addrmap =NULL ;struct cipso_v4_doi *cipsov4 =NULL ;u32 tmp_val; +struct netlbl_dom_map *entry =kzalloc (sizeof (*entry),GFP_KERNEL ); - entry =kzalloc (sizeof (*entry),GFP_KERNEL ); -if (entry =NULL ) { - ret_val = -ENOMEM ; - goto add_failure; - } +if (!entry) +return -ENOMEM ; entry->def.type =nla_get_u32 (info->attrs[NLBL_MGMT_A_PROTOCOL ]);if (info->attrs[NLBL_MGMT_A_DOMAIN ]) {size_t tmp_size =nla_len (info->attrs[NLBL_MGMT_A_DOMAIN ]); entry->domain =kmalloc (tmp_size,GFP_KERNEL );if (entry->domain =NULL ) { ret_val = -ENOMEM ; - goto add_failure; + goto add_free_entry; }nla_strlcpy (entry->domain, info->attrs[NLBL_MGMT_A_DOMAIN ], tmp_size);
@@ -125,16 +122,16 @@ static int netlbl_mgmt_add_common(struct genl_info *info,break ;case NETLBL_NLTYPE_CIPSOV4 :if (!info->attrs[NLBL_MGMT_A_CV4DOI ]) - goto add_failure; + goto add_free_domain; tmp_val =nla_get_u32 (info->attrs[NLBL_MGMT_A_CV4DOI ]); cipsov4 =cipso_v4_doi_getdef (tmp_val);if (cipsov4 =NULL ) - goto add_failure; + goto add_free_domain; entry->def.cipso = cipsov4;break ;default : - goto add_failure; + goto add_free_domain; }if (info->attrs[NLBL_MGMT_A_IPV4ADDR ]) {
@@ -145,7 +142,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info, addrmap =kzalloc (sizeof (*addrmap),GFP_KERNEL );if (addrmap =NULL ) { ret_val = -ENOMEM ; - goto add_failure; + goto add_doi_put_def; }INIT_LIST_HEAD (&addrmap->list4);INIT_LIST_HEAD (&addrmap->list6);
@@ -153,12 +150,12 @@ static int netlbl_mgmt_add_common(struct genl_info *info, if (nla_len(info->attrs[NLBL_MGMT_A_IPV4ADDR]) ! sizeof(struct in_addr)) { ret_val = -EINVAL ; - goto add_failure; + goto add_free_addrmap; } if (nla_len(info->attrs[NLBL_MGMT_A_IPV4MASK]) ! sizeof(struct in_addr)) { ret_val = -EINVAL ; - goto add_failure; + goto add_free_addrmap; } addr =nla_data (info->attrs[NLBL_MGMT_A_IPV4ADDR ]); mask =nla_data (info->attrs[NLBL_MGMT_A_IPV4MASK ]);
@@ -166,7 +163,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info, map =kzalloc (sizeof (*map),GFP_KERNEL );if (map =NULL ) { ret_val = -ENOMEM ; - goto add_failure; + goto add_free_addrmap; } map->list.addr = addr->s_addr & mask->s_addr; map->list.mask = mask->s_addr;
@@ -178,7 +175,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info, ret_val =netlbl_af4list_add (&map->list, &addrmap->list4);if (ret_val !=0 ) {kfree (map); - goto add_failure; + goto add_free_addrmap; } entry->def.type =NETLBL_NLTYPE_ADDRSELECT ;
@@ -192,7 +189,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info, addrmap =kzalloc (sizeof (*addrmap),GFP_KERNEL );if (addrmap =NULL ) { ret_val = -ENOMEM ; - goto add_failure; + goto add_doi_put_def; }INIT_LIST_HEAD (&addrmap->list4);INIT_LIST_HEAD (&addrmap->list6);
@@ -200,12 +197,12 @@ static int netlbl_mgmt_add_common(struct genl_info *info, if (nla_len(info->attrs[NLBL_MGMT_A_IPV6ADDR]) ! sizeof(struct in6_addr)) { ret_val = -EINVAL ; - goto add_failure; + goto add_free_addrmap; } if (nla_len(info->attrs[NLBL_MGMT_A_IPV6MASK]) ! sizeof(struct in6_addr)) { ret_val = -EINVAL ; - goto add_failure; + goto add_free_addrmap; } addr =nla_data (info->attrs[NLBL_MGMT_A_IPV6ADDR ]); mask =nla_data (info->attrs[NLBL_MGMT_A_IPV6MASK ]);
@@ -213,7 +210,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info, map =kzalloc (sizeof (*map),GFP_KERNEL );if (map =NULL ) { ret_val = -ENOMEM ; - goto add_failure; + goto add_free_addrmap; } map->list.addr = *addr; map->list.addr.s6_addr32[0 ] &= mask->s6_addr32[0 ];
@@ -227,7 +224,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info, ret_val =netlbl_af6list_add (&map->list, &addrmap->list6);if (ret_val !=0 ) {kfree (map); - goto add_failure; + goto add_free_addrmap; } entry->def.type =NETLBL_NLTYPE_ADDRSELECT ;
@@ -237,15 +234,17 @@ static int netlbl_mgmt_add_common(struct genl_info *info, ret_val =netlbl_domhsh_add (entry, audit_info);if (ret_val !=0 ) - goto add_failure; + goto add_free_addrmap;return 0 ; -add_failure: -cipso_v4_doi_putdef (cipsov4); -if (entry) -kfree (entry->domain); +add_free_addrmap:kfree (addrmap); +add_doi_put_def: +cipso_v4_doi_putdef (cipsov4); +add_free_domain: +kfree (entry->domain); +add_free_entry:kfree (entry);return ret_val; }
Signature · 1 line
2.2.2
Re: [PATCH v2 3/3] netlabel: Less function calls in netlbl_mgmt_add_common() after error detection
Quoted 12 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 1 Feb 2015 11:11:29 +0100The functions "
cipso_v4_doi_putdef" and "kfree" could be called in some cases by thenetlbl_mgmt_add_common()function during error handling even if the passed variables contained still a null pointer.* This implementation detail could be improved by adjustments for jump labels.
* Let us return immediately after the first failed function call according to the current Linux coding style convention.
Quoted 6 lines
* Let us delete also an unnecessary check for the variable "entry" there.
Signed-off-by Markus Elfring <[email protected]>--- net/netlabel/netlabel_mgmt.c | 49 ++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 25 deletions(-)
Thanks for fixing the label names.
Quoted 158 lines
net/netlabel/netlabel_mgmt.c +24
-26@@ -93,23 +93,20 @@ static int netlbl_mgmt_add_common(struct genl_info *info, struct netlbl_audit *audit_info) {int ret_val = -EINVAL ; -struct netlbl_dom_map *entry =NULL ;struct netlbl_domaddr_map *addrmap =NULL ;struct cipso_v4_doi *cipsov4 =NULL ;u32 tmp_val; +struct netlbl_dom_map *entry =kzalloc (sizeof (*entry),GFP_KERNEL ); - entry =kzalloc (sizeof (*entry),GFP_KERNEL ); -if (entry =NULL ) { - ret_val = -ENOMEM ; - goto add_failure; - } +if (!entry) +return -ENOMEM ; entry->def.type =nla_get_u32 (info->attrs[NLBL_MGMT_A_PROTOCOL ]);if (info->attrs[NLBL_MGMT_A_DOMAIN ]) {size_t tmp_size =nla_len (info->attrs[NLBL_MGMT_A_DOMAIN ]); entry->domain =kmalloc (tmp_size,GFP_KERNEL );if (entry->domain =NULL ) { ret_val = -ENOMEM ; - goto add_failure; + goto add_free_entry; }nla_strlcpy (entry->domain, info->attrs[NLBL_MGMT_A_DOMAIN ], tmp_size);@@ -125,16 +122,16 @@ static int netlbl_mgmt_add_common(struct genl_info *info,break ;case NETLBL_NLTYPE_CIPSOV4 :if (!info->attrs[NLBL_MGMT_A_CV4DOI ]) - goto add_failure; + goto add_free_domain; tmp_val =nla_get_u32 (info->attrs[NLBL_MGMT_A_CV4DOI ]); cipsov4 =cipso_v4_doi_getdef (tmp_val);if (cipsov4 =NULL ) - goto add_failure; + goto add_free_domain; entry->def.cipso = cipsov4;break ;default : - goto add_failure; + goto add_free_domain; }if (info->attrs[NLBL_MGMT_A_IPV4ADDR ]) {@@ -145,7 +142,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info, addrmap =kzalloc (sizeof (*addrmap),GFP_KERNEL );if (addrmap =NULL ) { ret_val = -ENOMEM ; - goto add_failure; + goto add_doi_put_def; }INIT_LIST_HEAD (&addrmap->list4);INIT_LIST_HEAD (&addrmap->list6);@@ -153,12 +150,12 @@ static int netlbl_mgmt_add_common(struct genl_info *info, if (nla_len(info->attrs[NLBL_MGMT_A_IPV4ADDR]) !> sizeof(struct in_addr)) { ret_val = -EINVAL ; - goto add_failure; + goto add_free_addrmap; } if (nla_len(info->attrs[NLBL_MGMT_A_IPV4MASK]) !> sizeof(struct in_addr)) { ret_val = -EINVAL ; - goto add_failure; + goto add_free_addrmap; } addr =nla_data (info->attrs[NLBL_MGMT_A_IPV4ADDR ]); mask =nla_data (info->attrs[NLBL_MGMT_A_IPV4MASK ]);@@ -166,7 +163,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info, map =kzalloc (sizeof (*map),GFP_KERNEL );if (map =NULL ) { ret_val = -ENOMEM ; - goto add_failure; + goto add_free_addrmap; } map->list.addr = addr->s_addr & mask->s_addr; map->list.mask = mask->s_addr;@@ -178,7 +175,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info, ret_val =netlbl_af4list_add (&map->list, &addrmap->list4);if (ret_val !=0 ) {kfree (map); - goto add_failure; + goto add_free_addrmap; } entry->def.type =NETLBL_NLTYPE_ADDRSELECT ;@@ -192,7 +189,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info, addrmap =kzalloc (sizeof (*addrmap),GFP_KERNEL );if (addrmap =NULL ) { ret_val = -ENOMEM ; - goto add_failure; + goto add_doi_put_def; }INIT_LIST_HEAD (&addrmap->list4);INIT_LIST_HEAD (&addrmap->list6);@@ -200,12 +197,12 @@ static int netlbl_mgmt_add_common(struct genl_info *info, if (nla_len(info->attrs[NLBL_MGMT_A_IPV6ADDR]) !> sizeof(struct in6_addr)) { ret_val = -EINVAL ; - goto add_failure; + goto add_free_addrmap; } if (nla_len(info->attrs[NLBL_MGMT_A_IPV6MASK]) !> sizeof(struct in6_addr)) { ret_val = -EINVAL ; - goto add_failure; + goto add_free_addrmap; } addr =nla_data (info->attrs[NLBL_MGMT_A_IPV6ADDR ]); mask =nla_data (info->attrs[NLBL_MGMT_A_IPV6MASK ]);@@ -213,7 +210,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info, map =kzalloc (sizeof (*map),GFP_KERNEL );if (map =NULL ) { ret_val = -ENOMEM ; - goto add_failure; + goto add_free_addrmap; } map->list.addr = *addr; map->list.addr.s6_addr32[0 ] &= mask->s6_addr32[0 ];@@ -227,7 +224,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info, ret_val =netlbl_af6list_add (&map->list, &addrmap->list6);if (ret_val !=0 ) {kfree (map); - goto add_failure; + goto add_free_addrmap; } entry->def.type =NETLBL_NLTYPE_ADDRSELECT ;@@ -237,15 +234,17 @@ static int netlbl_mgmt_add_common(struct genl_info *info, ret_val =netlbl_domhsh_add (entry, audit_info);if (ret_val !=0 ) - goto add_failure; + goto add_free_addrmap;return 0 ; -add_failure: -cipso_v4_doi_putdef (cipsov4); -if (entry) -kfree (entry->domain); +add_free_addrmap:kfree (addrmap); +add_doi_put_def: +cipso_v4_doi_putdef (cipsov4); +add_free_domain: +kfree (entry->domain); +add_free_entry:kfree (entry);return ret_val; } --2.2.2
Signature · 2 lines
paul moore www.paul-moore.com
David Miller
maintainerRe: [PATCH v2 3/3] netlabel: Less function calls in netlbl_mgmt_add_common() after error detection
In reply to SF Markus ElfringWhen you post a new version of a patch within a series, you must repost the entire series, not just the patch which is changing.
Thanks.
v3 cover netlabel: Deletion of a few unnecessary checks
From: Markus Elfring <[email protected]>
Date: Mon, 2 Feb 2015 11:15:56 +0100
Further update suggestions were taken into account after patches were applied from static source code analysis.
Markus Elfring (3):
Deletion of an unnecessary check before the function call "cipso_v4_doi_putdef" Deletion of an unnecessary check before the function call "cipso_v4_doi_free" Less function calls in netlbl_mgmt_add_common() after error detection
net/netlabel/netlabel_cipso_v4.c | 3 +-- net/netlabel/netlabel_mgmt.c | 50 +++++++++++++++++++--------------------- 2 files changed, 25 insertions(+), 28 deletions(-)
Signature · 1 line
2.2.2
PATCH v3 1/3 netlabel: Deletion of an unnecessary check before the function call "cipso_v4_doi_putdef"
From: Markus Elfring <[email protected]>
Date: Mon, 2 Feb 2015 10:01:45 +0100
The cipso_v4_doi_putdef() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- net/netlabel/netlabel_mgmt.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
net/netlabel/netlabel_mgmt.c +1 -2
@@ -242,8 +242,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info,return 0 ; add_failure: -if (cipsov4) -cipso_v4_doi_putdef (cipsov4); +cipso_v4_doi_putdef (cipsov4);if (entry)kfree (entry->domain);kfree (addrmap);
Signature · 1 line
2.2.2
PATCH v3 2/3 netlabel: Deletion of an unnecessary check before the function call "cipso_v4_doi_free"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 2 Feb 2015 10:40:30 +0100
The cipso_v4_doi_free() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- net/netlabel/netlabel_cipso_v4.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
net/netlabel/netlabel_cipso_v4.c +1 -2
@@ -324,8 +324,7 @@ static int netlbl_cipsov4_add_std(struct genl_info *info,return 0 ; add_std_failure: -if (doi_def) -cipso_v4_doi_free (doi_def); +cipso_v4_doi_free (doi_def);return ret_val; }
Signature · 1 line
2.2.2
PATCH v3 3/3 netlabel: Less function calls in netlbl_mgmt_add_common() after error detection
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 2 Feb 2015 11:00:24 +0100
The functions "cipso_v4_doi_putdef" and "kfree" could be called in some cases by the netlbl_mgmt_add_common() function during error handling even if the passed variables contained still a null pointer.
* This implementation detail could be improved by adjustments for jump labels.
* Let us return immediately after the first failed function call according to the current Linux coding style convention.
* Let us delete also an unnecessary check for the variable "entry" there.
--- net/netlabel/netlabel_mgmt.c | 49 ++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 25 deletions(-)
net/netlabel/netlabel_mgmt.c +24 -25
@@ -93,23 +93,20 @@ static int netlbl_mgmt_add_common(struct genl_info *info, struct netlbl_audit *audit_info) {int ret_val = -EINVAL ; -struct netlbl_dom_map *entry =NULL ;struct netlbl_domaddr_map *addrmap =NULL ;struct cipso_v4_doi *cipsov4 =NULL ;u32 tmp_val; +struct netlbl_dom_map *entry =kzalloc (sizeof (*entry),GFP_KERNEL ); - entry =kzalloc (sizeof (*entry),GFP_KERNEL ); -if (entry =NULL ) { - ret_val = -ENOMEM ; - goto add_failure; - } +if (!entry) +return -ENOMEM ; entry->def.type =nla_get_u32 (info->attrs[NLBL_MGMT_A_PROTOCOL ]);if (info->attrs[NLBL_MGMT_A_DOMAIN ]) {size_t tmp_size =nla_len (info->attrs[NLBL_MGMT_A_DOMAIN ]); entry->domain =kmalloc (tmp_size,GFP_KERNEL );if (entry->domain =NULL ) { ret_val = -ENOMEM ; - goto add_failure; + goto add_free_entry; }nla_strlcpy (entry->domain, info->attrs[NLBL_MGMT_A_DOMAIN ], tmp_size);
@@ -125,16 +122,16 @@ static int netlbl_mgmt_add_common(struct genl_info *info,break ;case NETLBL_NLTYPE_CIPSOV4 :if (!info->attrs[NLBL_MGMT_A_CV4DOI ]) - goto add_failure; + goto add_free_domain; tmp_val =nla_get_u32 (info->attrs[NLBL_MGMT_A_CV4DOI ]); cipsov4 =cipso_v4_doi_getdef (tmp_val);if (cipsov4 =NULL ) - goto add_failure; + goto add_free_domain; entry->def.cipso = cipsov4;break ;default : - goto add_failure; + goto add_free_domain; }if (info->attrs[NLBL_MGMT_A_IPV4ADDR ]) {
@@ -145,7 +142,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info, addrmap =kzalloc (sizeof (*addrmap),GFP_KERNEL );if (addrmap =NULL ) { ret_val = -ENOMEM ; - goto add_failure; + goto add_doi_put_def; }INIT_LIST_HEAD (&addrmap->list4);INIT_LIST_HEAD (&addrmap->list6);
@@ -153,12 +150,12 @@ static int netlbl_mgmt_add_common(struct genl_info *info, if (nla_len(info->attrs[NLBL_MGMT_A_IPV4ADDR]) ! sizeof(struct in_addr)) { ret_val = -EINVAL ; - goto add_failure; + goto add_free_addrmap; } if (nla_len(info->attrs[NLBL_MGMT_A_IPV4MASK]) ! sizeof(struct in_addr)) { ret_val = -EINVAL ; - goto add_failure; + goto add_free_addrmap; } addr =nla_data (info->attrs[NLBL_MGMT_A_IPV4ADDR ]); mask =nla_data (info->attrs[NLBL_MGMT_A_IPV4MASK ]);
@@ -166,7 +163,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info, map =kzalloc (sizeof (*map),GFP_KERNEL );if (map =NULL ) { ret_val = -ENOMEM ; - goto add_failure; + goto add_free_addrmap; } map->list.addr = addr->s_addr & mask->s_addr; map->list.mask = mask->s_addr;
@@ -178,7 +175,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info, ret_val =netlbl_af4list_add (&map->list, &addrmap->list4);if (ret_val !=0 ) {kfree (map); - goto add_failure; + goto add_free_addrmap; } entry->def.type =NETLBL_NLTYPE_ADDRSELECT ;
@@ -192,7 +189,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info, addrmap =kzalloc (sizeof (*addrmap),GFP_KERNEL );if (addrmap =NULL ) { ret_val = -ENOMEM ; - goto add_failure; + goto add_doi_put_def; }INIT_LIST_HEAD (&addrmap->list4);INIT_LIST_HEAD (&addrmap->list6);
@@ -200,12 +197,12 @@ static int netlbl_mgmt_add_common(struct genl_info *info, if (nla_len(info->attrs[NLBL_MGMT_A_IPV6ADDR]) ! sizeof(struct in6_addr)) { ret_val = -EINVAL ; - goto add_failure; + goto add_free_addrmap; } if (nla_len(info->attrs[NLBL_MGMT_A_IPV6MASK]) ! sizeof(struct in6_addr)) { ret_val = -EINVAL ; - goto add_failure; + goto add_free_addrmap; } addr =nla_data (info->attrs[NLBL_MGMT_A_IPV6ADDR ]); mask =nla_data (info->attrs[NLBL_MGMT_A_IPV6MASK ]);
@@ -213,7 +210,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info, map =kzalloc (sizeof (*map),GFP_KERNEL );if (map =NULL ) { ret_val = -ENOMEM ; - goto add_failure; + goto add_free_addrmap; } map->list.addr = *addr; map->list.addr.s6_addr32[0 ] &= mask->s6_addr32[0 ];
@@ -227,7 +224,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info, ret_val =netlbl_af6list_add (&map->list, &addrmap->list6);if (ret_val !=0 ) {kfree (map); - goto add_failure; + goto add_free_addrmap; } entry->def.type =NETLBL_NLTYPE_ADDRSELECT ;
@@ -237,15 +234,17 @@ static int netlbl_mgmt_add_common(struct genl_info *info, ret_val =netlbl_domhsh_add (entry, audit_info);if (ret_val !=0 ) - goto add_failure; + goto add_free_addrmap;return 0 ; -add_failure: -cipso_v4_doi_putdef (cipsov4); -if (entry) -kfree (entry->domain); +add_free_addrmap:kfree (addrmap); +add_doi_put_def: +cipso_v4_doi_putdef (cipsov4); +add_free_domain: +kfree (entry->domain); +add_free_entry:kfree (entry);return ret_val; }
Signature · 1 line
2.2.2
PATCH 1/1 jfs: Deletion of an unnecessary check before the function call "unload_nls"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 1 Feb 2015 17:00:24 +0100
The unload_nls() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- fs/jfs/super.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/jfs/super.c +1 -2
@@ -619,8 +619,7 @@ out_mount_failed:iput (sbi->direct_inode); sbi->direct_inode =NULL ; out_unload: -if (sbi->nls_tab) -unload_nls (sbi->nls_tab); +unload_nls (sbi->nls_tab); out_kfree:kfree (sbi);return ret;
Signature · 1 line
2.2.2
Re: [PATCH] jfs: Deletion of an unnecessary check before the function call "unload_nls"
Quoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 1 Feb 2015 17:00:24 +0100The
unload_nls()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Thanks! I'll push this upstream.
Dave
Quoted 19 lines
--- fs/jfs/super.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)fs/jfs/super.c +1
-2@@ -619,8 +619,7 @@ out_mount_failed:iput (sbi->direct_inode); sbi->direct_inode =NULL ; out_unload: -if (sbi->nls_tab) -unload_nls (sbi->nls_tab); +unload_nls (sbi->nls_tab); out_kfree:kfree (sbi);return ret;
PATCH 1/1 staging: gdm72xx: Deletion of an unnecessary check before the function call "kfree"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 1 Feb 2015 18:28:33 +0100
The kfree() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/staging/gdm72xx/gdm_wimax.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/gdm72xx/gdm_wimax.c +1 -1
@@ -362,7 +362,7 @@ static int gdm_wimax_close(struct net_device *dev)static void kdelete (void **buf) { -if (buf && *buf) { +if (buf) {kfree (*buf); *buf =NULL ; }
Signature · 1 line
2.2.2
Greg Kroah-Hartman
maintainerRe: [PATCH] staging: gdm72xx: Deletion of an unnecessary check before the function call "kfree"
Quoted 18 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 1 Feb 2015 18:28:33 +0100The
kfree()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/staging/gdm72xx/gdm_wimax.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/gdm72xx/gdm_wimax.c +0
-0
drivers/staging/gdm72xx/gdm_wimax.c static int gdm_wimax_close(struct net_device *dev) · line 368
Quoted 8 lines
drivers/staging/gdm72xx/gdm_wimax.c +1
-1@@ -362,7 +362,7 @@ static int gdm_wimax_close(struct net_device *dev)static void kdelete (void **buf) { -if (buf && *buf) { +if (buf) {kfree (*buf); *buf =NULL ; }
Instead we should delete this function and have the driver use the "correct" kfree calls instead, right? That extra setting the buffer to NULL is a waste for most of these calls.
thanks,
greg k-h
cover mn88472: Delete an unnecessary check
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 1 Feb 2015 20:00:17 +0100
Another update suggestion was taken into account after a patch was applied from static source code analysis.
Markus Elfring (2):
Deletion of an unnecessary check before the function call "release_firmware" One function call less in mn88472_init() after error detection
drivers/staging/media/mn88472/mn88472.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
Signature · 1 line
2.2.2
PATCH 1/2 mn88472: Deletion of an unnecessary check before the function call "release_firmware"
From: Markus Elfring <[email protected]>
Date: Sun, 1 Feb 2015 19:12:56 +0100
The release_firmware() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/staging/media/mn88472/mn88472.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/media/mn88472/mn88472.c +1 -2
@@ -315,8 +315,7 @@ static int mn88472_init(struct dvb_frontend *fe)return 0 ; err: -if (fw) -release_firmware (fw); +release_firmware (fw);dev_dbg (&client->dev,"failed=%d\n" , ret);return ret;
Signature · 1 line
2.2.2
PATCH 2/2 mn88472: One function call less in mn88472_init() after error detection
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 1 Feb 2015 19:34:37 +0100
The release_firmware() function was called in three cases by the mn88472_init() function during error handling even if the passed variable "fw" contained still a null pointer.
This implementation detail could be improved by the introduction of another jump label.
--- drivers/staging/media/mn88472/mn88472.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/staging/media/mn88472/mn88472.c +5 -5
@@ -286,7 +286,7 @@ static int mn88472_init(struct dvb_frontend *fe) ret =regmap_write (dev->regmap[0 ],0xf5 ,0x03 );if (ret) - goto err; + goto firmware_release;for (remaining = fw->size; remaining >0 ; remaining -= (dev->i2c_wr_max -1 )) {
@@ -299,13 +299,13 @@ static int mn88472_init(struct dvb_frontend *fe)if (ret) {dev_err (&client->dev,"firmware download failed=%d\n" , ret); - goto err; + goto firmware_release; } } ret =regmap_write (dev->regmap[0 ],0xf5 ,0x00 );if (ret) - goto err; + goto firmware_release;release_firmware (fw); fw =NULL ;
@@ -314,9 +314,9 @@ static int mn88472_init(struct dvb_frontend *fe) dev->warm = true;return 0 ; -err: +firmware_release:release_firmware (fw); - +err:dev_dbg (&client->dev,"failed=%d\n" , ret);return ret; }
Signature · 1 line
2.2.2
[media] staging: bcm2048: Delete an unnecessary check before the function call "video_unregister_device"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 2 Feb 2015 13:20:23 +0100
The video_unregister_device() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/staging/media/bcm2048/radio-bcm2048.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/staging/media/bcm2048/radio-bcm2048.c +1 -3
@@ -2684,9 +2684,7 @@ static int __exit bcm2048_i2c_driver_remove(struct i2c_client *client) vd = bdev->videodev;bcm2048_sysfs_unregister_properties (bdev,ARRAY_SIZE (attrs)); - -if (vd) -video_unregister_device (vd); +video_unregister_device (vd);if (bdev->power_state)bcm2048_set_power_state (bdev,BCM2048_POWER_OFF );
Signature · 1 line
2.2.2
cover md: Deletion of a few unnecessary checks
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 2 Feb 2015 15:51:43 +0100
Further update suggestions were taken into account together with results from static source code analysis.
Markus Elfring (3):
dm snapshot: Deletion of unnecessary checks before the function call "vfree" md/bitmap: Delete an unnecessary check before the function call "kfree" dm ioctl: Delete an unnecessary check before the function call "dm_table_destroy"
drivers/md/bitmap.c | 10 +++++----- drivers/md/dm-ioctl.c | 3 +-- drivers/md/dm-snap-persistent.c | 14 ++++---------- 3 files changed, 10 insertions(+), 17 deletions(-)
Signature · 1 line
2.2.2
PATCH 1/3 dm snapshot: Deletion of unnecessary checks before the function call "vfree"
From: Markus Elfring <[email protected]>
Date: Mon, 2 Feb 2015 14:38:29 +0100
The vfree() function performs also input parameter validation. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/md/dm-snap-persistent.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)
drivers/md/dm-snap-persistent.c +4 -10
@@ -200,16 +200,11 @@ err_area:static void free_area (struct pstore *ps) { -if (ps->area) -vfree (ps->area); +vfree (ps->area); ps->area =NULL ; - -if (ps->zero_area) -vfree (ps->zero_area); +vfree (ps->zero_area); ps->zero_area =NULL ; - -if (ps->header_area) -vfree (ps->header_area); +vfree (ps->header_area); ps->header_area =NULL ; }
@@ -605,8 +600,7 @@ static void persistent_dtr(struct dm_exception_store *store)free_area (ps);/* Allocated in persistent_read_metadata */ -if (ps->callbacks) -vfree (ps->callbacks); +vfree (ps->callbacks);kfree (ps); }
Signature · 1 line
2.2.2
PATCH 2/3 md/bitmap: Delete an unnecessary check before the function call "kfree"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 2 Feb 2015 15:10:57 +0100
The kfree() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
* This issue was detected by using the Coccinelle software.
* Let us also move an assignment for the variable "pages" to the place directly before it is really needed for a loop.
* Let us also move another kfree() call into a block which should belong to a previous check for the variable "bp".
--- drivers/md/bitmap.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/md/bitmap.c +5 -5
@@ -1586,15 +1586,15 @@ static void bitmap_free(struct bitmap *bitmap)bitmap_file_unmap (&bitmap->storage); bp = bitmap->counts.bp; - pages = bitmap->counts.pages;/* free all allocated memory */ - -if (bp)/* deallocate the page memory */ +if (bp) {/* deallocate the page memory */ + pages = bitmap->counts.pages;for (k =0 ; k < pages; k++) -if (bp[k].map && !bp[k].hijacked) +if (!bp[k].hijacked)kfree (bp[k].map); -kfree (bp); +kfree (bp); + }kfree (bitmap); }
Signature · 1 line
2.2.2
Re: [PATCH 2/3] md/bitmap: Delete an unnecessary check before the function call "kfree"
Quoted 34 lines · On Mon, 02 Feb 2015 16:20:42 +0100 SF Markus Elfring…
From: Markus Elfring <[email protected]>
Date: Mon, 2 Feb 2015 15:10:57 +0100The
kfree()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.* This issue was detected by using the Coccinelle software.
* Let us also move an assignment for the variable "pages" to the place directly before it is really needed for a loop.
* Let us also move another
kfree()call into a block which should belong to a previous check for the variable "bp".Signed-off-by Markus Elfring <[email protected]>--- drivers/md/bitmap.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)drivers/md/bitmap.c +2
-3@@ -1586,15 +1586,15 @@ static void bitmap_free(struct bitmap *bitmap)bitmap_file_unmap (&bitmap->storage); bp = bitmap->counts.bp; - pages = bitmap->counts.pages;/* free all allocated memory */ - -if (bp)/* deallocate the page memory */ +if (bp) {/* deallocate the page memory */ + pages = bitmap->counts.pages;
drivers/md/bitmap.c static void bitmap_free(struct bitmap *bitmap) · line 1600
Quoted 10 lines
drivers/md/bitmap.c +3
-2for (k =0 ; k < pages; k++) -if (bp[k].map && !bp[k].hijacked) +if (!bp[k].hijacked)kfree (bp[k].map); -kfree (bp); +kfree (bp); + }kfree (bitmap); }
Hi,
I'm somewhat amused that you removed a test for one kfree, but imposed a test on another. I realised the second test was already there, but why not just:
drivers/md/bitmap.c +1 -1
@@ -1592,7 +1592,7 @@ static void bitmap_free(struct bitmap *bitmap)if (bp)/* deallocate the page memory */ for (k =0 ; k < pages; k++) -if (bp[k].map && !bp[k].hijacked) +if (!bp[k].hijacked)kfree (bp[k].map);kfree (bp);kfree (bitmap);
It makes the intention of the patch much clearer.
I'd probably prefer to leave the code as it is. I don't think either patch is really an improvement in readability, and readability trumps performance in places like this.
Thanks,
NeilBrown
Re: [PATCH 2/3] md/bitmap: Delete an unnecessary check before the function call "kfree"
In reply to SF Markus ElfringAm 02.02.2015 20:46, schrieb NeilBrown:
Quoted 68 lines
Quoted 34 lines · On Mon, 02 Feb 2015 16:20:42 +0100 SF Markus Elfring…
From: Markus Elfring <[email protected]>
Date: Mon, 2 Feb 2015 15:10:57 +0100The
kfree()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.* This issue was detected by using the Coccinelle software.
* Let us also move an assignment for the variable "pages" to the place directly before it is really needed for a loop.
* Let us also move another
kfree()call into a block which should belong to a previous check for the variable "bp".Signed-off-by Markus Elfring <[email protected]>--- drivers/md/bitmap.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)drivers/md/bitmap.c +2
-3@@ -1586,15 +1586,15 @@ static void bitmap_free(struct bitmap *bitmap)bitmap_file_unmap (&bitmap->storage); bp = bitmap->counts.bp; - pages = bitmap->counts.pages;/* free all allocated memory */ - -if (bp)/* deallocate the page memory */ +if (bp) {/* deallocate the page memory */ + pages = bitmap->counts.pages;drivers/md/bitmap.c static void bitmap_free(struct bitmap *bitmap) · line 1600
Quoted 10 lines
drivers/md/bitmap.c +3
-2for (k =0 ; k < pages; k++) -if (bp[k].map && !bp[k].hijacked) +if (!bp[k].hijacked)kfree (bp[k].map); -kfree (bp); +kfree (bp); + }kfree (bitmap); }Hi,
I'm somewhat amused that you removed a test for one kfree, but imposed a test on another. I realised the second test was already there, but why not just:drivers/md/bitmap.c +1
-1@@ -1592,7 +1592,7 @@ static void bitmap_free(struct bitmap *bitmap)if (bp)/* deallocate the page memory */ for (k =0 ; k < pages; k++) -if (bp[k].map && !bp[k].hijacked) +if (!bp[k].hijacked)kfree (bp[k].map);kfree (bp);kfree (bitmap);
Quoted 6 lines
It makes the intention of the patch much clearer.
I'd probably prefer to leave the code as it is. I don't think either patch is really an improvement in readability, and readability trumps performance in places like this.
hello Neil,
just for my curiosity.
is it possible that a bp[k] exists but bp[k].hijacked is 0 ? if that case: kfree(bp) would free an object in use. otherwise hijacked seems useless here as it is possible to free everything.
re,
wh
Re: [PATCH 2/3] md/bitmap: Delete an unnecessary check before the function call "kfree"
In reply to SF Markus ElfringQuoted 86 lines · On Tue, 03 Feb 2015 09:48:01 +0100 walter harms <[email protected]> wrote:
Am 02.02.2015 20:46, schrieb NeilBrown:
Quoted 68 lines
Quoted 34 lines · On Mon, 02 Feb 2015 16:20:42 +0100 SF Markus Elfring…
From: Markus Elfring <[email protected]>
Date: Mon, 2 Feb 2015 15:10:57 +0100The
kfree()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.* This issue was detected by using the Coccinelle software.
* Let us also move an assignment for the variable "pages" to the place directly before it is really needed for a loop.
* Let us also move another
kfree()call into a block which should belong to a previous check for the variable "bp".Signed-off-by Markus Elfring <[email protected]>--- drivers/md/bitmap.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)drivers/md/bitmap.c +2
-3@@ -1586,15 +1586,15 @@ static void bitmap_free(struct bitmap *bitmap)bitmap_file_unmap (&bitmap->storage); bp = bitmap->counts.bp; - pages = bitmap->counts.pages;/* free all allocated memory */ - -if (bp)/* deallocate the page memory */ +if (bp) {/* deallocate the page memory */ + pages = bitmap->counts.pages;drivers/md/bitmap.c static void bitmap_free(struct bitmap *bitmap) · line 1600
Quoted 10 lines
drivers/md/bitmap.c +3
-2for (k =0 ; k < pages; k++) -if (bp[k].map && !bp[k].hijacked) +if (!bp[k].hijacked)kfree (bp[k].map); -kfree (bp); +kfree (bp); + }kfree (bitmap); }Hi,
I'm somewhat amused that you removed a test for one kfree, but imposed a test on another. I realised the second test was already there, but why not just:drivers/md/bitmap.c +1
-1@@ -1592,7 +1592,7 @@ static void bitmap_free(struct bitmap *bitmap)if (bp)/* deallocate the page memory */ for (k =0 ; k < pages; k++) -if (bp[k].map && !bp[k].hijacked) +if (!bp[k].hijacked)kfree (bp[k].map);kfree (bp);kfree (bitmap);Quoted 6 lines
It makes the intention of the patch much clearer.
I'd probably prefer to leave the code as it is. I don't think either patch is really an improvement in readability, and readability trumps performance in places like this.
hello Neil,
just for my curiosity.
is it possible that a bp[k] exists but bp[k].hijacked is 0 ? if that case: kfree(bp) would free an object in use. otherwise hijacked seems useless here as it is possible to free everything.
Quoted 2 lines
re,
wh
If .hijacked is 0, the .map is a pointer (that would need to be freed) or is NULL.
If .hijacked is 1, then .map has been re-tasked as 2 16-bit counters. They are probably bother zero at this point, but I think it is safer to completely skip the 'free' if 'hijacked' is set as in that case 'map' isn't a pointer.
NeilBrown
Re: [PATCH 2/3] md/bitmap: Delete an unnecessary check before the function call "kfree"
In reply to SF Markus ElfringAm 03.02.2015 10:07, schrieb NeilBrown:
Quoted 88 lines · On Tue, 03 Feb 2015 09:48:01 +0100 walter harms <[email protected]> wrote:
Quoted 87 lines
Am 02.02.2015 20:46, schrieb NeilBrown:
Quoted 68 lines
Quoted 34 lines · On Mon, 02 Feb 2015 16:20:42 +0100 SF Markus Elfring…
From: Markus Elfring <[email protected]>
Date: Mon, 2 Feb 2015 15:10:57 +0100The
kfree()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.* This issue was detected by using the Coccinelle software.
* Let us also move an assignment for the variable "pages" to the place directly before it is really needed for a loop.
* Let us also move another
kfree()call into a block which should belong to a previous check for the variable "bp".Signed-off-by Markus Elfring <[email protected]>--- drivers/md/bitmap.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)drivers/md/bitmap.c +2
-3@@ -1586,15 +1586,15 @@ static void bitmap_free(struct bitmap *bitmap)bitmap_file_unmap (&bitmap->storage); bp = bitmap->counts.bp; - pages = bitmap->counts.pages;/* free all allocated memory */ - -if (bp)/* deallocate the page memory */ +if (bp) {/* deallocate the page memory */ + pages = bitmap->counts.pages;drivers/md/bitmap.c static void bitmap_free(struct bitmap *bitmap) · line 1600
Quoted 10 lines
drivers/md/bitmap.c +3
-2for (k =0 ; k < pages; k++) -if (bp[k].map && !bp[k].hijacked) +if (!bp[k].hijacked)kfree (bp[k].map); -kfree (bp); +kfree (bp); + }kfree (bitmap); }Hi,
I'm somewhat amused that you removed a test for one kfree, but imposed a test on another. I realised the second test was already there, but why not just:drivers/md/bitmap.c +1
-1@@ -1592,7 +1592,7 @@ static void bitmap_free(struct bitmap *bitmap)if (bp)/* deallocate the page memory */ for (k =0 ; k < pages; k++) -if (bp[k].map && !bp[k].hijacked) +if (!bp[k].hijacked)kfree (bp[k].map);kfree (bp);kfree (bitmap);Quoted 6 lines
It makes the intention of the patch much clearer.
I'd probably prefer to leave the code as it is. I don't think either patch is really an improvement in readability, and readability trumps performance in places like this.
hello Neil,
just for my curiosity.
is it possible that a bp[k] exists but bp[k].hijacked is 0 ? if that case: kfree(bp) would free an object in use. otherwise hijacked seems useless here as it is possible to free everything.
Quoted 9 lines
Quoted 2 lines
re,
whIf .hijacked is 0, the .map is a pointer (that would need to be freed) or is NULL.
If .hijacked is 1, then .map has been re-tasked as 2 16-bit counters. They are probably bother zero at this point, but I think it is safer to completely skip the 'free' if 'hijacked' is set as in that case 'map' isn't a pointer.
It seems i was not clear enough, sorry about that.
we have a loop to kfree(bp[k].map), thats fine how it is done.
I am wondering about the kfree(bp) after the loop.
if bp[k].map is not freed for what ever reason how can it be freed later after a kfree(bp) ?
what is what i am missing ? Is there a hidden copy ?
re,
wh
Re: [PATCH 2/3] md/bitmap: Delete an unnecessary check before the function call "kfree"
In reply to SF Markus ElfringQuoted 103 lines · On Tue, 03 Feb 2015 11:19:58 +0100 walter harms <[email protected]> wrote:
Am 03.02.2015 10:07, schrieb NeilBrown:
Quoted 88 lines · On Tue, 03 Feb 2015 09:48:01 +0100 walter harms <[email protected]> wrote:
Quoted 87 lines
Am 02.02.2015 20:46, schrieb NeilBrown:
Quoted 68 lines
Quoted 34 lines · On Mon, 02 Feb 2015 16:20:42 +0100 SF Markus Elfring…
From: Markus Elfring <[email protected]>
Date: Mon, 2 Feb 2015 15:10:57 +0100The
kfree()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.* This issue was detected by using the Coccinelle software.
* Let us also move an assignment for the variable "pages" to the place directly before it is really needed for a loop.
* Let us also move another
kfree()call into a block which should belong to a previous check for the variable "bp".Signed-off-by Markus Elfring <[email protected]>--- drivers/md/bitmap.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)drivers/md/bitmap.c +2
-3@@ -1586,15 +1586,15 @@ static void bitmap_free(struct bitmap *bitmap)bitmap_file_unmap (&bitmap->storage); bp = bitmap->counts.bp; - pages = bitmap->counts.pages;/* free all allocated memory */ - -if (bp)/* deallocate the page memory */ +if (bp) {/* deallocate the page memory */ + pages = bitmap->counts.pages;drivers/md/bitmap.c static void bitmap_free(struct bitmap *bitmap) · line 1600
Quoted 10 lines
drivers/md/bitmap.c +3
-2for (k =0 ; k < pages; k++) -if (bp[k].map && !bp[k].hijacked) +if (!bp[k].hijacked)kfree (bp[k].map); -kfree (bp); +kfree (bp); + }kfree (bitmap); }Hi,
I'm somewhat amused that you removed a test for one kfree, but imposed a test on another. I realised the second test was already there, but why not just:drivers/md/bitmap.c +1
-1@@ -1592,7 +1592,7 @@ static void bitmap_free(struct bitmap *bitmap)if (bp)/* deallocate the page memory */ for (k =0 ; k < pages; k++) -if (bp[k].map && !bp[k].hijacked) +if (!bp[k].hijacked)kfree (bp[k].map);kfree (bp);kfree (bitmap);Quoted 6 lines
It makes the intention of the patch much clearer.
I'd probably prefer to leave the code as it is. I don't think either patch is really an improvement in readability, and readability trumps performance in places like this.
hello Neil,
just for my curiosity.
is it possible that a bp[k] exists but bp[k].hijacked is 0 ? if that case: kfree(bp) would free an object in use. otherwise hijacked seems useless here as it is possible to free everything.Quoted 9 lines
Quoted 2 lines
re,
whIf .hijacked is 0, the .map is a pointer (that would need to be freed) or is NULL.
If .hijacked is 1, then .map has been re-tasked as 2 16-bit counters. They are probably bother zero at this point, but I think it is safer to completely skip the 'free' if 'hijacked' is set as in that case 'map' isn't a pointer.It seems i was not clear enough, sorry about that.
Quoted 7 lines
we have a loop to
kfree(bp[k].map), thats fine how it is done.I am wondering about the kfree(bp) after the loop.
if bp[k].map is not freed for what ever reason how can it be freed later after a kfree(bp) ?what is what i am missing ? Is there a hidden copy ?
If bp[k].map is a pointer, it will be freed.
If bp[k].map is not a pointer (because it has been hijacked), then there is nothing to free.
So after the loop, all bp[k].maps that were allocated will have been freed.
Does that help?
NeilBrown
Quoted 6 lines
re,
wh
Re: [PATCH 2/3] md/bitmap: Delete an unnecessary check before the function call "kfree"
In reply to SF Markus ElfringAm 04.02.2015 07:48, schrieb NeilBrown:
Quoted 117 lines · On Tue, 03 Feb 2015 11:19:58 +0100 walter harms <[email protected]> wrote:
Quoted 104 lines
Am 03.02.2015 10:07, schrieb NeilBrown:
Quoted 88 lines · On Tue, 03 Feb 2015 09:48:01 +0100 walter harms <[email protected]> wrote:
Quoted 87 lines
Am 02.02.2015 20:46, schrieb NeilBrown:
Quoted 68 lines
Quoted 34 lines · On Mon, 02 Feb 2015 16:20:42 +0100 SF Markus Elfring…
From: Markus Elfring <[email protected]>
Date: Mon, 2 Feb 2015 15:10:57 +0100The
kfree()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.* This issue was detected by using the Coccinelle software.
* Let us also move an assignment for the variable "pages" to the place directly before it is really needed for a loop.
* Let us also move another
kfree()call into a block which should belong to a previous check for the variable "bp".Signed-off-by Markus Elfring <[email protected]>--- drivers/md/bitmap.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)drivers/md/bitmap.c +2
-3@@ -1586,15 +1586,15 @@ static void bitmap_free(struct bitmap *bitmap)bitmap_file_unmap (&bitmap->storage); bp = bitmap->counts.bp; - pages = bitmap->counts.pages;/* free all allocated memory */ - -if (bp)/* deallocate the page memory */ +if (bp) {/* deallocate the page memory */ + pages = bitmap->counts.pages;drivers/md/bitmap.c static void bitmap_free(struct bitmap *bitmap) · line 1600
Quoted 10 lines
drivers/md/bitmap.c +3
-2for (k =0 ; k < pages; k++) -if (bp[k].map && !bp[k].hijacked) +if (!bp[k].hijacked)kfree (bp[k].map); -kfree (bp); +kfree (bp); + }kfree (bitmap); }Hi,
I'm somewhat amused that you removed a test for one kfree, but imposed a test on another. I realised the second test was already there, but why not just:drivers/md/bitmap.c +1
-1@@ -1592,7 +1592,7 @@ static void bitmap_free(struct bitmap *bitmap)if (bp)/* deallocate the page memory */ for (k =0 ; k < pages; k++) -if (bp[k].map && !bp[k].hijacked) +if (!bp[k].hijacked)kfree (bp[k].map);kfree (bp);kfree (bitmap);Quoted 6 lines
It makes the intention of the patch much clearer.
I'd probably prefer to leave the code as it is. I don't think either patch is really an improvement in readability, and readability trumps performance in places like this.
hello Neil,
just for my curiosity.
is it possible that a bp[k] exists but bp[k].hijacked is 0 ? if that case: kfree(bp) would free an object in use. otherwise hijacked seems useless here as it is possible to free everything.Quoted 9 lines
Quoted 2 lines
re,
whIf .hijacked is 0, the .map is a pointer (that would need to be freed) or is NULL.
If .hijacked is 1, then .map has been re-tasked as 2 16-bit counters. They are probably bother zero at this point, but I think it is safer to completely skip the 'free' if 'hijacked' is set as in that case 'map' isn't a pointer.It seems i was not clear enough, sorry about that.
Quoted 7 lines
we have a loop to
kfree(bp[k].map), thats fine how it is done.I am wondering about the kfree(bp) after the loop.
if bp[k].map is not freed for what ever reason how can it be freed later after a kfree(bp) ?what is what i am missing ? Is there a hidden copy ?
If bp[k].map is a pointer, it will be freed.
If bp[k].map is not a pointer (because it has been hijacked), then there is nothing to free.
Quoted 6 lines
So after the loop, all bp[k].maps that were allocated will have been freed.
Does that help?
NeilBrown
thx for explanation,
i am happy now, no further questions.
re,
wh
PATCH 3/3 dm ioctl: Delete an unnecessary check before the function call "dm_table_destroy"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 2 Feb 2015 15:30:37 +0100
The dm_table_destroy() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/md/dm-ioctl.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/md/dm-ioctl.c +1 -2
@@ -1053,8 +1053,7 @@ static int do_resume(struct dm_ioctl *param)* Since dm_swap_table synchronizes RCU, nobody should be in * read-side critical section already. */ -if (old_map) -dm_table_destroy (old_map); +dm_table_destroy (old_map);if (!r)__dev_status (md, param);
Signature · 1 line
2.2.2
Mike Snitzer
NAKRe: [PATCH 3/3] dm ioctl: Delete an unnecessary check before the function call "dm_table_destroy"
Quoted 7 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Mon, 2 Feb 2015 15:30:37 +0100The
dm_table_destroy()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Your proposed patch (while technically correct) hurts code clarity.
Nack.
Re: [PATCH 3/3] dm ioctl: Delete an unnecessary check before the function call "dm_table_destroy"
Quoted 1 line
Your proposed patch (while technically correct) hurts code clarity.
How many source code readability and understanding challenges does each additional condition check cause?
Can the affected place become also a bit more efficient?
Regards,
Markus
Re: [PATCH 3/3] dm ioctl: Delete an unnecessary check before the function call "dm_table_destroy"
Quoted 4 lines · SF Markus Elfring
Quoted 1 line
Your proposed patch (while technically correct) hurts code clarity.
How many source code readability and understanding challenges does each additional condition check cause?
Please don't make a mountain out of a mole hill in an attempt to defend your robotic patch (I'm quite tired of some of these static analyzer patch submissions).
FYI, I did stage your other patch for 3.20, see:
https://git.kernel.org/cgit/linux/kernel/git/device-mapper/linux-dm.git/commit/?h=dm-for-3.20&id=d0ce7e911c97c7c6df1081dcedfefced82a0c6bf
Quoted 1 line
Can the affected place become also a bit more efficient?
Efficiency isn't a concern in this instance (it isn't a hot IO path). And even if it were, a branch (with current code) is more efficient vs a a jump + branch (your proposed patch) -- in the case that no active table exists. Now if it likely that old_map does exist then yes your patch is always a very slight win.
But given the duality of the calling function (deals with loading a new map and destroying the old map if it exists) I prefer to keep the code as is. Sorry.
Re: [PATCH 3/3] dm ioctl: Delete an unnecessary check before the function call "dm_table_destroy"
Quoted 2 lines
FYI, I did stage your other patch for 3.20, see:
https://git.kernel.org/cgit/linux/kernel/git/device-mapper/linux-dm.git/commit/?h=dm-for-3.20&id=d0ce7e911c97c7c6df1081dcedfefced82a0c6bf
Thanks for your acceptance of the suggested clean-up around vfree() function calls at least.
Additional source code places can also be reconsidered at other times, can't they?
Regards,
Markus
PATCH 1/1 EDAC: Deletion of unnecessary checks before the function call "pci_dev_put"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 2 Feb 2015 18:26:34 +0100
The pci_dev_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/edac/i82443bxgx_edac.c | 4 +--- drivers/edac/i82860_edac.c | 9 ++------- drivers/edac/i82875p_edac.c | 4 +--- drivers/edac/i82975x_edac.c | 4 +--- 4 files changed, 5 insertions(+), 16 deletions(-)
drivers/edac/i82443bxgx_edac.c +1 -3
@@ -445,9 +445,7 @@ fail1:pci_unregister_driver (&i82443bxgx_edacmc_driver); fail0: -if (mci_pdev !=NULL ) -pci_dev_put (mci_pdev); - +pci_dev_put (mci_pdev);return pci_rc; }
drivers/edac/i82860_edac.c +2 -7
@@ -343,20 +343,15 @@ fail1:pci_unregister_driver (&i82860_driver); fail0: -if (mci_pdev !=NULL ) -pci_dev_put (mci_pdev); - +pci_dev_put (mci_pdev);return pci_rc; } static void __exit i82860_exit(void) {edac_dbg (3 ,"\n" ); -pci_unregister_driver (&i82860_driver); - -if (mci_pdev !=NULL ) -pci_dev_put (mci_pdev); +pci_dev_put (mci_pdev); }module_init (i82860_init);
drivers/edac/i82875p_edac.c +1 -3
@@ -576,9 +576,7 @@ fail1:pci_unregister_driver (&i82875p_driver); fail0: -if (mci_pdev !=NULL ) -pci_dev_put (mci_pdev); - +pci_dev_put (mci_pdev);return pci_rc; }
drivers/edac/i82975x_edac.c +1 -3
@@ -685,9 +685,7 @@ fail1:pci_unregister_driver (&i82975x_driver); fail0: -if (mci_pdev !=NULL ) -pci_dev_put (mci_pdev); - +pci_dev_put (mci_pdev);return pci_rc; }
Signature · 1 line
2.2.2
Re: [PATCH] EDAC: Deletion of unnecessary checks before the function call "pci_dev_put"
Quoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Mon, 2 Feb 2015 18:26:34 +0100The
pci_dev_put()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Queued for 3.21, thanks.
Signature · 5 lines
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
--PATCH 1/1 ata: Delete unnecessary checks before the function call "pci_dev_put"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 2 Feb 2015 22:08:29 +0100
The pci_dev_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/ata/pata_cs5530.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/ata/pata_cs5530.c +2 -4
@@ -276,10 +276,8 @@ static int cs5530_init_chip(void)pci_dev_put (cs5530_0);return 0 ; fail_put: -if (master_0) -pci_dev_put (master_0); -if (cs5530_0) -pci_dev_put (cs5530_0); +pci_dev_put (master_0); +pci_dev_put (cs5530_0);return -ENODEV ; }
Signature · 1 line
2.2.2
Tejun Heo
AppliedRe: [PATCH] ata: Delete unnecessary checks before the function call "pci_dev_put"
Quoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Mon, 2 Feb 2015 22:08:29 +0100The
pci_dev_put()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Applied to libata/for-3.20.
Thanks.
Signature · 1 line
tejun
cover sata_mv: Deletion of a few unnecessary checks
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 3 Feb 2015 09:12:22 +0100
Another update suggestion was taken into account after a patch was applied from static source code analysis.
Markus Elfring (2):
Delete unnecessary checks before the function call "phy_power_off" More error handling for phy_power_off() in mv_platform_remove()
drivers/ata/sata_mv.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
Signature · 1 line
2.2.2
PATCH 1/2 sata_mv: Delete unnecessary checks before the function call "phy_power_off"
From: Markus Elfring <[email protected]>
Date: Mon, 2 Feb 2015 22:55:53 +0100
The phy_power_off() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/ata/sata_mv.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/ata/sata_mv.c +2 -4
@@ -4185,8 +4185,7 @@ err:clk_disable_unprepare (hpriv->port_clks[port]);clk_put (hpriv->port_clks[port]); } -if (hpriv->port_phys[port]) -phy_power_off (hpriv->port_phys[port]); +phy_power_off (hpriv->port_phys[port]); }return rc;
@@ -4216,8 +4215,7 @@ static int mv_platform_remove(struct platform_device *pdev)clk_disable_unprepare (hpriv->port_clks[port]);clk_put (hpriv->port_clks[port]); } -if (hpriv->port_phys[port]) -phy_power_off (hpriv->port_phys[port]); +phy_power_off (hpriv->port_phys[port]); }return 0 ; }
Signature · 1 line
2.2.2
Tejun Heo
AppliedRe: [PATCH 1/2] sata_mv: Delete unnecessary checks before the function call "phy_power_off"
Quoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Mon, 2 Feb 2015 22:55:53 +0100The
phy_power_off()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Applied to libata/for-3.20.
Thanks.
Signature · 1 line
tejun
PATCH 2/2 sata_mv: More error handling for phy_power_off() in mv_platform_remove()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 2 Feb 2015 23:30:34 +0100
The return value from the phy_power_off() function was not used by the mv_platform_remove() function.
Let us improve error detection and eventually return a corresponding failure code.
--- drivers/ata/sata_mv.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/ata/sata_mv.c +4 -2
@@ -4203,7 +4203,7 @@ static int mv_platform_remove(struct platform_device *pdev) {struct ata_host *host =platform_get_drvdata (pdev);struct mv_host_priv *hpriv = host->private_data; -int port; +int port, rc;ata_host_detach (host);if (!IS_ERR (hpriv->clk)) {
@@ -4215,7 +4215,9 @@ static int mv_platform_remove(struct platform_device *pdev)clk_disable_unprepare (hpriv->port_clks[port]);clk_put (hpriv->port_clks[port]); } -phy_power_off (hpriv->port_phys[port]); + rc =phy_power_off (hpriv->port_phys[port]); +if (rc) +return rc; }return 0 ; }
Signature · 1 line
2.2.2
Re: [PATCH 2/2] sata_mv: More error handling for phy_power_off() in mv_platform_remove()
On Tue, Feb 03, 2015 at 09:36:01AM +0100, SF Markus Elfring wrote:
...
drivers/ata/sata_mv.c static int mv_platform_remove(struct platform_device *pdev) · line 4220
Quoted 8 lines
drivers/ata/sata_mv.c +3
-1@@ -4215,7 +4215,9 @@ static int mv_platform_remove(struct platform_device *pdev)clk_disable_unprepare (hpriv->port_clks[port]);clk_put (hpriv->port_clks[port]); } -phy_power_off (hpriv->port_phys[port]); + rc =phy_power_off (hpriv->port_phys[port]); +if (rc) +return rc;
So, this is a removal function which is ignoring failure from turning off phy, which seems like the right thing to do. The same thing with suspend routines. If something auxliary which isn't strictly necessary in reaching suspend state fails, the failure should be ignored.
Running static code analysis to locate trivial irregularities and performing identity transformations is fine, even great, but you're changing the behavior here without actually understanding what's going on. Please don't do these things automatically.
Thanks.
Signature · 1 line
tejun
Re: [PATCH 2/2] sata_mv: More error handling for phy_power_off() in mv_platform_remove()
In reply to SF Markus ElfringAm 03.02.2015 13:10, schrieb Tejun Heo:
Quoted 17 lines · SF Markus Elfring
...
drivers/ata/sata_mv.c static int mv_platform_remove(struct platform_device *pdev) · line 4220
Quoted 8 lines
drivers/ata/sata_mv.c +3
-1@@ -4215,7 +4215,9 @@ static int mv_platform_remove(struct platform_device *pdev)clk_disable_unprepare (hpriv->port_clks[port]);clk_put (hpriv->port_clks[port]); } -phy_power_off (hpriv->port_phys[port]); + rc =phy_power_off (hpriv->port_phys[port]); +if (rc) +return rc;So, this is a removal function which is ignoring failure from turning off phy, which seems like the right thing to do. The same thing with suspend routines. If something auxliary which isn't strictly necessary in reaching suspend state fails, the failure should be ignored.
Quoted 7 lines
Running static code analysis to locate trivial irregularities and performing identity transformations is fine, even great, but you're changing the behavior here without actually understanding what's going on. Please don't do these things automatically.
Thanks.
maybe this can be changed into
(void) phy_power_off(hpriv->port_phys[port]);
that would tell the compiler and other readers that this is intentional.
Re: [PATCH 2/2] sata_mv: More error handling for phy_power_off() in mv_platform_remove()
In reply to SF Markus ElfringQuoted 4 lines · walter harms
maybe this can be changed into
(void)phy_power_off(hpriv->port_phys[port]);that would tell the compiler and other readers that this is intentional.
That's too anal to be helpful and too spurious to become even remotely consistent. Things like that are actualy harmful. Note that we have an annotation marking the other way - __must_check. Balance is to be found towards that direction, not this, so please stop.
Thanks.
Signature · 1 line
tejun
Re: [PATCH 2/2] sata_mv: More error handling for phy_power_off() in mv_platform_remove()
In reply to SF Markus ElfringQuoted 1 line · Tejun Heo
That's too anal to be helpful and too spurious to become even remotely
Let me clarify the "too anal" part a bit. Let's say people push this like crazy and we successfully mark all places to either check the return value or have (void) in front. It's not difficult to realize that that would be the exact same situation as right now just with more visual clutter. That's the problem when these things become obsessive - they become indisciminate and thus meaningless. Annotate the exceptionals, not the other way around.
Thanks.
Signature · 1 line
tejun
PATCH 1/1 ti-soc-thermal: Delete an unnecessary check before the function call "cpufreq_cooling_unregister"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 3 Feb 2015 11:15:14 +0100
The cpufreq_cooling_unregister() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/thermal/ti-soc-thermal/ti-thermal-common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/ti-soc-thermal/ti-thermal-common.c +1 -1
@@ -429,7 +429,7 @@ int ti_thermal_unregister_cpu_cooling(struct ti_bandgap *bgp, int id) data =ti_bandgap_get_sensor_data (bgp, id); -if (data && data->cool_dev) +if (data)cpufreq_cooling_unregister (data->cool_dev);return 0 ;
Signature · 1 line
2.2.2
PATCH 1/1 pwm: Delete an unnecessary check before the function call "of_node_put"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 3 Feb 2015 11:54:28 +0100
The of_node_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/pwm/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pwm/core.c +1 -1
@@ -192,7 +192,7 @@ static void of_pwmchip_add(struct pwm_chip *chip)static void of_pwmchip_remove (struct pwm_chip *chip) { -if (chip->dev && chip->dev->of_node) +if (chip->dev)of_node_put (chip->dev->of_node); }
Signature · 1 line
2.2.2
Thierry Reding
AppliedRe: [PATCH] pwm: Delete an unnecessary check before the function call "of_node_put"
Quoted 18 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Tue, 3 Feb 2015 11:54:28 +0100The
of_node_put()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/pwm/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/pwm/core.c +0
-0
drivers/pwm/core.c static void of_pwmchip_add(struct pwm_chip *chip) · line 198
Quoted 8 lines
drivers/pwm/core.c +1
-1@@ -192,7 +192,7 @@ static void of_pwmchip_add(struct pwm_chip *chip)static void of_pwmchip_remove (struct pwm_chip *chip) { -if (chip->dev && chip->dev->of_node) +if (chip->dev)of_node_put (chip->dev->of_node); }
Applied, thanks.
Thierry
PATCH 1/1 x86: Intel-perf_event: Delete an unnecessary check before the function call "pci_dev_put"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 3 Feb 2015 12:40:54 +0100
The pci_dev_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- arch/x86/kernel/cpu/perf_event_intel_uncore_snbep.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/x86/kernel/cpu/perf_event_intel_uncore_snbep.c +1 -2
@@ -1132,8 +1132,7 @@ static int snbep_pci2phy_map_init(int devid) } } -if (ubox_dev) -pci_dev_put (ubox_dev); +pci_dev_put (ubox_dev);return err ?pcibios_err_to_errno (err) :0 ; }
Signature · 1 line
2.2.2
tip-bot for Markus Elfring
merge bot[tip:perf/core] perf/x86/intel/uncore: Delete an unnecessary check before pci_dev_put() call
perf/x86/intel/uncore: Delete an unnecessary check before pci_dev_put() call
Commit-ID: 8e57c586c6a8333c266a6cf76d50e110f2954558 Gitweb: http://git.kernel.org/tip/8e57c586c6a8333c266a6cf76d50e110f2954558 Author: Markus Elfring <[email protected]> AuthorDate: Tue, 3 Feb 2015 12:40:54 +0100 Committer: Ingo Molnar <[email protected]> CommitDate: Wed, 18 Feb 2015 17:01:42 +0100
perf/x86/intel/uncore: Delete an unnecessary check before pci_dev_put() call
The pci_dev_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- arch/x86/kernel/cpu/perf_event_intel_uncore_snbep.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/x86/kernel/cpu/perf_event_intel_uncore_snbep.c +1 -2
@@ -1132,8 +1132,7 @@ static int snbep_pci2phy_map_init(int devid) } } -if (ubox_dev) -pci_dev_put (ubox_dev); +pci_dev_put (ubox_dev);return err ?pcibios_err_to_errno (err) :0 ; }
PATCH 1/1 PowerPC-PCI: Delete unnecessary checks before the function call "kfree"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 3 Feb 2015 13:55:53 +0100
The kfree() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- arch/powerpc/platforms/cell/celleb_pci.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
arch/powerpc/platforms/cell/celleb_pci.c +2 -3
@@ -393,11 +393,10 @@ static int __init celleb_setup_fake_pci_device(struct device_node *node, error:if (mem_init_done) { -if (config && *config) +if (config)kfree (*config); -if (res && *res) +if (res)kfree (*res); - }else {if (config && *config) { size =256 ;
Signature · 1 line
2.2.2
PATCH 1/1 PowerPC-rheap: Delete an unnecessary check before the function call "kfree"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 3 Feb 2015 14:34:10 +0100
The kfree() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- arch/powerpc/lib/rheap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/lib/rheap.c +1 -1
@@ -284,7 +284,7 @@ EXPORT_SYMBOL_GPL(rh_create);*/ void rh_destroy (rh_info_t * info) { -if ((info->flags &RHIF_STATIC_BLOCK ) =0 && info->block !=NULL ) +if ((info->flags &RHIF_STATIC_BLOCK ) =0 )kfree (info->block);if ((info->flags &RHIF_STATIC_INFO ) =0 )
Signature · 1 line
2.2.2
PATCH 1/1 sp2: Delete an unnecessary check before the function call "kfree"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 3 Feb 2015 15:05:26 +0100
The kfree() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/media/dvb-frontends/sp2.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/media/dvb-frontends/sp2.c +1 -4
@@ -413,11 +413,8 @@ static int sp2_remove(struct i2c_client *client)struct sp2 *s =i2c_get_clientdata (client);dev_dbg (&client->dev,"\n" ); -sp2_exit (client); -if (s !=NULL ) -kfree (s); - +kfree (s);return 0 ; }
Signature · 1 line
2.2.2
PATCH 1/1 V4L2: Delete an unnecessary check before the function call "media_entity_put"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 3 Feb 2015 15:27:38 +0100
The media_entity_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/media/v4l2-core/v4l2-subdev.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/media/v4l2-core/v4l2-subdev.c +1 -2
@@ -93,8 +93,7 @@ static int subdev_open(struct file *file) err:#if defined(CONFIG_MEDIA_CONTROLLER ) -if (entity) -media_entity_put (entity); +media_entity_put (entity);#endif v4l2_fh_del (&subdev_fh->vfh);v4l2_fh_exit (&subdev_fh->vfh);
Signature · 1 line
2.2.2
cover DVB: Deletion of a few unnecessary checks
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 3 Feb 2015 16:50:07 +0100
Another update suggestion was taken into account after a patch was applied from static source code analysis.
Markus Elfring (2):
Delete an unnecessary check before the function call "dvb_unregister_device" Less function calls in dvb_ca_en50221_init() after error detection
drivers/media/dvb-core/dvb_ca_en50221.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
Signature · 1 line
2.2.2
PATCH 1/2 DVB: Delete an unnecessary check before the function call "dvb_unregister_device"
From: Markus Elfring <[email protected]>
Date: Tue, 3 Feb 2015 16:01:40 +0100
The dvb_unregister_device() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/media/dvb-core/dvb_ca_en50221.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/media/dvb-core/dvb_ca_en50221.c +1 -2
@@ -1726,8 +1726,7 @@ int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter, error:if (ca !=NULL ) { -if (ca->dvbdev !=NULL ) -dvb_unregister_device (ca->dvbdev); +dvb_unregister_device (ca->dvbdev);kfree (ca->slot_info);kfree (ca); }
Signature · 1 line
2.2.2
PATCH 2/2 DVB: Less function calls in dvb_ca_en50221_init() after error detection
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 3 Feb 2015 16:47:48 +0100
The functions "dvb_unregister_device" and "kfree" could still be called by the dvb_ca_en50221_init() function in the case that a previous resource allocation failed.
* Corresponding details could be improved by adjustments for jump targets.
* Let us delete also an unnecessary check for the variable "ca" there.
--- drivers/media/dvb-core/dvb_ca_en50221.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-)
drivers/media/dvb-core/dvb_ca_en50221.c +12 -11
@@ -1676,14 +1676,14 @@ int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter,/* initialise the system data */ if ((ca =kzalloc (sizeof (struct dvb_ca_private ),GFP_KERNEL )) =NULL ) { ret = -ENOMEM ; - goto error; + goto exit; } ca->pub = pubca; ca->flags = flags; ca->slot_count = slot_count;if ((ca->slot_info =kcalloc (slot_count,sizeof (struct dvb_ca_slot ),GFP_KERNEL )) =NULL ) { ret = -ENOMEM ; - goto error; + goto free_ca; }init_waitqueue_head (&ca->wait_queue); ca->open =0 ;
@@ -1694,7 +1694,7 @@ int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter,/* register the DVB device */ ret =dvb_register_device (dvb_adapter, &ca->dvbdev, &dvbdev_ca, ca,DVB_DEVICE_CA );if (ret) - goto error; + goto free_slot_info;/* now initialise each slot */ for (i =0 ; i < slot_count; i++) {
@@ -1709,7 +1709,7 @@ int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter,if (signal_pending (current)) { ret = -EINTR ; - goto error; + goto unregister_device; }mb ();
@@ -1720,16 +1720,17 @@ int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter, ret =PTR_ERR (ca->thread);printk ("dvb_ca_init: failed to start kernel_thread (%d)\n" , ret); - goto error; + goto unregister_device; }return 0 ; -error: -if (ca !=NULL ) { -dvb_unregister_device (ca->dvbdev); -kfree (ca->slot_info); -kfree (ca); - } +unregister_device: +dvb_unregister_device (ca->dvbdev); +free_slot_info: +kfree (ca->slot_info); +free_ca: +kfree (ca); +exit: pubca->private =NULL ;return ret; }
Signature · 1 line
2.2.2
PATCH 1/1 stk-webcam: Delete an unnecessary check before the function call "vfree"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 3 Feb 2015 18:36:35 +0100
The vfree() function performs also input parameter validation. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/media/usb/stkwebcam/stk-webcam.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/media/usb/stkwebcam/stk-webcam.c +2 -4
@@ -556,10 +556,8 @@ static int stk_free_sio_buffers(struct stk_camera *dev) nbufs = dev->n_sbufs; dev->n_sbufs =0 ;spin_unlock_irqrestore (&dev->spinlock, flags); -for (i =0 ; i < nbufs; i++) { -if (dev->sio_bufs[i].buffer !=NULL ) -vfree (dev->sio_bufs[i].buffer); - } +for (i =0 ; i < nbufs; i++) +vfree (dev->sio_bufs[i].buffer);kfree (dev->sio_bufs); dev->sio_bufs =NULL ;return 0 ;
Signature · 1 line
2.2.2
PATCH 1/1 au0828: Delete unnecessary checks before the function call "video_unregister_device"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 3 Feb 2015 19:00:25 +0100
The video_unregister_device() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/media/usb/au0828/au0828-video.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/media/usb/au0828/au0828-video.c +2 -6
@@ -870,12 +870,8 @@ void au0828_analog_unregister(struct au0828_dev *dev) {dprintk (1 ,"au0828_release_resources called\n" );mutex_lock (&au0828_sysfs_lock); - -if (dev->vdev) -video_unregister_device (dev->vdev); -if (dev->vbi_dev) -video_unregister_device (dev->vbi_dev); - +video_unregister_device (dev->vdev); +video_unregister_device (dev->vbi_dev);mutex_unlock (&au0828_sysfs_lock); }
Signature · 1 line
2.2.2
PATCH 1/1 cpufreq-dt: Delete an unnecessary check before the function call "cpufreq_cooling_unregister"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 3 Feb 2015 19:21:21 +0100
The cpufreq_cooling_unregister() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/cpufreq/cpufreq-dt.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/cpufreq/cpufreq-dt.c +1 -2
@@ -320,8 +320,7 @@ static int cpufreq_exit(struct cpufreq_policy *policy) {struct private_data *priv = policy->driver_data; -if (priv->cdev) -cpufreq_cooling_unregister (priv->cdev); +cpufreq_cooling_unregister (priv->cdev);dev_pm_opp_free_cpufreq_table (priv->cpu_dev, &policy->freq_table);of_free_opp_table (priv->cpu_dev);clk_put (policy->clk);
Signature · 1 line
2.2.2
Rafael J. Wysocki
AppliedRe: [PATCH] cpufreq-dt: Delete an unnecessary check before the function call "cpufreq_cooling_unregister"
Quoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Tue, 3 Feb 2015 19:21:21 +0100The
cpufreq_cooling_unregister()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Queued up for 3.20, thanks!
Quoted 19 lines
--- drivers/cpufreq/cpufreq-dt.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/cpufreq/cpufreq-dt.c +1
-2@@ -320,8 +320,7 @@ static int cpufreq_exit(struct cpufreq_policy *policy) {struct private_data *priv = policy->driver_data; -if (priv->cdev) -cpufreq_cooling_unregister (priv->cdev); +cpufreq_cooling_unregister (priv->cdev);dev_pm_opp_free_cpufreq_table (priv->cpu_dev, &policy->freq_table);of_free_opp_table (priv->cpu_dev);clk_put (policy->clk);
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
PATCH 1/1 IBM-EMAC: Delete an unnecessary check before the function call "of_dev_put"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 3 Feb 2015 19:47:33 +0100
The of_dev_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/net/ethernet/ibm/emac/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/ibm/emac/core.c +1 -1
@@ -2367,7 +2367,7 @@ static int emac_wait_deps(struct emac_instance *dev) err =emac_check_deps (dev, deps) ?0 : -ENODEV ;for (i =0 ; i <EMAC_DEP_COUNT ; i++) {of_node_put (deps[i].node); -if (err && deps[i].ofdev) +if (err)of_dev_put (deps[i].ofdev); }if (err =0 ) {
Signature · 1 line
2.2.2
Re: [PATCH] IBM-EMAC: Delete an unnecessary check before the function call "of_dev_put"
From: SF Markus Elfring <[email protected]>
Date: Tue, 03 Feb 2015 19:51:38 +0100
Quoted 9 lines
From: Markus Elfring <[email protected]>
Date: Tue, 3 Feb 2015 19:47:33 +0100The
of_dev_put()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Applied.
PATCH 1/1 NetCP: Deletion of unnecessary checks before two function calls
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 3 Feb 2015 20:12:25 +0100
The functions cpsw_ale_destroy() and of_dev_put() test whether their argument is NULL and then return immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/net/ethernet/ti/netcp_ethss.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/net/ethernet/ti/netcp_ethss.c +2 -4
@@ -2010,12 +2010,10 @@ static int gbe_probe(struct netcp_device *netcp_device, struct device *dev, quit:if (gbe_dev->hw_stats)devm_kfree (dev, gbe_dev->hw_stats); -if (gbe_dev->ale) -cpsw_ale_destroy (gbe_dev->ale); +cpsw_ale_destroy (gbe_dev->ale);if (gbe_dev->ss_regs)devm_iounmap (dev, gbe_dev->ss_regs); -if (interfaces) -of_node_put (interfaces); +of_node_put (interfaces);devm_kfree (dev, gbe_dev);return ret; }
Signature · 1 line
2.2.2
Re: [PATCH] NetCP: Deletion of unnecessary checks before two function calls
From: SF Markus Elfring <[email protected]>
Date: Tue, 03 Feb 2015 20:22:23 +0100
Quoted 10 lines
From: Markus Elfring <[email protected]>
Date: Tue, 3 Feb 2015 20:12:25 +0100The functions
cpsw_ale_destroy()andof_dev_put()test whether their argument is NULL and then return immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Applied.
Re: [PATCH] NetCP: Deletion of unnecessary checks before two function calls
In reply to SF Markus ElfringHi Wingman,
There are some bugs in this error handling.
Quoted 6 lines · SF Markus Elfring
drivers/net/ethernet/ti/netcp_ethss.c +0
-0@@ -2010,12 +2010,10 @@ static int gbe_probe(struct netcp_device *netcp_device, struct device *dev, quit:
drivers/net/ethernet/ti/netcp_ethss.c static int gbe_probe(struct netcp_device *netcp_device, struct device *dev, · line 2016
Quoted 10 lines
drivers/net/ethernet/ti/netcp_ethss.c +2
-4if (gbe_dev->hw_stats)devm_kfree (dev, gbe_dev->hw_stats); -if (gbe_dev->ale) -cpsw_ale_destroy (gbe_dev->ale); +cpsw_ale_destroy (gbe_dev->ale);if (gbe_dev->ss_regs)devm_iounmap (dev, gbe_dev->ss_regs); -if (interfaces) -of_node_put (interfaces); +of_node_put (interfaces);
^^^^^^^^^^
"interfaces" is sometimes unintialized in this code. I don't know why GCC doesn't catch this... :(
This is a "one rrr bug", which is caused because you just have one error label "quit" which handles all the error handling. Please read my Google+ comment on error handling.
https://plus.google.com/106378716002406849458/posts/dnanfhQ4mHQ
drivers/net/ethernet/ti/netcp_ethss.c static int gbe_probe(struct netcp_device *netcp_device, struct device *dev, · line 2017
Quoted 1 line
drivers/net/ethernet/ti/netcp_ethss.c +0
-0devm_kfree (dev, gbe_dev);
^^^^^^^^^^^^^^^^^^^^^^^^
This is not the right way to use the devm_ interface. These things are freed automatically on error or when we are done with them. This driver is double freeing pretty much everything. Grep for devm_kfree() and fix everything.
I don't know why kbuild didn't catch this...
regards
dan carpenter
RE: [PATCH] NetCP: Deletion of unnecessary checks before two function calls
RGFuLA0KDQpUaGFua3MuICBXZSdsbCBsb29rIGludG8gaXQgYW5kIHNlbmQgYSBwYXRjaCBzb29u Lg0KDQpSZWdhcmRzLA0KV2luZ01hbg0KDQo+IC0tLS0tT3JpZ2luYWwgTWVzc2FnZS0tLS0tDQo+ IEZyb206IERhbiBDYXJwZW50ZXIgW21haWx0bzpkYW4uY2FycGVudGVyQG9yYWNsZS5jb21dDQo+ IFNlbnQ6IFRodXJzZGF5LCBGZWJydWFyeSAwNSwgMjAxNSA3OjAyIEFNDQo+IFRvOiBLd29rLCBX aW5nTWFuDQo+IENjOiBTRiBNYXJrdXMgRWxmcmluZzsgS2FyaWNoZXJpLCBNdXJhbGlkaGFyYW47 IEt3b2ssIFdpbmdNYW47DQo+IG5ldGRldkB2Z2VyLmtlcm5lbC5vcmc7IExLTUw7IGtlcm5lbC1q YW5pdG9yc0B2Z2VyLmtlcm5lbC5vcmc7IEp1bGlhIExhd2FsbA0KPiBTdWJqZWN0OiBSZTogW1BB VENIXSBOZXRDUDogRGVsZXRpb24gb2YgdW5uZWNlc3NhcnkgY2hlY2tzIGJlZm9yZSB0d28NCj4g ZnVuY3Rpb24gY2FsbHMNCj4gDQo+IEhpIFdpbmdtYW4sDQo+IA0KPiBUaGVyZSBhcmUgc29tZSBi dWdzIGluIHRoaXMgZXJyb3IgaGFuZGxpbmcuDQo+IA0KPiBPbiBUdWUsIEZlYiAwMywgMjAxNSBh dCAwODoyMjoyM1BNICswMTAwLCBTRiBNYXJrdXMgRWxmcmluZyB3cm90ZToNCj4gPiBkaWZmIC0t Z2l0IGEvZHJpdmVycy9uZXQvZXRoZXJuZXQvdGkvbmV0Y3BfZXRoc3MuYw0KPiBiL2RyaXZlcnMv bmV0L2V0aGVybmV0L3RpL25ldGNwX2V0aHNzLmMNCj4gPiBpbmRleCBmYTEwNDFhLi5jYmQ2ZGRl IDEwMDY0NA0KPiA+IC0tLSBhL2RyaXZlcnMvbmV0L2V0aGVybmV0L3RpL25ldGNwX2V0aHNzLmMN Cj4gPiArKysgYi9kcml2ZXJzL25ldC9ldGhlcm5ldC90aS9uZXRjcF9ldGhzcy5jDQo+ID4gQEAg LTIwMTAsMTIgKzIwMTAsMTAgQEAgc3RhdGljIGludCBnYmVfcHJvYmUoc3RydWN0IG5ldGNwX2Rl dmljZQ0KPiAqbmV0Y3BfZGV2aWNlLCBzdHJ1Y3QgZGV2aWNlICpkZXYsDQo+ID4gIHF1aXQ6DQo+ ID4gIAlpZiAoZ2JlX2Rldi0+aHdfc3RhdHMpDQo+ID4gIAkJZGV2bV9rZnJlZShkZXYsIGdiZV9k ZXYtPmh3X3N0YXRzKTsNCj4gPiAtCWlmIChnYmVfZGV2LT5hbGUpDQo+ID4gLQkJY3Bzd19hbGVf ZGVzdHJveShnYmVfZGV2LT5hbGUpOw0KPiA+ICsJY3Bzd19hbGVfZGVzdHJveShnYmVfZGV2LT5h bGUpOw0KPiA+ICAJaWYgKGdiZV9kZXYtPnNzX3JlZ3MpDQo+ID4gIAkJZGV2bV9pb3VubWFwKGRl diwgZ2JlX2Rldi0+c3NfcmVncyk7DQo+ID4gLQlpZiAoaW50ZXJmYWNlcykNCj4gPiAtCQlvZl9u b2RlX3B1dChpbnRlcmZhY2VzKTsNCj4gPiArCW9mX25vZGVfcHV0KGludGVyZmFjZXMpOw0KPiAg ICAgICAgICAgICAgICAgICAgIF5eXl5eXl5eXl4NCj4gImludGVyZmFjZXMiIGlzIHNvbWV0aW1l cyB1bmludGlhbGl6ZWQgaW4gdGhpcyBjb2RlLiAgSSBkb24ndCBrbm93IHdoeQ0KPiBHQ0MgZG9l c24ndCBjYXRjaCB0aGlzLi4uICA6KA0KPiANCj4gVGhpcyBpcyBhICJvbmUgcnJyIGJ1ZyIsIHdo aWNoIGlzIGNhdXNlZCBiZWNhdXNlIHlvdSBqdXN0IGhhdmUgb25lIGVycm9yDQo+IGxhYmVsICJx dWl0IiB3aGljaCBoYW5kbGVzIGFsbCB0aGUgZXJyb3IgaGFuZGxpbmcuICBQbGVhc2UgcmVhZCBt eQ0KPiBHb29nbGUrIGNvbW1lbnQgb24gZXJyb3IgaGFuZGxpbmcuDQo+IA0KPiBodHRwczovL3Bs dXMuZ29vZ2xlLmNvbS8xMDYzNzg3MTYwMDI0MDY4NDk0NTgvcG9zdHMvZG5hbmZoUTRtSFENCj4g DQo+ID4gIAlkZXZtX2tmcmVlKGRldiwgZ2JlX2Rldik7DQo+ICAgICAgICAgXl5eXl5eXl5eXl5e Xl5eXl5eXl5eXl5eDQo+IFRoaXMgaXMgbm90IHRoZSByaWdodCB3YXkgdG8gdXNlIHRoZSBkZXZt XyBpbnRlcmZhY2UuICBUaGVzZSB0aGluZ3MgYXJlDQo+IGZyZWVkIGF1dG9tYXRpY2FsbHkgb24g ZXJyb3Igb3Igd2hlbiB3ZSBhcmUgZG9uZSB3aXRoIHRoZW0uICBUaGlzIGRyaXZlcg0KPiBpcyBk b3VibGUgZnJlZWluZyBwcmV0dHkgbXVjaCBldmVyeXRoaW5nLiAgR3JlcCBmb3IgZGV2bV9rZnJl ZSgpIGFuZA0KPiBmaXggZXZlcnl0aGluZy4NCj4gDQo+IEkgZG9uJ3Qga25vdyB3aHkga2J1aWxk IGRpZG4ndCBjYXRjaCB0aGlzLi4uDQo+IA0KPiByZWdhcmRzDQo+IGRhbiBjYXJwZW50ZXINCg0K
PATCH 1/1 cxgb4: Delete an unnecessary check before the function call "release_firmware"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 11:28:43 +0100
The release_firmware() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +1 -2
@@ -5129,8 +5129,7 @@ static int adap_init0(struct adapter *adap) state, &reset);/* Cleaning up */ -if (fw !=NULL ) -release_firmware (fw); +release_firmware (fw);t4_free_mem (card_fw);if (ret <0 )
Signature · 1 line
2.2.2
Re: [PATCH] cxgb4: Delete an unnecessary check before the function call "release_firmware"
From: SF Markus Elfring <[email protected]>
Date: Wed, 04 Feb 2015 11:38:39 +0100
Quoted 9 lines
From: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 11:28:43 +0100The
release_firmware()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Applied.
PATCH 1/1 myri10ge: Delete an unnecessary check before the function call "kfree"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 12:32:14 +0100
The kfree() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/net/ethernet/myricom/myri10ge/myri10ge.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/myricom/myri10ge/myri10ge.c +1 -2
@@ -4226,8 +4226,7 @@ static void myri10ge_remove(struct pci_dev *pdev)mtrr_del (mgp->mtrr, mgp->iomem_base, mgp->board_span);#endif myri10ge_free_slices (mgp); -if (mgp->msix_vectors !=NULL ) -kfree (mgp->msix_vectors); +kfree (mgp->msix_vectors);dma_free_coherent (&pdev->dev,sizeof (*mgp->cmd), mgp->cmd, mgp->cmd_bus);
Signature · 1 line
2.2.2
Re: [PATCH] myri10ge: Delete an unnecessary check before the function call "kfree"
From: SF Markus Elfring <[email protected]>
Date: Wed, 04 Feb 2015 12:36:02 +0100
Quoted 9 lines
From: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 12:32:14 +0100The
kfree()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Applied.
PATCH 1/1 net: fec: Delete unnecessary checks before the function call "kfree"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 12:56:42 +0100
The kfree() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/net/ethernet/freescale/fec_main.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/net/ethernet/freescale/fec_main.c +2 -5
@@ -2584,12 +2584,9 @@ static void fec_enet_free_queue(struct net_device *ndev) }for (i =0 ; i < fep->num_rx_queues; i++) -if (fep->rx_queue[i]) -kfree (fep->rx_queue[i]); - +kfree (fep->rx_queue[i]);for (i =0 ; i < fep->num_tx_queues; i++) -if (fep->tx_queue[i]) -kfree (fep->tx_queue[i]); +kfree (fep->tx_queue[i]); }static int fec_enet_alloc_queue (struct net_device *ndev)
Signature · 1 line
2.2.2
Re: [PATCH] net: fec: Delete unnecessary checks before the function call "kfree"
From: SF Markus Elfring <[email protected]>
Date: Wed, 04 Feb 2015 13:00:46 +0100
Quoted 9 lines
From: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 12:56:42 +0100The
kfree()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Applied.
PATCH 1/1 netxen: Delete an unnecessary check before the function call "kfree"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 13:17:48 +0100
The kfree() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c +1 -3
@@ -176,9 +176,7 @@ netxen_alloc_sds_rings(struct netxen_recv_context *recv_ctx, int count)static void netxen_free_sds_rings (struct netxen_recv_context *recv_ctx) { -if (recv_ctx->sds_rings !=NULL ) -kfree (recv_ctx->sds_rings); - +kfree (recv_ctx->sds_rings); recv_ctx->sds_rings =NULL ; }
Signature · 1 line
2.2.2
Re: [PATCH] netxen: Delete an unnecessary check before the function call "kfree"
From: SF Markus Elfring <[email protected]>
Date: Wed, 04 Feb 2015 13:21:29 +0100
Quoted 9 lines
From: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 13:17:48 +0100The
kfree()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Applied.
PATCH 1/1 qlogic: Deletion of unnecessary checks before two function calls
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 14:07:56 +0100
The functions kfree() and vfree() perform also input parameter validation. Thus the test around their calls is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c | 24 ++++++++-------------- .../net/ethernet/qlogic/qlcnic/qlcnic_minidump.c | 3 +-- 2 files changed, 9 insertions(+), 18 deletions(-)
drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c +8 -16
@@ -294,9 +294,7 @@ int qlcnic_alloc_sds_rings(struct qlcnic_recv_context *recv_ctx, int count)void qlcnic_free_sds_rings (struct qlcnic_recv_context *recv_ctx) { -if (recv_ctx->sds_rings !=NULL ) -kfree (recv_ctx->sds_rings); - +kfree (recv_ctx->sds_rings); recv_ctx->sds_rings =NULL ; }
@@ -1257,8 +1255,7 @@ qlcnic_check_options(struct qlcnic_adapter *adapter)if (ahw->op_mode !=QLCNIC_NON_PRIV_FUNC ) {if (fw_dump->tmpl_hdr =NULL || adapter->fw_version > prev_fw_version) { -if (fw_dump->tmpl_hdr) -vfree (fw_dump->tmpl_hdr); +vfree (fw_dump->tmpl_hdr);if (!qlcnic_fw_cmd_get_minidump_temp (adapter))dev_info (&pdev->dev,"Supports FW dump capability\n" );
@@ -2374,13 +2371,12 @@ void qlcnic_free_tx_rings(struct qlcnic_adapter *adapter)for (ring =0 ; ring < adapter->drv_tx_rings; ring++) { tx_ring = &adapter->tx_ring[ring]; -if (tx_ring && tx_ring->cmd_buf_arr !=NULL ) { +if (tx_ring) {vfree (tx_ring->cmd_buf_arr); tx_ring->cmd_buf_arr =NULL ; } } -if (adapter->tx_ring !=NULL ) -kfree (adapter->tx_ring); +kfree (adapter->tx_ring); } int qlcnic_alloc_tx_rings(struct qlcnic_adapter *adapter,
@@ -2758,13 +2754,9 @@ static void qlcnic_remove(struct pci_dev *pdev) }qlcnic_dcb_free (adapter->dcb); -qlcnic_detach (adapter); - -if (adapter->npars !=NULL ) -kfree (adapter->npars); -if (adapter->eswitch !=NULL ) -kfree (adapter->eswitch); +kfree (adapter->npars); +kfree (adapter->eswitch);if (qlcnic_82xx_check (adapter))qlcnic_clr_all_drv_state (adapter,0 );
@@ -2932,13 +2924,13 @@ void qlcnic_alloc_lb_filters_mem(struct qlcnic_adapter *adapter)static void qlcnic_free_lb_filters_mem (struct qlcnic_adapter *adapter) { -if (adapter->fhash.fmax && adapter->fhash.fhead) +if (adapter->fhash.fmax)kfree (adapter->fhash.fhead); adapter->fhash.fhead =NULL ; adapter->fhash.fmax =0 ; -if (adapter->rx_fhash.fmax && adapter->rx_fhash.fhead) +if (adapter->rx_fhash.fmax)kfree (adapter->rx_fhash.fhead); adapter->rx_fhash.fmax =0 ;
drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c +1 -2
@@ -1407,8 +1407,7 @@ void qlcnic_83xx_get_minidump_template(struct qlcnic_adapter *adapter) current_version =qlcnic_83xx_get_fw_version (adapter);if (fw_dump->tmpl_hdr =NULL || current_version > prev_version) { -if (fw_dump->tmpl_hdr) -vfree (fw_dump->tmpl_hdr); +vfree (fw_dump->tmpl_hdr);if (!qlcnic_fw_cmd_get_minidump_temp (adapter))dev_info (&pdev->dev,"Supports FW dump capability\n" ); }
Signature · 1 line
2.2.2
Re: [PATCH] qlogic: Deletion of unnecessary checks before two function calls
From: SF Markus Elfring <[email protected]>
Date: Wed, 04 Feb 2015 14:13:37 +0100
Quoted 9 lines
From: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 14:07:56 +0100The functions
kfree()andvfree()perform also input parameter validation. Thus the test around their calls is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Applied.
PATCH 1/1 net: Mellanox: Delete unnecessary checks before the function call "vunmap"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 15:17:00 +0100
The vunmap() function performs also input parameter validation. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/net/ethernet/mellanox/mlx4/alloc.c | 2 +- drivers/net/ethernet/mellanox/mlx5/core/alloc.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx4/alloc.c +1 -1
@@ -660,7 +660,7 @@ void mlx4_buf_free(struct mlx4_dev *dev, int size, struct mlx4_buf *buf)dma_free_coherent (&dev->pdev->dev, size, buf->direct.buf, buf->direct.map); else { -if (BITS_PER_LONG =64 && buf->direct.buf) +if (BITS_PER_LONG =64 )vunmap (buf->direct.buf);for (i =0 ; i < buf->nbufs; ++i)
drivers/net/ethernet/mellanox/mlx5/core/alloc.c +1 -1
@@ -121,7 +121,7 @@ void mlx5_buf_free(struct mlx5_core_dev *dev, struct mlx5_buf *buf)dma_free_coherent (&dev->pdev->dev, buf->size, buf->direct.buf, buf->direct.map); else { -if (BITS_PER_LONG =64 && buf->direct.buf) +if (BITS_PER_LONG =64 )vunmap (buf->direct.buf);for (i =0 ; i < buf->nbufs; i++)
Signature · 1 line
2.2.2
Re: [PATCH] net: Mellanox: Delete unnecessary checks before the function call "vunmap"
Quoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 15:17:00 +0100The
vunmap()function performs also input parameter validation. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
David Miller
maintainerRe: [PATCH] net: Mellanox: Delete unnecessary checks before the function call "vunmap"
In reply to SF Markus ElfringFrom: SF Markus Elfring <[email protected]>
Date: Wed, 04 Feb 2015 15:22:33 +0100
Quoted 9 lines
From: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 15:17:00 +0100The
vunmap()function performs also input parameter validation. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
This does not apply cleanly to the net-next tree, please respin.
PATCH v2 1/1 net: Mellanox: Delete unnecessary checks before the function call "vunmap"
From: Markus Elfring <[email protected]>
Date: Mon, 9 Feb 2015 11:10:41 +0100
The vunmap() function performs also input parameter validation. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/net/ethernet/mellanox/mlx4/alloc.c | 2 +- drivers/net/ethernet/mellanox/mlx5/core/alloc.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx4/alloc.c +1 -1
@@ -662,7 +662,7 @@ void mlx4_buf_free(struct mlx4_dev *dev, int size, struct mlx4_buf *buf) buf->direct.buf, buf->direct.map); else { -if (BITS_PER_LONG =64 && buf->direct.buf) +if (BITS_PER_LONG =64 )vunmap (buf->direct.buf);for (i =0 ; i < buf->nbufs; ++i)
drivers/net/ethernet/mellanox/mlx5/core/alloc.c +1 -1
@@ -121,7 +121,7 @@ void mlx5_buf_free(struct mlx5_core_dev *dev, struct mlx5_buf *buf)dma_free_coherent (&dev->pdev->dev, buf->size, buf->direct.buf, buf->direct.map); else { -if (BITS_PER_LONG =64 && buf->direct.buf) +if (BITS_PER_LONG =64 )vunmap (buf->direct.buf);for (i =0 ; i < buf->nbufs; i++)
Signature · 1 line
2.2.2
David Miller
AppliedRe: [PATCH v2] net: Mellanox: Delete unnecessary checks before the function call "vunmap"
From: SF Markus Elfring <[email protected]>
Date: Mon, 09 Feb 2015 11:21:26 +0100
Quoted 10 lines
From: Markus Elfring <[email protected]>
Date: Mon, 9 Feb 2015 11:10:41 +0100The
vunmap()function performs also input parameter validation. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>Acked-by Eli Cohen <[email protected]>
Applied.
PATCH 1/1 net: ep93xx_eth: Delete unnecessary checks before the function call "kfree"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 15:56:58 +0100
The kfree() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/net/ethernet/cirrus/ep93xx_eth.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/net/ethernet/cirrus/ep93xx_eth.c +2 -4
@@ -475,8 +475,7 @@ static void ep93xx_free_buffers(struct ep93xx_priv *ep)if (d)dma_unmap_single (dev, d,PKT_BUF_SIZE ,DMA_FROM_DEVICE ); -if (ep->rx_buf[i] !=NULL ) -kfree (ep->rx_buf[i]); +kfree (ep->rx_buf[i]); }for (i =0 ; i <TX_QUEUE_ENTRIES ; i++) {
@@ -486,8 +485,7 @@ static void ep93xx_free_buffers(struct ep93xx_priv *ep)if (d)dma_unmap_single (dev, d,PKT_BUF_SIZE ,DMA_TO_DEVICE ); -if (ep->tx_buf[i] !=NULL ) -kfree (ep->tx_buf[i]); +kfree (ep->tx_buf[i]); } dma_free_coherent(dev, sizeof(struct ep93xx_descs), ep->descs,
Signature · 1 line
2.2.2
RE: [PATCH] net: ep93xx_eth: Delete unnecessary checks before the function call "kfree"
Quoted 25 lines · Markus Elfring
The
kfree()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/net/ethernet/cirrus/ep93xx_eth.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)drivers/net/ethernet/cirrus/ep93xx_eth.c +1
-2@@ -475,8 +475,7 @@ static void ep93xx_free_buffers(struct ep93xx_priv *ep)if (d)dma_unmap_single (dev, d,PKT_BUF_SIZE ,DMA_FROM_DEVICE ); -if (ep->rx_buf[i] !=NULL ) -kfree (ep->rx_buf[i]); +kfree (ep->rx_buf[i]); }for (i =0 ; i <TX_QUEUE_ENTRIES ; i++) {
drivers/net/ethernet/cirrus/ep93xx_eth.c static void ep93xx_free_buffers(struct ep93xx_priv *ep) · line 491
Quoted 9 lines
drivers/net/ethernet/cirrus/ep93xx_eth.c +1
-2@@ -486,8 +485,7 @@ static void ep93xx_free_buffers(struct ep93xx_priv *ep)if (d)dma_unmap_single (dev, d,PKT_BUF_SIZE ,DMA_TO_DEVICE ); -if (ep->tx_buf[i] !=NULL ) -kfree (ep->tx_buf[i]); +kfree (ep->tx_buf[i]); } dma_free_coherent(dev, sizeof(struct ep93xx_descs), ep->descs,
Thanks
Re: [PATCH] net: ep93xx_eth: Delete unnecessary checks before the function call "kfree"
In reply to SF Markus ElfringFrom: SF Markus Elfring <[email protected]>
Date: Wed, 04 Feb 2015 16:00:37 +0100
Quoted 9 lines
From: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 15:56:58 +0100The
kfree()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Applied.
cover CW1200: Deletion of an unnecessary check
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 17:31:00 +0100
Another update suggestion was taken into account after a patch was applied from static source code analysis.
Markus Elfring (2):
Delete an unnecessary check before the function call "release_firmware" Less function calls in cw1200_load_firmware_cw1200() after error detection
drivers/net/wireless/cw1200/fwio.c | 40 +++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 16 deletions(-)
Signature · 1 line
2.2.2
PATCH 1/2 CW1200: Delete an unnecessary check before the function call "release_firmware"
From: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 16:32:15 +0100
The release_firmware() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/net/wireless/cw1200/fwio.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/wireless/cw1200/fwio.c +1 -2
@@ -246,8 +246,7 @@ static int cw1200_load_firmware_cw1200(struct cw1200_common *priv) error:kfree (buf); -if (firmware) -release_firmware (firmware); +release_firmware (firmware);return ret;#undef APB_WRITE
Signature · 1 line
2.2.2
Re: [1/2] cw1200: Delete an unnecessary check before the function call "release_firmware"
Quoted 10 lines
From: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 16:32:15 +0100The
release_firmware()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Thanks, 2 patches applied to wireless-drivers-next.git:
df970d39b90e cw1200: Delete an unnecessary check before the function call "release_firmware" ee4ddad82356 cw1200: Less function calls in cw1200_load_firmware_cw1200() after error detection
Kalle Valo
PATCH 2/2 CW1200: Less function calls in cw1200_load_firmware_cw1200() after error detection
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 17:28:41 +0100
The functions kfree() and release_firmware() were called in a few cases by the cw1200_load_firmware_cw1200() function during error handling even if the passed variables contained still a null pointer.
Corresponding implementation details could be improved by adjustments for jump targets.
--- drivers/net/wireless/cw1200/fwio.c | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-)
drivers/net/wireless/cw1200/fwio.c +23 -14
@@ -66,25 +66,31 @@ static int cw1200_load_firmware_cw1200(struct cw1200_common *priv)do { \ ret =cw1200_apb_write_32 (priv,CW1200_APB (reg), (val)); \if (ret <0 ) \ - goto error; \ + goto exit; \ + } while (0) +#define APB_WRITE2 (reg, val) \ + do { \ + ret = cw1200_apb_write_32(priv, CW1200_APB(reg), (val)); \ + if (ret < 0) \ + goto free_buffer; \ } while (0)#define APB_READ (reg, val) \ do { \ ret = cw1200_apb_read_32(priv, CW1200_APB(reg), &(val)); \ if (ret < 0) \ - goto error; \ + goto free_buffer; \ } while (0)#define REG_WRITE (reg, val) \ do { \ ret = cw1200_reg_write_32(priv, (reg), (val)); \ if (ret < 0) \ - goto error; \ + goto exit; \ } while (0)#define REG_READ (reg, val) \ do { \ ret = cw1200_reg_read_32(priv, (reg), &(val)); \ if (ret < 0) \ - goto error; \ + goto exit; \ } while (0)switch (priv->hw_revision) {
@@ -142,14 +148,14 @@ static int cw1200_load_firmware_cw1200(struct cw1200_common *priv) ret =request_firmware (&firmware, fw_path, priv->pdev);if (ret) {pr_err ("Can't load firmware file %s.\n" , fw_path); - goto error; + goto exit; } buf =kmalloc (DOWNLOAD_BLOCK_SIZE ,GFP_KERNEL |GFP_DMA );if (!buf) {pr_err ("Can't allocate firmware load buffer.\n" ); ret = -ENOMEM ; - goto error; + goto firmware_release; }/* Check if the bootloader is ready */
@@ -163,7 +169,7 @@ static int cw1200_load_firmware_cw1200(struct cw1200_common *priv)if (val32 !=DOWNLOAD_I_AM_HERE ) {pr_err ("Bootloader is not ready.\n" ); ret = -ETIMEDOUT ; - goto error; + goto free_buffer; }/* Calculcate number of download blocks */
@@ -171,7 +177,7 @@ static int cw1200_load_firmware_cw1200(struct cw1200_common *priv)/* Updating the length in Download Ctrl Area */ val32 = firmware->size;/* Explicit cast from size_t to u32 */ -APB_WRITE (DOWNLOAD_IMAGE_SIZE_REG , val32); +APB_WRITE2 (DOWNLOAD_IMAGE_SIZE_REG , val32);/* Firmware downloading loop */ for (block =0 ; block < num_blocks; block++) {
@@ -183,7 +189,7 @@ static int cw1200_load_firmware_cw1200(struct cw1200_common *priv)if (val32 !=DOWNLOAD_PENDING ) {pr_err ("Bootloader reported error %d.\n" , val32); ret = -EIO ; - goto error; + goto free_buffer; }/* loop until put - get <= 24K */
@@ -198,7 +204,7 @@ static int cw1200_load_firmware_cw1200(struct cw1200_common *priv)if ((put - get) > (DOWNLOAD_FIFO_SIZE -DOWNLOAD_BLOCK_SIZE )) {pr_err ("Timeout waiting for FIFO.\n" ); ret = -ETIMEDOUT ; - goto error; + goto free_buffer; }/* calculate the block size */
@@ -220,12 +226,12 @@ static int cw1200_load_firmware_cw1200(struct cw1200_common *priv)if (ret <0 ) {pr_err ("Can't write firmware block @ %d!\n" , put & (DOWNLOAD_FIFO_SIZE -1 )); - goto error; + goto free_buffer; }/* update the put register */ put += block_size; -APB_WRITE (DOWNLOAD_PUT_REG , put); +APB_WRITE2 (DOWNLOAD_PUT_REG , put); }/* End of firmware download loop */ /* Wait for the download completion */
@@ -238,18 +244,21 @@ static int cw1200_load_firmware_cw1200(struct cw1200_common *priv)if (val32 !=DOWNLOAD_SUCCESS ) {pr_err ("Wait for download completion failed: 0x%.8X\n" , val32); ret = -ETIMEDOUT ; - goto error; + goto free_buffer; }else {pr_info ("Firmware download completed.\n" ); ret =0 ; } -error: +free_buffer:kfree (buf); +firmware_release:release_firmware (firmware); +exit:return ret;#undef APB_WRITE +#undef APB_WRITE2#undef APB_READ#undef REG_WRITE#undef REG_READ
Signature · 1 line
2.2.2
PATCH 1/1 ath9k: Delete an unnecessary check before the function call "relay_close"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 18:48:28 +0100
The relay_close() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/net/wireless/ath/ath9k/common-spectral.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath9k/common-spectral.c +1 -1
@@ -582,7 +582,7 @@ static struct rchan_callbacks rfs_spec_scan_cb = {void ath9k_cmn_spectral_deinit_debug (struct ath_spec_scan_priv *spec_priv) { -if (config_enabled (CONFIG_ATH9K_DEBUGFS ) && spec_priv->rfs_chan_spec_scan) { +if (config_enabled (CONFIG_ATH9K_DEBUGFS )) {relay_close (spec_priv->rfs_chan_spec_scan); spec_priv->rfs_chan_spec_scan =NULL ; }
Signature · 1 line
2.2.2
Kalle Valo
AppliedRe: ath9k: Delete an unnecessary check before the function call"relay_close"
Quoted 10 lines
From: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 18:48:28 +0100The
relay_close()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Thanks, applied to wireless-drivers-next.git.
Kalle Valo
PATCH 1/1 ath10k: Delete unnecessary checks before the function call "release_firmware"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 19:30:23 +0100
The release_firmware() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/net/wireless/ath/ath10k/core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/wireless/ath/ath10k/core.c +4 -4
@@ -393,16 +393,16 @@ static int ath10k_download_fw(struct ath10k *ar, enum ath10k_firmware_mode mode)static void ath10k_core_free_firmware_files (struct ath10k *ar) { -if (ar->board && !IS_ERR (ar->board)) +if (!IS_ERR (ar->board))release_firmware (ar->board); -if (ar->otp && !IS_ERR (ar->otp)) +if (!IS_ERR (ar->otp))release_firmware (ar->otp); -if (ar->firmware && !IS_ERR (ar->firmware)) +if (!IS_ERR (ar->firmware))release_firmware (ar->firmware); -if (ar->cal_file && !IS_ERR (ar->cal_file)) +if (!IS_ERR (ar->cal_file))release_firmware (ar->cal_file); ar->board =NULL ;
Signature · 1 line
2.2.2
Kalle Valo
AppliedRe: [PATCH] ath10k: Delete unnecessary checks before the function call "release_firmware"
Quoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 19:30:23 +0100The
release_firmware()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Thanks, applied to ath.git.
Signature · 1 line
Kalle Valo
PATCH 1/1 orinoco: Delete an unnecessary check before the function call "kfree"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 19:53:11 +0100
The kfree() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/net/wireless/orinoco/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/orinoco/main.c +1 -1
@@ -2342,7 +2342,7 @@ void free_orinocodev(struct orinoco_private *priv)list_for_each_entry_safe (sd, sdtemp, &priv->scan_list, list) {list_del (&sd->list); -if ((sd->len >0 ) && sd->buf) +if (sd->len >0 )kfree (sd->buf);kfree (sd); }
Signature · 1 line
2.2.2
Kalle Valo
AppliedRe: orinoco: Delete an unnecessary check before the function call "kfree"
Quoted 10 lines
From: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 19:53:11 +0100The
kfree()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Thanks, applied to wireless-drivers-next.git.
Kalle Valo
PATCH 1/1 HostAP: Delete an unnecessary check before the function call "kfree"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 20:06:39 +0100
The kfree() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/net/wireless/hostap/hostap_ap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/hostap/hostap_ap.c +1 -1
@@ -145,7 +145,7 @@ static void ap_free_sta(struct ap_data *ap, struct sta_info *sta)if (sta->aid >0 ) ap->sta_aid[sta->aid -1 ] =NULL ; -if (!sta->ap && sta->u.sta.challenge) +if (!sta->ap)kfree (sta->u.sta.challenge);del_timer_sync (&sta->timer);#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
Signature · 1 line
2.2.2
Kalle Valo
AppliedRe: hostap: Delete an unnecessary check before the function call "kfree"
Quoted 10 lines
From: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 20:06:39 +0100The
kfree()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Thanks, applied to wireless-drivers-next.git.
Kalle Valo
PATCH 1/1 net: brcm80211: Delete unnecessary checks before two function calls
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 20:28:49 +0100
The functions brcmu_pkt_buf_free_skb() and usb_free_urb() test whether their argument is NULL and then return immediately. Thus the test around the call is not needed.
--- drivers/net/wireless/brcm80211/brcmfmac/sdio.c | 3 +-- drivers/net/wireless/brcm80211/brcmfmac/usb.c | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-)
drivers/net/wireless/brcm80211/brcmfmac/sdio.c +1 -2
@@ -2543,8 +2543,7 @@ static void brcmf_sdio_bus_stop(struct device *dev)brcmu_pktq_flush (&bus->txq, true,NULL ,NULL );/* Clear any held glomming stuff */ -if (bus->glomd) -brcmu_pkt_buf_free_skb (bus->glomd); +brcmu_pkt_buf_free_skb (bus->glomd);brcmf_sdio_free_glom (bus);/* Clear rx control and wake any waiters */
drivers/net/wireless/brcm80211/brcmfmac/usb.c +1 -1
@@ -421,7 +421,7 @@ fail:brcmf_err ("fail!\n" );while (!list_empty (q)) { req = list_entry(q->next, struct brcmf_usbreq, list); -if (req && req->urb) +if (req)usb_free_urb (req->urb);list_del (q->next); }
Signature · 1 line
2.2.2
Kalle Valo
AppliedRe: brcm80211: Delete unnecessary checks before two function calls
Quoted 9 lines
From: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 20:28:49 +0100The functions
brcmu_pkt_buf_free_skb()andusb_free_urb()test whether their argument is NULL and then return immediately. Thus the test around the call is not needed.Signed-off-by Markus Elfring <[email protected]>
Thanks, applied to wireless-drivers-next.git.
Kalle Valo
PATCH 1/1 SGI-XPC: Delete an unnecessary check before the function call "kfree"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 20:50:31 +0100
The kfree() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/misc/sgi-xp/xpc_partition.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/misc/sgi-xp/xpc_partition.c +1 -2
@@ -98,8 +98,7 @@ xpc_get_rsvd_page_pa(int nasid) len =L1_CACHE_ALIGN (len);if (len > buf_len) { -if (buf_base !=NULL ) -kfree (buf_base); +kfree (buf_base); buf_len =L1_CACHE_ALIGN (len); buf =xpc_kmalloc_cacheline_aligned (buf_len,GFP_KERNEL , &buf_base);
Signature · 1 line
2.2.2
PATCH 1/1 macintosh: Delete an unnecessary check before the function call "of_node_put"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 21:32:27 +0100
The of_node_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/macintosh/smu.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/macintosh/smu.c +1 -2
@@ -557,8 +557,7 @@ int __init smu_init (void)return 0 ; fail_msg_node: -if (smu->msg_node) -of_node_put (smu->msg_node); +of_node_put (smu->msg_node); fail_db_node:of_node_put (smu->db_node); fail_bootmem:
Signature · 1 line
2.2.2
Re: [PATCH] macintosh: Delete an unnecessary check before the function call "of_node_put"
Am 04.02.2015 um 21:36 schrieb SF Markus Elfring:
Quoted 19 lines
From: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 21:32:27 +0100The
of_node_put()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/macintosh/smu.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/macintosh/smu.c +0
-0
drivers/macintosh/smu.c int __init smu_init (void) · line 563
Quoted 9 lines
drivers/macintosh/smu.c +1
-2@@ -557,8 +557,7 @@ int __init smu_init (void)return 0 ; fail_msg_node: -if (smu->msg_node) -of_node_put (smu->msg_node); +of_node_put (smu->msg_node); fail_db_node:of_node_put (smu->db_node); fail_bootmem:
Would you like to integrate this update suggestion into another source code repository?
Regards,
Markus
PATCH 1/1 GPU-DRM-Exynos: Delete unnecessary checks before two function calls
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 21:54:45 +0100
The functions phy_power_on() and vunmap() perform also input parameter validation. Thus the test around their calls is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/gpu/drm/exynos/exynos_dp_core.c | 6 ++---- drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-)
drivers/gpu/drm/exynos/exynos_dp_core.c +2 -4
@@ -1057,14 +1057,12 @@ static int exynos_dp_create_connector(struct exynos_drm_display *display,static void exynos_dp_phy_init (struct exynos_dp_device *dp) { -if (dp->phy) -phy_power_on (dp->phy); +phy_power_on (dp->phy); }static void exynos_dp_phy_exit (struct exynos_dp_device *dp) { -if (dp->phy) -phy_power_off (dp->phy); +phy_power_off (dp->phy); }static void exynos_dp_poweron (struct exynos_drm_display *display)
drivers/gpu/drm/exynos/exynos_drm_fbdev.c +1 -1
@@ -313,7 +313,7 @@ static void exynos_drm_fbdev_destroy(struct drm_device *dev,struct exynos_drm_gem_obj *exynos_gem_obj = exynos_fbd->exynos_gem_obj;struct drm_framebuffer *fb; -if (is_drm_iommu_supported (dev) && exynos_gem_obj->buffer->kvaddr) +if (is_drm_iommu_supported (dev))vunmap (exynos_gem_obj->buffer->kvaddr);/* release drm framebuffer and real buffer */
Signature · 1 line
2.2.2
Re: [PATCH] GPU-DRM-Exynos: Delete unnecessary checks before two function calls
Hi,
Quoted 41 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 21:54:45 +0100The functions
phy_power_on()andvunmap()perform also input parameter validation. Thus the test around their calls is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/gpu/drm/exynos/exynos_dp_core.c | 6 ++---- drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-)drivers/gpu/drm/exynos/exynos_dp_core.c +2
-4@@ -1057,14 +1057,12 @@ static int exynos_dp_create_connector(struct exynos_drm_display *display,static void exynos_dp_phy_init (struct exynos_dp_device *dp) { -if (dp->phy) -phy_power_on (dp->phy); +phy_power_on (dp->phy); }static void exynos_dp_phy_exit (struct exynos_dp_device *dp) { -if (dp->phy) -phy_power_off (dp->phy); +phy_power_off (dp->phy); }static void exynos_dp_poweron (struct exynos_drm_display *display)drivers/gpu/drm/exynos/exynos_drm_fbdev.c +0
-0
drivers/gpu/drm/exynos/exynos_drm_fbdev.c static void exynos_drm_fbdev_destroy(struct drm_device *dev, · line 319
Quoted 8 lines
drivers/gpu/drm/exynos/exynos_drm_fbdev.c +1
-1@@ -313,7 +313,7 @@ static void exynos_drm_fbdev_destroy(struct drm_device *dev,struct exynos_drm_gem_obj *exynos_gem_obj = exynos_fbd->exynos_gem_obj;struct drm_framebuffer *fb; -if (is_drm_iommu_supported (dev) && exynos_gem_obj->buffer->kvaddr) +if (is_drm_iommu_supported (dev))vunmap (exynos_gem_obj->buffer->kvaddr);/* release drm framebuffer and real buffer */
Thanks.
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH] GPU-DRM-Exynos: Delete unnecessary checks before two function calls
Quoted 43 lines
Quoted 43 lines
From: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 21:54:45 +0100The functions
phy_power_on()andvunmap()perform also input parameter validation. Thus the test around their calls is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/gpu/drm/exynos/exynos_dp_core.c | 6 ++---- drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-)drivers/gpu/drm/exynos/exynos_dp_core.c +2
-4@@ -1057,14 +1057,12 @@ static int exynos_dp_create_connector(struct exynos_drm_display *display,static void exynos_dp_phy_init (struct exynos_dp_device *dp) { -if (dp->phy) -phy_power_on (dp->phy); +phy_power_on (dp->phy); }static void exynos_dp_phy_exit (struct exynos_dp_device *dp) { -if (dp->phy) -phy_power_off (dp->phy); +phy_power_off (dp->phy); }static void exynos_dp_poweron (struct exynos_drm_display *display)drivers/gpu/drm/exynos/exynos_drm_fbdev.c +0
-0@@ -313,7 +313,7 @@ static void exynos_drm_fbdev_destroy(struct drm_device *dev,struct exynos_drm_gem_obj *exynos_gem_obj = exynos_fbd->exynos_gem_obj;struct drm_framebuffer *fb;
Quoted 8 lines
drivers/gpu/drm/exynos/exynos_drm_fbdev.c static void exynos_drm_fbdev_destroy(struct drm_device *dev, · line 319
Quoted 6 lines
drivers/gpu/drm/exynos/exynos_drm_fbdev.c +1
-1-if (is_drm_iommu_supported (dev) && exynos_gem_obj->buffer->kvaddr) +if (is_drm_iommu_supported (dev))vunmap (exynos_gem_obj->buffer->kvaddr);/* release drm framebuffer and real buffer */ Acked-by Joonyoung Shim <[email protected]>
Do the chances increase to integrate this update suggestion into another source code repository?
Regards,
Markus
PATCH 1/1 GPU-DRM-Exynos: Delete an unnecessary check before the function call "vunmap"
In reply to Joonyoung ShimFrom: Markus Elfring <[email protected]>
Date: Thu, 21 Jul 2016 19:23:25 +0200
The vunmap() function performs also input parameter validation. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/exynos/exynos_drm_fbdev.c +1 -2
@@ -269,8 +269,7 @@ static void exynos_drm_fbdev_destroy(struct drm_device *dev,struct exynos_drm_gem *exynos_gem = exynos_fbd->exynos_gem;struct drm_framebuffer *fb; -if (exynos_gem->kvaddr) -vunmap (exynos_gem->kvaddr); +vunmap (exynos_gem->kvaddr);/* release drm framebuffer and real buffer */ if (fb_helper->fb && fb_helper->fb->funcs) {
Signature · 1 line
2.9.2
Sean Paul
AppliedRe: [PATCH] GPU-DRM-Exynos: Delete an unnecessary check before the function call "vunmap"
Quoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Thu, 21 Jul 2016 19:23:25 +0200The
vunmap()function performs also input parameter validation. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Applied to drm-misc
Quoted 25 lines
--- drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/gpu/drm/exynos/exynos_drm_fbdev.c +1
-3@@ -269,8 +269,7 @@ static void exynos_drm_fbdev_destroy(struct drm_device *dev,struct exynos_drm_gem *exynos_gem = exynos_fbd->exynos_gem;struct drm_framebuffer *fb; -if (exynos_gem->kvaddr) -vunmap (exynos_gem->kvaddr); +vunmap (exynos_gem->kvaddr);/* release drm framebuffer and real buffer */ if (fb_helper->fb && fb_helper->fb->funcs) { --2.9.2
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 1/1 GPU-DRM-OMAP: Delete unnecessary checks before two function calls
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 4 Feb 2015 22:22:36 +0100
The functions framebuffer_release() and vunmap() perform also input parameter validation. Thus the test around their calls is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/gpu/drm/omapdrm/omap_fbdev.c | 3 +-- drivers/gpu/drm/omapdrm/omap_gem.c | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-)
drivers/gpu/drm/omapdrm/omap_fbdev.c +1 -2
@@ -270,8 +270,7 @@ fail_unlock: fail:if (ret) { -if (fbi) -framebuffer_release (fbi); +framebuffer_release (fbi);if (fb) {drm_framebuffer_unregister_private (fb);drm_framebuffer_remove (fb);
drivers/gpu/drm/omapdrm/omap_gem.c +2 -3
@@ -1292,12 +1292,11 @@ void omap_gem_free_object(struct drm_gem_object *obj)if (omap_obj->pages)omap_gem_detach_pages (obj); -if (!is_shmem (obj)) { +if (!is_shmem (obj))dma_free_writecombine (dev->dev, obj->size, omap_obj->vaddr, omap_obj->paddr); - }else if (omap_obj->vaddr) { +else vunmap (omap_obj->vaddr); - } }/* don't free externally allocated syncobj */
Signature · 1 line
2.2.2
PATCH 1/1 GPU-DRM-OMAP: Delete unnecessary checks before two function calls
From: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 08:28:31 +0200
The following functions test whether their argument is NULL and then return immediately.
* backlight_device_unregister
* drm_gem_object_unreference_unlocked
Thus the test around the calls is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c | 3 +-- drivers/gpu/drm/omapdrm/omap_fb.c | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-)
drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c +1 -2
@@ -1284,8 +1284,7 @@ static int dsicm_probe(struct platform_device *pdev)return 0 ; err_sysfs_create: -if (bldev !=NULL ) -backlight_device_unregister (bldev); +backlight_device_unregister (bldev); err_bl:destroy_workqueue (ddata->workqueue); err_reg:
drivers/gpu/drm/omapdrm/omap_fb.c +2 -2
@@ -115,8 +115,8 @@ static void omap_framebuffer_destroy(struct drm_framebuffer *fb)for (i =0 ; i < n; i++) {struct plane *plane = &omap_fb->planes[i]; -if (plane->bo) -drm_gem_object_unreference_unlocked (plane->bo); + +drm_gem_object_unreference_unlocked (plane->bo); }kfree (omap_fb);
Signature · 1 line
2.9.2
PATCH 1/1 GPU-DRM-Tegra: Delete an unnecessary check before the function call "vunmap"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 5 Feb 2015 10:12:51 +0100
The vunmap() function performs also input parameter validation. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/gpu/drm/tegra/fb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/tegra/fb.c +1 -1
@@ -66,7 +66,7 @@ static void tegra_fb_destroy(struct drm_framebuffer *framebuffer)struct tegra_bo *bo = fb->planes[i];if (bo) { -if (bo->pages && bo->vaddr) +if (bo->pages)vunmap (bo->vaddr);drm_gem_object_unreference_unlocked (&bo->gem);
Signature · 1 line
2.2.2
Re: [PATCH] GPU-DRM-Tegra: Delete an unnecessary check before the function call "vunmap"
Quoted 19 lines
From: Markus Elfring <[email protected]>
Date: Thu, 5 Feb 2015 10:12:51 +0100The
vunmap()function performs also input parameter validation. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/gpu/drm/tegra/fb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/tegra/fb.c +0
-0
drivers/gpu/drm/tegra/fb.c static void tegra_fb_destroy(struct drm_framebuffer *framebuffer) · line 72
Quoted 8 lines
drivers/gpu/drm/tegra/fb.c +1
-1@@ -66,7 +66,7 @@ static void tegra_fb_destroy(struct drm_framebuffer *framebuffer)struct tegra_bo *bo = fb->planes[i];if (bo) { -if (bo->pages && bo->vaddr) +if (bo->pages)vunmap (bo->vaddr);drm_gem_object_unreference_unlocked (&bo->gem);
Would you like to integrate this update suggestion into another source code repository?
Regards,
Markus
Alexandre Courbot
Acked-byRe: [PATCH] GPU-DRM-Tegra: Delete an unnecessary check before the function call "vunmap"
Quoted 7 lines · SF Markus Elfring
Quoted 7 lines
From: Markus Elfring <[email protected]>
Date: Thu, 5 Feb 2015 10:12:51 +0100The
vunmap()function performs also input parameter validation. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
The fix is correct, but the subject looks weird.
"GPU-DRM-Tegra:"should be "drm/tegra:".
Otherwise,
Maybe Thierry can take it through his tree once this issue is addressed?
PATCH 1/1 drm/tegra: Delete an unnecessary check before the function call "vunmap"
From: Markus Elfring <[email protected]>
Date: Sat, 16 Jul 2016 07:23:42 +0200
The vunmap() function performs also input parameter validation. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/gpu/drm/tegra/fb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/tegra/fb.c +1 -1
@@ -68,7 +68,7 @@ static void tegra_fb_destroy(struct drm_framebuffer *framebuffer)struct tegra_bo *bo = fb->planes[i];if (bo) { -if (bo->pages && bo->vaddr) +if (bo->pages)vunmap (bo->vaddr);drm_gem_object_unreference_unlocked (&bo->gem);
Signature · 1 line
2.9.1
PATCH 1/1 driver core: Delete an unnecessary check before the function call "put_device"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 5 Feb 2015 11:48:26 +0100
The put_device() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/base/core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/base/core.c +1 -2
@@ -1095,8 +1095,7 @@ done:kobject_del (&dev->kobj); Error:cleanup_device_parent (dev); -if (parent) -put_device (parent); +put_device (parent); name_error:kfree (dev->p); dev->p =NULL ;
Signature · 1 line
2.2.2
PATCH 1/1 InfiniBand: Delete unnecessary checks before the function, call "srp_destroy_fr_pool"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 5 Feb 2015 13:20:42 +0100
The srp_destroy_fr_pool() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/infiniband/ulp/srp/ib_srp.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/infiniband/ulp/srp/ib_srp.c +5 -7
@@ -549,8 +549,7 @@ static int srp_create_ch_ib(struct srp_rdma_ch *ch) "FR pool allocation failed (%d)\n", ret); goto err_qp; } -if (ch->fr_pool) -srp_destroy_fr_pool (ch->fr_pool); +srp_destroy_fr_pool (ch->fr_pool); ch->fr_pool = fr_pool; }else if (!dev->use_fast_reg && dev->has_fmr) { fmr_pool =srp_alloc_fmr_pool (target);
@@ -615,13 +614,12 @@ static void srp_free_ch_ib(struct srp_target_port *target,if (!ch->qp)return ; -if (dev->use_fast_reg) { -if (ch->fr_pool) -srp_destroy_fr_pool (ch->fr_pool); - }else { +if (dev->use_fast_reg) +srp_destroy_fr_pool (ch->fr_pool); +else if (ch->fmr_pool)ib_destroy_fmr_pool (ch->fmr_pool); - } +srp_destroy_qp (ch);ib_destroy_cq (ch->send_cq);ib_destroy_cq (ch->recv_cq);
Signature · 1 line
2.2.2
Re: [PATCH] InfiniBand: Delete unnecessary checks before the function, call "srp_destroy_fr_pool"
Quoted 35 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Thu, 5 Feb 2015 13:20:42 +0100The
srp_destroy_fr_pool()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/infiniband/ulp/srp/ib_srp.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)drivers/infiniband/ulp/srp/ib_srp.c +1
-6@@ -549,8 +549,7 @@ static int srp_create_ch_ib(struct srp_rdma_ch *ch) "FR pool allocation failed (%d)\n", ret); goto err_qp; } -if (ch->fr_pool) -srp_destroy_fr_pool (ch->fr_pool); +srp_destroy_fr_pool (ch->fr_pool); ch->fr_pool = fr_pool; }else if (!dev->use_fast_reg && dev->has_fmr) { fmr_pool =srp_alloc_fmr_pool (target);@@ -615,13 +614,12 @@ static void srp_free_ch_ib(struct srp_target_port *target,if (!ch->qp)return ; -if (dev->use_fast_reg) { -if (ch->fr_pool) -srp_destroy_fr_pool (ch->fr_pool); - }else {
drivers/infiniband/ulp/srp/ib_srp.c static void srp_free_ch_ib(struct srp_target_port *target, · line 625
Quoted 10 lines
drivers/infiniband/ulp/srp/ib_srp.c +4
-1+if (dev->use_fast_reg) +srp_destroy_fr_pool (ch->fr_pool); +else if (ch->fmr_pool)ib_destroy_fmr_pool (ch->fmr_pool); - } +srp_destroy_qp (ch);ib_destroy_cq (ch->send_cq);ib_destroy_cq (ch->recv_cq);
This patch makes the code in srp_free_ch_ib() asymmetric which is unfortunate. Please add a test in ib_destroy_fmr_pool() such that the check before ib_destroy_fmr_pool() can also be eliminated.
Bart.
PATCH 1/1 au1100fb: Delete unnecessary checks before two function calls
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 5 Feb 2015 14:10:21 +0100
The functions clk_enable() and clk_disable() test whether their argument is NULL and then return immediately. Thus the test around the calls is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/video/fbdev/au1100fb.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/video/fbdev/au1100fb.c +2 -8
@@ -605,11 +605,8 @@ int au1100fb_drv_suspend(struct platform_device *dev, pm_message_t state)/* Blank the LCD */ au1100fb_fb_blank (VESA_POWERDOWN , &fbdev->info); -if (fbdev->lcdclk) -clk_disable (fbdev->lcdclk); - +clk_disable (fbdev->lcdclk);memcpy (&fbregs, fbdev->regs,sizeof (struct au1100fb_regs )); -return 0 ; }
@@ -621,13 +618,10 @@ int au1100fb_drv_resume(struct platform_device *dev)return 0 ;memcpy (fbdev->regs, &fbregs,sizeof (struct au1100fb_regs )); - -if (fbdev->lcdclk) -clk_enable (fbdev->lcdclk); +clk_enable (fbdev->lcdclk);/* Unblank the LCD */ au1100fb_fb_blank (VESA_NO_BLANKING , &fbdev->info); - return 0; }#else
Signature · 1 line
2.2.2
Re: [PATCH] au1100fb: Delete unnecessary checks before two function calls
Quoted 5 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Thu, 5 Feb 2015 14:10:21 +0100The functions
clk_enable()andclk_disable()test whether their argument is NULL and then return immediately.
This isn't true for clk_enable().
"I find it acceptable that some of my update suggestions do not fit to your quality expectations at the moment." --
https://lkml.org/lkml/2015/1/22/446
It's frustrating that you make the same mistake over and over and you are fine with doing that. If you make a mistake and you are fixing a bug, then hopefully you fix more bugs than you introduce. If you make a mistake and you are doing a cleanup then you are really just introducing bugs and that's not helpful. I wish you would find something useful to do instead of sending these patches. :(
regards,
dan carpenter
Re: [PATCH] au1100fb: Delete unnecessary checks before two function calls
Quoted 4 lines
Quoted 2 lines
The functions
clk_enable()andclk_disable()test whether their argument is NULL and then return immediately.This isn't true for
clk_enable().
I stumble on an interesting name space issue once more.
Quoted 2 lines
It's frustrating that you make the same mistake over and over and you are fine with doing that.
I admit that there can be also risks with my update suggestions in similar ways to contributions from other software developers.
A specific function implementation exists which performs also input parameter validation.
http://lxr.free-electrons.com/source/drivers/sh/clk/core.c#L291
Such variants might not fit to the functions au1100fb_drv_suspend() and au1100fb_drv_resume().
Do you want that I send a reduced patch?
Regards,
Markus
Re: [PATCH] au1100fb: Delete unnecessary checks before two function calls
Quoted 7 lines · SF Markus Elfring
Quoted 4 lines
Quoted 2 lines
The functions
clk_enable()andclk_disable()test whether their argument is NULL and then return immediately.This isn't true for
clk_enable().I stumble on an interesting name space issue once more.
The "once more" is the problem in this statement. Other people would have stopped making the mistake by now. I am able to see your bugs so you should be able to see your bugs as well.
Quoted 7 lines
Quoted 3 lines
It's frustrating that you make the same mistake over and over and you are fine with doing that.
I admit that there can be also risks with my update suggestions in similar ways to contributions from other software developers.
At times, I have told other people to stop sending cleanups until they can at least fix a bugs to balance out the bugs they have introduced. It's unacceptable to only introduce bugs and never fix any.
regards,
dan carpenter
Re: [PATCH] au1100fb: Delete unnecessary checks before two function calls
Quoted 1 line
It's unacceptable to only introduce bugs
Such a view is generally fine.
Would you like to point any more update candidates out from my suggestion collection?
Quoted 1 line
and never fix any.
Would you like to clarify any statistics around my update suggestions?
Regards,
Markus
PATCH 1/1 USB: appledisplay: Deletion of a check before backlight_device_unregister()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 5 Feb 2015 16:07:43 +0100
The backlight_device_unregister() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/usb/misc/appledisplay.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/misc/appledisplay.c +1 -1
@@ -329,7 +329,7 @@ error: pdata->urbdata, pdata->urb->transfer_dma);usb_free_urb (pdata->urb); } -if (pdata->bd && !IS_ERR (pdata->bd)) +if (!IS_ERR (pdata->bd))backlight_device_unregister (pdata->bd);kfree (pdata->msgdata); }
Signature · 1 line
2.2.2
PATCH 1/1 ueagle-atm: Delete unnecessary checks before the function call "release_firmware"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 5 Feb 2015 16:33:09 +0100
The release_firmware() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/usb/atm/ueagle-atm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/atm/ueagle-atm.c +2 -2
@@ -952,7 +952,7 @@ static void uea_load_page_e1(struct work_struct *work)int i;/* reload firmware when reboot start and it's loaded already */ -if (ovl =0 && pageno =0 && sc->dsp_firm) { +if (ovl =0 && pageno =0 ) {release_firmware (sc->dsp_firm); sc->dsp_firm =NULL ; }
@@ -1074,7 +1074,7 @@ static void uea_load_page_e4(struct work_struct *work)uea_dbg (INS_TO_USBDEV (sc),"sending DSP page %u\n" , pageno);/* reload firmware when reboot start and it's loaded already */ -if (pageno =0 && sc->dsp_firm) { +if (pageno =0 ) {release_firmware (sc->dsp_firm); sc->dsp_firm =NULL ; }
Signature · 1 line
2.2.2
PATCH 1/1 USB: whci-hcd: Delete an unnecessary check before the function call "usb_put_hcd"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 5 Feb 2015 16:54:12 +0100
The usb_put_hcd() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/usb/host/whci/hcd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/usb/host/whci/hcd.c +1 -2
@@ -313,8 +313,7 @@ error_wusbhc_create:uwb_rc_put (wusbhc->uwb_rc); error:whc_clean_up (whc); -if (usb_hcd) -usb_put_hcd (usb_hcd); +usb_put_hcd (usb_hcd);return ret; }
Signature · 1 line
2.2.2
PATCH 1/1 Input: Delete an unnecessary check before the function call "input_free_device"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 5 Feb 2015 17:35:35 +0100
The input_free_device() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/input/joystick/adi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/input/joystick/adi.c +1 -2
@@ -535,8 +535,7 @@ static int adi_connect(struct gameport *gameport, struct gameport_driver *drv) } } fail2:for (i =0 ; i <2 ; i++) -if (port->adi[i].dev) -input_free_device (port->adi[i].dev); +input_free_device (port->adi[i].dev);gameport_close (gameport); fail1:gameport_set_drvdata (gameport,NULL );kfree (port);
Signature · 1 line
2.2.2
Re: [PATCH] Input: Delete an unnecessary check before the function call "input_free_device"
Quoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Thu, 5 Feb 2015 17:35:35 +0100The
input_free_device()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Applied, thank you.
Quoted 21 lines
--- drivers/input/joystick/adi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/input/joystick/adi.c +1
-2@@ -535,8 +535,7 @@ static int adi_connect(struct gameport *gameport, struct gameport_driver *drv) } } fail2:for (i =0 ; i <2 ; i++) -if (port->adi[i].dev) -input_free_device (port->adi[i].dev); +input_free_device (port->adi[i].dev);gameport_close (gameport); fail1:gameport_set_drvdata (gameport,NULL );kfree (port);Signature · 1 line
2.2.2
Signature · 1 line
Dmitry
PATCH 1/1 uwb/whci: Delete an unnecessary check before the function call "umc_device_unregister"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 5 Feb 2015 21:40:29 +0100
The umc_device_unregister() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/uwb/whci.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/uwb/whci.c +1 -2
@@ -133,8 +133,7 @@ static void whci_del_cap(struct whci_card *card, int n) {struct umc_dev *umc = card->devs[n]; -if (umc !=NULL ) -umc_device_unregister (umc); +umc_device_unregister (umc); }static int whci_n_caps (struct pci_dev *pci)
Signature · 1 line
2.2.2
PATCH 1/1 SCSI-bfa: Delete more unnecessary checks before the function call "vfree"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 5 Feb 2015 22:02:16 +0100
The vfree() function performs also input parameter validation. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/scsi/bfa/bfad.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/scsi/bfa/bfad.c +3 -3
@@ -1810,11 +1810,11 @@ bfad_load_fwimg(struct pci_dev *pdev)static void bfad_free_fwimg (void ) { -if (bfi_image_ct2_size && bfi_image_ct2) +if (bfi_image_ct2_size)vfree (bfi_image_ct2); -if (bfi_image_ct_size && bfi_image_ct) +if (bfi_image_ct_size)vfree (bfi_image_ct); -if (bfi_image_cb_size && bfi_image_cb) +if (bfi_image_cb_size)vfree (bfi_image_cb); }
Signature · 1 line
2.2.2
PATCH 1/1 SCSI-aic7...: Delete unnecessary checks before the function call "kfree"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 5 Feb 2015 22:23:48 +0100
The kfree() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/scsi/aic7xxx/aic7xxx_core.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
drivers/scsi/aic7xxx/aic7xxx_core.c +5 -10
@@ -2200,8 +2200,7 @@ ahc_free_tstate(struct ahc_softc *ahc, u_int scsi_id, char channel, int force)if (channel ='B' ) scsi_id +=8 ; tstate = ahc->enabled_targets[scsi_id]; -if (tstate !=NULL ) -kfree (tstate); +kfree (tstate); ahc->enabled_targets[scsi_id] = NULL; }#endif
@@ -4482,8 +4481,7 @@ ahc_set_unit(struct ahc_softc *ahc, int unit)void ahc_set_name (struct ahc_softc *ahc,char *name) { -if (ahc->name !=NULL ) -kfree (ahc->name); +kfree (ahc->name); ahc->name = name; }
@@ -4550,10 +4548,8 @@ ahc_free(struct ahc_softc *ahc) kfree(ahc->black_hole); }#endif -if (ahc->name !=NULL ) -kfree (ahc->name); -if (ahc->seep_config !=NULL ) -kfree (ahc->seep_config); +kfree (ahc->name); +kfree (ahc->seep_config);#ifndef __FreeBSD__kfree (ahc);#endif
@@ -4958,8 +4954,7 @@ ahc_fini_scbdata(struct ahc_softc *ahc)case 0 :break ; } -if (scb_data->scbarray !=NULL ) -kfree (scb_data->scbarray); +kfree (scb_data->scbarray); } static void
Signature · 1 line
2.2.2
Re: [PATCH] SCSI-aic7...: Delete unnecessary checks before the function call "kfree"
Am 05.02.2015 um 22:27 schrieb SF Markus Elfring:
Quoted 52 lines
From: Markus Elfring <[email protected]>
Date: Thu, 5 Feb 2015 22:23:48 +0100The
kfree()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/scsi/aic7xxx/aic7xxx_core.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)drivers/scsi/aic7xxx/aic7xxx_core.c +4
-8@@ -2200,8 +2200,7 @@ ahc_free_tstate(struct ahc_softc *ahc, u_int scsi_id, char channel, int force)if (channel ='B' ) scsi_id +=8 ; tstate = ahc->enabled_targets[scsi_id]; -if (tstate !=NULL ) -kfree (tstate); +kfree (tstate); ahc->enabled_targets[scsi_id] = NULL; }#endif @@ -4482,8 +4481,7 @@ ahc_set_unit(struct ahc_softc *ahc, int unit)void ahc_set_name (struct ahc_softc *ahc,char *name) { -if (ahc->name !=NULL ) -kfree (ahc->name); +kfree (ahc->name); ahc->name = name; }@@ -4550,10 +4548,8 @@ ahc_free(struct ahc_softc *ahc) kfree(ahc->black_hole); }#endif -if (ahc->name !=NULL ) -kfree (ahc->name); -if (ahc->seep_config !=NULL ) -kfree (ahc->seep_config); +kfree (ahc->name); +kfree (ahc->seep_config);#ifndef __FreeBSD__kfree (ahc);#endif
drivers/scsi/aic7xxx/aic7xxx_core.c ahc_fini_scbdata(struct ahc_softc *ahc) · line 4960
Quoted 9 lines
drivers/scsi/aic7xxx/aic7xxx_core.c +1
-2@@ -4958,8 +4954,7 @@ ahc_fini_scbdata(struct ahc_softc *ahc)case 0 :break ; } -if (scb_data->scbarray !=NULL ) -kfree (scb_data->scbarray); +kfree (scb_data->scbarray); } static void
Would you like to integrate this update suggestion into another source code repository?
Regards,
Markus
cover SCSI-lpfc: Deletion of an unnecessary check
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 5 Feb 2015 23:17:52 +0100
Another update suggestion was taken into account after a patch was applied from static source code analysis.
Markus Elfring (2):
Delete an unnecessary check before the function call "kfree" One function call less in lpfc_bsg_hba_set_event() after error detection
drivers/scsi/lpfc/lpfc_bsg.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
Signature · 1 line
2.2.2
PATCH 1/2 SCSI-lpfc: Delete an unnecessary check before the function call "kfree"
From: Markus Elfring <[email protected]>
Date: Thu, 5 Feb 2015 22:45:02 +0100
The kfree() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/scsi/lpfc/lpfc_bsg.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/scsi/lpfc/lpfc_bsg.c +1 -3
@@ -1261,9 +1261,7 @@ lpfc_bsg_hba_set_event(struct fc_bsg_job *job)return 0 ;/* call job done later */ job_error: -if (dd_data !=NULL ) -kfree (dd_data); - +kfree (dd_data); job->dd_data =NULL ;return rc; }
Signature · 1 line
2.2.2
PATCH 2/2 SCSI-lpfc: One function call less in lpfc_bsg_hba_set_event() after error detection
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 5 Feb 2015 23:03:52 +0100
The kfree() function was called in two cases by the lpfc_bsg_hba_set_event() function during error handling even if the passed variable "dd_data" contained still a null pointer.
This implementation detail could be improved by the introduction of another jump label.
--- drivers/scsi/lpfc/lpfc_bsg.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/scsi/lpfc/lpfc_bsg.c +3 -2
@@ -1240,7 +1240,7 @@ lpfc_bsg_hba_set_event(struct fc_bsg_job *job)"2617 Failed allocation of event " "waiter\n"); rc = -ENOMEM ; - goto job_error; + goto free_data; } dd_data->type =TYPE_EVT ; dd_data->set_job =NULL ;
@@ -1260,8 +1260,9 @@ lpfc_bsg_hba_set_event(struct fc_bsg_job *job)spin_unlock_irqrestore (&phba->ct_ev_lock, flags);return 0 ;/* call job done later */ -job_error: +free_data:kfree (dd_data); +job_error: job->dd_data =NULL ;return rc; }
Signature · 1 line
2.2.2
Re: [PATCH 0/2] SCSI-lpfc: Deletion of an unnecessary check
In reply to SF Markus ElfringMarkus,
Suggestions noted. If not merged, I'll pull them into the next patch set.
-- james
Quoted 13 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Thu, 5 Feb 2015 23:17:52 +0100Another update suggestion was taken into account after a patch was applied from static source code analysis.
Markus Elfring (2):
Delete an unnecessary check before the function call "kfree" One function call less inlpfc_bsg_hba_set_event()after error detectiondrivers/scsi/lpfc/lpfc_bsg.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
cover SCSI-debug: Deletion of a few unnecessary checks
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 6 Feb 2015 18:08:53 +0100
Further update suggestions were taken into account after a patch was applied from static source code analysis.
Markus Elfring (3):
Deletion of unnecessary checks before the function call "vfree" Less function calls in scsi_debug_init() after error detection Fix exception handling for an alignment/granularity mismatch
in scsi_debug_init()
drivers/scsi/scsi_debug.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-)
Signature · 1 line
2.2.2
PATCH 1/3 SCSI-debug: Deletion of unnecessary checks before the function call "vfree"
From: Markus Elfring <[email protected]>
Date: Fri, 6 Feb 2015 16:56:57 +0100
The vfree() function performs also input parameter validation. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/scsi/scsi_debug.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/scsi/scsi_debug.c +3 -9
@@ -4969,12 +4969,9 @@ bus_unreg: dev_unreg:root_device_unregister (pseudo_primary); free_vm: -if (map_storep) -vfree (map_storep); -if (dif_storep) -vfree (dif_storep); +vfree (map_storep); +vfree (dif_storep);vfree (fake_storep); -return ret; }
@@ -4989,10 +4986,7 @@ static void __exit scsi_debug_exit(void)driver_unregister (&sdebug_driverfs_driver);bus_unregister (&pseudo_lld_bus);root_device_unregister (pseudo_primary); - -if (dif_storep) -vfree (dif_storep); - +vfree (dif_storep);vfree (fake_storep); }
Signature · 1 line
2.2.2
Re: [PATCH 1/3] SCSI-debug: Deletion of unnecessary checks before the function call "vfree"
Quoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 6 Feb 2015 16:56:57 +0100The
vfree()function performs also input parameter validation. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Quoted 36 lines
--- drivers/scsi/scsi_debug.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)drivers/scsi/scsi_debug.c +3
-9@@ -4969,12 +4969,9 @@ bus_unreg: dev_unreg:root_device_unregister (pseudo_primary); free_vm: -if (map_storep) -vfree (map_storep); -if (dif_storep) -vfree (dif_storep); +vfree (map_storep); +vfree (dif_storep);vfree (fake_storep); -return ret; }@@ -4989,10 +4986,7 @@ static void __exit scsi_debug_exit(void)driver_unregister (&sdebug_driverfs_driver);bus_unregister (&pseudo_lld_bus);root_device_unregister (pseudo_primary); - -if (dif_storep) -vfree (dif_storep); - +vfree (dif_storep);vfree (fake_storep); }
PATCH 2/3 SCSI-debug: Less function calls in scsi_debug_init() after error detection
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 6 Feb 2015 17:48:34 +0100
The vfree() function was called in two cases by the scsi_debug_init() function during error handling even if the passed variables "dif_storep" and "map_storep" contained null pointers eventually.
This implementation detail could be improved by the introduction of two jump labels.
--- drivers/scsi/scsi_debug.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/scsi/scsi_debug.c +6 -4
@@ -4887,7 +4887,7 @@ static int __init scsi_debug_init(void)if (dif_storep =NULL ) {pr_err ("%s: out of mem. (DIX)\n" , __func__); ret = -ENOMEM ; - goto free_vm; + goto free_fake; }memset (dif_storep,0xff , dif_size);
@@ -4920,7 +4920,7 @@ static int __init scsi_debug_init(void)if (map_storep =NULL ) {pr_err ("%s: out of mem. (MAP)\n" , __func__); ret = -ENOMEM ; - goto free_vm; + goto free_dif; }bitmap_zero (map_storep, map_size);
@@ -4934,7 +4934,7 @@ static int __init scsi_debug_init(void)if (IS_ERR (pseudo_primary)) {pr_warn ("%s: root_device_register() error\n" , __func__); ret =PTR_ERR (pseudo_primary); - goto free_vm; + goto free_map; } ret =bus_register (&pseudo_lld_bus);if (ret <0 ) {
@@ -4968,9 +4968,11 @@ bus_unreg:bus_unregister (&pseudo_lld_bus); dev_unreg:root_device_unregister (pseudo_primary); -free_vm: +free_map:vfree (map_storep); +free_dif:vfree (dif_storep); +free_fake:vfree (fake_storep);return ret; }
Signature · 1 line
2.2.2
Re: [PATCH 2/3] SCSI-debug: Less function calls in scsi_debug_init() after error detection
Quoted 11 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 6 Feb 2015 17:48:34 +0100The
vfree()function was called in two cases by thescsi_debug_init()function during error handling even if the passed variables "dif_storep" and "map_storep" contained null pointers eventually.This implementation detail could be improved by the introduction of two jump labels.
Signed-off-by Markus Elfring <[email protected]>
Quoted 49 lines
--- drivers/scsi/scsi_debug.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)drivers/scsi/scsi_debug.c +6
-4@@ -4887,7 +4887,7 @@ static int __init scsi_debug_init(void)if (dif_storep =NULL ) {pr_err ("%s: out of mem. (DIX)\n" , __func__); ret = -ENOMEM ; - goto free_vm; + goto free_fake; }memset (dif_storep,0xff , dif_size);@@ -4920,7 +4920,7 @@ static int __init scsi_debug_init(void)if (map_storep =NULL ) {pr_err ("%s: out of mem. (MAP)\n" , __func__); ret = -ENOMEM ; - goto free_vm; + goto free_dif; }bitmap_zero (map_storep, map_size);@@ -4934,7 +4934,7 @@ static int __init scsi_debug_init(void)if (IS_ERR (pseudo_primary)) {pr_warn ("%s: root_device_register() error\n" , __func__); ret =PTR_ERR (pseudo_primary); - goto free_vm; + goto free_map; } ret =bus_register (&pseudo_lld_bus);if (ret <0 ) {@@ -4968,9 +4968,11 @@ bus_unreg:bus_unregister (&pseudo_lld_bus); dev_unreg:root_device_unregister (pseudo_primary); -free_vm: +free_map:vfree (map_storep); +free_dif:vfree (dif_storep); +free_fake:vfree (fake_storep);return ret; }
PATCH 3/3 SCSI-debug: Fix exception handling for an alignment/granularity mismatch in scsi_debug_init()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 6 Feb 2015 17:57:32 +0100
The scsi_debug_init() function returned directly if the data items "alignment" and "granularity" did not fit together.
Let us improve the affected exception handling by replacing the return statement by a goto statement so that previously allocated resources will also be appropriately released.
--- drivers/scsi/scsi_debug.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/scsi/scsi_debug.c +2 -1
@@ -4909,7 +4909,8 @@ static int __init scsi_debug_init(void) scsi_debug_unmap_alignment) {pr_err ("%s: ERR: unmap_granularity <= unmap_alignment\n" , __func__); -return -EINVAL ; + ret = -EINVAL ; + goto free_dif; } map_size =lba_to_map_index (sdebug_store_sectors -1 ) +1 ;
Signature · 1 line
2.2.2
Re: [PATCH 3/3] SCSI-debug: Fix exception handling for an alignment/granularity mismatch in scsi_debug_init()
Quoted 11 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 6 Feb 2015 17:57:32 +0100The
scsi_debug_init()function returned directly if the data items "alignment" and "granularity" did not fit together.Let us improve the affected exception handling by replacing the return statement by a goto statement so that previously allocated resources will also be appropriately released.
Signed-off-by Markus Elfring <[email protected]>
Quoted 19 lines
--- drivers/scsi/scsi_debug.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/scsi/scsi_debug.c +2
-1@@ -4909,7 +4909,8 @@ static int __init scsi_debug_init(void) scsi_debug_unmap_alignment) {pr_err ("%s: ERR: unmap_granularity <= unmap_alignment\n" , __func__); -return -EINVAL ; + ret = -EINVAL ; + goto free_dif; } map_size =lba_to_map_index (sdebug_store_sectors -1 ) +1 ;
PATCH 1/1 SCSI-csiostor: Delete an unnecessary check before the function call "release_firmware"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 6 Feb 2015 19:10:25 +0100
The release_firmware() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/scsi/csiostor/csio_hw.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/scsi/csiostor/csio_hw.c +1 -2
@@ -2117,8 +2117,7 @@ csio_hw_flash_fw(struct csio_hw *hw, int *reset) hw->fw_state, reset);/* Cleaning up */ -if (fw !=NULL ) -release_firmware (fw); +release_firmware (fw);kfree (card_fw);return ret; }
Signature · 1 line
2.2.2
cover SCSI-QLA4...: Deletion of some unnecessary checks
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 6 Feb 2015 23:03:41 +0100
Further update suggestions were taken into account after a patch was applied from static source code analysis.
Markus Elfring (4):
Deletion of unnecessary checks before three function calls Less function calls in qla4xxx_is_session_exists() after error detection Less function calls in qla4xxx_is_flash_ddb_exists() after error detection Less function calls in qla4xxx_sysfs_ddb_logout() after error detection
drivers/scsi/qla4xxx/ql4_mbx.c | 2 +- drivers/scsi/qla4xxx/ql4_os.c | 96 ++++++++++++++++++------------------------ 2 files changed, 42 insertions(+), 56 deletions(-)
Signature · 1 line
2.2.2
PATCH 1/4 SCSI-QLA4...: Deletion of unnecessary checks before three function calls
From: Markus Elfring <[email protected]>
Date: Fri, 6 Feb 2015 20:38:23 +0100
The following functions perform also input parameter validation.
* iscsi_boot_destroy_kset
* kfree
* vfree
Thus the test around their calls is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/scsi/qla4xxx/ql4_mbx.c | 2 +- drivers/scsi/qla4xxx/ql4_os.c | 31 ++++++++++--------------------- 2 files changed, 11 insertions(+), 22 deletions(-)
drivers/scsi/qla4xxx/ql4_mbx.c +1 -1
@@ -2410,7 +2410,7 @@ exit_free_acb:dma_free_coherent (&ha->pdev->dev,sizeof (struct addr_ctrl_blk ), acb, acb_dma); exit_config_acb: -if ((acb_config =ACB_CONFIG_SET ) && ha->saved_acb) { +if (acb_config =ACB_CONFIG_SET ) {kfree (ha->saved_acb); ha->saved_acb =NULL ; }
drivers/scsi/qla4xxx/ql4_os.c +10 -21
@@ -4131,9 +4131,7 @@ static void qla4xxx_mem_free(struct scsi_qla_host *ha)dma_free_coherent (&ha->pdev->dev, ha->queues_len, ha->queues, ha->queues_dma); -if (ha->fw_dump) -vfree (ha->fw_dump); - +vfree (ha->fw_dump); ha->queues_len =0 ; ha->queues =NULL ; ha->queues_dma =0 ;
@@ -4155,8 +4153,7 @@ static void qla4xxx_mem_free(struct scsi_qla_host *ha)if (ha->chap_dma_pool)dma_pool_destroy (ha->chap_dma_pool); -if (ha->chap_list) -vfree (ha->chap_list); +vfree (ha->chap_list); ha->chap_list =NULL ;if (ha->fw_ddb_dma_pool)
@@ -4175,9 +4172,7 @@ static void qla4xxx_mem_free(struct scsi_qla_host *ha)iounmap (ha->reg); } -if (ha->reset_tmplt.buff) -vfree (ha->reset_tmplt.buff); - +vfree (ha->reset_tmplt.buff);pci_release_regions (ha->pdev); }
@@ -6370,10 +6365,8 @@ static int qla4xxx_is_session_exists(struct scsi_qla_host *ha, } exit_check: -if (fw_tddb) -vfree (fw_tddb); -if (tmp_tddb) -vfree (tmp_tddb); +vfree (fw_tddb); +vfree (tmp_tddb);return ret; }
@@ -6525,10 +6518,8 @@ static int qla4xxx_is_flash_ddb_exists(struct scsi_qla_host *ha, } exit_check: -if (fw_tddb) -vfree (fw_tddb); -if (tmp_tddb) -vfree (tmp_tddb); +vfree (fw_tddb); +vfree (tmp_tddb);return ret; }
@@ -7806,10 +7797,8 @@ static int qla4xxx_sysfs_ddb_logout(struct iscsi_bus_flash_session *fnode_sess, ret = -ESRCH ; exit_ddb_logout: -if (flash_tddb) -vfree (flash_tddb); -if (tmp_tddb) -vfree (tmp_tddb); +vfree (flash_tddb); +vfree (tmp_tddb);if (fw_ddb_entry)dma_pool_free (ha->fw_ddb_dma_pool, fw_ddb_entry, fw_ddb_dma);
@@ -9002,7 +8991,7 @@ static void qla4xxx_remove_adapter(struct pci_dev *pdev)/* destroy iface from sysfs */ qla4xxx_destroy_ifaces (ha); -if ((!ql4xdisablesysfsboot) && ha->boot_kset) +if (!ql4xdisablesysfsboot)iscsi_boot_destroy_kset (ha->boot_kset);qla4xxx_destroy_fw_ddb_session (ha);
Signature · 1 line
2.2.2
PATCH 2/4 SCSI-QLA4...: Less function calls in qla4xxx_is_session_exists() after error detection
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 6 Feb 2015 21:14:40 +0100
The vfree() function was called in two cases by the qla4xxx_is_session_exists() function during error handling even if the passed variables "fw_tddb" and "tmp_tddb" contained still a null pointer.
* This implementation detail could be improved by adjustments for jump labels.
* Let us return immediately after the first failed function call according to the current Linux coding style convention.
--- drivers/scsi/qla4xxx/ql4_os.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
drivers/scsi/qla4xxx/ql4_os.c +8 -9
@@ -6327,17 +6327,15 @@ static int qla4xxx_is_session_exists(struct scsi_qla_host *ha, uint32_t *index) {struct ddb_entry *ddb_entry; -struct ql4_tuple_ddb *fw_tddb =NULL ; -struct ql4_tuple_ddb *tmp_tddb =NULL ;int idx;int ret =QLA_ERROR ; +struct ql4_tuple_ddb *tmp_tddb; +struct ql4_tuple_ddb *fw_tddb =vzalloc (sizeof (*fw_tddb)); - fw_tddb =vzalloc (sizeof (*fw_tddb));if (!fw_tddb) {DEBUG2 (ql4_printk (KERN_WARNING , ha,"Memory Allocation failed.\n" )); - ret =QLA_SUCCESS ; - goto exit_check; +return QLA_SUCCESS ; } tmp_tddb =vzalloc (sizeof (*tmp_tddb));
@@ -6345,7 +6343,7 @@ static int qla4xxx_is_session_exists(struct scsi_qla_host *ha,DEBUG2 (ql4_printk (KERN_WARNING , ha,"Memory Allocation failed.\n" )); ret =QLA_SUCCESS ; - goto exit_check; + goto free_fw; }qla4xxx_convert_param_ddb (fw_ddb_entry, fw_tddb,NULL );
@@ -6360,13 +6358,14 @@ static int qla4xxx_is_session_exists(struct scsi_qla_host *ha, ret =QLA_SUCCESS ;/* found */ if (index !=NULL ) *index = idx; - goto exit_check; + goto free_tmp; } } -exit_check: -vfree (fw_tddb); +free_tmp:vfree (tmp_tddb); +free_fw: +vfree (fw_tddb);return ret; }
Signature · 1 line
2.2.2
Re: [PATCH 2/4] SCSI-QLA4...: Less function calls in qla4xxx_is_session_exists() after error detection
Quoted 5 lines · SF Markus Elfring
drivers/scsi/qla4xxx/ql4_os.c +0
-0
drivers/scsi/qla4xxx/ql4_os.c static int qla4xxx_is_session_exists(struct scsi_qla_host *ha, · line 6334
Quoted 10 lines
drivers/scsi/qla4xxx/ql4_os.c +2
-2@@ -6327,17 +6327,15 @@ static int qla4xxx_is_session_exists(struct scsi_qla_host *ha, uint32_t *index) {struct ddb_entry *ddb_entry; -struct ql4_tuple_ddb *fw_tddb =NULL ; -struct ql4_tuple_ddb *tmp_tddb =NULL ;int idx;int ret =QLA_ERROR ; +struct ql4_tuple_ddb *tmp_tddb; +struct ql4_tuple_ddb *fw_tddb =vzalloc (sizeof (*fw_tddb));
Don't do allocations in the initializers. Same for patches 3 and 4 as well.
regards,
dan carpenter
Re: [PATCH 2/4] SCSI-QLA4...: Less function calls in qla4xxx_is_session_exists() after error detection
Quoted 11 lines · Dan Carpenter
Quoted 10 lines · SF Markus Elfring
drivers/scsi/qla4xxx/ql4_os.c +0
-2@@ -6327,17 +6327,15 @@ static int qla4xxx_is_session_exists(struct scsi_qla_host *ha, uint32_t *index) {struct ddb_entry *ddb_entry; -struct ql4_tuple_ddb *fw_tddb =NULL ; -struct ql4_tuple_ddb *tmp_tddb =NULL ;
Quoted 8 lines
drivers/scsi/qla4xxx/ql4_os.c static int qla4xxx_is_session_exists(struct scsi_qla_host *ha, · line 6334
Quoted 5 lines
drivers/scsi/qla4xxx/ql4_os.c +2
-0int idx;int ret =QLA_ERROR ; +struct ql4_tuple_ddb *tmp_tddb; +struct ql4_tuple_ddb *fw_tddb =vzalloc (sizeof (*fw_tddb));Don't do allocations in the initializers. Same for patches 3 and 4 as well.
Why not? I can think of some reasons, but I am wondering what is the precise one.
thanks,
julia
Re: [PATCH 2/4] SCSI-QLA4...: Less function calls in qla4xxx_is_session_exists() after error detection
Quoted 22 lines · Julia Lawall
Quoted 11 lines · Dan Carpenter
Quoted 10 lines · SF Markus Elfring
drivers/scsi/qla4xxx/ql4_os.c +0
-2@@ -6327,17 +6327,15 @@ static int qla4xxx_is_session_exists(struct scsi_qla_host *ha, uint32_t *index) {struct ddb_entry *ddb_entry; -struct ql4_tuple_ddb *fw_tddb =NULL ; -struct ql4_tuple_ddb *tmp_tddb =NULL ;Quoted 8 lines
drivers/scsi/qla4xxx/ql4_os.c static int qla4xxx_is_session_exists(struct scsi_qla_host *ha, · line 6334
Quoted 5 lines
drivers/scsi/qla4xxx/ql4_os.c +2
-0int idx;int ret =QLA_ERROR ; +struct ql4_tuple_ddb *tmp_tddb; +struct ql4_tuple_ddb *fw_tddb =vzalloc (sizeof (*fw_tddb));Don't do allocations in the initializers. Same for patches 3 and 4 as well.
Quoted 2 lines
Why not? I can think of some reasons, but I am wondering what is the precise one.
1) People gloss over initializers without reading them. You shouldn't put complicated code in initializers. Sarah Sharp is more strict on this than I am. http://www.spinics.net/lists/linux-usb/msg44389.html
2) It means you have to put a line of separation between the allocation and the NULL check, but they should be next to each other.
regards,
dan carpenter
Re: [PATCH 2/4] SCSI-QLA4...: Less function calls in qla4xxx_is_session_exists() after error detection
Quoted 1 line
1) People gloss over initializers without reading them.
I would find such a habit strange.
Quoted 1 line
You shouldn't put complicated code in initializers.
Does the affected memory allocation fall into such a category?
Quoted 2 lines
2) It means you have to put a line of separation between the allocation and the NULL check, but they should be next to each other.
Would you like to extend the Linux coding style documentation?
Regards,
Markus
PATCH 3/4 SCSI-QLA4...: Less function calls in qla4xxx_is_flash_ddb_exists() after error detection
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 6 Feb 2015 21:55:55 +0100
The vfree() function was called in two cases by the qla4xxx_is_flash_ddb_exists() function during error handling even if the passed variables "fw_tddb" and "tmp_tddb" contained still a null pointer.
* This implementation detail could be improved by adjustments for jump labels.
* Let us return immediately after the first failed function call according to the current Linux coding style convention.
--- drivers/scsi/qla4xxx/ql4_os.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
drivers/scsi/qla4xxx/ql4_os.c +9 -10
@@ -6470,16 +6470,14 @@ static int qla4xxx_is_flash_ddb_exists(struct scsi_qla_host *ha, struct dev_db_entry *fw_ddb_entry) {struct qla_ddb_index *nt_ddb_idx, *nt_ddb_idx_tmp; -struct ql4_tuple_ddb *fw_tddb =NULL ; -struct ql4_tuple_ddb *tmp_tddb =NULL ;int rval, ret =QLA_ERROR ; +struct ql4_tuple_ddb *tmp_tddb; +struct ql4_tuple_ddb *fw_tddb =vzalloc (sizeof (*fw_tddb)); - fw_tddb =vzalloc (sizeof (*fw_tddb));if (!fw_tddb) {DEBUG2 (ql4_printk (KERN_WARNING , ha,"Memory Allocation failed.\n" )); - ret =QLA_SUCCESS ; - goto exit_check; +return QLA_SUCCESS ; } tmp_tddb =vzalloc (sizeof (*tmp_tddb));
@@ -6487,7 +6485,7 @@ static int qla4xxx_is_flash_ddb_exists(struct scsi_qla_host *ha,DEBUG2 (ql4_printk (KERN_WARNING , ha,"Memory Allocation failed.\n" )); ret =QLA_SUCCESS ; - goto exit_check; + goto vfree_fw; }qla4xxx_convert_param_ddb (fw_ddb_entry, fw_tddb,NULL );
@@ -6498,7 +6496,7 @@ static int qla4xxx_is_flash_ddb_exists(struct scsi_qla_host *ha, ret =qla4xxx_compare_tuple_ddb (ha, fw_tddb, tmp_tddb, true);/* found duplicate ddb */ if (ret =QLA_SUCCESS ) - goto exit_check; + goto vfree_tmp; }list_for_each_entry_safe (nt_ddb_idx, nt_ddb_idx_tmp, list_nt, list) {
@@ -6512,13 +6510,14 @@ static int qla4xxx_is_flash_ddb_exists(struct scsi_qla_host *ha,else ret =QLA_SUCCESS ; - goto exit_check; + goto vfree_tmp; } } -exit_check: -vfree (fw_tddb); +vfree_tmp:vfree (tmp_tddb); +vfree_fw: +vfree (fw_tddb);return ret; }
Signature · 1 line
2.2.2
PATCH 4/4 SCSI-QLA4...: Less function calls in qla4xxx_sysfs_ddb_logout() after error detection
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 6 Feb 2015 22:44:23 +0100
The vfree() function was called in three cases by the qla4xxx_sysfs_ddb_logout() function during error handling even if the passed variables "flash_tddb" and "tmp_tddb" contained still a null pointer.
* This implementation detail could be improved by adjustments for jump labels.
* Let us return immediately after the first failed function call according to the current Linux coding style convention.
* Delete also an unnecessary check for the variable "fw_ddb_entry" there.
--- drivers/scsi/qla4xxx/ql4_os.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-)
drivers/scsi/qla4xxx/ql4_os.c +17 -18
@@ -7699,23 +7699,22 @@ static int qla4xxx_sysfs_ddb_logout(struct iscsi_bus_flash_session *fnode_sess, {struct Scsi_Host *shost =iscsi_flash_session_to_shost (fnode_sess);struct scsi_qla_host *ha =to_qla_host (shost); -struct ql4_tuple_ddb *flash_tddb =NULL ; -struct ql4_tuple_ddb *tmp_tddb =NULL ; -struct dev_db_entry *fw_ddb_entry =NULL ; -struct ddb_entry *ddb_entry =NULL ;dma_addr_t fw_ddb_dma;uint32_t next_idx =0 ;uint32_t state =0 , conn_err =0 ;uint16_t conn_id =0 ;int idx, index;int status, ret =0 ; +struct ql4_tuple_ddb *flash_tddb; +struct ql4_tuple_ddb *tmp_tddb; +struct ddb_entry *ddb_entry; +struct dev_db_entry *fw_ddb_entry =dma_pool_alloc (ha->fw_ddb_dma_pool, +GFP_KERNEL , + &fw_ddb_dma); - fw_ddb_entry =dma_pool_alloc (ha->fw_ddb_dma_pool,GFP_KERNEL , - &fw_ddb_dma); -if (fw_ddb_entry =NULL ) { +if (!fw_ddb_entry) {ql4_printk (KERN_ERR , ha,"%s:Out of memory\n" , __func__); - ret = -ENOMEM ; - goto exit_ddb_logout; +return -ENOMEM ; } flash_tddb =vzalloc (sizeof (*flash_tddb));
@@ -7723,7 +7722,7 @@ static int qla4xxx_sysfs_ddb_logout(struct iscsi_bus_flash_session *fnode_sess,ql4_printk (KERN_WARNING , ha,"%s:Memory Allocation failed.\n" , __func__); ret = -ENOMEM ; - goto exit_ddb_logout; + goto free_pool; } tmp_tddb =vzalloc (sizeof (*tmp_tddb));
@@ -7731,7 +7730,7 @@ static int qla4xxx_sysfs_ddb_logout(struct iscsi_bus_flash_session *fnode_sess,ql4_printk (KERN_WARNING , ha,"%s:Memory Allocation failed.\n" , __func__); ret = -ENOMEM ; - goto exit_ddb_logout; + goto free_flash; }if (!fnode_sess->targetname) {
@@ -7739,7 +7738,7 @@ static int qla4xxx_sysfs_ddb_logout(struct iscsi_bus_flash_session *fnode_sess,"%s:Cannot logout from SendTarget entry\n" , __func__); ret = -EPERM ; - goto exit_ddb_logout; + goto free_tmp; }if (fnode_sess->is_boot_target) {
@@ -7747,7 +7746,7 @@ static int qla4xxx_sysfs_ddb_logout(struct iscsi_bus_flash_session *fnode_sess,"%s: Logout from boot target entry is not permitted.\n" , __func__); ret = -EPERM ; - goto exit_ddb_logout; + goto free_tmp; } strlcpy(flash_tddb->iscsi_name, fnode_sess->targetname,
@@ -7794,12 +7793,12 @@ static int qla4xxx_sysfs_ddb_logout(struct iscsi_bus_flash_session *fnode_sess,if (idx =MAX_DDB_ENTRIES ) ret = -ESRCH ; -exit_ddb_logout: -vfree (flash_tddb); +free_tmp:vfree (tmp_tddb); -if (fw_ddb_entry) -dma_pool_free (ha->fw_ddb_dma_pool, fw_ddb_entry, fw_ddb_dma); - +free_flash: +vfree (flash_tddb); +free_pool: +dma_pool_free (ha->fw_ddb_dma_pool, fw_ddb_entry, fw_ddb_dma);return ret; }
Signature · 1 line
2.2.2
PATCH 1/1 video: fbdev-SIS: Deletion of unnecessary checks before three function calls
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 21 Feb 2015 14:14:56 +0100
The functions sisfb_search_crt2type(), sisfb_search_specialtiming() and sisfb_search_tvstd() test whether their argument is NULL and then return immediately. Thus the test around their calls is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/video/fbdev/sis/sis_main.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)
drivers/video/fbdev/sis/sis_main.c +3 -8
@@ -6605,12 +6605,9 @@ static int __init sisfb_init_module(void) sisfb_scalelcd = scalelcd ^1 ;/* Need to check crt2 type first for fstn/dstn */ +sisfb_search_crt2type (forcecrt2type); -if (forcecrt2type) -sisfb_search_crt2type (forcecrt2type); - -if (tvstandard) -sisfb_search_tvstd (tvstandard); +sisfb_search_tvstd (tvstandard);if (mode)sisfb_search_mode (mode, false);
@@ -6656,9 +6653,7 @@ static int __init sisfb_init_module(void) sisfb_pdca = (pdc1 &0x1f ); sisfb_nocrt2rate = nocrt2rate; - -if (specialtiming) -sisfb_search_specialtiming (specialtiming); +sisfb_search_specialtiming (specialtiming);if ((lvdshl >=0 ) && (lvdshl <=3 )) sisfb_lvdshl = lvdshl;
Signature · 1 line
2.3.0
PATCH 1/1 crypto-jitterentropy: Delete unnecessary checks before the function call "kzfree"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 23 Jun 2015 22:30:21 +0200
The kzfree() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- crypto/jitterentropy.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
crypto/jitterentropy.c +2 -4
@@ -698,11 +698,9 @@ static struct rand_data *jent_entropy_collector_alloc(unsigned int osr,static void jent_entropy_collector_free (struct rand_data *entropy_collector) { -if (entropy_collector->mem) -kzfree (entropy_collector->mem); +kzfree (entropy_collector->mem); entropy_collector->mem =NULL ; -if (entropy_collector) -kzfree (entropy_collector); +kzfree (entropy_collector); entropy_collector =NULL ; }
Signature · 1 line
2.4.4
Stephan Mueller
NAKRe: [PATCH] crypto-jitterentropy: Delete unnecessary checks before the function call "kzfree"
Am Dienstag, 23. Juni 2015, 23:20:21 schrieb SF Markus Elfring:
Hi Markus,
Quoted 7 lines
From: Markus Elfring <[email protected]>
Date: Tue, 23 Jun 2015 22:30:21 +0200The
kzfree()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Ack: the patch is correct and I was overzealous.
Nack: I just proposed a patch earlier today to avoid compiler warnings [1]. That patch clashes with yours. May I ask you to wait briefly to see whether that patch will be accepted? If yes, it would be great if you could repost the patch that applies to the changed code.
PS: when you are at it, maybe even the last line in the function can be
removed: setting the entropy_collector to NULL at that the end of the function is moot as well.
Thanks.
[1] http://lkml.iu.edu/hypermail/linux/kernel/1506.2/05196.html
Quoted 24 lines
Signed-off-by Markus Elfring <[email protected]>--- crypto/jitterentropy.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)crypto/jitterentropy.c +2
-4@@ -698,11 +698,9 @@ static struct rand_data *jent_entropy_collector_alloc(unsigned int osr, static void jent_entropy_collector_free(struct rand_data *entropy_collector) { -if (entropy_collector->mem) -kzfree (entropy_collector->mem); +kzfree (entropy_collector->mem); entropy_collector->mem =NULL ; -if (entropy_collector) -kzfree (entropy_collector); +kzfree (entropy_collector); entropy_collector =NULL ; }
Signature · 2 lines
Ciao Stephan
Re: [PATCH] crypto-jitterentropy: Delete unnecessary checks before the function call "kzfree"
The other NULL assignment isn't useful either. Also If "entropy_collector" is NULL then we would oops calling
kzfree(entropy_collector->mem);
^^^^^^^^^^^^^^^^^^^^^^Dereference.
I don't understand the patch that you sent. We shouldn't be introducing jent_zalloc() or jent_zfree(). Why are you adding abstractions there? Quite bad ones as well.
regards,
dan carpenter
Re: [PATCH] crypto-jitterentropy: Delete unnecessary checks before the function call "kzfree"
Am Mittwoch, 24. Juni 2015, 10:48:19 schrieb Dan Carpenter:
Hi Dan,
Quoted 8 lines
The other NULL assignment isn't useful either. Also If "
entropy_collector" is NULL then we would oops callingkzfree(entropy_collector->mem); ^^^^^^^^^^^^^^^^^^^^^^Dereference.
I don't understand the patch that you sent. We shouldn't be introducing
jent_zalloc()orjent_zfree(). Why are you adding abstractions there?
The one C file should have no dependencies on any kernel header files. Thus, all links to kernel functions are wrapped.
Quoted 1 line
Quite bad ones as well.
What would you suggest to change?
Thanks.
Ciao
Stephan
Re: [PATCH] crypto-jitterentropy: Delete unnecessary checks before the function call "kzfree"
Ah. I should have read the whole thread. I sort of assumed we were just adding abstractions for the fun of it (because I have worked in staging for too long).
regards,
dan carpenter
Re: [PATCH] crypto-jitterentropy: Delete unnecessary checks before the function call "kzfree"
In reply to SF Markus ElfringQuoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Tue, 23 Jun 2015 22:30:21 +0200The
kzfree()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Applied.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
ACPI-APEI: Make exception handling a bit more efficient in __einj_error_trigger()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 24 Jun 2015 11:41:46 +0200
Return from the __einj_error_trigger() function directly after a failed call for the request_mem_region() function according to the current Linux coding style convention.
Drop an unnecessary initialisation for the variable "trigger_tab" then.
--- drivers/acpi/apei/einj.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/acpi/apei/einj.c +3 -3
@@ -299,7 +299,7 @@ static struct acpi_generic_address *einj_get_trigger_parameter_region(static int __einj_error_trigger (u64 trigger_paddr,u32 type,u64 param1,u64 param2) { -struct acpi_einj_trigger *trigger_tab =NULL ; +struct acpi_einj_trigger *trigger_tab;struct apei_exec_context trigger_ctx;struct apei_resources trigger_resources;struct acpi_whea_header *trigger_entry;
@@ -316,7 +316,7 @@ static int __einj_error_trigger(u64 trigger_paddr, u32 type, (unsigned long long )trigger_paddr, (unsigned long long )trigger_paddr + sizeof(*trigger_tab) - 1); - goto out; +return rc; } trigger_tab =ioremap_cache (trigger_paddr,sizeof (*trigger_tab));if (!trigger_tab) {
@@ -407,7 +407,7 @@ out_rel_entry: table_size - sizeof(*trigger_tab)); out_rel_header:release_mem_region (trigger_paddr,sizeof (*trigger_tab)); -out: +if (trigger_tab)iounmap (trigger_tab);
Signature · 1 line
2.4.4
PATCH 1/1 ACPICA: Delete an unnecessary check before the function call "acpi_ds_delete_walk_state"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 24 Jun 2015 13:33:47 +0200
The acpi_ds_delete_walk_state() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/acpi/acpica/dsmethod.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/acpi/acpica/dsmethod.c +1 -4
@@ -574,10 +574,7 @@ cleanup:/* On error, we must terminate the method properly */ acpi_ds_terminate_control_method (obj_desc, next_walk_state); -if (next_walk_state) { -acpi_ds_delete_walk_state (next_walk_state); - } - +acpi_ds_delete_walk_state (next_walk_state);return_ACPI_STATUS (status); }
Signature · 1 line
2.4.4
RE: [PATCH] ACPICA: Delete an unnecessary check before the function call "acpi_ds_delete_walk_state"
Got it, thanks.
Quoted 41 lines
-----Original Message-----
From: SF Markus Elfring [mailto:elfring(a)users.sourceforge.net]
Sent: Wednesday, June 24, 2015 4:46 AM
To: Len Brown; Zheng, Lv; Wysocki, Rafael J; Moore, Robert; linux- acpi(a)vger.kernel.org; devel(a)acpica.org
Cc: LKML; kernel-janitors(a)vger.kernel.org; Julia Lawall
Subject: [PATCH] ACPICA: Delete an unnecessary check before the function call "acpi_ds_delete_walk_state"From: Markus Elfring <elfring(a)users.sourceforge.net>
Date: Wed, 24 Jun 2015 13:33:47 +0200The
acpi_ds_delete_walk_state()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <elfring(a)users.sourceforge.net>--- drivers/acpi/acpica/dsmethod.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)(quoted diff) +0
-0
b/drivers/acpi/acpica/dsmethod.cindex 85bb951..188b254 100644drivers/acpi/acpica/dsmethod.c +1
-5@@ -574,10 +574,7 @@ cleanup:/* On error, we must terminate the method properly */ acpi_ds_terminate_control_method (obj_desc, next_walk_state); -if (next_walk_state) { -acpi_ds_delete_walk_state (next_walk_state); - } - +acpi_ds_delete_walk_state (next_walk_state);return_ACPI_STATUS (status); } --2.4.4
PATCH 1/1 kdbus: Delete an unnecessary check before the function call "kdbus_domain_unref"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 24 Jun 2015 14:30:17 +0200
The kdbus_domain_unref() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- ipc/kdbus/fs.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
ipc/kdbus/fs.c +1 -3
@@ -325,9 +325,7 @@ static void fs_super_kill(struct super_block *sb) }kill_anon_super (sb); - -if (domain) -kdbus_domain_unref (domain); +kdbus_domain_unref (domain); }static int fs_super_set (struct super_block *sb,void *data)
Signature · 1 line
2.4.4
Re: [PATCH] kdbus: Delete an unnecessary check before the function call "kdbus_domain_unref"
Hi
Quoted 18 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 24 Jun 2015 14:30:17 +0200The
kdbus_domain_unref()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- ipc/kdbus/fs.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)ipc/kdbus/fs.c +0
-0
ipc/kdbus/fs.c static void fs_super_kill(struct super_block *sb) · line 328
Quoted 7 lines
ipc/kdbus/fs.c +1
-3@@ -325,9 +325,7 @@ static void fs_super_kill(struct super_block *sb) }kill_anon_super (sb); - -if (domain) -kdbus_domain_unref (domain); +kdbus_domain_unref (domain);
Yeah, your patch is correct. The condition was kinda nice as it shows the connection to the tear-down before the call to kill_anon_super(). But the function is simple enough for a reader to figure out themselves.
Thanks
David
Quoted 6 lines
ipc/kdbus/fs.c +0
-1}static int fs_super_set (struct super_block *sb,void *data) --2.4.4
Re: [PATCH] kdbus: Delete an unnecessary check before the function call "kdbus_domain_unref"
In reply to SF Markus ElfringQuoted 31 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 24 Jun 2015 14:30:17 +0200The
kdbus_domain_unref()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- ipc/kdbus/fs.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)ipc/kdbus/fs.c +1
-3@@ -325,9 +325,7 @@ static void fs_super_kill(struct super_block *sb) }kill_anon_super (sb); - -if (domain) -kdbus_domain_unref (domain); +kdbus_domain_unref (domain); }static int fs_super_set (struct super_block *sb,void *data)Signature · 1 line
2.4.4
Signature · 2 lines
Djalal Harouni http://opendz.org
David Herrmann
AppliedRe: [PATCH] kdbus: Delete an unnecessary check before the function call "kdbus_domain_unref"
In reply to SF Markus ElfringHi
Quoted 6 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 24 Jun 2015 14:30:17 +0200The
kdbus_domain_unref()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
Quoted 6 lines
This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- ipc/kdbus/fs.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
Applied!
Thanks
David
Quoted 18 lines
ipc/kdbus/fs.c +1
-4@@ -325,9 +325,7 @@ static void fs_super_kill(struct super_block *sb) }kill_anon_super (sb); - -if (domain) -kdbus_domain_unref (domain); +kdbus_domain_unref (domain); }static int fs_super_set (struct super_block *sb,void *data) --2.4.4
PATCH 1/1 SCSI-wd33c93: Deletion of a check before the function call "wd33c93_setup"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 24 Jun 2015 17:15:17 +0200
The wd33c93_setup() function performs also input parameter validation. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/scsi/wd33c93.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/wd33c93.c +1 -1
@@ -1939,7 +1939,7 @@ wd33c93_init(struct Scsi_Host *instance, const wd33c93_regs regs,int val;char buf[32 ]; -if (!done_setup && setup_strings) +if (!done_setup)wd33c93_setup (setup_strings); hostdata = (struct WD33C93_hostdata *) instance->hostdata;
Signature · 1 line
2.4.4
Re: [PATCH] SCSI-wd33c93: Deletion of a check before the function call "wd33c93_setup"
Quoted 6 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 24 Jun 2015 17:15:17 +0200The
wd33c93_setup()function performs also input parameter validation. Thus the test around the call is not needed.
Guys, you should be aware that Markus auto generates his patches and he doesn't even do a cursory review.
"I find it acceptable that some of my update suggestions do not fit to your quality expectations at the moment." -- Markus Elfring
(https://lkml.org/lkml/2015/1/22/446)
regards,
dan carpenter
PATCH 1/1 s390/process: Delete an unnecessary check before the function call "kfree"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 24 Jun 2015 22:40:30 +0200
The kfree() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- arch/s390/kernel/process.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/s390/kernel/process.c +1 -2
@@ -81,8 +81,7 @@ void release_thread(struct task_struct *dead_task)void arch_release_task_struct (struct task_struct *tsk) { -if (tsk->thread.vxrs) -kfree (tsk->thread.vxrs); +kfree (tsk->thread.vxrs); } int copy_thread(unsigned long clone_flags, unsigned long new_stackp,
Signature · 1 line
2.4.4
Re: [PATCH] s390/process: Delete an unnecessary check before the function call "kfree"
Am 24.06.2015 22:48, schrieb SF Markus Elfring:
Quoted 18 lines
From: Markus Elfring <[email protected]>
Date: Wed, 24 Jun 2015 22:40:30 +0200The
kfree()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- arch/s390/kernel/process.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)arch/s390/kernel/process.c +0
-0
arch/s390/kernel/process.c void release_thread(struct task_struct *dead_task) · line 87
Quoted 9 lines
arch/s390/kernel/process.c +1
-2@@ -81,8 +81,7 @@ void release_thread(struct task_struct *dead_task)void arch_release_task_struct (struct task_struct *tsk) { -if (tsk->thread.vxrs) -kfree (tsk->thread.vxrs); +kfree (tsk->thread.vxrs); } int copy_thread(unsigned long clone_flags, unsigned long new_stackp,
maybe the intention was to check tsk != NULL ?
re,
wh
Re: [PATCH] s390/process: Delete an unnecessary check before the function call "kfree"
Quoted 21 lines · walter harms
Am 24.06.2015 22:48, schrieb SF Markus Elfring:
Quoted 19 lines
From: Markus Elfring <[email protected]>
Date: Wed, 24 Jun 2015 22:40:30 +0200The
kfree()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- arch/s390/kernel/process.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)arch/s390/kernel/process.c +0
-0@@ -81,8 +81,7 @@ void release_thread(struct task_struct *dead_task)
Quoted 6 lines
arch/s390/kernel/process.c void release_thread(struct task_struct *dead_task) · line 85
Quoted 6 lines
arch/s390/kernel/process.c +1
-2void arch_release_task_struct (struct task_struct *tsk) { -if (tsk->thread.vxrs) -kfree (tsk->thread.vxrs); +kfree (tsk->thread.vxrs); }
This code will be changed soon anyway. So it would be rather pointless to apply your patch now. Thanks anyway!
Quoted 2 lines
arch/s390/kernel/process.c void release_thread(struct task_struct *dead_task) · line 87
Quoted 1 line
arch/s390/kernel/process.c +0
-0int copy_thread(unsigned long clone_flags, unsigned long new_stackp,maybe the intention was to check tsk != NULL ?
No.
cover ARM-OMAP2+: Deletion of unnecessary checks before two function calls
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 25 Jun 2015 13:24:35 +0200
Some functions which release a system resource tolerate the passing of a null pointer. I do not see a need because of this fact that a function caller repeats a corresponding check.
Markus Elfring (2):
Delete a check before the function call "omap_device_delete" Delete a check before the function call "of_node_put"
arch/arm/mach-omap2/omap_device.c | 3 +-- arch/arm/mach-omap2/timer.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-)
Signature · 1 line
2.4.4
PATCH 1/2 ARM-OMAP2+: Delete an unnecessary check before the function call "omap_device_delete"
From: Markus Elfring <[email protected]>
Date: Thu, 25 Jun 2015 13:00:11 +0200
The omap_device_delete() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- arch/arm/mach-omap2/omap_device.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm/mach-omap2/omap_device.c +1 -2
@@ -193,8 +193,7 @@ static int _omap_device_notifier_call(struct notifier_block *nb,switch (event) {case BUS_NOTIFY_DEL_DEVICE : -if (pdev->archdata.od) -omap_device_delete (pdev->archdata.od); +omap_device_delete (pdev->archdata.od);break ;case BUS_NOTIFY_ADD_DEVICE :if (pdev->dev.of_node)
Signature · 1 line
2.4.4
PATCH 2/2 ARM-OMAP2+: Delete an unnecessary check before the function call "of_node_put"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 25 Jun 2015 13:05:28 +0200
The of_node_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- arch/arm/mach-omap2/timer.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm/mach-omap2/timer.c +1 -2
@@ -208,8 +208,7 @@ static void __init omap_dmtimer_init(void)/* If we are a secure device, remove any secure timer nodes */ if ((omap_type () !=OMAP2_DEVICE_TYPE_GP )) { np =omap_get_timer_dt (omap_timer_match,"ti,timer-secure" ); -if (np) -of_node_put (np); +of_node_put (np); } }
Signature · 1 line
2.4.4
Tony Lindgren
maintainerRe: [PATCH 0/2] ARM-OMAP2+: Deletion of unnecessary checks before two function calls
In reply to SF Markus ElfringQuoted 7 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Thu, 25 Jun 2015 13:24:35 +0200Some functions which release a system resource tolerate the passing of a null pointer. I do not see a need because of this fact that a function caller repeats a corresponding check.
Quoted 7 lines
Markus Elfring (2):
Delete a check before the function call "omap_device_delete" Delete a check before the function call "of_node_put"arch/arm/mach-omap2/omap_device.c | 3 +-- arch/arm/mach-omap2/timer.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-)
Applying both into omap-for-v4.3/soc thanks.
Tony
cover ARM-kernel: Deletion of unnecessary checks before two function calls
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Some functions tolerate the passing of a null pointer. I do not see a need because of this fact that a function caller repeats a corresponding check.
Markus Elfring (2):
Delete a check before the function call "smp_set_ops" Delete a check before the function call "unwind_table_del"
arch/arm/kernel/module.c | 3 +-- arch/arm/kernel/setup.c | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-)
Signature · 1 line
2.4.4
PATCH 1/2 ARM-kernel: Delete an unnecessary check before the function call "smp_set_ops"
From: Markus Elfring <[email protected]>
Date: Thu, 25 Jun 2015 15:00:17 +0200
The smp_set_ops() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- arch/arm/kernel/setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/kernel/setup.c +1 -1
@@ -977,7 +977,7 @@ void __init setup_arch(char **cmdline_p)if (!mdesc->smp_init || !mdesc->smp_init ()) {if (psci_smp_available ())smp_set_ops (&psci_smp_ops); -else if (mdesc->smp) +else smp_set_ops (mdesc->smp); }smp_init_cpus ();
Signature · 1 line
2.4.4
PATCH 2/2 ARM-kernel: Delete an unnecessary check before the function call "unwind_table_del"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 25 Jun 2015 15:05:21 +0200
The unwind_table_del() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- arch/arm/kernel/module.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm/kernel/module.c +1 -2
@@ -390,7 +390,6 @@ module_arch_cleanup(struct module *mod)int i;for (i =0 ; i <ARM_SEC_MAX ; i++) -if (mod->arch.unwind[i]) -unwind_table_del (mod->arch.unwind[i]); +unwind_table_del (mod->arch.unwind[i]);#endif }
Signature · 1 line
2.4.4
cover perf header: Deletion of an unnecessary check
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Further update suggestions were taken into account after a patch was applied from static source code analysis.
Markus Elfring (2):
Delete an unnecessary check before the function call "free_event_desc" Less function calls in read_event_desc() after error detection
tools/perf/util/header.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-)
Signature · 1 line
2.4.4
PATCH 1/2 perf header: Delete an unnecessary check before the function call "free_event_desc"
From: Markus Elfring <[email protected]>
Date: Thu, 25 Jun 2015 17:12:32 +0200
The free_event_desc() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- tools/perf/util/header.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
tools/perf/util/header.c +1 -2
@@ -1063,8 +1063,7 @@ out:free (buf);return events; error: -if (events) -free_event_desc (events); +free_event_desc (events); events =NULL ; goto out; }
Signature · 1 line
2.4.4
Arnaldo Carvalho de Melo
maintainerRe: [PATCH 1/2] perf header: Delete an unnecessary check before the function call "free_event_desc"
Em Thu, Jun 25, 2015 at 06:22:18PM +0200, SF Markus Elfring escreveu:
Quoted 7 lines
From: Markus Elfring <[email protected]>
Date: Thu, 25 Jun 2015 17:12:32 +0200The
free_event_desc()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Thanks, applying.
- Arnaldo
Quoted 21 lines
Signed-off-by Markus Elfring <[email protected]>--- tools/perf/util/header.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)tools/perf/util/header.c +1
-2@@ -1063,8 +1063,7 @@ out:free (buf);return events; error: -if (events) -free_event_desc (events); +free_event_desc (events); events =NULL ; goto out; }Signature · 1 line
2.4.4
tip-bot for Markus Elfring
merge bot[tip:perf/urgent] perf header: Delete an unnecessary check before the calling free_event_desc()
In reply to SF Markus Elfringperf header: Delete an unnecessary check before the calling free_event_desc()
Commit-ID: 4cc97614812e96c135e369f3d723fcda07d33437 Gitweb: http://git.kernel.org/tip/4cc97614812e96c135e369f3d723fcda07d33437 Author: Markus Elfring <[email protected]> AuthorDate: Thu, 25 Jun 2015 17:12:32 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Thu, 25 Jun 2015 15:15:49 -0300
perf header: Delete an unnecessary check before the calling free_event_desc()
The free_event_desc() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- tools/perf/util/header.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
tools/perf/util/header.c +1 -2
@@ -1063,8 +1063,7 @@ out:free (buf);return events; error: -if (events) -free_event_desc (events); +free_event_desc (events); events =NULL ; goto out; }
PATCH 2/2 perf header: Less function calls in read_event_desc() after error detection
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 25 Jun 2015 17:50:37 +0200
The functions "free" and "free_event_desc" were called in a few cases by the function "read_event_desc" during error handling even if the passed variable contained a null pointer.
This implementation detail could be improved by the adjustment of jump targets. Drop unnecessary initialisations for the variables "buf" and "events" then.
--- tools/perf/util/header.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-)
tools/perf/util/header.c +15 -14
@@ -978,9 +978,9 @@ static void free_event_desc(struct perf_evsel *events)static struct perf_evsel *read_event_desc (struct perf_header *ph,int fd) { -struct perf_evsel *evsel, *events =NULL ; +struct perf_evsel *evsel, *events;u64 *id; -void *buf =NULL ; +void *buf;u32 nre, sz, nr, i, j;ssize_t ret;size_t msz;
@@ -988,14 +988,14 @@ read_event_desc(struct perf_header *ph, int fd)/* number of events */ ret =readn (fd, &nre,sizeof (nre));if (ret != (ssize_t )sizeof (nre)) - goto error; +return NULL ;if (ph->needs_swap) nre =bswap_32 (nre); ret =readn (fd, &sz,sizeof (sz));if (ret != (ssize_t )sizeof (sz)) - goto error; +return NULL ;if (ph->needs_swap) sz =bswap_32 (sz);
@@ -1003,12 +1003,12 @@ read_event_desc(struct perf_header *ph, int fd)/* buffer to hold on file attr struct */ buf =malloc (sz);if (!buf) - goto error; +return NULL ;/* the last event terminates with evsel->attr.size = 0: */ events =calloc (nre +1 ,sizeof (*events));if (!events) - goto error; + goto free_buffer; msz =sizeof (evsel->attr);if (sz < msz)
@@ -1023,7 +1023,7 @@ read_event_desc(struct perf_header *ph, int fd)*/ ret =readn (fd, buf, sz);if (ret != (ssize_t )sz) - goto error; + goto free_events;if (ph->needs_swap)perf_event__attr_swap (buf);
@@ -1032,7 +1032,7 @@ read_event_desc(struct perf_header *ph, int fd) ret =readn (fd, &nr,sizeof (nr));if (ret != (ssize_t )sizeof (nr)) - goto error; + goto free_events;if (ph->needs_swap) { nr =bswap_32 (nr);
@@ -1046,26 +1046,27 @@ read_event_desc(struct perf_header *ph, int fd) id =calloc (nr,sizeof (*id));if (!id) - goto error; + goto free_events; evsel->ids = nr; evsel->id = id;for (j =0 ; j < nr; j++) { ret =readn (fd, id,sizeof (*id));if (ret != (ssize_t )sizeof (*id)) - goto error; + goto free_events;if (ph->needs_swap) *id =bswap_64 (*id); id++; } } -out: +free (buf);return events; -error: +free_events:free_event_desc (events); - events =NULL ; - goto out; +free_buffer: +free (buf); +return NULL ; } static int __desc_attr__fprintf(FILE *fp, const char *name, const char *val,
Signature · 1 line
2.4.4
Arnaldo Carvalho de Melo
maintainerRe: [PATCH 2/2] perf header: Less function calls in read_event_desc() after error detection
Em Thu, Jun 25, 2015 at 06:24:09PM +0200, SF Markus Elfring escreveu:
Quoted 6 lines
From: Markus Elfring <[email protected]>
Date: Thu, 25 Jun 2015 17:50:37 +0200The functions "free" and "
free_event_desc" were called in a few cases by the function "read_event_desc" during error handling even if the passed variable contained a null pointer.
And that is not a problem, free(NULL) is perfectly valid, as is valid to call free_event_desc(NULL).
But if you want to avoid those extra NULL checks done at those functions, then add a new out: label that just do 'return events;' that is NULL, etc.
- Arnaldo
Quoted 25 lines
This implementation detail could be improved by the adjustment of jump targets. Drop unnecessary initialisations for the variables "buf" and "events" then.
Signed-off-by Markus Elfring <[email protected]>--- tools/perf/util/header.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-)tools/perf/util/header.c +2
-2@@ -978,9 +978,9 @@ static void free_event_desc(struct perf_evsel *events)static struct perf_evsel *read_event_desc (struct perf_header *ph,int fd) { -struct perf_evsel *evsel, *events =NULL ; +struct perf_evsel *evsel, *events;u64 *id; -void *buf =NULL ; +void *buf;u32 nre, sz, nr, i, j;ssize_t ret;size_t msz;
tools/perf/util/header.c read_event_desc(struct perf_header *ph, int fd) · line 991
Quoted 5 lines
tools/perf/util/header.c +1
-1@@ -988,14 +988,14 @@ read_event_desc(struct perf_header *ph, int fd)/* number of events */ ret =readn (fd, &nre,sizeof (nre));if (ret != (ssize_t )sizeof (nre)) - goto error; +return NULL ;
Please leave the single point of exit, i.e. this should 'goto out:' and the out: label will return events, that is set to NULL
Quoted 80 lines
tools/perf/util/header.c +12
-11if (ph->needs_swap) nre =bswap_32 (nre); ret =readn (fd, &sz,sizeof (sz));if (ret != (ssize_t )sizeof (sz)) - goto error; +return NULL ;if (ph->needs_swap) sz =bswap_32 (sz);@@ -1003,12 +1003,12 @@ read_event_desc(struct perf_header *ph, int fd)/* buffer to hold on file attr struct */ buf =malloc (sz);if (!buf) - goto error; +return NULL ;/* the last event terminates with evsel->attr.size = 0: */ events =calloc (nre +1 ,sizeof (*events));if (!events) - goto error; + goto free_buffer; msz =sizeof (evsel->attr);if (sz < msz)@@ -1023,7 +1023,7 @@ read_event_desc(struct perf_header *ph, int fd)*/ ret =readn (fd, buf, sz);if (ret != (ssize_t )sz) - goto error; + goto free_events;if (ph->needs_swap)perf_event__attr_swap (buf);@@ -1032,7 +1032,7 @@ read_event_desc(struct perf_header *ph, int fd) ret =readn (fd, &nr,sizeof (nr));if (ret != (ssize_t )sizeof (nr)) - goto error; + goto free_events;if (ph->needs_swap) { nr =bswap_32 (nr);@@ -1046,26 +1046,27 @@ read_event_desc(struct perf_header *ph, int fd) id =calloc (nr,sizeof (*id));if (!id) - goto error; + goto free_events; evsel->ids = nr; evsel->id = id;for (j =0 ; j < nr; j++) { ret =readn (fd, id,sizeof (*id));if (ret != (ssize_t )sizeof (*id)) - goto error; + goto free_events;if (ph->needs_swap) *id =bswap_64 (*id); id++; } } -out: +free (buf);return events; -error: +free_events:free_event_desc (events); - events =NULL ; - goto out; +free_buffer: +free (buf); +return NULL ; } static int __desc_attr__fprintf(FILE *fp, const char *name, const char *val,Signature · 1 line
2.4.4
Re: [PATCH 2/2] perf header: Less function calls in read_event_desc() after error detection
Quoted 6 lines
Quoted 3 lines
The functions "free" and "
free_event_desc" were called in a few cases by the function "read_event_desc" during error handling even if the passed variable contained a null pointer.And that is not a problem, free(NULL) is perfectly valid, as is valid to call
free_event_desc(NULL).
I hope that inefficient exception handling can be fixed.
Quoted 2 lines
But if you want to avoid those extra NULL checks done at those functions, then add a new out: label that just do 'return events;' that is NULL, etc.
I adjusted the jump labels in the affected function already.
Quoted 25 lines
Quoted 25 lines
This implementation detail could be improved by the adjustment of jump targets. Drop unnecessary initialisations for the variables "buf" and "events" then.
Signed-off-by Markus Elfring <[email protected]>--- tools/perf/util/header.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-)tools/perf/util/header.c +2
-2@@ -978,9 +978,9 @@ static void free_event_desc(struct perf_evsel *events)static struct perf_evsel *read_event_desc (struct perf_header *ph,int fd) { -struct perf_evsel *evsel, *events =NULL ; +struct perf_evsel *evsel, *events;u64 *id; -void *buf =NULL ; +void *buf;u32 nre, sz, nr, i, j;ssize_t ret;size_t msz;@@ -988,14 +988,14 @@ read_event_desc(struct perf_header *ph, int fd)
Quoted 8 lines
tools/perf/util/header.c read_event_desc(struct perf_header *ph, int fd) · line 991
Quoted 5 lines
tools/perf/util/header.c +1
-1/* number of events */ ret =readn (fd, &nre,sizeof (nre));if (ret != (ssize_t )sizeof (nre)) - goto error; +return NULL ;Please leave the single point of exit, i.e. this should 'goto out:' and the out: label will return events, that is set to NULL
Does my update suggestion fit to the wording "If there is no cleanup needed then just return directly." from the Linux coding style documentation?
Quoted 79 lines
Quoted 79 lines
tools/perf/util/header.c +12
-11if (ph->needs_swap) nre =bswap_32 (nre); ret =readn (fd, &sz,sizeof (sz));if (ret != (ssize_t )sizeof (sz)) - goto error; +return NULL ;if (ph->needs_swap) sz =bswap_32 (sz);@@ -1003,12 +1003,12 @@ read_event_desc(struct perf_header *ph, int fd)/* buffer to hold on file attr struct */ buf =malloc (sz);if (!buf) - goto error; +return NULL ;/* the last event terminates with evsel->attr.size = 0: */ events =calloc (nre +1 ,sizeof (*events));if (!events) - goto error; + goto free_buffer; msz =sizeof (evsel->attr);if (sz < msz)@@ -1023,7 +1023,7 @@ read_event_desc(struct perf_header *ph, int fd)*/ ret =readn (fd, buf, sz);if (ret != (ssize_t )sz) - goto error; + goto free_events;if (ph->needs_swap)perf_event__attr_swap (buf);@@ -1032,7 +1032,7 @@ read_event_desc(struct perf_header *ph, int fd) ret =readn (fd, &nr,sizeof (nr));if (ret != (ssize_t )sizeof (nr)) - goto error; + goto free_events;if (ph->needs_swap) { nr =bswap_32 (nr);@@ -1046,26 +1046,27 @@ read_event_desc(struct perf_header *ph, int fd) id =calloc (nr,sizeof (*id));if (!id) - goto error; + goto free_events; evsel->ids = nr; evsel->id = id;for (j =0 ; j < nr; j++) { ret =readn (fd, id,sizeof (*id));if (ret != (ssize_t )sizeof (*id)) - goto error; + goto free_events;if (ph->needs_swap) *id =bswap_64 (*id); id++; } } -out: +free (buf);return events; -error: +free_events:free_event_desc (events); - events =NULL ; - goto out; +free_buffer: +free (buf); +return NULL ; } static int __desc_attr__fprintf(FILE *fp, const char *name, const char *val,Signature · 1 line
2.4.4
PATCH 1/1 keys: Delete an unnecessary check before the function call "key_put"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 26 Jun 2015 16:10:54 +0200
The key_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- fs/ext4/crypto_key.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/ext4/crypto_key.c +1 -2
@@ -89,8 +89,7 @@ void ext4_free_crypt_info(struct ext4_crypt_info *ci)if (!ci)return ; -if (ci->ci_keyring_key) -key_put (ci->ci_keyring_key); +key_put (ci->ci_keyring_key);crypto_free_ablkcipher (ci->ci_ctfm);kmem_cache_free (ext4_crypt_info_cachep, ci); }
Signature · 1 line
2.4.4
PATCH 1/1 fs-ext4 crypto: Delete an unnecessary check before the function call "key_put"
From: Markus Elfring <[email protected]>
Date: Fri, 26 Jun 2015 16:10:54 +0200
Subject: [PATCH] fs-ext4 crypto: Delete an unnecessary check before the
function call "key_put"
The key_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- fs/ext4/crypto_key.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/ext4/crypto_key.c +1 -2
@@ -89,8 +89,7 @@ void ext4_free_crypt_info(struct ext4_crypt_info *ci)if (!ci)return ; -if (ci->ci_keyring_key) -key_put (ci->ci_keyring_key); +key_put (ci->ci_keyring_key);crypto_free_ablkcipher (ci->ci_ctfm);kmem_cache_free (ext4_crypt_info_cachep, ci); }
Signature · 1 line
2.4.4
PATCH 1/1 f2fs crypto: Delete an unnecessary check before the function call "key_put"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 26 Jun 2015 17:28:55 +0200
The key_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- fs/f2fs/crypto_key.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/f2fs/crypto_key.c +1 -2
@@ -92,8 +92,7 @@ static void f2fs_free_crypt_info(struct f2fs_crypt_info *ci)if (!ci)return ; -if (ci->ci_keyring_key) -key_put (ci->ci_keyring_key); +key_put (ci->ci_keyring_key);crypto_free_ablkcipher (ci->ci_ctfm);kmem_cache_free (f2fs_crypt_info_cachep, ci); }
Signature · 1 line
2.4.4
PATCH 1/1 eCryptfs: Delete a check before the function call "key_put"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 26 Jun 2015 18:18:54 +0200
The key_put() function tests whether its argument is NULL and then returns immediately. Thus the test around this call might not be needed.
This issue was detected by using the Coccinelle software.
--- fs/ecryptfs/crypto.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/ecryptfs/crypto.c +1 -2
@@ -258,8 +258,7 @@ void ecryptfs_destroy_mount_crypt_stat( &mount_crypt_stat->global_auth_tok_list, mount_crypt_stat_list) {list_del (&auth_tok->mount_crypt_stat_list); -if (auth_tok->global_auth_tok_key - && !(auth_tok->flags &ECRYPTFS_AUTH_TOK_INVALID )) +if (!(auth_tok->flags &ECRYPTFS_AUTH_TOK_INVALID ))key_put (auth_tok->global_auth_tok_key);kmem_cache_free (ecryptfs_global_auth_tok_cache, auth_tok); }
Signature · 1 line
2.4.4
Re: [PATCH] eCryptfs: Delete a check before the function call "key_put"
Quoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 26 Jun 2015 18:18:54 +0200The
key_put()function tests whether its argument is NULL and then returns immediately. Thus the test around this call might not be needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Thanks for the cleanup. I'll include it in an upcoming eCryptfs pull request.
Tyler
Quoted 21 lines
--- fs/ecryptfs/crypto.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)fs/ecryptfs/crypto.c +1
-2@@ -258,8 +258,7 @@ void ecryptfs_destroy_mount_crypt_stat( &mount_crypt_stat->global_auth_tok_list, mount_crypt_stat_list) {list_del (&auth_tok->mount_crypt_stat_list); -if (auth_tok->global_auth_tok_key - && !(auth_tok->flags &ECRYPTFS_AUTH_TOK_INVALID )) +if (!(auth_tok->flags &ECRYPTFS_AUTH_TOK_INVALID ))key_put (auth_tok->global_auth_tok_key);kmem_cache_free (ecryptfs_global_auth_tok_cache, auth_tok); }Signature · 1 line
2.4.4
PATCH 1/1 crypto-qat: Deletion of unnecessary checks before two function calls
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 26 Jun 2015 20:30:11 +0200
The functions kfree() and release_firmware() test whether their argument is NULL and then return immediately.
Thus the test around the calls is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/crypto/qat/qat_common/adf_accel_engine.c | 5 +---- drivers/crypto/qat/qat_common/adf_transport.c | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-)
drivers/crypto/qat/qat_common/adf_accel_engine.c +1 -4
@@ -88,10 +88,7 @@ void adf_ae_fw_release(struct adf_accel_dev *accel_dev)qat_uclo_del_uof_obj (loader_data->fw_loader);qat_hal_deinit (loader_data->fw_loader); - -if (loader_data->uof_fw) -release_firmware (loader_data->uof_fw); - +release_firmware (loader_data->uof_fw); loader_data->uof_fw =NULL ; loader_data->fw_loader =NULL ; }
drivers/crypto/qat/qat_common/adf_transport.c +1 -1
@@ -449,7 +449,7 @@ static int adf_init_bank(struct adf_accel_dev *accel_dev, err:for (i =0 ; i <ADF_ETR_MAX_RINGS_PER_BANK ; i++) { ring = &bank->rings[i]; -if (hw_data->tx_rings_mask & (1 << i) && ring->inflights) +if (hw_data->tx_rings_mask & (1 << i))kfree (ring->inflights); }return -ENOMEM ;
Signature · 1 line
2.4.4
Re: [PATCH] crypto-qat: Deletion of unnecessary checks before two function calls
Quoted 10 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 26 Jun 2015 20:30:11 +0200The functions
kfree()andrelease_firmware()test whether their argument is NULL and then return immediately.
Thus the test around the calls is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Applied.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
PATCH 1/1 tc1100-wmi: Delete an unnecessary check before the function call "kfree"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 26 Jun 2015 21:21:16 +0200
The kfree() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/platform/x86/tc1100-wmi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/tc1100-wmi.c +1 -1
@@ -82,7 +82,7 @@ static int get_state(u32 *out, u8 instance) tmp =0 ; } -if (result.length >0 && result.pointer) +if (result.length >0 )kfree (result.pointer);switch (instance) {
Signature · 1 line
2.4.4
Darren Hart
AppliedRe: [PATCH] tc1100-wmi: Delete an unnecessary check before the function call "kfree"
Quoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 26 Jun 2015 21:21:16 +0200The
kfree()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Queued, thanks.
Signature · 2 lines
Darren Hart Intel Open Source Technology Center
PATCH 1/1 staging: xgifb: Delete an unnecessary check before the function call "XGIfb_search_crt2type"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 26 Jun 2015 21:50:41 +0200
The XGIfb_search_crt2type() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/staging/xgifb/XGI_main_26.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/xgifb/XGI_main_26.c +1 -2
@@ -2090,8 +2090,7 @@ static int __init xgifb_init(void) {char *option =NULL ; -if (forcecrt2type !=NULL ) -XGIfb_search_crt2type (forcecrt2type); +XGIfb_search_crt2type (forcecrt2type);if (fb_get_options ("xgifb" , &option))return -ENODEV ;XGIfb_setup (option);
Signature · 1 line
2.4.4
PATCH 1/1 staging: lustre: Deletion of unnecessary checks before three function calls
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 26 Jun 2015 23:10:42 +0200
The following functions test whether their argument is NULL and then return immediately.
* kfree
* ll_file_data_put
* ptlrpc_connection_put
Thus the test around such calls is not needed.
This issue was detected by using the Coccinelle software.
See also a previous update suggestion:
"remove unneeded null test before free" by Julia Lawall
https://lkml.org/lkml/2015/5/1/498
https://www.mail-archive.com/[email protected]/msg878600.html
--- drivers/staging/lustre/lustre/llite/file.c | 3 +-- drivers/staging/lustre/lustre/llite/llite_lib.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/import.c | 6 ++---- drivers/staging/lustre/lustre/ptlrpc/service.c | 4 +--- 4 files changed, 5 insertions(+), 10 deletions(-)
drivers/staging/lustre/lustre/llite/file.c +1 -2
@@ -702,8 +702,7 @@ out_och_free: out_openerr:if (opendir_set !=0 )ll_stop_statahead (inode, lli->lli_opendir_key); -if (fd !=NULL ) -ll_file_data_put (fd); +ll_file_data_put (fd); }else {ll_stats_ops_tally (ll_i2sbi (inode),LPROC_LL_OPEN ,1 ); }
drivers/staging/lustre/lustre/llite/llite_lib.c +1 -1
@@ -1114,7 +1114,7 @@ void ll_clear_inode(struct inode *inode)if (lli->lli_mds_read_och)ll_md_real_close (inode,FMODE_READ ); -if (S_ISLNK (inode->i_mode) && lli->lli_symlink_name) { +if (S_ISLNK (inode->i_mode)) {kfree (lli->lli_symlink_name); lli->lli_symlink_name =NULL ; }
drivers/staging/lustre/lustre/ptlrpc/import.c +2 -4
@@ -555,14 +555,12 @@ static int import_select_connection(struct obd_import *imp) imp_conn->oic_last_attempt =cfs_time_current_64 ();/* switch connection, don't mind if it's same as the current one */ -if (imp->imp_connection) -ptlrpc_connection_put (imp->imp_connection); +ptlrpc_connection_put (imp->imp_connection); imp->imp_connection =ptlrpc_connection_addref (imp_conn->oic_conn); dlmexp =class_conn2export (&imp->imp_dlm_handle);LASSERT (dlmexp !=NULL ); -if (dlmexp->exp_connection) -ptlrpc_connection_put (dlmexp->exp_connection); +ptlrpc_connection_put (dlmexp->exp_connection); dlmexp->exp_connection =ptlrpc_connection_addref (imp_conn->oic_conn);class_export_put (dlmexp);
drivers/staging/lustre/lustre/ptlrpc/service.c +1 -3
@@ -2826,9 +2826,7 @@ void ptlrpc_hr_fini(void)ptlrpc_stop_hr_threads ();cfs_percpt_for_each (hrp, i, ptlrpc_hr.hr_partitions) { -if (hrp->hrp_thrs !=NULL ) { -kfree (hrp->hrp_thrs); - } +kfree (hrp->hrp_thrs); }cfs_percpt_free (ptlrpc_hr.hr_partitions);
Signature · 1 line
2.4.4
Greg Kroah-Hartman
maintainerRe: [PATCH] staging: lustre: Deletion of unnecessary checks before three function calls
Quoted 2 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 26 Jun 2015 23:10:42 +0200
Sorry, I'm not taking any of your patches until you fix this all up.
greg k-h
PATCH 1/1 staging: lustre: Deletion of unnecessary checks before three function calls
From: Markus Elfring <[email protected]>
The following functions test whether their argument is NULL and then return immediately.
* kfree
* ll_file_data_put
* ptlrpc_connection_put
Thus the test around such calls is not needed.
This issue was detected by using the Coccinelle software.
See also a previous update suggestion:
"remove unneeded null test before free" by Julia Lawall
https://lkml.org/lkml/2015/5/1/498
https://www.mail-archive.com/[email protected]/msg878600.html
--- drivers/staging/lustre/lustre/llite/file.c | 3 +-- drivers/staging/lustre/lustre/llite/llite_lib.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/import.c | 6 ++---- drivers/staging/lustre/lustre/ptlrpc/service.c | 4 +--- 4 files changed, 5 insertions(+), 10 deletions(-)
drivers/staging/lustre/lustre/llite/file.c +1 -2
@@ -702,8 +702,7 @@ out_och_free: out_openerr:if (opendir_set !=0 )ll_stop_statahead (inode, lli->lli_opendir_key); -if (fd !=NULL ) -ll_file_data_put (fd); +ll_file_data_put (fd); }else {ll_stats_ops_tally (ll_i2sbi (inode),LPROC_LL_OPEN ,1 ); }
drivers/staging/lustre/lustre/llite/llite_lib.c +1 -1
@@ -1114,7 +1114,7 @@ void ll_clear_inode(struct inode *inode)if (lli->lli_mds_read_och)ll_md_real_close (inode,FMODE_READ ); -if (S_ISLNK (inode->i_mode) && lli->lli_symlink_name) { +if (S_ISLNK (inode->i_mode)) {kfree (lli->lli_symlink_name); lli->lli_symlink_name =NULL ; }
drivers/staging/lustre/lustre/ptlrpc/import.c +2 -4
@@ -555,14 +555,12 @@ static int import_select_connection(struct obd_import *imp) imp_conn->oic_last_attempt =cfs_time_current_64 ();/* switch connection, don't mind if it's same as the current one */ -if (imp->imp_connection) -ptlrpc_connection_put (imp->imp_connection); +ptlrpc_connection_put (imp->imp_connection); imp->imp_connection =ptlrpc_connection_addref (imp_conn->oic_conn); dlmexp =class_conn2export (&imp->imp_dlm_handle);LASSERT (dlmexp !=NULL ); -if (dlmexp->exp_connection) -ptlrpc_connection_put (dlmexp->exp_connection); +ptlrpc_connection_put (dlmexp->exp_connection); dlmexp->exp_connection =ptlrpc_connection_addref (imp_conn->oic_conn);class_export_put (dlmexp);
drivers/staging/lustre/lustre/ptlrpc/service.c +1 -3
@@ -2826,9 +2826,7 @@ void ptlrpc_hr_fini(void)ptlrpc_stop_hr_threads ();cfs_percpt_for_each (hrp, i, ptlrpc_hr.hr_partitions) { -if (hrp->hrp_thrs !=NULL ) { -kfree (hrp->hrp_thrs); - } +kfree (hrp->hrp_thrs); }cfs_percpt_free (ptlrpc_hr.hr_partitions);
Signature · 1 line
2.4.4
PATCH 1/1 staging: comedi: adl_pci9118: Delete an unnecessary check before the function call "pci_dev_put"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 27 Jun 2015 13:50:43 +0200
The pci_dev_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/staging/comedi/drivers/adl_pci9118.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/comedi/drivers/adl_pci9118.c +1 -2
@@ -1717,8 +1717,7 @@ static void pci9118_detach(struct comedi_device *dev)pci9118_reset (dev);comedi_pci_detach (dev);pci9118_free_dma (dev); -if (pcidev) -pci_dev_put (pcidev); +pci_dev_put (pcidev); }static struct comedi_driver adl_pci9118_driver = {
Signature · 1 line
2.4.4
Re: [PATCH] staging: comedi: adl_pci9118: Delete an unnecessary check before the function call "pci_dev_put"
Quoted 19 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 27 Jun 2015 13:50:43 +0200The
pci_dev_put()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/staging/comedi/drivers/adl_pci9118.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/staging/comedi/drivers/adl_pci9118.c +0
-0
drivers/staging/comedi/drivers/adl_pci9118.c static void pci9118_detach(struct comedi_device *dev) · line 1723
Quoted 9 lines
drivers/staging/comedi/drivers/adl_pci9118.c +1
-2@@ -1717,8 +1717,7 @@ static void pci9118_detach(struct comedi_device *dev)pci9118_reset (dev);comedi_pci_detach (dev);pci9118_free_dma (dev); -if (pcidev) -pci_dev_put (pcidev); +pci_dev_put (pcidev); }static struct comedi_driver adl_pci9118_driver = {
The same patch was posted independently (and earlier) by Maninder Singh, but I think we concluded that the code was more understandable without this change, as the test within pci_dev_put() is more of a safety net.
Signature · 2 lines
-=( Ian Abbott @ MEV Ltd. E-mail: <[email protected]> )=- -=( Web: http://www.mev.co.uk/ )=-
cover staging: wilc1000: Deletion of two unnecessary checks
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Further update suggestions were taken into account after a patch was applied from static source code analysis.
Markus Elfring (2):
Delete unnecessary checks before two function calls One function call less in mac_ioctl() after error detection
drivers/staging/wilc1000/linux_wlan.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-)
Signature · 1 line
2.4.4
PATCH 1/2 staging: wilc1000: Delete unnecessary checks before two function calls
From: Markus Elfring <[email protected]>
Date: Sat, 27 Jun 2015 15:56:57 +0200
The functions kfree() and release_firmware() test whether their argument is NULL and then return immediately.
Thus the test around the calls is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/staging/wilc1000/linux_wlan.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/staging/wilc1000/linux_wlan.c +2 -7
@@ -2421,11 +2421,7 @@ int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd) } done: - -if (buff !=NULL ) { -kfree (buff); - } - +kfree (buff);return s32Error; }
@@ -2707,8 +2703,7 @@ static void __exit exit_wilc_driver(void) } } - -if ((g_linux_wlan !=NULL ) && g_linux_wlan->wilc_firmware !=NULL ) { +if (g_linux_wlan) {release_firmware (g_linux_wlan->wilc_firmware); g_linux_wlan->wilc_firmware =NULL ; }
Signature · 1 line
2.4.4
Greg Kroah-Hartman
maintainerRe: [PATCH 1/2] staging: wilc1000: Delete unnecessary checks before two function calls
Quoted 2 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 27 Jun 2015 15:56:57 +0200
Why is this in the body of the email? Please fix your email client or just use git send-email properly.
Re: Clarification for the use of additional fields in the message body
Quoted 4 lines
Quoted 2 lines
From: Markus Elfring <[email protected]>
Date: Sat, 27 Jun 2015 15:56:57 +0200Why is this in the body of the email?
Does the canonical patch format support to preserve specific details about a shown commit by specification of fields like "Date" and "From" in the message body?
Regards,
Markus
Re: Clarification for the use of additional fields in the message body
Quoted 8 lines · SF Markus Elfring
Quoted 4 lines
Quoted 2 lines
From: Markus Elfring <[email protected]>
Date: Sat, 27 Jun 2015 15:56:57 +0200Why is this in the body of the email?
Does the canonical patch format support to preserve specific details about a shown commit by specification of fields like "Date" and "From" in the message body?
Using "From:" in the body can be used to provide your properly spelled name, or the name/e-mail of the actual author, if that happens not to be the sender. git-send-email will do that automagically for you. If "From:" is not specified in the message body, the e-mails sender will be used as author.
The date, as far as I know, is ignored. It is the commit date, not the authoring date, and once your patch is applied by a maintainer (i.e. committed), the date gets reset anyway. No need to try and preserve it.
Frans
Re: Clarification for the use of additional fields in the message body
Quoted 3 lines
The date, as far as I know, is ignored. It is the commit date, not the authoring date, and once your patch is applied by a maintainer (i.e. committed), the date gets reset anyway.
Thanks for your feedback.
Quoted 1 line
No need to try and preserve it.
I find that it might occasionally help to share and keep the record on timestamps about the evolution for an original update suggestion.
Regards,
Markus
Re: Clarification for the use of additional fields in the message body
Quoted 4 lines · SF Markus Elfring
Quoted 1 line
No need to try and preserve it.
I find that it might occasionally help to share and keep the record on timestamps about the evolution for an original update suggestion.
I think that as far as these kernel mailing lists are concerned, the date of the update suggestion is the date on which you submitted the patch, rather than the date you originally committed it to your local tree. If you wish to keep track of this evolution for yourself, or wish to share it, you're better off stashing it somewhere in a (public) git repo that you control. If you wish, you can always make mention of that repo below the ---, just above the diffstat. If you insist on placing the date somewhere, you can also put the date there if you wish. It'll be ignored by git when applied.
Cheers,
Frans
Re: Clarification for the use of additional fields in the message body
Quoted 3 lines
I think that as far as these kernel mailing lists are concerned, the date of the update suggestion is the date on which you submitted the patch, rather than the date you originally committed it to your local tree.
I imagine that there are committers who would like to keep corresponding software development history a bit more accurate.
Quoted 3 lines
If you wish to keep track of this evolution for yourself, or wish to share it, you're better off stashing it somewhere in a (public) git repo that you control.
Would it be nicer to preserve such data directly also by the usual mail interface?
Quoted 2 lines
If you insist on placing the date somewhere, you can also put the date there if you wish. It'll be ignored by git when applied.
This content management tool provides the capability to store the discussed information by the parameters "--author=" and "--date=", doesn't it?
Is the environment variable "GIT_AUTHOR_DATE" also interesting occasionally?
How often do you take extra care for passing appropriate data there?
Regards,
Markus
Re: Clarification for the use of additional fields in the message body
Quoted 6 lines · SF Markus Elfring
Quoted 3 lines
I think that as far as these kernel mailing lists are concerned, the date of the update suggestion is the date on which you submitted the patch, rather than the date you originally committed it to your local tree.
I imagine that there are committers who would like to keep corresponding software development history a bit more accurate.
I guess it depends on what your view on accurate is.
Quoted 11 lines
Quoted 3 lines
If you wish to keep track of this evolution for yourself, or wish to share it, you're better off stashing it somewhere in a (public) git repo that you control.
Would it be nicer to preserve such data directly also by the usual mail interface?
Quoted 2 lines
If you insist on placing the date somewhere, you can also put the date there if you wish. It'll be ignored by git when applied.
Quoted 6 lines
This content management tool provides the capability to store the discussed information by the parameters "--author=" and "--date=", doesn't it?
Is the environment variable "GIT_AUTHOR_DATE" also interesting occasionally?How often do you take extra care for passing appropriate data there?
I can't remember ever changing or explicitly preserving the commit date. I don't think I care enough. I did change the author on botched patches, but that's an exception. Remembering the author separately from the committer is something git does by design anyway.
Frans
Re: Clarification for the use of additional fields in the message body
Quoted 2 lines
I can't remember ever changing or explicitly preserving the commit date. I don't think I care enough.
Would any more software developers and maintainers like to share their experiences around such details?
When do commit timestamps become relevant as a documentation item for contribution authorship?
Quoted 2 lines
Remembering the author separately from the committer is something git does by design anyway.
Do you usually just reuse a procedure from a well-known command for which a description is provided like the following?
http://git-scm.com/docs/git-am
'…
"From: " and "Subject: " lines starting the body override the respective commit author name and title values taken from the headers.
…'
Will further fields be eventually mentioned there?
Regards,
Markus
Re: Clarification for the use of additional fields in the message body
Hi Markus,
Quoted 8 lines · SF Markus Elfring
Quoted 2 lines
I can't remember ever changing or explicitly preserving the commit date. I don't think I care enough.
Would any more software developers and maintainers like to share their experiences around such details?
When do commit timestamps become relevant as a documentation item for contribution authorship?
They are never relevant.
"When" a commit happened is never relevant except in relation to other things, at which point the actual date and time is almost completely irrelevant.
Just submit your patches using git-format-patch or git-send-email and friends. There's a file in the documentation directory of the kernel tree describing submitting patches and email client setup. Read them both, do what they say without anything extra.
Quoted 12 lines
Quoted 2 lines
Remembering the author separately from the committer is something git does by design anyway.
Do you usually just reuse a procedure from a well-known command for which a description is provided like the following?
http://git-scm.com/docs/git-am
'…
"From: " and "Subject: " lines starting the body override the respective commit author name and title values taken from the headers.
…'
Quoted 1 line
Will further fields be eventually mentioned there?
Why? Just do what is described in SubmittingPatches. Your attempts to "improve" on the system are unnecessary and annoying people. The instructions there are the recommended way to do things for a reason.
Thanks,
Signature · 4 lines
Julian Calaby Email: [email protected] Profile: http://www.google.com/profiles/julian.calaby/
Re: Clarification for the use of additional fields in the message body
Quoted 3 lines
There's a file in the documentation directory of the kernel tree describing submitting patches and email client setup. Read them both,
I read this information several times.
Quoted 1 line
do what they say without anything extra.
Do you see any special consequences if a bit of "extra" functionality is already provided by the Git software for a while?
Quoted 1 line
Your attempts to "improve" on the system are unnecessary
It seems that my approach does not need improvements for the current command "git am".
Would a few extensions for the available documentation help to clarify the situation?
Do items like "commit mail address" and "commit timestamp" belong together for the data structure "author" by design in this content management system?
Quoted 1 line
and annoying people.
I understand that various update suggestions can be surprising. It is also usual that corresponding acceptance might take a bit longer than what some contributors would prefer.
Regards,
Markus
Re: Clarification for the use of additional fields in the message body
Hi Markus,
Quoted 11 lines · SF Markus Elfring
Quoted 3 lines
There's a file in the documentation directory of the kernel tree describing submitting patches and email client setup. Read them both,
I read this information several times.
Quoted 1 line
do what they say without anything extra.
Do you see any special consequences if a bit of "extra" functionality is already provided by the Git software for a while?
If it's harmless, then no, but in this case, people are questioning why you're adding it as it adds no value to anyone and makes it look like you don't know what you're doing.
Quoted 6 lines
Quoted 1 line
Your attempts to "improve" on the system are unnecessary
It seems that my approach does not need improvements for the current command "git am".
Would a few extensions for the available documentation help to clarify the situation?
The issue is that the headers you're adding, From: and Date: are unnecessary.
The From: header you add is unnecessary as your email's From: header has the exact same information. The reason it's there is because sometimes people forward patches on from other people, e.g. if I were to resend one of your patches, I'd add a From: header to the body of the email so it'd be credited to you.
The Date: header you add is unnecessary as git-format-patch sets the date header in the email it produces to the author date stored in the commit. (see below) So if you're sending your patches in emails produced by git-format-patch, there's absolutely no reason to include it.
Quoted 3 lines
Do items like "commit mail address" and "commit timestamp" belong together for the data structure "author" by design in this content management system?
The information stored for a commit is:
= = = = =
tree 09496defc9eb793c665a7b80aa22f24c7bd5f204
parent 63c07589832bfe5ec49f2523ddb0e94a20af0f31
author Julian Calaby <[email protected]> 1435196810 +1000 committer Julian Calaby <[email protected]> 1436322540 +1000
= = = = =
Then the subject and commit message.
The numbers after the email addresses are the timestamps. They are both almost completely irrelevant for most workflows as people are less interested in when a commit was made and more interested in what release it's in, how it was merged, etc. All of which should be determined without using the timestamp.
To be honest, I've only ever used that timestamp for reporting purposes at work, and I'd be surprised if anyone was doing anything other than that with them.
In short, nobody cares, and nobody's going to be upset if the actual time you authored a patch is different to the time recorded upstream.
Quoted 5 lines
Quoted 1 line
and annoying people.
I understand that various update suggestions can be surprising. It is also usual that corresponding acceptance might take a bit longer than what some contributors would prefer.
How would you feel if someone came in to your place of work and told you to change how you do the job you've been doing for years without a good reason?
Thanks,
Signature · 4 lines
Julian Calaby Email: [email protected] Profile: http://www.google.com/profiles/julian.calaby/
Re: Clarification for the use of additional fields in the message body
Quoted 2 lines
If it's harmless, then no, but in this case, people are questioning why you're adding it as it adds no value
Some Git software developers care to keep the information complete for the author commit.
Quoted 1 line
to anyone and makes it look like you don't know what you're doing.
I specify message field overrides in my update suggestions intentionally.
Quoted 1 line
The issue is that the headers you're adding, From: and Date: are unnecessary.
We have got different opinions about the purpose.
Quoted 2 lines
The From: header you add is unnecessary as your email's From: header has the exact same information.
I would like to point out that there is a slight difference in my use case.
Quoted 3 lines
The reason it's there is because sometimes people forward patches on from other people, e.g. if I were to resend one of your patches, I'd add a From: header to the body of the email so it'd be credited to you.
I am also interested in such an use case.
Quoted 2 lines
The Date: header you add is unnecessary as git-format-patch sets the date header in the email it produces to the author date stored in the commit.
How do you think about my extra patch preparation for the mentioned mail forwarding?
Quoted 2 lines
So if you're sending your patches in emails produced by git-format-patch, there's absolutely no reason to include it.
I disagree here to some degree.
The difference in suggested commit timestamps of a few minutes might look negligible for some patches. There are few occasions where the delay between a concrete commit and its publishing by an interface like email can become days.
Quoted 4 lines
They are both almost completely irrelevant for most workflows as people are less interested in when a commit was made and more interested in what release it's in, how it was merged, etc. All of which should be determined without using the timestamp.
How often will it matter who made and published a change first?
Quoted 3 lines
To be honest, I've only ever used that timestamp for reporting purposes at work, and I'd be surprised if anyone was doing anything other than that with them.
Thanks for your detailed feedback.
Quoted 3 lines
How would you feel if someone came in to your place of work and told you to change how you do the job you've been doing for years without a good reason?
You might feel uncomfortable for a moment if you would interpret such a suggestion as a personal attack.
I guess that I point only a few technical details out which can change the popularity of existing functionality from the Git software.
Regards,
Markus
Re: Clarification for the use of additional fields in the message body
Hi Markus,
Quoted 7 lines · SF Markus Elfring
Quoted 2 lines
If it's harmless, then no, but in this case, people are questioning why you're adding it as it adds no value
Some Git software developers care to keep the information complete for the author commit.
Quoted 8 lines
Quoted 1 line
to anyone and makes it look like you don't know what you're doing.
I specify message field overrides in my update suggestions intentionally.
Quoted 1 line
The issue is that the headers you're adding, From: and Date: are unnecessary.
We have got different opinions about the purpose.
Let me rephrase that: they _should_ be unnecessary.
Quoted 4 lines
Quoted 2 lines
The From: header you add is unnecessary as your email's From: header has the exact same information.
I would like to point out that there is a slight difference in my use case.
Then fix your email client or patch submission process.
Quoted 5 lines
Quoted 3 lines
The reason it's there is because sometimes people forward patches on from other people, e.g. if I were to resend one of your patches, I'd add a From: header to the body of the email so it'd be credited to you.
I am also interested in such an use case.
This happens automatically if you use git-format-patch on a commit you didn't author. Nobody is adding this manually.
Quoted 5 lines
Quoted 2 lines
The Date: header you add is unnecessary as git-format-patch sets the date header in the email it produces to the author date stored in the commit.
How do you think about my extra patch preparation for the mentioned mail forwarding?
It sounds like you're using what could only be described as a Rube-Goldberg process to send email. Is there truly no way to simplify that process? (Also, are the servers you send it through re-writing the original headers?)
You should be sending the patches directly with SMTP using git-send-email, if you're not, then you're making things overly complicated for yourself.
Quoted 9 lines
Quoted 2 lines
So if you're sending your patches in emails produced by git-format-patch, there's absolutely no reason to include it.
I disagree here to some degree.
The difference in suggested commit timestamps of a few minutes might look negligible for some patches. There are few occasions where the delay between a concrete commit and its publishing by an interface like email can become days.
I made a commit a month ago, it got rebased today, in fact, I sent it's metadata in my previous email. When I ran git-format-patch on it, the timestamp in the headers of the email produced was the date from a month ago.
If I then sent that email, I believe it'd make it to the list here with that date intact. If it hadn't, I'd be trying to figure out why and either fix it or find a different path to get my patch here.
Quoted 6 lines
Quoted 4 lines
They are both almost completely irrelevant for most workflows as people are less interested in when a commit was made and more interested in what release it's in, how it was merged, etc. All of which should be determined without using the timestamp.
How often will it matter who made and published a change first?
If multiple people are submitting identical changes, then the one that is applied is the one the maintainer sees first, which will most likely be determined by which one hit their inbox / list first. Nobody is going to look at timestamps in emails to determine which one will be applied.
If you're worried about which one of several versions of a patch will be applied, change the subject to [PATCH v2] ..... instead of [PATCH] .... for the second version.
Quoted 7 lines
Quoted 3 lines
To be honest, I've only ever used that timestamp for reporting purposes at work, and I'd be surprised if anyone was doing anything other than that with them.
Thanks for your detailed feedback.
Quoted 6 lines
Quoted 3 lines
How would you feel if someone came in to your place of work and told you to change how you do the job you've been doing for years without a good reason?
You might feel uncomfortable for a moment if you would interpret such a suggestion as a personal attack.
I'm not interpreting this as a personal attack.
Quoted 2 lines
I guess that I point only a few technical details out which can change the popularity of existing functionality from the Git software.
Git was originally written to manage the Linux kernel. This feature was probably added by either Linus himself or one of the original developers who I believe were kernel developers. The patch submission process has been around for a long time, if this feature isn't used, it's for a good reason.
Having a feature doesn't mean that it should be used.
Thanks,
Signature · 4 lines
Julian Calaby Email: [email protected] Profile: http://www.google.com/profiles/julian.calaby/
Re: Clarification for the use of additional fields in the message body
Quoted 1 line
Is there truly no way to simplify that process?
I see some software development possibilities which could improve the communication with high volume mailing lists.
Quoted 1 line
You should be sending the patches directly with SMTP using git-send-email,
This tool is also fine for the publishing of a lot of patches.
Quoted 1 line
if you're not, then you're making things overly complicated for yourself.
But I prefer a graphical user interface for my mail handling so far.
Quoted 1 line
Having a feature doesn't mean that it should be used.
Does any of the "questionable functionality" get occasionally overlooked a bit too often?
Regards,
Markus
Re: Clarification for the use of additional fields in the message body
Hi Markus,
Quoted 4 lines · SF Markus Elfring
Quoted 1 line
Is there truly no way to simplify that process?
I see some software development possibilities which could improve the communication with high volume mailing lists.
You shouldn't need any software development, most people's processes are:
1. Make changes
2. git add <files>
3. git commit
4. Repeat 1-3 for all changes they want to make
5. git-format-patch
6. git-send-email through some SMTP server to the list and appropriate other people
From what I've read, you appear to have some semi-automatic tool for steps 1 through 4. I'd strongly recommend changing your patch submission process to use git-format-patch and git-send-email. If Sourceforge's email system doesn't let you send emails with SMTP directly, then you might want to try sending emails through your ISP's mail server.
Maintainers use a very similar process, however they collect and review patches in some personal repository in addition to making changes and committing them. Tools like patchwork are simply fancy methods of accumulating patches into git trees. Most people are using git-format-patch and git-send-email, possibly with some scripting around them, to format and send patches.
Quoted 3 lines
Quoted 1 line
You should be sending the patches directly with SMTP using git-send-email,
This tool is also fine for the publishing of a lot of patches.
git-send-email or some other tool?
Quoted 3 lines
Quoted 1 line
if you're not, then you're making things overly complicated for yourself.
But I prefer a graphical user interface for my mail handling so far.
I send my patches using git-send-email through gmail's servers then deal with literally everything else through gmail's web interface or Android app. Using git-send-email doesn't mean you can't use a graphical mail interface.
I used to send patches through a carefully configured instance of Thunderbird, however this required too many steps and it loved to mangle patches in ways that annoyed people.
Quoted 4 lines
Quoted 1 line
Having a feature doesn't mean that it should be used.
Does any of the "questionable functionality" get occasionally overlooked a bit too often?
It's not "questionable functionality", it's functionality we don't see a need for.
If I wanted to, I could insert a patch at any point in the history of Linux in my own repository, however any attempt to push that upstream would cause enormous amounts of pain and annoyance, to everyone who attempted to deal with it, so I don't.
Thanks,
Signature · 4 lines
Julian Calaby Email: [email protected] Profile: http://www.google.com/profiles/julian.calaby/
Theodore Ts'o
maintainerRe: Clarification for the use of additional fields in the message body
In reply to Julian CalabyQuoted 5 lines · Julian Calaby
If multiple people are submitting identical changes, then the one that is applied is the one the maintainer sees first, which will most likely be determined by which one hit their inbox / list first. Nobody is going to look at timestamps in emails to determine which one will be applied.
And some maintainers may choose *not* to act on a patch first, even if they see it first. They might be focused on bug fix patches, and not act on cleanup or feature patches until -rc3 or rc4. Or maybe they will use separate branches for "urgent_for_linus" patches, so two different patchs may end up in completely different git flows.
Quoted 3 lines
If you're worried about which one of several versions of a patch will be applied, change the subject to [PATCH v2] ..... instead of [PATCH] .... for the second version.
*Please* do this. In fact, this is the one thing I wish git send-email would do automatically, along with having a place to edit and track the 0/N summary patch.
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
To be honest, I've only ever used that timestamp for reporting purposes at work, and I'd be surprised if anyone was doing anything other than that with them.
Thanks for your detailed feedback.
Note also that some maintainers have work flow that deliberately smash the date (i.e., because they are using a system such as guilt), so if you are depending on the submitted timestamp, it's going to break on you.
- Ted
Re: Clarification for the use of additional fields in the message body
Quoted 4 lines
Note also that some maintainers have work flow that deliberately smash the date (i.e., because they are using a system such as guilt), so if you are depending on the submitted timestamp, it's going to break on you.
Thanks for your hint.
I am just trying to offer the possibility for the reuse of a more precise commit timestamp together with an appropriate author mail address for my update suggestions.
Do you reject any more such message field overrides?
Regards,
Markus
Theodore Ts'o
maintainerRe: Clarification for the use of additional fields in the message body
Quoted 11 lines · SF Markus Elfring
Quoted 4 lines
Note also that some maintainers have work flow that deliberately smash the date (i.e., because they are using a system such as guilt), so if you are depending on the submitted timestamp, it's going to break on you.
Thanks for your hint.
I am just trying to offer the possibility for the reuse of a more precise commit timestamp together with an appropriate author mail address for my update suggestions.
Do you reject any more such message field overrides?
Well, I won't hold it against you, since I also often need to fix patches or git commit descriptions anyway. But at the same time, my workflow (which you have no right to dictate) **will** destroy your timestamp. Given that you haven't explained why you want to do this, I'm not going have much sympathy if you complain.
Personally, given that you're going through some extremely baroque e-mail/patchsubmission scheme, I don't understand why you can't also arrange to override the Date field in the e-mail header. But I don't really care all that much, because I can ignore your timestamp no matter where you put it.
Regards,
- Ted
PATCH 2/2 staging: wilc1000: One function call less in mac_ioctl() after error detection
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 27 Jun 2015 16:00:59 +0200
The kfree() function was called in two cases by the mac_ioctl() function during error handling even if the passed variable did not contain a pointer for a valid data item.
* This implementation detail could be improved by the introduction of another jump label.
* Drop an unnecessary initialisation for the variable "buff" then.
--- drivers/staging/wilc1000/linux_wlan.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/staging/wilc1000/linux_wlan.c +4 -6
@@ -2351,16 +2351,13 @@ int mac_close(struct net_device *ndev)int mac_ioctl (struct net_device *ndev,struct ifreq *req,int cmd) { - -u8 *buff =NULL ; +u8 *buff;s8 rssi;u32 size =0 , length =0 ;perInterface_wlan_t *nic;struct WILC_WFI_priv *priv;s32 s32Error =WILC_SUCCESS ; - -/* struct iwreq *wrq = (struct iwreq *) req; // tony moved to case SIOCSIWPRIV */ #ifdef USE_WIRELESS nic =netdev_priv (ndev);
@@ -2405,7 +2402,7 @@ int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd)if (copy_to_user (wrq->u.data.pointer, buff, size)) {PRINT_ER ("%s: failed to copy data to user buffer\n" , __func__); s32Error = -EFAULT ; - goto done; + goto free_buffer; } } }
@@ -2420,8 +2417,9 @@ int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd) } } -done: +free_buffer:kfree (buff); +done:return s32Error; }
Signature · 1 line
2.4.4
Re: [PATCH 2/2] staging: wilc1000: One function call less in mac_ioctl() after error detection
Quoted 26 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 27 Jun 2015 16:00:59 +0200The
kfree()function was called in two cases by themac_ioctl()function during error handling even if the passed variable did not contain a pointer for a valid data item.* This implementation detail could be improved by the introduction of another jump label.
* Drop an unnecessary initialisation for the variable "buff" then.
Signed-off-by Markus Elfring <[email protected]>--- drivers/staging/wilc1000/linux_wlan.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)drivers/staging/wilc1000/linux_wlan.c +0
-1@@ -2351,16 +2351,13 @@ int mac_close(struct net_device *ndev)int mac_ioctl (struct net_device *ndev,struct ifreq *req,int cmd) { -
drivers/staging/wilc1000/linux_wlan.c int mac_close(struct net_device *ndev) · line 2363
Quoted 10 lines
drivers/staging/wilc1000/linux_wlan.c +1
-3-u8 *buff =NULL ; +u8 *buff;s8 rssi;u32 size =0 , length =0 ;perInterface_wlan_t *nic;struct WILC_WFI_priv *priv;s32 s32Error =WILC_SUCCESS ; - -
Removing these blank lines seems to have nothing to do with the topic of the patch.
julia
Quoted 31 lines
drivers/staging/wilc1000/linux_wlan.c +3
-3/* struct iwreq *wrq = (struct iwreq *) req; // tony moved to case SIOCSIWPRIV */ #ifdef USE_WIRELESS nic =netdev_priv (ndev);@@ -2405,7 +2402,7 @@ int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd)if (copy_to_user (wrq->u.data.pointer, buff, size)) {PRINT_ER ("%s: failed to copy data to user buffer\n" , __func__); s32Error = -EFAULT ; - goto done; + goto free_buffer; } } }@@ -2420,8 +2417,9 @@ int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd) } } -done: +free_buffer:kfree (buff); +done:return s32Error; } --2.4.4
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Greg Kroah-Hartman
maintainerRe: [PATCH 2/2] staging: wilc1000: One function call less in mac_ioctl() after error detection
In reply to SF Markus ElfringQuoted 2 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 27 Jun 2015 16:00:59 +0200
Again, please fix.
Quoted 9 lines
The
kfree()function was called in two cases by themac_ioctl()function during error handling even if the passed variable did not contain a pointer for a valid data item.* This implementation detail could be improved by the introduction of another jump label.
* Drop an unnecessary initialisation for the variable "buff" then.
That's a different issue, please fix it in a separate patch.
thanks,
greg k-h
Re: staging: wilc1000: One function call less in mac_ioctl() after error detection
Quoted 10 lines
Quoted 8 lines
The
kfree()function was called in two cases by themac_ioctl()function during error handling even if the passed variable did not contain a pointer for a valid data item.* This implementation detail could be improved by the introduction of another jump label.
* Drop an unnecessary initialisation for the variable "buff" then.
That's a different issue, please fix it in a separate patch.
I have got an other opinion here.
This update suggestion depends on a small source code clean-up from the previous patch, doesn't it?
Do you want that I split the second suggestion from this series into more steps?
Regards,
Markus
cover staging: wilc1000: Fine-tuning for two function implementations
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Further update suggestions were taken into account after a patch was applied from static source code analysis.
Markus Elfring (3):
Delete an unnecessary check before the function call "release_firmware" One function call less in mac_ioctl() after error detection Reduce scope for a few variables in mac_ioctl()
drivers/staging/wilc1000/linux_wlan.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-)
Signature · 1 line
2.9.2
PATCH 1/3 staging: wilc1000: Delete an unnecessary check before the function call "release_firmware"
From: Markus Elfring <[email protected]>
Date: Sun, 24 Jul 2016 21:00:20 +0200
The release_firmware() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/staging/wilc1000/linux_wlan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/wilc1000/linux_wlan.c +1 -1
@@ -1223,7 +1223,7 @@ void wilc_netdev_cleanup(struct wilc *wilc) vif[i] =netdev_priv (wilc->vif[i]->ndev); } -if (wilc && wilc->firmware) { +if (wilc) {release_firmware (wilc->firmware); wilc->firmware =NULL ; }
Signature · 1 line
2.9.2
PATCH 2/3 staging: wilc1000: One function call less in mac_ioctl() after error detection
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 24 Jul 2016 21:15:23 +0200
The kfree() function was called in two cases by the mac_ioctl() function during error handling even if the passed variable did not contain a pointer for a valid data item.
Improve this implementation detail by the introduction of another jump label.
--- drivers/staging/wilc1000/linux_wlan.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/staging/wilc1000/linux_wlan.c +3 -5
@@ -1130,7 +1130,7 @@ static int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd)if (copy_to_user (wrq->u.data.pointer, buff, size)) {netdev_err (ndev,"failed to copy\n" ); ret = -EFAULT ; - goto done; + goto free_buffer; } } }
@@ -1144,11 +1144,9 @@ static int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd) goto done; } } - -done: - +free_buffer:kfree (buff); - +done:return ret; }
Signature · 1 line
2.9.2
Re: [PATCH 2/3] staging: wilc1000: One function call less in mac_ioctl() after error detection
Hi Marcus,
Quoted 11 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 24 Jul 2016 21:15:23 +0200The
kfree()function was called in two cases by themac_ioctl()function during error handling even if the passed variable did not contain a pointer for a valid data item.Improve this implementation detail by the introduction of another jump label.
Signed-off-by Markus Elfring <[email protected]>
This is pointless micro-optimisation: kfree(NULL) is perfectly valid and buff is either malloc'd memory or NULL when it's called.
Thanks,
Signature · 4 lines
Julian Calaby Email: [email protected] Profile: http://www.google.com/profiles/julian.calaby/
PATCH 3/3 staging: wilc1000: Reduce scope for a few variables in mac_ioctl()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 24 Jul 2016 21:45:37 +0200
Three local variables were used only within a single case branch.
* Thus move the data type definition for "rssi" and "size" into the corresponding code block.
* The variable "length" was not modified after its initialisation. Thus pass a constant value in the affected function call instead.
--- drivers/staging/wilc1000/linux_wlan.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/staging/wilc1000/linux_wlan.c +4 -5
@@ -1094,8 +1094,6 @@ int wilc_mac_close(struct net_device *ndev)static int mac_ioctl (struct net_device *ndev,struct ifreq *req,int cmd) {u8 *buff =NULL ; -s8 rssi; -u32 size =0 , length =0 ;struct wilc_vif *vif;s32 ret =0 ;struct wilc *wilc;
@@ -1110,8 +1108,7 @@ static int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd)case SIOCSIWPRIV : {struct iwreq *wrq = (struct iwreq *)req; - - size = wrq->u.data.length; +u32 size = wrq->u.data.length;if (size && wrq->u.data.pointer) { buff = memdup_user(wrq->u.data.pointer,
@@ -1119,7 +1116,9 @@ static int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd)if (IS_ERR (buff))return PTR_ERR (buff); -if (strncasecmp (buff,"RSSI" , length) =0 ) { +if (strncasecmp (buff,"RSSI" ,0 ) =0 ) { +s8 rssi; + ret =wilc_get_rssi (vif, &rssi);netdev_info (ndev,"RSSI :%d\n" , rssi);
Signature · 1 line
2.9.2
Re: [PATCH 3/3] staging: wilc1000: Reduce scope for a few variables in mac_ioctl()
drivers/staging/wilc1000/linux_wlan.c static int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd) · line 1121
Quoted 5 lines
drivers/staging/wilc1000/linux_wlan.c +3
-1-if (strncasecmp (buff,"RSSI" , length) =0 ) { +if (strncasecmp (buff,"RSSI" ,0 ) =0 ) { +s8 rssi; +
Um, please think a second about if it makes any sense at all to compare zero chars of two strings.
Lino
Re: [PATCH 3/3] staging: wilc1000: Reduce scope for a few variables in mac_ioctl()
Am 25.07.2016 21:17, schrieb Lino Sanfilippo:
Quoted 10 lines
drivers/staging/wilc1000/linux_wlan.c static int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd) · line 1121
Quoted 5 lines
drivers/staging/wilc1000/linux_wlan.c +3
-1-if (strncasecmp (buff,"RSSI" , length) =0 ) { +if (strncasecmp (buff,"RSSI" ,0 ) =0 ) { +s8 rssi; +Um, please think a second about if it makes any sense at all to compare zero chars of two strings.
Lino
also:
the switch has only one case and default.
re,
wh
Re: staging: wilc1000: Reduce scope for a few variables in mac_ioctl()
In reply to Lino SanfilippoQuoted 7 lines
drivers/staging/wilc1000/linux_wlan.c static int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd) · line 1121
Quoted 4 lines
drivers/staging/wilc1000/linux_wlan.c +3
-1-if (strncasecmp (buff,"RSSI" , length) =0 ) { +if (strncasecmp (buff,"RSSI" ,0 ) =0 ) { +s8 rssi; +Um, please think a second about if it makes any sense at all to compare zero chars of two strings.
Under which circumstances should the variable "length" contain an other value than zero?
How can this open issue be fixed better?
Regards,
Markus
Aw: Re: staging: wilc1000: Reduce scope for a few variables in mac_ioctl()
Quoted 14 lines
Gesendet: Dienstag, 26. Juli 2016 um 08:25 Uhr
Von: "SF Markus Elfring" <[email protected]>Quoted 7 lines
drivers/staging/wilc1000/linux_wlan.c static int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd) · line 1121
Quoted 4 lines
drivers/staging/wilc1000/linux_wlan.c +3
-1-if (strncasecmp (buff,"RSSI" , length) =0 ) { +if (strncasecmp (buff,"RSSI" ,0 ) =0 ) { +s8 rssi; +Um, please think a second about if it makes any sense at all to compare zero chars of two strings.
Quoted 2 lines
Under which circumstances should the variable "length" contain an other value than zero?
Which circumstances do "not any sense at all" imply?
Quoted 2 lines
How can this open issue be fixed better?
The code is not too complicated and I think it is very obvious which value/variable should be passed instead of 0. I suggest to fix this since it is indeed a bug, instead of doing "micro optimizations" - which is the last thing that code in the staging area needs (as IIRC you have already been told by others, including the staging maintainer).
Regards,
Lino
Re: staging: wilc1000: Reduce scope for a few variables in mac_ioctl()
Quoted 1 line
Which circumstances do "not any sense at all" imply?
Should the expression 'strlen("RSSI")' be passed for the parameter 'length' instead?
Quoted 1 line
I suggest to fix this since it is indeed a bug,
We can agree that this function implementation was broken for a while there.
Quoted 2 lines
instead of doing "micro optimizations" - which is the last thing that code in the staging area needs (as IIRC you have already been told by others, including the staging maintainer).
The acceptance might grow a bit more for such software fine-tuning (like refactoring around variable usage).
Regards,
Markus
PATCH 1/1 ipmi: Delete an unnecessary check before the function call "cleanup_one_si"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 27 Jun 2015 18:12:14 +0200
The cleanup_one_si() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/char/ipmi/ipmi_si_intf.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/char/ipmi/ipmi_si_intf.c +1 -3
@@ -2778,9 +2778,7 @@ static int ipmi_remove(struct platform_device *dev) {struct smi_info *info =dev_get_drvdata (&dev->dev); -if (info) -cleanup_one_si (info); - +cleanup_one_si (info);return 0 ; }
Signature · 1 line
2.4.4
PATCH 1/1 drm/bridge: ps8622: Delete a check before backlight_device_unregister()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 27 Jun 2015 20:44:49 +0200
The backlight_device_unregister() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/gpu/drm/bridge/ps8622.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/bridge/ps8622.c +1 -3
@@ -646,9 +646,7 @@ static int ps8622_remove(struct i2c_client *client) {struct ps8622_bridge *ps8622 =i2c_get_clientdata (client); -if (ps8622->bl) -backlight_device_unregister (ps8622->bl); - +backlight_device_unregister (ps8622->bl);drm_bridge_remove (&ps8622->bridge);return 0 ;
Signature · 1 line
2.4.4
PATCH 1/1 drm/bridge: ps8622: Delete an unnecessary check before backlight_device_unregister()
From: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 14:45:51 +0200
The backlight_device_unregister() function tests whether its argument is NULL and then returns immediately.
Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/gpu/drm/bridge/parade-ps8622.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/bridge/parade-ps8622.c +1 -3
@@ -636,9 +636,7 @@ static int ps8622_remove(struct i2c_client *client) {struct ps8622_bridge *ps8622 =i2c_get_clientdata (client); -if (ps8622->bl) -backlight_device_unregister (ps8622->bl); - +backlight_device_unregister (ps8622->bl);drm_bridge_remove (&ps8622->bridge);return 0 ;
Signature · 1 line
2.9.2
Sean Paul
AppliedRe: [PATCH] drm/bridge: ps8622: Delete an unnecessary check before backlight_device_unregister()
Quoted 10 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 14:45:51 +0200The
backlight_device_unregister()function tests whether its argument is NULL and then returns immediately.
Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Applied to drm-misc
Quoted 26 lines
--- drivers/gpu/drm/bridge/parade-ps8622.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)drivers/gpu/drm/bridge/parade-ps8622.c +1
-4@@ -636,9 +636,7 @@ static int ps8622_remove(struct i2c_client *client) {struct ps8622_bridge *ps8622 =i2c_get_clientdata (client); -if (ps8622->bl) -backlight_device_unregister (ps8622->bl); - +backlight_device_unregister (ps8622->bl);drm_bridge_remove (&ps8622->bridge);return 0 ; --2.9.2
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
cover drm/msm/dsi: Deletion of an unnecessary check
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Further update suggestions were taken into account after a patch was applied from static source code analysis.
Markus Elfring (2):
Delete an unnecessary check before the function call "dsi_destroy" One function call less in dsi_init() after error detection
drivers/gpu/drm/msm/dsi/dsi.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-)
Signature · 1 line
2.4.4
PATCH 1/2 drm/msm/dsi: Delete an unnecessary check before the function call "dsi_destroy"
From: Markus Elfring <[email protected]>
Date: Sat, 27 Jun 2015 22:05:31 +0200
The dsi_destroy() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/gpu/drm/msm/dsi/dsi.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/msm/dsi/dsi.c +1 -3
@@ -110,9 +110,7 @@ static struct msm_dsi *dsi_init(struct platform_device *pdev)return msm_dsi; fail: -if (msm_dsi) -dsi_destroy (msm_dsi); - +dsi_destroy (msm_dsi);return ERR_PTR (ret); }
Signature · 1 line
2.4.4
PATCH 2/2 drm/msm/dsi: One function call less in dsi_init() after error detection
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 27 Jun 2015 22:23:28 +0200
The dsi_destroy() function was called in two cases by the dsi_init() function during error handling even if the passed variable contained a null pointer.
* This implementation detail could be improved by adjustments for jump targets according to the Linux coding style convention.
* Drop an unnecessary initialisation for the variable "msm_dsi" then.
--- drivers/gpu/drm/msm/dsi/dsi.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-)
drivers/gpu/drm/msm/dsi/dsi.c +9 -13
@@ -74,19 +74,15 @@ static void dsi_destroy(struct msm_dsi *msm_dsi)static struct msm_dsi *dsi_init (struct platform_device *pdev) { -struct msm_dsi *msm_dsi =NULL ; +struct msm_dsi *msm_dsi;int ret; -if (!pdev) { - ret = -ENXIO ; - goto fail; - } +if (!pdev) +return -ENXIO ; msm_dsi =devm_kzalloc (&pdev->dev,sizeof (*msm_dsi),GFP_KERNEL ); -if (!msm_dsi) { - ret = -ENOMEM ; - goto fail; - } +if (!msm_dsi) +return -ENOMEM ;DBG ("dsi probed=%p" , msm_dsi); msm_dsi->pdev = pdev;
@@ -95,21 +91,21 @@ static struct msm_dsi *dsi_init(struct platform_device *pdev)/* Init dsi host */ ret =msm_dsi_host_init (msm_dsi);if (ret) - goto fail; + goto destroy_dsi;/* GET dsi PHY */ ret =dsi_get_phy (msm_dsi);if (ret) - goto fail; + goto destroy_dsi;/* Register to dsi manager */ ret =msm_dsi_manager_register (msm_dsi);if (ret) - goto fail; + goto destroy_dsi;return msm_dsi; -fail: +destroy_dsi:dsi_destroy (msm_dsi);return ERR_PTR (ret); }
Signature · 1 line
2.4.4
PATCH 1/1 drm/amdgpu: Delete an unnecessary check before the function call "kfree"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 28 Jun 2015 10:27:35 +0200
The kfree() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -2
@@ -1575,8 +1575,7 @@ void amdgpu_device_fini(struct amdgpu_device *adev)amdgpu_fence_driver_fini (adev);amdgpu_fbdev_fini (adev); r =amdgpu_fini (adev); -if (adev->ip_block_enabled) -kfree (adev->ip_block_enabled); +kfree (adev->ip_block_enabled); adev->ip_block_enabled =NULL ; adev->accel_working = false;/* free i2c buses */
Signature · 1 line
2.4.4
Re: [PATCH] drm/amdgpu: Delete an unnecessary check before the function call "kfree"
Quoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 28 Jun 2015 10:27:35 +0200The
kfree()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
I already have the same patch from Maninder Singh.
Thanks!
Alex
Quoted 25 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-3@@ -1575,8 +1575,7 @@ void amdgpu_device_fini(struct amdgpu_device *adev)amdgpu_fence_driver_fini (adev);amdgpu_fbdev_fini (adev); r =amdgpu_fini (adev); -if (adev->ip_block_enabled) -kfree (adev->ip_block_enabled); +kfree (adev->ip_block_enabled); adev->ip_block_enabled =NULL ; adev->accel_working = false;/* free i2c buses */ --2.4.4
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
cover drm/amdgpu: Fine-tuning for three function implementations
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 16 Jul 2016 16:23:21 +0200
Further update suggestions were taken into account after patches were applied from static source code analysis.
Markus Elfring (8):
Delete an unnecessary check before drm_gem_object_unreference_unlocked() Delete unnecessary checks before the function call "kfree"
One function call less in amdgpu_cgs_acpi_eval_object() after error detection Delete a variable in amdgpu_cgs_acpi_eval_object()
Delete an unnecessary variable initialisation in amdgpu_cgs_acpi_eval_object() Change assignment for a variable in amdgpu_cgs_acpi_eval_object() Change assignment for a buffer variable in phm_dispatch_table() Delete an unnecessary variable initialisation in phm_dispatch_table()
drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | 28 ++++++++++------------ drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 4 +--- .../gpu/drm/amd/powerplay/hwmgr/functiontables.c | 12 ++++------ 3 files changed, 19 insertions(+), 25 deletions(-)
Signature · 1 line
2.9.1
PATCH 1/8 drm/amdgpu: Delete an unnecessary check before drm_gem_object_unreference_unlocked()
From: Markus Elfring <[email protected]>
Date: Sat, 16 Jul 2016 11:28:36 +0200
The drm_gem_object_unreference_unlocked() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +1 -3
@@ -516,9 +516,7 @@ static void amdgpu_user_framebuffer_destroy(struct drm_framebuffer *fb) {struct amdgpu_framebuffer *amdgpu_fb =to_amdgpu_framebuffer (fb); -if (amdgpu_fb->obj) { -drm_gem_object_unreference_unlocked (amdgpu_fb->obj); - } +drm_gem_object_unreference_unlocked (amdgpu_fb->obj);drm_framebuffer_cleanup (fb);kfree (amdgpu_fb); }
Signature · 1 line
2.9.1
PATCH 2/8 drm/amdgpu/powerplay: Delete unnecessary checks before the function call "kfree"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 16 Jul 2016 12:38:12 +0200
The kfree() function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | 3 +-- drivers/gpu/drm/amd/powerplay/hwmgr/functiontables.c | 5 +---- 2 files changed, 2 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c +1 -2
@@ -1053,8 +1053,7 @@ static int amdgpu_cgs_acpi_eval_object(struct cgs_device *cgs_device, } error: -if (obj !=NULL ) -kfree (obj); +kfree (obj);kfree ((void *)input.pointer);return result; }
drivers/gpu/drm/amd/powerplay/hwmgr/functiontables.c +1 -4
@@ -76,10 +76,7 @@ int phm_dispatch_table(struct pp_hwmgr *hwmgr, } result =phm_run_table (hwmgr, rt_table, input, output, temp_storage); - -if (NULL != temp_storage) -kfree (temp_storage); - +kfree (temp_storage);return result; }
Signature · 1 line
2.9.1