RDMA/iwpm: Adjustments for three function implementations
Subsystems (2)
cover RDMA/iwpm: Adjustments for three function implementations
From: Markus Elfring <[email protected]>
Date: Sat, 27 Jan 2018 22:12:34 +0100
Three update suggestions were taken into account
from static source code analysis.
Markus Elfring (3):
Delete an error message for a failed memory allocation in iwpm_create_nlmsg() Adjust a variable initialisation in iwpm_create_nlmsg()
Improve a size determination in two functions
drivers/infiniband/core/iwpm_util.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
Signature · 1 line
2.16.1
PATCH 1/3 RDMA/iwpm: Delete an error message for a failed memory allocation in iwpm_create_nlmsg()
From: Markus Elfring <[email protected]>
Date: Sat, 27 Jan 2018 21:48:01 +0100
Omit an extra message for a memory allocation failure in this function.
This issue was detected by using the Coccinelle software.
--- drivers/infiniband/core/iwpm_util.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/infiniband/core/iwpm_util.c +2 -3
@@ -439,10 +439,9 @@ struct sk_buff *iwpm_create_nlmsg(u32 nl_op, struct nlmsghdr **nlh,struct sk_buff *skb =NULL ; skb =dev_alloc_skb (IWPM_MSG_SIZE ); -if (!skb) { -pr_err ("%s Unable to allocate skb\n" , __func__); +if (!skb) goto create_nlmsg_exit; - } +if (!(ibnl_put_msg (skb, nlh,0 ,0 , nl_client, nl_op,NLM_F_REQUEST ))) {pr_warn ("%s: Unable to put the nlmsg header\n" , __func__);
Signature · 1 line
2.16.1
Jason Gunthorpe
AppliedRe: [PATCH 1/3] RDMA/iwpm: Delete an error message for a failed memory allocation in iwpm_create_nlmsg()
Quoted 10 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 27 Jan 2018 21:48:01 +0100Omit an extra message for a memory allocation failure in this function.
This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>drivers/infiniband/core/iwpm_util.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
applied to for-next
Jason
PATCH 2/3 RDMA/iwpm: Adjust a variable initialisation in iwpm_create_nlmsg()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 27 Jan 2018 21:56:54 +0100
The local variable "skb" will be reassigned by a following statement. Thus adjust the initialisation at the beginning.
--- drivers/infiniband/core/iwpm_util.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/infiniband/core/iwpm_util.c +1 -2
@@ -436,9 +436,8 @@ int iwpm_compare_sockaddr(struct sockaddr_storage *a_sockaddr,struct sk_buff *iwpm_create_nlmsg (u32 nl_op,struct nlmsghdr **nlh,int nl_client) { -struct sk_buff *skb =NULL ; +struct sk_buff *skb =dev_alloc_skb (IWPM_MSG_SIZE ); - skb =dev_alloc_skb (IWPM_MSG_SIZE );if (!skb) goto create_nlmsg_exit;
Signature · 1 line
2.16.1
PATCH 3/3 RDMA/iwpm: Improve a size determination in two functions
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 27 Jan 2018 22:05:54 +0100
Replace the specification of data structures by pointer dereferences as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention.
This issue was detected by using the Coccinelle software.
--- drivers/infiniband/core/iwpm_util.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/infiniband/core/iwpm_util.c +3 -2
@@ -121,7 +121,8 @@ int iwpm_create_mapinfo(struct sockaddr_storage *local_sockaddr,if (!iwpm_valid_client (nl_client))return ret; - map_info =kzalloc (sizeof (struct iwpm_mapping_info ),GFP_KERNEL ); + + map_info =kzalloc (sizeof (*map_info),GFP_KERNEL );if (!map_info)return -ENOMEM ;
@@ -298,7 +299,7 @@ struct iwpm_nlmsg_request *iwpm_get_nlmsg_request(__u32 nlmsg_seq,struct iwpm_nlmsg_request *nlmsg_request =NULL ;unsigned long flags; - nlmsg_request =kzalloc (sizeof (struct iwpm_nlmsg_request ), gfp); + nlmsg_request =kzalloc (sizeof (*nlmsg_request), gfp);if (!nlmsg_request)return NULL ;
Signature · 1 line
2.16.1