IB/hns: Fine-tuning for two function implementations
Subsystems (3)
cover IB/hns: Fine-tuning for two function implementations
From: Markus Elfring <[email protected]>
Date: Thu, 16 Feb 2017 09:55:43 +0100
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (2):
Use kmalloc_array() in hns_roce_cmd_use_events() Use kcalloc() in hns_roce_buddy_init()
drivers/infiniband/hw/hns/hns_roce_cmd.c | 6 +++--- drivers/infiniband/hw/hns/hns_roce_mr.c | 11 ++++++----- 2 files changed, 9 insertions(+), 8 deletions(-)
Signature · 1 line
2.11.1
PATCH 1/2 IB/hns: Use kmalloc_array() in hns_roce_cmd_use_events()
From: Markus Elfring <[email protected]>
Date: Thu, 16 Feb 2017 08:50:11 +0100
* A multiplication for the size determination of a memory allocation indicated that an array data structure should be processed. Thus use the corresponding function "kmalloc_array".
This issue was detected by using the Coccinelle software.
* Replace the specification of a data structure by a pointer dereference to make the corresponding size determination a bit safer according to the Linux coding style convention.
--- drivers/infiniband/hw/hns/hns_roce_cmd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/infiniband/hw/hns/hns_roce_cmd.c +3 -3
@@ -299,9 +299,9 @@ int hns_roce_cmd_use_events(struct hns_roce_dev *hr_dev)struct hns_roce_cmdq *hr_cmd = &hr_dev->cmd;int i; - hr_cmd->context =kmalloc (hr_cmd->max_cmds * -sizeof (struct hns_roce_cmd_context ), -GFP_KERNEL ); + hr_cmd->context =kmalloc_array (hr_cmd->max_cmds, +sizeof (*hr_cmd->context), +GFP_KERNEL );if (!hr_cmd->context)return -ENOMEM ;
Signature · 1 line
2.11.1
PATCH 2/2 IB/hns: Use kcalloc() in hns_roce_buddy_init()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 16 Feb 2017 09:30:55 +0100
* Multiplications for the size determination of memory allocations indicated that array data structures should be processed. Thus use the corresponding function "kcalloc".
This issue was detected by using the Coccinelle software.
* Replace the specification of data types by pointer dereferences to make the corresponding size determinations a bit safer according to the Linux coding style convention.
--- drivers/infiniband/hw/hns/hns_roce_mr.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/infiniband/hw/hns/hns_roce_mr.c +6 -5
@@ -127,11 +127,12 @@ static int hns_roce_buddy_init(struct hns_roce_buddy *buddy, int max_order) buddy->max_order = max_order;spin_lock_init (&buddy->lock); - - buddy->bits =kzalloc ((buddy->max_order +1 ) *sizeof (long *), -GFP_KERNEL ); - buddy->num_free =kzalloc ((buddy->max_order +1 ) *sizeof (int *), -GFP_KERNEL ); + buddy->bits =kcalloc (buddy->max_order +1 , +sizeof (*buddy->bits), +GFP_KERNEL ); + buddy->num_free =kcalloc (buddy->max_order +1 , +sizeof (*buddy->num_free), +GFP_KERNEL );if (!buddy->bits || !buddy->num_free) goto err_out;
Signature · 1 line
2.11.1
Quoted 6 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Thu, 16 Feb 2017 09:55:43 +0100A few update suggestions were taken into account
from static source code analysis.
Quoted 7 lines
Markus Elfring (2):
Usekmalloc_array()inhns_roce_cmd_use_events()Usekcalloc()inhns_roce_buddy_init()drivers/infiniband/hw/hns/hns_roce_cmd.c | 6 +++--- drivers/infiniband/hw/hns/hns_roce_mr.c | 11 ++++++-----
2 files changed, 9 insertions(+), 8 deletions(-)
Series applied, thanks.
Signature · 4 lines
Doug Ledford <[email protected]> GPG KeyID: B826A3330E572FDD Key fingerprint = AE6B 1BDA 122B 23B4 265B 1274 B826 A333 0E57 2FDD