From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933459AbdBPUm5 (ORCPT ); Thu, 16 Feb 2017 15:42:57 -0500 Received: from mail-wr0-f196.google.com ([209.85.128.196]:33843 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933086AbdBPUm4 (ORCPT ); Thu, 16 Feb 2017 15:42:56 -0500 From: Peter Malone To: mst@redhat.com, jasowang@redhat.com, linux-kernel@vger.kernel.org Cc: Peter Malone Subject: [PATCH] ringtest: ring.c malloc & memset to calloc Date: Thu, 16 Feb 2017 15:42:26 -0500 Message-Id: <1487277746-23279-1-git-send-email-peter.malone@gmail.com> X-Mailer: git-send-email 1.7.10.4 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Code cleanup change - moving from malloc & memset to calloc. Signed-off-by: Peter Malone --- 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 747c5dd..fa92638 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 */ -- 1.7.10.4