From patchwork Fri Oct 6 23:50:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 822831 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Ou2JdHKO"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y86yZ68QTz9t3m for ; Sat, 7 Oct 2017 11:36:54 +1100 (AEDT) Received: from localhost ([::1]:47792 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e0d6q-0004bG-SB for incoming@patchwork.ozlabs.org; Fri, 06 Oct 2017 20:36:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43355) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e0cS3-0001wZ-Er for qemu-devel@nongnu.org; Fri, 06 Oct 2017 19:54:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e0cS1-0007f3-V9 for qemu-devel@nongnu.org; Fri, 06 Oct 2017 19:54:43 -0400 Received: from mail-qk0-x242.google.com ([2607:f8b0:400d:c09::242]:38002) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e0cS1-0007eV-PX; Fri, 06 Oct 2017 19:54:41 -0400 Received: by mail-qk0-x242.google.com with SMTP id 17so5920385qkq.5; Fri, 06 Oct 2017 16:54:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zbrNxpd/pIWhJ0CPFZVJdm4d3wIqGdRGFMKeWZzx0to=; b=Ou2JdHKOJBnA8633GZVvH8pLqrhoqBQHUhO75J3jLlqZ+TKItD/xvUT6mHQHbSkW+C G4uMXv13R7wAjXZF3TjeD1fgyxVnbfy8qSlUQPZiRGxMlj0MwsomA/SqRrHk4qOisQ7m oP3h1ISdA4S8ianshqGWGVNjQHyQpBQY4SZ8WvtV3PzwEWJW8I2V7eSydub8mqIAxgpf NEOfERktmAZCZ4eYQCjc62xdExI8t7/El6vbQExRrFqKFPsIM3+N2MmGt4wcGVxpgpq/ lMKNjhZwwjplo7rg0nUxJrt/3U+9aiw2D6wxre/zuhOrgKXgwjLcMOvk1IdkPxHCeqW3 Fmxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=zbrNxpd/pIWhJ0CPFZVJdm4d3wIqGdRGFMKeWZzx0to=; b=rOvLxC+DncBljHCCcb38GAel9K1aTKywx3dBGl2fAHkfYalCeX4iRBcNNn2gFKN/B0 0c9Kaa9Tn37uyeh/F3uDbUNw4FjWcsTCYEBk4tDC+MhMg4eUS07N9UvaLrp1AUyAR7AN A32vB63H2M86CJNiuxgC9418nWPwpTE/K/ywEZTg1/nSn3b1DzdBq0R7CsVqsGxiFIY1 g6Dad0OtNz6xtCkqc+sVjoVa1gNvLHDoe7b+T784PbjNt2WZwQRHEr9I9L2p7MpvpGD1 gdlVdoZARWCLlxZg8k8cy5jEZ0RIl/77CNzPOaiZOUu8wDRTx9ayKKsYUwC684l43g6D 8FQg== X-Gm-Message-State: AMCzsaXiCmaueSNz+wwqVwpawT8aenGAu2CIKGbaL2x6gYhj8SvfoYtz qtFymdM5G75aZXYT4cLzT5g= X-Google-Smtp-Source: AOwi7QAjaN3vp7Tm/FwKstrFELZvZ/tbvFp0iWkeQyifTpxkLFE3fPeNY9h1srPYty1RAVSqRMeYlQ== X-Received: by 10.55.6.149 with SMTP id 143mr674880qkg.231.1507334081136; Fri, 06 Oct 2017 16:54:41 -0700 (PDT) Received: from yoga.lan ([181.93.89.178]) by smtp.gmail.com with ESMTPSA id g1sm1705226qta.95.2017.10.06.16.54.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Oct 2017 16:54:40 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Markus Armbruster , Eric Blake , Jeff Cody , Kevin Wolf , Max Reitz Date: Fri, 6 Oct 2017 20:50:05 -0300 Message-Id: <20171006235023.11952-71-f4bug@amsat.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171006235023.11952-1-f4bug@amsat.org> References: <20171006235023.11952-1-f4bug@amsat.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c09::242 Subject: [Qemu-devel] [PATCH 70/88] block: use g_new() family of functions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu trival , =?utf-8?q?Marc-Andr=C3=A9_Lurea?= =?utf-8?q?u?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Philippe Mathieu-Daudé --- block/backup.c | 2 +- block/blkdebug.c | 4 ++-- block/commit.c | 2 +- block/linux-aio.c | 2 +- block/mirror.c | 2 +- block/qapi.c | 4 ++-- block/qcow2-refcount.c | 12 +++++------- block/qed-l2-cache.c | 2 +- block/sheepdog.c | 2 +- block/stream.c | 2 +- block/vhdx.c | 2 +- block/win32-aio.c | 2 +- 12 files changed, 18 insertions(+), 20 deletions(-) diff --git a/block/backup.c b/block/backup.c index 06ddbfd03d..cd73e7d905 100644 --- a/block/backup.c +++ b/block/backup.c @@ -514,7 +514,7 @@ static void coroutine_fn backup_run(void *opaque) qemu_co_rwlock_unlock(&job->flush_rwlock); g_free(job->done_bitmap); - data = g_malloc(sizeof(*data)); + data = g_new(BackupCompleteData, 1); data->ret = ret; block_job_defer_to_main_loop(&job->common, backup_complete, data); } diff --git a/block/blkdebug.c b/block/blkdebug.c index 46e53f2f09..4d05bcb1d9 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -175,7 +175,7 @@ static int add_rule(void *opaque, QemuOpts *opts, Error **errp) } /* Set attributes common for all actions */ - rule = g_malloc0(sizeof(*rule)); + rule = g_new(struct BlkdebugRule, 1); *rule = (struct BlkdebugRule) { .event = event, .action = d->action, @@ -727,7 +727,7 @@ static int blkdebug_debug_breakpoint(BlockDriverState *bs, const char *event, return -ENOENT; } - rule = g_malloc(sizeof(*rule)); + rule = g_new(struct BlkdebugRule, 1); *rule = (struct BlkdebugRule) { .event = blkdebug_event, .action = ACTION_SUSPEND, diff --git a/block/commit.c b/block/commit.c index 5036eec434..e698311d5f 100644 --- a/block/commit.c +++ b/block/commit.c @@ -210,7 +210,7 @@ static void coroutine_fn commit_run(void *opaque) out: qemu_vfree(buf); - data = g_malloc(sizeof(*data)); + data = g_new(CommitCompleteData, 1); data->ret = ret; block_job_defer_to_main_loop(&s->common, commit_complete, data); } diff --git a/block/linux-aio.c b/block/linux-aio.c index 88b8d55ec7..e5a9d7fdeb 100644 --- a/block/linux-aio.c +++ b/block/linux-aio.c @@ -474,7 +474,7 @@ LinuxAioState *laio_init(void) { LinuxAioState *s; - s = g_malloc0(sizeof(*s)); + s = g_new0(LinuxAioState, 1); if (event_notifier_init(&s->e, false) < 0) { goto out_free_state; } diff --git a/block/mirror.c b/block/mirror.c index 153758ca9f..948e5321a7 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -904,7 +904,7 @@ immediate_exit: g_free(s->in_flight_bitmap); bdrv_dirty_iter_free(s->dbi); - data = g_malloc(sizeof(*data)); + data = g_new(MirrorExitData, 1); data->ret = ret; if (need_drain) { diff --git a/block/qapi.c b/block/qapi.c index 7fa2437923..808246bfc4 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -455,7 +455,7 @@ static BlockStats *bdrv_query_bds_stats(BlockDriverState *bs, { BlockStats *s = NULL; - s = g_malloc0(sizeof(*s)); + s = g_new0(BlockStats, 1); s->stats = g_malloc0(sizeof(*s->stats)); if (!bs) { @@ -503,7 +503,7 @@ BlockInfoList *qmp_query_block(Error **errp) continue; } - info = g_malloc0(sizeof(*info)); + info = g_new0(BlockInfoList, 1); bdrv_query_info(blk, &info->value, &local_err); if (local_err) { error_propagate(errp, local_err); diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index aa3fd6cf17..dd2387d2bb 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -755,7 +755,7 @@ static void update_refcount_discard(BlockDriverState *bs, } } - d = g_malloc(sizeof(*d)); + d = g_new(Qcow2DiscardRegion, 1); *d = (Qcow2DiscardRegion) { .bs = bs, .offset = offset, @@ -2189,9 +2189,8 @@ write_refblocks: reftable_size = ROUND_UP((refblock_index + 1) * sizeof(uint64_t), s->cluster_size) / sizeof(uint64_t); - new_on_disk_reftable = g_try_realloc(on_disk_reftable, - reftable_size * - sizeof(uint64_t)); + new_on_disk_reftable = g_try_renew(uint64_t, on_disk_reftable, + reftable_size); if (!new_on_disk_reftable) { res->check_errors++; ret = -ENOMEM; @@ -2656,8 +2655,7 @@ static int alloc_refblock(BlockDriverState *bs, uint64_t **reftable, return -ENOTSUP; } - new_reftable = g_try_realloc(*reftable, new_reftable_size * - sizeof(uint64_t)); + new_reftable = g_try_renew(uint64_t, *reftable, new_reftable_size); if (!new_reftable) { error_setg(errp, "Failed to increase reftable buffer size"); return -ENOMEM; @@ -3119,7 +3117,7 @@ int qcow2_shrink_reftable(BlockDriverState *bs) { BDRVQcow2State *s = bs->opaque; uint64_t *reftable_tmp = - g_malloc(s->refcount_table_size * sizeof(uint64_t)); + g_new(uint64_t, s->refcount_table_size); int i, ret; for (i = 0; i < s->refcount_table_size; i++) { diff --git a/block/qed-l2-cache.c b/block/qed-l2-cache.c index b548362398..48689a6650 100644 --- a/block/qed-l2-cache.c +++ b/block/qed-l2-cache.c @@ -90,7 +90,7 @@ CachedL2Table *qed_alloc_l2_cache_entry(L2TableCache *l2_cache) { CachedL2Table *entry; - entry = g_malloc0(sizeof(*entry)); + entry = g_new0(CachedL2Table, 1); entry->ref++; trace_qed_alloc_l2_cache_entry(l2_cache, entry); diff --git a/block/sheepdog.c b/block/sheepdog.c index 696a71442a..1f67ed43ca 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -467,7 +467,7 @@ static inline AIOReq *alloc_aio_req(BDRVSheepdogState *s, SheepdogAIOCB *acb, { AIOReq *aio_req; - aio_req = g_malloc(sizeof(*aio_req)); + aio_req = g_new(AIOReq, 1); aio_req->aiocb = acb; aio_req->iov_offset = iov_offset; aio_req->oid = oid; diff --git a/block/stream.c b/block/stream.c index e6f72346e5..2b4c67de41 100644 --- a/block/stream.c +++ b/block/stream.c @@ -202,7 +202,7 @@ static void coroutine_fn stream_run(void *opaque) out: /* Modify backing chain and close BDSes in main loop */ - data = g_malloc(sizeof(*data)); + data = g_new(StreamCompleteData, 1); data->ret = ret; block_job_defer_to_main_loop(&s->common, stream_complete, data); } diff --git a/block/vhdx.c b/block/vhdx.c index 7ae4589879..8260fb46cd 100644 --- a/block/vhdx.c +++ b/block/vhdx.c @@ -244,7 +244,7 @@ static void vhdx_region_register(BDRVVHDXState *s, { VHDXRegionEntry *r; - r = g_malloc0(sizeof(*r)); + r = g_new0(VHDXRegionEntry, 1); r->start = start; r->end = start + length; diff --git a/block/win32-aio.c b/block/win32-aio.c index 3be8f458fa..dfa062562f 100644 --- a/block/win32-aio.c +++ b/block/win32-aio.c @@ -190,7 +190,7 @@ QEMUWin32AIOState *win32_aio_init(void) { QEMUWin32AIOState *s; - s = g_malloc0(sizeof(*s)); + s = g_new0(QEMUWin32AIOState, 1); if (event_notifier_init(&s->e, false) < 0) { goto out_free_state; }