From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55280) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbRYJ-0006uc-Ew for qemu-devel@nongnu.org; Mon, 14 Sep 2015 07:04:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbRYG-0006oZ-7W for qemu-devel@nongnu.org; Mon, 14 Sep 2015 07:04:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53830) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbRYG-0006oM-3P for qemu-devel@nongnu.org; Mon, 14 Sep 2015 07:04:00 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id B71888E3C4 for ; Mon, 14 Sep 2015 11:03:59 +0000 (UTC) From: Markus Armbruster Date: Mon, 14 Sep 2015 13:03:55 +0200 Message-Id: <1442228637-31481-2-git-send-email-armbru@redhat.com> Subject: [Qemu-devel] [PATCH] qxl: Use g_new() & friends where that makes obvious sense List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kraxel@redhat.com g_new(T, n) is neater than g_malloc(sizeof(T) * n). It's also safer, for two reasons. One, it catches multiplication overflowing size_t. Two, it returns T * rather than void *, which lets the compiler catch more type errors. This commit only touches allocations with size arguments of the form sizeof(T). Same Coccinelle semantic patch as in commit b45c03f. Signed-off-by: Markus Armbruster --- hw/display/qxl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/display/qxl.c b/hw/display/qxl.c index 2288238..a05690d 100644 --- a/hw/display/qxl.c +++ b/hw/display/qxl.c @@ -2156,7 +2156,7 @@ static int qxl_post_load(void *opaque, int version) qxl_create_guest_primary(d, 1, QXL_SYNC); /* replay surface-create and cursor-set commands */ - cmds = g_malloc0(sizeof(QXLCommandExt) * (d->ssd.num_surfaces + 1)); + cmds = g_new0(QXLCommandExt, d->ssd.num_surfaces + 1); for (in = 0, out = 0; in < d->ssd.num_surfaces; in++) { if (d->guest_surfaces.cmds[in] == 0) { continue; -- 2.4.3