diff options
author | Peter Malone <peter.malone@gmail.com> | 2017-02-16 21:42:26 +0100 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2018-02-01 15:26:46 +0100 |
commit | 03ee47ae8a7c608975be7e45287bff0482e295d6 (patch) | |
tree | 05ea298938a19379f4a49963c23c175f47327957 /tools/virtio/ringtest | |
parent | virtio_vop: don't kfree device on register failure (diff) | |
download | linux-03ee47ae8a7c608975be7e45287bff0482e295d6.tar.xz linux-03ee47ae8a7c608975be7e45287bff0482e295d6.zip |
ringtest: ring.c malloc & memset to calloc
Code cleanup change - moving from malloc & memset to calloc.
Signed-off-by: Peter Malone <peter.malone@gmail.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'tools/virtio/ringtest')
-rw-r--r-- | tools/virtio/ringtest/ring.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/tools/virtio/ringtest/ring.c b/tools/virtio/ringtest/ring.c index 2b9859beea65..5a41404aaef5 100644 --- a/tools/virtio/ringtest/ring.c +++ b/tools/virtio/ringtest/ring.c @@ -84,12 +84,11 @@ void alloc_ring(void) perror("Unable to allocate ring buffer.\n"); exit(3); } - event = malloc(sizeof *event); + event = calloc(1, sizeof(*event)); if (!event) { perror("Unable to allocate event buffer.\n"); exit(3); } - memset(event, 0, sizeof *event); guest.avail_idx = 0; guest.kicked_avail_idx = -1; guest.last_used_idx = 0; @@ -102,12 +101,11 @@ void alloc_ring(void) ring[i] = desc; } guest.num_free = ring_size; - data = malloc(ring_size * sizeof *data); + data = calloc(ring_size, sizeof(*data)); if (!data) { perror("Unable to allocate data buffer.\n"); exit(3); } - memset(data, 0, ring_size * sizeof *data); } /* guest side */ |