Skip to content

Commit

Permalink
lkl: Minor cleanup to virtio_net
Browse files Browse the repository at this point in the history
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 <pscollins@google.com>
  • Loading branch information
pscollins committed Feb 24, 2016
1 parent 1f5a1af commit 71916f0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tools/lkl/lib/virtio_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 { \
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 71916f0

Please sign in to comment.