linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] ATM-ZeitNet: Fine-tuning for three function implementations
@ 2016-09-10  8:57 SF Markus Elfring
  2016-09-10  9:00 ` [PATCH 1/4] ATM-ZeitNet: Use kmalloc_array() in start_tx() SF Markus Elfring
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: SF Markus Elfring @ 2016-09-10  8:57 UTC (permalink / raw)
  To: linux-atm-general, netdev, Chas Williams
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/4] ATM-ZeitNet: Use kmalloc_array() in start_tx()
  2016-09-10  8:57 [PATCH 0/4] ATM-ZeitNet: Fine-tuning for three function implementations SF Markus Elfring
@ 2016-09-10  9:00 ` SF Markus Elfring
  2016-09-10  9:01 ` [PATCH 2/4] ATM-ZeitNet: Improve a size determination in zatm_open() SF Markus Elfring
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: SF Markus Elfring @ 2016-09-10  9:00 UTC (permalink / raw)
  To: linux-atm-general, netdev, Chas Williams
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/4] ATM-ZeitNet: Improve a size determination in zatm_open()
  2016-09-10  8:57 [PATCH 0/4] ATM-ZeitNet: Fine-tuning for three function implementations SF Markus Elfring
  2016-09-10  9:00 ` [PATCH 1/4] ATM-ZeitNet: Use kmalloc_array() in start_tx() SF Markus Elfring
@ 2016-09-10  9:01 ` SF Markus Elfring
  2016-09-10  9:02 ` [PATCH 3/4] ATM-ZeitNet: Replace one kzalloc() call by kcalloc() SF Markus Elfring
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: SF Markus Elfring @ 2016-09-10  9:01 UTC (permalink / raw)
  To: linux-atm-general, netdev, Chas Williams
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/4] ATM-ZeitNet: Replace one kzalloc() call by kcalloc()
  2016-09-10  8:57 [PATCH 0/4] ATM-ZeitNet: Fine-tuning for three function implementations SF Markus Elfring
  2016-09-10  9:00 ` [PATCH 1/4] ATM-ZeitNet: Use kmalloc_array() in start_tx() SF Markus Elfring
  2016-09-10  9:01 ` [PATCH 2/4] ATM-ZeitNet: Improve a size determination in zatm_open() SF Markus Elfring
@ 2016-09-10  9:02 ` SF Markus Elfring
  2016-09-10  9:03 ` [PATCH 4/4] ATM-ZeitNet: Fix indentation for one DPRINTK() call in start_rx() SF Markus Elfring
  2016-09-11  4:46 ` [PATCH 0/4] ATM-ZeitNet: Fine-tuning for three function implementations David Miller
  4 siblings, 0 replies; 6+ messages in thread
From: SF Markus Elfring @ 2016-09-10  9:02 UTC (permalink / raw)
  To: linux-atm-general, netdev, Chas Williams
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 4/4] ATM-ZeitNet: Fix indentation for one DPRINTK() call in start_rx()
  2016-09-10  8:57 [PATCH 0/4] ATM-ZeitNet: Fine-tuning for three function implementations SF Markus Elfring
                   ` (2 preceding siblings ...)
  2016-09-10  9:02 ` [PATCH 3/4] ATM-ZeitNet: Replace one kzalloc() call by kcalloc() SF Markus Elfring
@ 2016-09-10  9:03 ` SF Markus Elfring
  2016-09-11  4:46 ` [PATCH 0/4] ATM-ZeitNet: Fine-tuning for three function implementations David Miller
  4 siblings, 0 replies; 6+ messages in thread
From: SF Markus Elfring @ 2016-09-10  9:03 UTC (permalink / raw)
  To: linux-atm-general, netdev, Chas Williams
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/4] ATM-ZeitNet: Fine-tuning for three function implementations
  2016-09-10  8:57 [PATCH 0/4] ATM-ZeitNet: Fine-tuning for three function implementations SF Markus Elfring
                   ` (3 preceding siblings ...)
  2016-09-10  9:03 ` [PATCH 4/4] ATM-ZeitNet: Fix indentation for one DPRINTK() call in start_rx() SF Markus Elfring
@ 2016-09-11  4:46 ` David Miller
  4 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2016-09-11  4:46 UTC (permalink / raw)
  To: elfring
  Cc: linux-atm-general, netdev, 3chas3, linux-kernel, kernel-janitors,
	julia.lawall, pbonzini

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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-09-11  4:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-10  8:57 [PATCH 0/4] ATM-ZeitNet: Fine-tuning for three function implementations SF Markus Elfring
2016-09-10  9:00 ` [PATCH 1/4] ATM-ZeitNet: Use kmalloc_array() in start_tx() SF Markus Elfring
2016-09-10  9:01 ` [PATCH 2/4] ATM-ZeitNet: Improve a size determination in zatm_open() SF Markus Elfring
2016-09-10  9:02 ` [PATCH 3/4] ATM-ZeitNet: Replace one kzalloc() call by kcalloc() SF Markus Elfring
2016-09-10  9:03 ` [PATCH 4/4] ATM-ZeitNet: Fix indentation for one DPRINTK() call in start_rx() SF Markus Elfring
2016-09-11  4:46 ` [PATCH 0/4] ATM-ZeitNet: Fine-tuning for three function implementations David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).