ringtest: ring.c malloc & memset to calloc

"Linux Kernel Mailing List" <[email protected]>
Newsgroups gmane.linux.kernel.commits.head
Message-ID <[email protected]>
Web:        https://git.kernel.org/torvalds/c/03ee47ae8a7c608975be7e45287bff0482e295d6
Commit:     03ee47ae8a7c608975be7e45287bff0482e295d6
Parent:     0063e8bbd2b62d13645d416625478c2199fdee0f
Refname:    refs/heads/master
Author:     Peter Malone <[email protected]>
AuthorDate: Thu Feb 16 15:42:26 2017 -0500
Committer:  Michael S. Tsirkin <[email protected]>
CommitDate: Thu Feb 1 16:26:46 2018 +0200

    ringtest: ring.c malloc & memset to calloc
    
    Code cleanup change - moving from malloc & memset to calloc.
    
    Signed-off-by: Peter Malone <[email protected]>
    Signed-off-by: Michael S. Tsirkin <[email protected]>
---
 tools/virtio/ringtest/ring.c | 6 ++----
 1 file 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 */
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.