From nobody Sun Feb 8 08:27:28 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1601920146; cv=none; d=zohomail.com; s=zohoarc; b=e+z027HD6tZfnPoUoyRLMavNIM9NTJxLOSDV+nZ+3uBjIKnmfLhlvRbha3ws6eXhF+FW85Ty0wsQo45ZMZwibOarVycSEQQv7sW9pgZb0ErS0Qm0hEirLOOnVK/BhG+l2htjLU5yjcmsc+oouOenec5avzWXMuuS6r/5iySxPeg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601920146; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Sd5NI5Zpu6NrEAAyXn3Fhf57FwxoOkdF1EqI8U+t4X0=; b=idz6GcPax8lPxhuAsawT3NIB0HmC5zb/CSEZ2ofWlhFnukvgLroCiRJqbWIqrnF3v8dESjoUUciG6qhPzT11NPvZqweVA0LeWyZd0iUoK7wIdHwBX825cYvteemIHU+FTG5k7//cWvtofBGr77apG9yKuksjtYe1JY8WUYvDnFI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1601920146404497.8856712892547; Mon, 5 Oct 2020 10:49:06 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-17-qBayrdQ8PIugYFCrE4DFbA-1; Mon, 05 Oct 2020 13:49:01 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 793BB85C705; Mon, 5 Oct 2020 17:48:55 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 548495D9CC; Mon, 5 Oct 2020 17:48:55 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 1B45844A6D; Mon, 5 Oct 2020 17:48:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 095HmgCu015674 for ; Mon, 5 Oct 2020 13:48:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id D31145C1C4; Mon, 5 Oct 2020 17:48:42 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3425C5C1BD for ; Mon, 5 Oct 2020 17:48:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601920145; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Sd5NI5Zpu6NrEAAyXn3Fhf57FwxoOkdF1EqI8U+t4X0=; b=gpMrHoHU+LGfLwnNenW0wNnxRtHrxxl0fLO7X3N82nxejV80EiQCz7BGih6DU3v7XqaQzq trolyRTXTqAJCj6SLK3pKXgbDeWD4YRpqYFa3rznqwqkWQ7Slo1asQH43SbNeIRJ6CM4pk 8iKKBY2k8FAWJnWeeAClMAnQV4YSjHc= X-MC-Unique: qBayrdQ8PIugYFCrE4DFbA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 11/12] util: a-n: use g_new0 Date: Mon, 5 Oct 2020 19:48:26 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Signed-off-by: J=C3=A1n Tomko --- src/util/iohelper.c | 3 +-- src/util/virarptable.c | 3 +-- src/util/virauthconfig.c | 6 ++---- src/util/virbitmap.c | 4 +--- src/util/vircgroup.c | 7 ++----- src/util/vircrypto.c | 6 ++---- src/util/virdnsmasq.c | 12 ++++-------- src/util/virebtables.c | 3 +-- src/util/virfile.c | 12 +++--------- src/util/virfirmware.c | 6 ++---- src/util/virhash.c | 8 ++------ src/util/virhostcpu.c | 9 +++------ src/util/virjson.c | 15 +++++---------- src/util/virlockspace.c | 17 +++++------------ src/util/virlog.c | 5 +---- src/util/virmdev.c | 6 ++---- src/util/virnetlink.c | 3 +-- src/util/virnuma.c | 7 ++----- 18 files changed, 40 insertions(+), 92 deletions(-) diff --git a/src/util/iohelper.c b/src/util/iohelper.c index c3eb6f8c54..49d939d290 100644 --- a/src/util/iohelper.c +++ b/src/util/iohelper.c @@ -63,8 +63,7 @@ runIO(const char *path, int fd, int oflags) } buf =3D base; #else - if (VIR_ALLOC_N(buf, buflen + alignMask) < 0) - goto cleanup; + buf =3D g_new0(char, buflen + alignMask); base =3D buf; buf =3D (char *) (((intptr_t) base + alignMask) & ~alignMask); #endif diff --git a/src/util/virarptable.c b/src/util/virarptable.c index c4b46604a9..01a27c0093 100644 --- a/src/util/virarptable.c +++ b/src/util/virarptable.c @@ -74,8 +74,7 @@ virArpTableGet(void) if (msglen < 0) return NULL; =20 - if (VIR_ALLOC(table) < 0) - return NULL; + table =3D g_new0(virArpTable, 1); =20 nh =3D (struct nlmsghdr*)nlData; =20 diff --git a/src/util/virauthconfig.c b/src/util/virauthconfig.c index 2e50609531..6b5487c4b0 100644 --- a/src/util/virauthconfig.c +++ b/src/util/virauthconfig.c @@ -40,8 +40,7 @@ virAuthConfigPtr virAuthConfigNew(const char *path) { virAuthConfigPtr auth; =20 - if (VIR_ALLOC(auth) < 0) - goto error; + auth =3D g_new0(virAuthConfig, 1); =20 auth->path =3D g_strdup(path); =20 @@ -65,8 +64,7 @@ virAuthConfigPtr virAuthConfigNewData(const char *path, { virAuthConfigPtr auth; =20 - if (VIR_ALLOC(auth) < 0) - goto error; + auth =3D g_new0(virAuthConfig, 1); =20 auth->path =3D g_strdup(path); =20 diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c index 319bd7b7ce..4fde6f4fd2 100644 --- a/src/util/virbitmap.c +++ b/src/util/virbitmap.c @@ -704,9 +704,7 @@ virBitmapToData(virBitmapPtr bitmap, else len =3D (len + CHAR_BIT) / CHAR_BIT; =20 - if (VIR_ALLOC_N(*data, len) < 0) - return -1; - + *data =3D g_new0(unsigned char, len); *dataLen =3D len; =20 virBitmapToDataBuf(bitmap, *data, *dataLen); diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 08758b5306..5c0543c66a 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -664,10 +664,8 @@ virCgroupNew(pid_t pid, { VIR_DEBUG("pid=3D%lld path=3D%s parent=3D%p controllers=3D%d group=3D%= p", (long long) pid, path, parent, controllers, group); - *group =3D NULL; =20 - if (VIR_ALLOC((*group)) < 0) - goto error; + *group =3D g_new0(virCgroup, 1); =20 if (path[0] =3D=3D '/' || !parent) { (*group)->path =3D g_strdup(path); @@ -2170,8 +2168,7 @@ virCgroupGetPercpuStats(virCgroupPtr group, param_idx =3D 1; =20 if (guestvcpus && param_idx < nparams) { - if (VIR_ALLOC_N(sum_cpu_time, need_cpus) < 0) - goto cleanup; + sum_cpu_time =3D g_new0(unsigned long long, need_cpus); if (virCgroupGetPercpuVcpuSum(group, guestvcpus, sum_cpu_time, need_cpus, cpumap) < 0) goto cleanup; diff --git a/src/util/vircrypto.c b/src/util/vircrypto.c index 90aed32c53..c4874550af 100644 --- a/src/util/vircrypto.c +++ b/src/util/vircrypto.c @@ -88,8 +88,7 @@ virCryptoHashString(virCryptoHash hash, =20 hashstrlen =3D (rc * 2) + 1; =20 - if (VIR_ALLOC_N(*output, hashstrlen) < 0) - return -1; + *output =3D g_new0(char, hashstrlen); =20 for (i =3D 0; i < rc; i++) { (*output)[i * 2] =3D hex[(buf[i] >> 4) & 0xf]; @@ -167,8 +166,7 @@ virCryptoEncryptDataAESgnutls(gnutls_cipher_algorithm_t= gnutls_enc_alg, * data from non-padded data. Hence datalen + 1 */ ciphertextlen =3D VIR_ROUND_UP(datalen + 1, 16); - if (VIR_ALLOC_N(ciphertext, ciphertextlen) < 0) - return -1; + ciphertext =3D g_new0(uint8_t, ciphertextlen); memcpy(ciphertext, data, datalen); =20 /* Fill in the padding of the buffer with the size of the padding diff --git a/src/util/virdnsmasq.c b/src/util/virdnsmasq.c index 44aa7ad95d..9030f9218a 100644 --- a/src/util/virdnsmasq.c +++ b/src/util/virdnsmasq.c @@ -109,8 +109,7 @@ addnhostsAdd(dnsmasqAddnHostsfile *addnhostsfile, goto error; =20 idx =3D addnhostsfile->nhosts; - if (VIR_ALLOC(addnhostsfile->hosts[idx].hostnames) < 0) - goto error; + addnhostsfile->hosts[idx].hostnames =3D g_new0(char *, 1); =20 addnhostsfile->hosts[idx].ip =3D g_strdup(ipstr); =20 @@ -141,8 +140,7 @@ addnhostsNew(const char *name, dnsmasqAddnHostsfile *addnhostsfile; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 - if (VIR_ALLOC(addnhostsfile) < 0) - return NULL; + addnhostsfile =3D g_new0(dnsmasqAddnHostsfile, 1); =20 addnhostsfile->hosts =3D NULL; addnhostsfile->nhosts =3D 0; @@ -343,8 +341,7 @@ hostsfileNew(const char *name, dnsmasqHostsfile *hostsfile; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 - if (VIR_ALLOC(hostsfile) < 0) - return NULL; + hostsfile =3D g_new0(dnsmasqHostsfile, 1); =20 hostsfile->hosts =3D NULL; hostsfile->nhosts =3D 0; @@ -444,8 +441,7 @@ dnsmasqContextNew(const char *network_name, { dnsmasqContext *ctx; =20 - if (VIR_ALLOC(ctx) < 0) - return NULL; + ctx =3D g_new0(dnsmasqContext, 1); =20 ctx->config_dir =3D g_strdup(config_dir); =20 diff --git a/src/util/virebtables.c b/src/util/virebtables.c index 1887d718a3..b23ce21ae9 100644 --- a/src/util/virebtables.c +++ b/src/util/virebtables.c @@ -55,8 +55,7 @@ ebtablesContextNew(const char *driver) { ebtablesContext *ctx =3D NULL; =20 - if (VIR_ALLOC(ctx) < 0) - return NULL; + ctx =3D g_new0(ebtablesContext, 1); =20 ctx->chain =3D g_strdup_printf("libvirt_%s_FORWARD", driver); =20 diff --git a/src/util/virfile.c b/src/util/virfile.c index e120d277d0..7d0a40b0fb 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -258,8 +258,7 @@ virFileWrapperFdNew(int *fd, const char *name, unsigned= int flags) return NULL; } =20 - if (VIR_ALLOC(ret) < 0) - return NULL; + ret =3D g_new0(virFileWrapperFd, 1); =20 mode =3D fcntl(*fd, F_GETFL); =20 @@ -1178,11 +1177,7 @@ safezero_slow(int fd, off_t offset, off_t len) remain =3D len; bytes =3D MIN(1024 * 1024, len); =20 - r =3D VIR_ALLOC_N(buf, bytes); - if (r < 0) { - errno =3D ENOMEM; - return -1; - } + buf =3D g_new0(char, bytes); =20 while (remain) { if (bytes > remain) @@ -3160,8 +3155,7 @@ virFileOpenTty(int *ttyprimary, char **ttyName, int r= awmode) size_t len =3D 64; int rc; =20 - if (VIR_ALLOC_N(name, len) < 0) - goto cleanup; + name =3D g_new0(char, len); =20 while ((rc =3D ttyname_r(secondary, name, len)) =3D=3D ERANGE) { if (VIR_RESIZE_N(name, len, len, len) < 0) diff --git a/src/util/virfirmware.c b/src/util/virfirmware.c index 513ec56621..6b8a64eafa 100644 --- a/src/util/virfirmware.c +++ b/src/util/virfirmware.c @@ -112,15 +112,13 @@ virFirmwareParseList(const char *list, } =20 if (i) { - if (VIR_ALLOC_N(*firmwares, i / 2) < 0) - goto cleanup; + *firmwares =3D g_new0(virFirmwarePtr, i / 2); *nfirmwares =3D i / 2; =20 for (j =3D 0; j < i / 2; j++) { virFirmwarePtr *fws =3D *firmwares; =20 - if (VIR_ALLOC(fws[j]) < 0) - goto cleanup; + fws[j] =3D g_new0(virFirmware, 1); fws[j]->name =3D g_strdup(token[2 * j]); fws[j]->nvram =3D g_strdup(token[2 * j + 1]); } diff --git a/src/util/virhash.c b/src/util/virhash.c index abec757d99..4b503a0313 100644 --- a/src/util/virhash.c +++ b/src/util/virhash.c @@ -271,10 +271,7 @@ virHashGrow(virHashTablePtr table, size_t size) if (oldtable =3D=3D NULL) return -1; =20 - if (VIR_ALLOC_N(table->table, size) < 0) { - table->table =3D oldtable; - return -1; - } + table->table =3D g_new0(virHashEntryPtr, size); table->size =3D size; =20 for (i =3D 0; i < oldsize; i++) { @@ -792,8 +789,7 @@ virHashKeyValuePairPtr virHashGetItems(virHashTablePtr = table, if (numElems < 0) return NULL; =20 - if (VIR_ALLOC_N(iter.sortArray, numElems + 1)) - return NULL; + iter.sortArray =3D g_new0(virHashKeyValuePair, numElems + 1); =20 virHashForEach(table, virHashGetKeysIterator, &iter); =20 diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c index 28f032b972..4ae4dca067 100644 --- a/src/util/virhostcpu.c +++ b/src/util/virhostcpu.c @@ -145,8 +145,7 @@ virHostCPUGetStatsFreeBSD(int cpuNum, =20 cpu_times_size =3D sizeof(long) * cpu_times_num * CPUSTATES; =20 - if (VIR_ALLOC_N(cpu_times, cpu_times_num * CPUSTATES) < 0) - goto cleanup; + cpu_times =3D g_new0(long, cpu_times_num * CPUSTATES); =20 if (sysctlbyname(sysctl_name, cpu_times, &cpu_times_size, NULL, 0) < 0= ) { virReportSystemError(errno, @@ -366,8 +365,7 @@ virHostCPUParseNode(const char *node, sock_max++; =20 /* allocate cores maps for each socket */ - if (VIR_ALLOC_N(cores_maps, sock_max) < 0) - goto cleanup; + cores_maps =3D g_new0(virBitmapPtr, sock_max); =20 for (i =3D 0; i < sock_max; i++) cores_maps[i] =3D virBitmapNew(0); @@ -1385,8 +1383,7 @@ virHostCPUGetTscInfo(void) return NULL; } =20 - if (VIR_ALLOC(info) < 0) - return NULL; + info =3D g_new0(virHostCPUTscInfo, 1); =20 info->frequency =3D rc * 1000ULL; =20 diff --git a/src/util/virjson.c b/src/util/virjson.c index a4fc9e990e..3fa9a9ca24 100644 --- a/src/util/virjson.c +++ b/src/util/virjson.c @@ -438,8 +438,7 @@ virJSONValueNewString(const char *data) if (!data) return virJSONValueNewNull(); =20 - if (VIR_ALLOC(val) < 0) - return NULL; + val =3D g_new0(virJSONValue, 1); =20 val->type =3D VIR_JSON_TYPE_STRING; val->data.string =3D g_strdup(data); @@ -457,8 +456,7 @@ virJSONValueNewStringLen(const char *data, if (!data) return virJSONValueNewNull(); =20 - if (VIR_ALLOC(val) < 0) - return NULL; + val =3D g_new0(virJSONValue, 1); =20 val->type =3D VIR_JSON_TYPE_STRING; val->data.string =3D g_strndup(data, length); @@ -472,8 +470,7 @@ virJSONValueNewNumber(const char *data) { virJSONValuePtr val; =20 - if (VIR_ALLOC(val) < 0) - return NULL; + val =3D g_new0(virJSONValue, 1); =20 val->type =3D VIR_JSON_TYPE_NUMBER; val->data.number =3D g_strdup(data); @@ -533,8 +530,7 @@ virJSONValueNewBoolean(int boolean_) { virJSONValuePtr val; =20 - if (VIR_ALLOC(val) < 0) - return NULL; + val =3D g_new0(virJSONValue, 1); =20 val->type =3D VIR_JSON_TYPE_BOOLEAN; val->data.boolean =3D boolean_; @@ -548,8 +544,7 @@ virJSONValueNewNull(void) { virJSONValuePtr val; =20 - if (VIR_ALLOC(val) < 0) - return NULL; + val =3D g_new0(virJSONValue, 1); =20 val->type =3D VIR_JSON_TYPE_NULL; =20 diff --git a/src/util/virlockspace.c b/src/util/virlockspace.c index 9a54192cd1..ef370936a3 100644 --- a/src/util/virlockspace.c +++ b/src/util/virlockspace.c @@ -119,8 +119,7 @@ virLockSpaceResourceNew(virLockSpacePtr lockspace, virLockSpaceResourcePtr res; bool shared =3D !!(flags & VIR_LOCK_SPACE_ACQUIRE_SHARED); =20 - if (VIR_ALLOC(res) < 0) - return NULL; + res =3D g_new0(virLockSpaceResource, 1); =20 res->fd =3D -1; res->flags =3D flags; @@ -241,8 +240,7 @@ virLockSpacePtr virLockSpaceNew(const char *directory) =20 VIR_DEBUG("directory=3D%s", NULLSTR(directory)); =20 - if (VIR_ALLOC(lockspace) < 0) - return NULL; + lockspace =3D g_new0(virLockSpace, 1); =20 if (virMutexInit(&lockspace->lock) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -292,8 +290,7 @@ virLockSpacePtr virLockSpaceNewPostExecRestart(virJSONV= aluePtr object) =20 VIR_DEBUG("object=3D%p", object); =20 - if (VIR_ALLOC(lockspace) < 0) - return NULL; + lockspace =3D g_new0(virLockSpace, 1); =20 if (virMutexInit(&lockspace->lock) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -331,8 +328,7 @@ virLockSpacePtr virLockSpaceNewPostExecRestart(virJSONV= aluePtr object) size_t j; size_t m; =20 - if (VIR_ALLOC(res) < 0) - goto error; + res =3D g_new0(virLockSpaceResource, 1); res->fd =3D -1; =20 if (!(tmp =3D virJSONValueObjectGetString(child, "name"))) { @@ -391,10 +387,7 @@ virLockSpacePtr virLockSpaceNewPostExecRestart(virJSON= ValuePtr object) } =20 m =3D virJSONValueArraySize(owners); - if (VIR_ALLOC_N(res->owners, res->nOwners) < 0) { - virLockSpaceResourceFree(res); - goto error; - } + res->owners =3D g_new0(pid_t, res->nOwners); res->nOwners =3D m; =20 for (j =3D 0; j < res->nOwners; j++) { diff --git a/src/util/virlog.c b/src/util/virlog.c index 285c130d36..6b7a4512e9 100644 --- a/src/util/virlog.c +++ b/src/util/virlog.c @@ -1271,10 +1271,7 @@ virLogOutputNew(virLogOutputFunc f, ndup =3D g_strdup(name); } =20 - if (VIR_ALLOC(ret) < 0) { - VIR_FREE(ndup); - return NULL; - } + ret =3D g_new0(virLogOutput, 1); =20 ret->logInitMessage =3D true; ret->f =3D f; diff --git a/src/util/virmdev.c b/src/util/virmdev.c index 26cb8300ff..31994631ed 100644 --- a/src/util/virmdev.c +++ b/src/util/virmdev.c @@ -150,8 +150,7 @@ virMediatedDeviceNew(const char *uuidstr, virMediatedDe= viceModelType model) return NULL; } =20 - if (VIR_ALLOC(dev) < 0) - return NULL; + dev =3D g_new0(virMediatedDevice, 1); =20 dev->path =3D g_steal_pointer(&sysfspath); =20 @@ -494,8 +493,7 @@ virMediatedDeviceTypeReadAttrs(const char *sysfspath, } \ } while (0) =20 - if (VIR_ALLOC(tmp) < 0) - return -1; + tmp =3D g_new0(virMediatedDeviceType, 1); =20 tmp->id =3D g_path_get_basename(sysfspath); =20 diff --git a/src/util/virnetlink.c b/src/util/virnetlink.c index ea06db51ee..fdd3a6a4d0 100644 --- a/src/util/virnetlink.c +++ b/src/util/virnetlink.c @@ -1018,8 +1018,7 @@ virNetlinkEventServiceStart(unsigned int protocol, un= signed int groups) =20 VIR_INFO("starting netlink event service with protocol %d", protocol); =20 - if (VIR_ALLOC(srv) < 0) - return -1; + srv =3D g_new0(virNetlinkEventSrvPrivate, 1); =20 if (virMutexInit(&srv->lock) < 0) { VIR_FREE(srv); diff --git a/src/util/virnuma.c b/src/util/virnuma.c index 6728f62a87..5d40d13977 100644 --- a/src/util/virnuma.c +++ b/src/util/virnuma.c @@ -265,8 +265,7 @@ virNumaGetNodeCPUs(int node, return -2; } =20 - if (VIR_ALLOC_N(mask, mask_n_bytes / sizeof(*mask)) < 0) - return -1; + mask =3D g_new0(unsigned long, mask_n_bytes / sizeof(*mask)); =20 if (numa_node_to_cpus(node, mask, mask_n_bytes) < 0) { VIR_WARN("NUMA topology for cell %d is not available, ignoring", n= ode); @@ -477,9 +476,7 @@ virNumaGetDistances(int node, if ((max_node =3D virNumaGetMaxNode()) < 0) return -1; =20 - if (VIR_ALLOC_N(*distances, max_node + 1) < 0) - return -1; - + *distances =3D g_new0(int, max_node + 1); *ndistances =3D max_node + 1; =20 for (i =3D 0; i <=3D max_node; i++) { --=20 2.26.2