From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36780) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XwVwG-0001kn-GF for qemu-devel@nongnu.org; Thu, 04 Dec 2014 07:55:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XwVwA-00046M-6a for qemu-devel@nongnu.org; Thu, 04 Dec 2014 07:55:20 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52545) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XwVw9-00044x-Un for qemu-devel@nongnu.org; Thu, 04 Dec 2014 07:55:14 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sB4CtCMY022164 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 4 Dec 2014 07:55:12 -0500 From: Markus Armbruster Date: Thu, 4 Dec 2014 13:55:09 +0100 Message-Id: <1417697709-13087-1-git-send-email-armbru@redhat.com> Subject: [Qemu-devel] [PATCH] block: Use g_new0() for a bit of extra type checking List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, mreitz@redhat.com g_new(T, 1) is safer than g_malloc(sizeof(T)), because it returns T * rather than void *, which lets the compiler catch more type errors. Missed in commit 02c4f26. Signed-off-by: Markus Armbruster --- aio-posix.c | 2 +- aio-win32.c | 4 ++-- async.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/aio-posix.c b/aio-posix.c index d3ac06e..cbd4c34 100644 --- a/aio-posix.c +++ b/aio-posix.c @@ -73,7 +73,7 @@ void aio_set_fd_handler(AioContext *ctx, } else { if (node == NULL) { /* Alloc and insert if it's not already there */ - node = g_malloc0(sizeof(AioHandler)); + node = g_new0(AioHandler, 1); node->pfd.fd = fd; QLIST_INSERT_HEAD(&ctx->aio_handlers, node, node); diff --git a/aio-win32.c b/aio-win32.c index d81313b..e6f4ced 100644 --- a/aio-win32.c +++ b/aio-win32.c @@ -67,7 +67,7 @@ void aio_set_fd_handler(AioContext *ctx, if (node == NULL) { /* Alloc and insert if it's not already there */ - node = g_malloc0(sizeof(AioHandler)); + node = g_new0(AioHandler, 1); node->pfd.fd = fd; QLIST_INSERT_HEAD(&ctx->aio_handlers, node, node); } @@ -129,7 +129,7 @@ void aio_set_event_notifier(AioContext *ctx, } else { if (node == NULL) { /* Alloc and insert if it's not already there */ - node = g_malloc0(sizeof(AioHandler)); + node = g_new0(AioHandler, 1); node->e = e; node->pfd.fd = (uintptr_t)event_notifier_get_handle(e); node->pfd.events = G_IO_IN; diff --git a/async.c b/async.c index 6e1b282..3939b79 100644 --- a/async.c +++ b/async.c @@ -44,7 +44,7 @@ struct QEMUBH { QEMUBH *aio_bh_new(AioContext *ctx, QEMUBHFunc *cb, void *opaque) { QEMUBH *bh; - bh = g_malloc0(sizeof(QEMUBH)); + bh = g_new0(QEMUBH, 1); bh->ctx = ctx; bh->cb = cb; bh->opaque = opaque; -- 1.9.3