Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1480537 > unrolled thread
| Started by | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| First post | 2016-09-10 11:00 +0200 |
| Last post | 2016-09-11 06:50 +0200 |
| Articles | 6 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH 0/4] ATM-ZeitNet: Fine-tuning for three function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-10 11:00 +0200
[PATCH 2/4] ATM-ZeitNet: Improve a size determination in zatm_open() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-10 11:10 +0200
[PATCH 4/4] ATM-ZeitNet: Fix indentation for one DPRINTK() call in start_rx() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-10 11:10 +0200
[PATCH 3/4] ATM-ZeitNet: Replace one kzalloc() call by kcalloc() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-10 11:10 +0200
[PATCH 1/4] ATM-ZeitNet: Use kmalloc_array() in start_tx() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-10 11:10 +0200
Re: [PATCH 0/4] ATM-ZeitNet: Fine-tuning for three function implementations David Miller <davem@davemloft.net> - 2016-09-11 06:50 +0200
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2016-09-10 11:00 +0200 |
| Subject | [PATCH 0/4] ATM-ZeitNet: Fine-tuning for three function implementations |
| Message-ID | <sfMiJ-6sU-11@gated-at.bofh.it> |
From: Markus Elfring <elfring@users.sourceforge.net> Date: Sat, 10 Sep 2016 10:54:04 +0200 A few update suggestions were taken into account from static source code analysis. Markus Elfring (4): Use kmalloc_array() in start_tx() Improve a size determination in zatm_open() Replace one kzalloc() call by kcalloc() Fix indentation for one DPRINTK() call in start_rx() drivers/atm/zatm.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) -- 2.10.0
[toc] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2016-09-10 11:10 +0200 |
| Subject | [PATCH 2/4] ATM-ZeitNet: Improve a size determination in zatm_open() |
| Message-ID | <sfMsp-6KX-5@gated-at.bofh.it> |
| In reply to | #1480537 |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 10 Sep 2016 10:07:38 +0200
Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/atm/zatm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
index d378ff2..218c6af 100644
--- a/drivers/atm/zatm.c
+++ b/drivers/atm/zatm.c
@@ -1399,7 +1399,7 @@ static int zatm_open(struct atm_vcc *vcc)
DPRINTK(DEV_LABEL "(itf %d): open %d.%d\n",vcc->dev->number,vcc->vpi,
vcc->vci);
if (!test_bit(ATM_VF_PARTIAL,&vcc->flags)) {
- zatm_vcc = kmalloc(sizeof(struct zatm_vcc),GFP_KERNEL);
+ zatm_vcc = kmalloc(sizeof(*zatm_vcc), GFP_KERNEL);
if (!zatm_vcc) {
clear_bit(ATM_VF_ADDR,&vcc->flags);
return -ENOMEM;
--
2.10.0
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2016-09-10 11:10 +0200 |
| Subject | [PATCH 4/4] ATM-ZeitNet: Fix indentation for one DPRINTK() call in start_rx() |
| Message-ID | <sfMsq-6KX-9@gated-at.bofh.it> |
| In reply to | #1480537 |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 10 Sep 2016 10:38:04 +0200
Adjust the indentation for a call of the macro "DPRINTK" in this function.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/atm/zatm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
index 2cc9e2a..d3dc954 100644
--- a/drivers/atm/zatm.c
+++ b/drivers/atm/zatm.c
@@ -600,7 +600,7 @@ static int start_rx(struct atm_dev *dev)
struct zatm_dev *zatm_dev;
int i;
-DPRINTK("start_rx\n");
+ DPRINTK("start_rx\n");
zatm_dev = ZATM_DEV(dev);
zatm_dev->rx_map = kcalloc(zatm_dev->chans,
sizeof(*zatm_dev->rx_map),
--
2.10.0
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2016-09-10 11:10 +0200 |
| Subject | [PATCH 3/4] ATM-ZeitNet: Replace one kzalloc() call by kcalloc() |
| Message-ID | <sfMsq-6KX-13@gated-at.bofh.it> |
| In reply to | #1480537 |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 10 Sep 2016 10:21:15 +0200
* The script "checkpatch.pl" can point information out like the following.
WARNING: Prefer kcalloc over kzalloc with multiply
Thus fix the affected source code place.
* Replace the specification of a data type by a pointer dereference
to make the corresponding size determination a bit safer according to
the Linux coding style convention.
* Delete the local variable "size" which became unnecessary with
this refactoring.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/atm/zatm.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
index 218c6af..2cc9e2a 100644
--- a/drivers/atm/zatm.c
+++ b/drivers/atm/zatm.c
@@ -598,12 +598,13 @@ static void close_rx(struct atm_vcc *vcc)
static int start_rx(struct atm_dev *dev)
{
struct zatm_dev *zatm_dev;
- int size,i;
+ int i;
DPRINTK("start_rx\n");
zatm_dev = ZATM_DEV(dev);
- size = sizeof(struct atm_vcc *)*zatm_dev->chans;
- zatm_dev->rx_map = kzalloc(size,GFP_KERNEL);
+ zatm_dev->rx_map = kcalloc(zatm_dev->chans,
+ sizeof(*zatm_dev->rx_map),
+ GFP_KERNEL);
if (!zatm_dev->rx_map) return -ENOMEM;
/* set VPI/VCI split (use all VCIs and give what's left to VPIs) */
zpokel(zatm_dev,(1 << dev->ci_range.vci_bits)-1,uPD98401_VRR);
--
2.10.0
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2016-09-10 11:10 +0200 |
| Subject | [PATCH 1/4] ATM-ZeitNet: Use kmalloc_array() in start_tx() |
| Message-ID | <sfMsq-6KX-11@gated-at.bofh.it> |
| In reply to | #1480537 |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 10 Sep 2016 09:55:53 +0200
* 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 type by a pointer dereference
to make the corresponding size determination a bit safer according to
the Linux coding style convention.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/atm/zatm.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
index cecfb94..d378ff2 100644
--- a/drivers/atm/zatm.c
+++ b/drivers/atm/zatm.c
@@ -998,8 +998,9 @@ static int start_tx(struct atm_dev *dev)
DPRINTK("start_tx\n");
zatm_dev = ZATM_DEV(dev);
- zatm_dev->tx_map = kmalloc(sizeof(struct atm_vcc *)*
- zatm_dev->chans,GFP_KERNEL);
+ zatm_dev->tx_map = kmalloc_array(zatm_dev->chans,
+ sizeof(*zatm_dev->tx_map),
+ GFP_KERNEL);
if (!zatm_dev->tx_map) return -ENOMEM;
zatm_dev->tx_bw = ATM_OC3_PCR;
zatm_dev->free_shapers = (1 << NR_SHAPERS)-1;
--
2.10.0
[toc] | [prev] | [next] | [standalone]
| From | David Miller <davem@davemloft.net> |
|---|---|
| Date | 2016-09-11 06:50 +0200 |
| Message-ID | <sg4Sl-1vD-1@gated-at.bofh.it> |
| In reply to | #1480537 |
From: SF Markus Elfring <elfring@users.sourceforge.net> Date: Sat, 10 Sep 2016 10:57:37 +0200 > A few update suggestions were taken into account > from static source code analysis. Series applied.
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web