Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1480544

[PATCH 3/4] ATM-ZeitNet: Replace one kzalloc() call by kcalloc()

From SF Markus Elfring <elfring@users.sourceforge.net>
Newsgroups linux.kernel
Subject [PATCH 3/4] ATM-ZeitNet: Replace one kzalloc() call by kcalloc()
Date 2016-09-10 11:10 +0200
Message-ID <sfMsq-6KX-13@gated-at.bofh.it> (permalink)
References <sfMiJ-6sU-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[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

csiph-web