From 71916f0d01bc43e62af35ccb509c5fe46891d8fc Mon Sep 17 00:00:00 2001 From: Patrick Collins Date: Wed, 24 Feb 2016 10:49:08 -0800 Subject: [PATCH] lkl: Minor cleanup to virtio_net This commit adds a meaningful name for one of the constants in virtio_net, and avoids using memset in init_queue_locks by more careful bookkeeping. Signed-off-by: Patrick Collins --- tools/lkl/lib/virtio_net.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/lkl/lib/virtio_net.c b/tools/lkl/lib/virtio_net.c index 46cb7102f3a0f8..c9d5a5f8c0c535 100644 --- a/tools/lkl/lib/virtio_net.c +++ b/tools/lkl/lib/virtio_net.c @@ -12,6 +12,7 @@ #define RX_QUEUE_IDX 0 #define TX_QUEUE_IDX 1 #define NUM_QUEUES (TX_QUEUE_IDX + 1) +#define QUEUE_DEPTH 32 #ifdef DEBUG #define bad_request(s) do { \ @@ -143,11 +144,10 @@ static struct lkl_mutex_t **init_queue_locks(int num_queues) if (!ret) return NULL; - memset(ret, 0, sizeof(struct lkl_mutex_t*) * num_queues); for (i = 0; i < num_queues; i++) { ret[i] = lkl_host_ops.mutex_alloc(); if (!ret[i]) { - free_queue_locks(ret, num_queues); + free_queue_locks(ret, i); return NULL; } } @@ -193,7 +193,7 @@ int lkl_netdev_add(union lkl_netdev nd, void *mac) * could init the queues in virtio_dev_setup to help enforce * this, but netdevs are the only flavor that need these * locks, so it's better to do it here. */ - ret = virtio_dev_setup(&dev->dev, NUM_QUEUES, 32); + ret = virtio_dev_setup(&dev->dev, NUM_QUEUES, QUEUE_DEPTH); if (ret) goto out_free;