public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber•org>
To: "Michael S. Tsirkin" <mst@redhat•com>
Cc: netdev@vger•kernel.org, Stephen Hemminger <stephen@networkplumber•org>
Subject: [PATCH net-next v2 3/3] virtio: use kcalloc and kmalloc_array
Date: Tue, 26 Jul 2016 09:37:15 -0700	[thread overview]
Message-ID: <20160726163747.437348999@networkplumber.org> (raw)
In-Reply-To: 20160726163712.721213063@networkplumber.org

[-- Attachment #1: virtio-kcalloc.patch --]
[-- Type: text/plain, Size: 1323 bytes --]

Preferred style is to use kcalloc and kmalloc_array.

Signed-off-by: Stephen Hemminger <stephen@networkplumber•org>

--- a/drivers/net/virtio_net.c	2016-07-26 09:28:21.401557546 -0700
+++ b/drivers/net/virtio_net.c	2016-07-26 09:36:05.107695337 -0700
@@ -1551,13 +1551,13 @@ static int virtnet_find_vqs(struct virtn
 		    virtio_has_feature(vi->vdev, VIRTIO_NET_F_CTRL_VQ);
 
 	/* Allocate space for find_vqs parameters */
-	vqs = kzalloc(total_vqs * sizeof(*vqs), GFP_KERNEL);
+	vqs = kcalloc(total_vqs, sizeof(*vqs), GFP_KERNEL);
 	if (!vqs)
 		goto err_vq;
-	callbacks = kmalloc(total_vqs * sizeof(*callbacks), GFP_KERNEL);
+	callbacks = kmalloc_array(total_vqs, sizeof(*callbacks), GFP_KERNEL);
 	if (!callbacks)
 		goto err_callback;
-	names = kmalloc(total_vqs * sizeof(*names), GFP_KERNEL);
+	names = kmalloc_array(total_vqs, sizeof(*names), GFP_KERNEL);
 	if (!names)
 		goto err_names;
 
@@ -1613,10 +1613,10 @@ static int virtnet_alloc_queues(struct v
 {
 	int i;
 
-	vi->sq = kzalloc(sizeof(*vi->sq) * vi->max_queue_pairs, GFP_KERNEL);
+	vi->sq = kcalloc(vi->max_queue_pairs, sizeof(*vi->sq), GFP_KERNEL);
 	if (!vi->sq)
 		goto err_sq;
-	vi->rq = kzalloc(sizeof(*vi->rq) * vi->max_queue_pairs, GFP_KERNEL);
+	vi->rq = kcalloc(vi->max_queue_pairs, sizeof(*vi->rq), GFP_KERNEL);
 	if (!vi->rq)
 		goto err_rq;
 

  parent reply	other threads:[~2016-07-26 16:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-26 16:37 [PATCH net-next v2 0/3] virtio: style cleanups Stephen Hemminger
2016-07-26 16:37 ` [PATCH net-next v2 1/3] virtio: whitespace cleanups Stephen Hemminger
2016-07-26 16:58   ` Michael S. Tsirkin
2016-07-26 16:37 ` [PATCH net-next v2 2/3] virtio: cleanup sizeof usage Stephen Hemminger
2016-07-26 16:37 ` Stephen Hemminger [this message]
2016-07-26 18:11 ` [PATCH net-next v2 0/3] virtio: style cleanups Michael S. Tsirkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160726163747.437348999@networkplumber.org \
    --to=stephen@networkplumber$(echo .)org \
    --cc=mst@redhat$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox