From nobody Sun Apr 28 04:45:17 2024 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=1616197060; cv=none; d=zohomail.com; s=zohoarc; b=JCmOKTgLw0HQ5nxnv+K+Jo/X4z7pduRuh02BZWB1JGYUhTdft4PiDYqk9MXNJfMBY6lS9lo8jdbAiystRNU8o+ZBBXd975v91IQqzzjZMvoVuCqMyfIhANLf2Tj/LObeN9IFsGtwW/I/vY/liA0oJkD/pGT1pRCRAfHWK7ThzSA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616197060; 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=VNdppDcYHyO/njshIbcBX9c9I4aTWGICjwXcYNUDPPo=; b=AZVAJmr29sAgMcb8WIQz8O4lGNcBnj2Ty1MT+mBUU9dXM8KTT2lgkqIMJJr2K0JICzjQFkb8kuHh3pUsXNyYIw1YGj4xzzFMSyun6L/T86JLhcf/edA/5gsIxmh8gf0zzOZqsts3GCytMXXIM/CkDdsGS2O9g38bs580dCnj0SQ= 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 1616197060178978.3517242180327; Fri, 19 Mar 2021 16:37:40 -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-399-L_6Rq5kWOguyOeuwuS4iew-1; Fri, 19 Mar 2021 19:37:37 -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 057F7107ACCD; Fri, 19 Mar 2021 23:37:31 +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 D699C5DDAD; Fri, 19 Mar 2021 23:37:30 +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 9B4614A7CB; Fri, 19 Mar 2021 23:37:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 12JNbCek029422 for ; Fri, 19 Mar 2021 19:37:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4F2521F052; Fri, 19 Mar 2021 23:37:12 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.40.194.173]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 213F71F41B for ; Fri, 19 Mar 2021 23:37:08 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 6AB2A24015B; Sat, 20 Mar 2021 00:37:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616197059; 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=VNdppDcYHyO/njshIbcBX9c9I4aTWGICjwXcYNUDPPo=; b=fMv37qoX98cFxENVLaZotfrULJzc67A+amMa7f6SHRGXdkF2EzrI6lxzuODTnWhWfmxtWm 58+OnGxbLuMS0tGjFruD5QPdeuEH4SXRwqq/UBSGwcZwJ4YCXgRHrBshQ1wXmzKd3jVlPr 55pyw2Sb+1hqoyi152PGUAA8rQLWM9w= X-MC-Unique: L_6Rq5kWOguyOeuwuS4iew-1 From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH 1/7] util: Drop G_GNUC_WARN_UNUSED_RESULT from reallocation APIs Date: Sat, 20 Mar 2021 00:37:00 +0100 Message-Id: <690377c31ef3fbdad11f01dcff6733d986064493.1616196713.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Our reallocation APIs already abort on OOM and thus can only return 0. There's no need to force callers to check the result. Signed-off-by: Jiri Denemark Reviewed-by: Michal Privoznik --- src/util/viralloc.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/util/viralloc.h b/src/util/viralloc.h index e3027622c4..d656d4ba0e 100644 --- a/src/util/viralloc.h +++ b/src/util/viralloc.h @@ -35,11 +35,11 @@ =20 /* Don't call these directly - use the macros below */ int virReallocN(void *ptrptr, size_t size, size_t count) - G_GNUC_WARN_UNUSED_RESULT ATTRIBUTE_NONNULL(1); + ATTRIBUTE_NONNULL(1); int virExpandN(void *ptrptr, size_t size, size_t *count, size_t add) - G_GNUC_WARN_UNUSED_RESULT ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3); + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3); int virResizeN(void *ptrptr, size_t size, size_t *alloc, size_t count, siz= e_t desired) - G_GNUC_WARN_UNUSED_RESULT ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3); + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3); void virShrinkN(void *ptrptr, size_t size, size_t *count, size_t toremove) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3); int virInsertElementsN(void *ptrptr, size_t size, size_t at, size_t *count= ptr, --=20 2.31.0 From nobody Sun Apr 28 04:45:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1616197059; cv=none; d=zohomail.com; s=zohoarc; b=Y6Nkp4CVg5G30ZMmIbJZhsvZUlJ6I329VJaoFs/0MFQ+gnSoQ51z8BIgdvVvRK+IUbzO7lQE0Eil+rcHmC94LXSxRfwGecWwhWt7nlL1qnuQzALtZDwi05BZyS1ZlomFvkYVggaNRfX83HhtioSqjLcIB9kyKbFVs4VapysUoyQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616197059; 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=Zu3MXYv2D+gHiJxl+bKhfMkNFXDIF9EB+v+mbmCJK1w=; b=k92O6LhYNOL3N6wHLjBvLuM0kpXCBO0RtPY6nxR28f8xVM6U6ObyxohLy9rBIH/smVGS2kaJVxGWtBKHoRoIRELQplPR9nVT5zEAXwExOiukdLay2O/x3G4H5RrfVnF4c0DShSymbsol+Dxma3tLU5UbsK0CYitZf3ZM7yqxxis= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 1616197059898144.4176770658072; Fri, 19 Mar 2021 16:37:39 -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-522-D-4QLNzbNJC_DSF7fPCoLw-1; Fri, 19 Mar 2021 19:37:36 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 137DB1034B34; Fri, 19 Mar 2021 23:37:31 +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 DCD3619D9D; Fri, 19 Mar 2021 23:37:30 +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 A027C4A7CD; Fri, 19 Mar 2021 23:37:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 12JNbGeV029466 for ; Fri, 19 Mar 2021 19:37:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 872A260C04; Fri, 19 Mar 2021 23:37:16 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.40.194.173]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0A2D060C17 for ; Fri, 19 Mar 2021 23:37:08 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 6D095244031; Sat, 20 Mar 2021 00:37:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616197058; 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=Zu3MXYv2D+gHiJxl+bKhfMkNFXDIF9EB+v+mbmCJK1w=; b=Plv8zD4so/UeAfVFg4l5xGliswdVPPxdDO2lc2ZCl4ur+ysOHuupEd+TANKGiOEqvO2FeD zzlJZX8uaEtc+DSKsAfTPTy5z6uS2rteYDytMcyqf1JgWX8EHa17T/fiCiit5MKd36Ey5F McuDQdAEz4sET/B+ipGR3Cm+i8uXU/s= X-MC-Unique: D-4QLNzbNJC_DSF7fPCoLw-1 From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH 2/7] Do not check return value of VIR_RESIZE_N Date: Sat, 20 Mar 2021 00:37:01 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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.84 on 10.5.11.23 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiri Denemark Reviewed-by: Michal Privoznik --- src/bhyve/bhyve_capabilities.c | 5 +---- src/bhyve/bhyve_parse_command.c | 11 ++-------- src/conf/capabilities.c | 36 ++++++++------------------------- src/conf/cpu_conf.c | 11 ++-------- src/conf/domain_capabilities.c | 5 ++--- src/esx/esx_driver.c | 3 +-- src/hyperv/hyperv_driver.c | 3 +-- src/qemu/qemu_domain.c | 13 +++++------- src/util/virbitmap.c | 5 ++--- src/util/vircommand.c | 16 +++++++-------- src/util/virfile.c | 3 +-- src/util/virfirewall.c | 5 +---- src/util/virnetlink.c | 7 +++---- src/util/virtypedparam-public.c | 24 ++++++++-------------- src/util/virtypedparam.c | 6 ++---- src/util/viruri.c | 8 +------- src/util/virutil.c | 14 ++++--------- tests/viralloctest.c | 3 +-- 18 files changed, 53 insertions(+), 125 deletions(-) diff --git a/src/bhyve/bhyve_capabilities.c b/src/bhyve/bhyve_capabilities.c index e9b4e5176d..efd6a59aec 100644 --- a/src/bhyve/bhyve_capabilities.c +++ b/src/bhyve/bhyve_capabilities.c @@ -154,10 +154,7 @@ virBhyveDomainCapsBuild(bhyveConnPtr conn, =20 if (virDirOpenIfExists(&dir, firmware_dir) > 0) { while ((virDirRead(dir, &entry, firmware_dir)) > 0) { - if (VIR_RESIZE_N(firmwares->values, - firmwares_alloc, firmwares->nvalues, 1) < 0) - goto cleanup; - + VIR_RESIZE_N(firmwares->values, firmwares_alloc, firmwares->nv= alues, 1); firmwares->values[firmwares->nvalues] =3D g_strdup_printf("%s/= %s", firmware_dir, entry->d= _name); firmwares->nvalues++; diff --git a/src/bhyve/bhyve_parse_command.c b/src/bhyve/bhyve_parse_comman= d.c index 2762b7e921..8d9a21e671 100644 --- a/src/bhyve/bhyve_parse_command.c +++ b/src/bhyve/bhyve_parse_command.c @@ -153,10 +153,7 @@ bhyveCommandLineToArgv(const char *nativeConfig, else line =3D g_strdup(curr); =20 - if (VIR_RESIZE_N(lines, lines_alloc, line_count, 2) < 0) { - VIR_FREE(line); - goto error; - } + VIR_RESIZE_N(lines, lines_alloc, line_count, 2); =20 if (*line) lines[line_count++] =3D line; @@ -203,11 +200,7 @@ bhyveCommandLineToArgv(const char *nativeConfig, if (next && (*next =3D=3D '\'' || *next =3D=3D '"')) next++; =20 - if (VIR_RESIZE_N(arglist, args_alloc, args_count, 2) < 0) { - VIR_FREE(arg); - goto error; - } - + VIR_RESIZE_N(arglist, args_alloc, args_count, 2); arglist[args_count++] =3D arg; arglist[args_count] =3D NULL; =20 diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index f610975ae5..14f0d48930 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -280,10 +280,8 @@ int virCapabilitiesAddHostFeature(virCapsPtr caps, const char *name) { - if (VIR_RESIZE_N(caps->host.features, caps->host.nfeatures_max, - caps->host.nfeatures, 1) < 0) - return -1; - + VIR_RESIZE_N(caps->host.features, caps->host.nfeatures_max, + caps->host.nfeatures, 1); caps->host.features[caps->host.nfeatures] =3D g_strdup(name); caps->host.nfeatures++; =20 @@ -301,10 +299,8 @@ int virCapabilitiesAddHostMigrateTransport(virCapsPtr caps, const char *name) { - if (VIR_RESIZE_N(caps->host.migrateTrans, caps->host.nmigrateTrans_max, - caps->host.nmigrateTrans, 1) < 0) - return -1; - + VIR_RESIZE_N(caps->host.migrateTrans, caps->host.nmigrateTrans_max, + caps->host.nmigrateTrans, 1); caps->host.migrateTrans[caps->host.nmigrateTrans] =3D g_strdup(name); caps->host.nmigrateTrans++; =20 @@ -447,9 +443,7 @@ virCapabilitiesAddGuest(virCapsPtr caps, guest->arch.defaultInfo.emulator =3D g_strdup(emulator); guest->arch.defaultInfo.loader =3D g_strdup(loader); =20 - if (VIR_RESIZE_N(caps->guests, caps->nguests_max, - caps->nguests, 1) < 0) - goto error; + VIR_RESIZE_N(caps->guests, caps->nguests_max, caps->nguests, 1); caps->guests[caps->nguests++] =3D guest; =20 if (nmachines) { @@ -458,10 +452,6 @@ virCapabilitiesAddGuest(virCapsPtr caps, } =20 return guest; - - error: - virCapabilitiesFreeGuest(guest); - return NULL; } =20 =20 @@ -493,9 +483,8 @@ virCapabilitiesAddGuestDomain(virCapsGuestPtr guest, dom->info.emulator =3D g_strdup(emulator); dom->info.loader =3D g_strdup(loader); =20 - if (VIR_RESIZE_N(guest->arch.domains, guest->arch.ndomains_max, - guest->arch.ndomains, 1) < 0) - goto error; + VIR_RESIZE_N(guest->arch.domains, guest->arch.ndomains_max, + guest->arch.ndomains, 1); guest->arch.domains[guest->arch.ndomains] =3D dom; guest->arch.ndomains++; =20 @@ -505,10 +494,6 @@ virCapabilitiesAddGuestDomain(virCapsGuestPtr guest, } =20 return dom; - - error: - virCapabilitiesFreeGuestDomain(dom); - return NULL; } =20 =20 @@ -803,15 +788,10 @@ virCapabilitiesAddStoragePool(virCapsPtr caps, =20 pool->type =3D poolType; =20 - if (VIR_RESIZE_N(caps->pools, caps->npools_max, caps->npools, 1) < 0) - goto error; + VIR_RESIZE_N(caps->pools, caps->npools_max, caps->npools, 1); caps->pools[caps->npools++] =3D pool; =20 return 0; - - error: - virCapabilitiesFreeStoragePool(pool); - return -1; } =20 =20 diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index 8d800bd80d..380a74691d 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -593,10 +593,7 @@ virCPUDefParseXML(xmlXPathContextPtr ctxt, return -1; } =20 - if (VIR_RESIZE_N(def->features, def->nfeatures_max, - def->nfeatures, n) < 0) - return -1; - + VIR_RESIZE_N(def->features, def->nfeatures_max, def->nfeatures, n); def->nfeatures =3D n; } =20 @@ -898,12 +895,8 @@ virCPUDefAddFeatureInternal(virCPUDefPtr def, } } =20 - if (VIR_RESIZE_N(def->features, def->nfeatures_max, - def->nfeatures, 1) < 0) - return -1; - + VIR_RESIZE_N(def->features, def->nfeatures_max, def->nfeatures, 1); def->features[def->nfeatures].name =3D g_strdup(name); - def->features[def->nfeatures].policy =3D policy; def->nfeatures++; =20 diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c index fc48cc3fba..e0d7eddd2c 100644 --- a/src/conf/domain_capabilities.c +++ b/src/conf/domain_capabilities.c @@ -191,9 +191,8 @@ virDomainCapsCPUModelsAdd(virDomainCapsCPUModelsPtr cpu= Models, =20 nameCopy =3D g_strdup(name); =20 - if (VIR_RESIZE_N(cpuModels->models, cpuModels->nmodels_max, - cpuModels->nmodels, 1) < 0) - return -1; + VIR_RESIZE_N(cpuModels->models, cpuModels->nmodels_max, + cpuModels->nmodels, 1); =20 cpu =3D cpuModels->models + cpuModels->nmodels; cpuModels->nmodels++; diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 96cc8bda0d..9d73bc6de8 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -4917,8 +4917,7 @@ esxConnectListAllDomains(virConnectPtr conn, continue; } =20 - if (VIR_RESIZE_N(doms, ndoms, count, 2) < 0) - goto cleanup; + VIR_RESIZE_N(doms, ndoms, count, 2); =20 /* Only running/suspended virtual machines have an ID !=3D -1 */ if (powerState =3D=3D esxVI_VirtualMachinePowerState_PoweredOff) diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index e4f537bd12..17f5be1f0d 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -3524,8 +3524,7 @@ hypervConnectListAllDomains(virConnectPtr conn, continue; } =20 - if (VIR_RESIZE_N(doms, ndoms, count, 2) < 0) - goto cleanup; + VIR_RESIZE_N(doms, ndoms, count, 2); =20 domain =3D NULL; =20 diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index fff67481a7..3b54adc614 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4287,10 +4287,8 @@ qemuDomainDefCPUPostParse(virDomainDefPtr def, sveFeature->policy =3D VIR_CPU_FEATURE_REQUIRE; } } else { - if (VIR_RESIZE_N(def->cpu->features, def->cpu->nfeatures_max, - def->cpu->nfeatures, 1) < 0) { - return -1; - } + VIR_RESIZE_N(def->cpu->features, def->cpu->nfeatures_max, + def->cpu->nfeatures, 1); =20 def->cpu->features[def->cpu->nfeatures].name =3D g_strdup("sve= "); def->cpu->features[def->cpu->nfeatures].policy =3D VIR_CPU_FEA= TURE_REQUIRE; @@ -7340,10 +7338,9 @@ qemuDomainCleanupAdd(virDomainObjPtr vm, return 0; } =20 - if (VIR_RESIZE_N(priv->cleanupCallbacks, - priv->ncleanupCallbacks_max, - priv->ncleanupCallbacks, 1) < 0) - return -1; + VIR_RESIZE_N(priv->cleanupCallbacks, + priv->ncleanupCallbacks_max, + priv->ncleanupCallbacks, 1); =20 priv->cleanupCallbacks[priv->ncleanupCallbacks++] =3D cb; return 0; diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c index b2569b0b03..9242af6fb5 100644 --- a/src/util/virbitmap.c +++ b/src/util/virbitmap.c @@ -139,9 +139,8 @@ virBitmapExpand(virBitmapPtr map, =20 /* resize the memory if necessary */ if (map->map_len < new_len) { - if (VIR_RESIZE_N(map->map, map->map_alloc, map->map_len, - new_len - map->map_len) < 0) - return -1; + VIR_RESIZE_N(map->map, map->map_alloc, map->map_len, + new_len - map->map_len); } =20 map->nbits =3D b + 1; diff --git a/src/util/vircommand.c b/src/util/vircommand.c index 99bb8b6506..d647463f35 100644 --- a/src/util/vircommand.c +++ b/src/util/vircommand.c @@ -1358,7 +1358,7 @@ virCommandAddEnv(virCommandPtr cmd, } =20 /* Arg plus trailing NULL. */ - ignore_value(VIR_RESIZE_N(cmd->env, cmd->maxenv, cmd->nenv, 1 + 1)); + VIR_RESIZE_N(cmd->env, cmd->maxenv, cmd->nenv, 1 + 1); =20 cmd->env[cmd->nenv++] =3D g_steal_pointer(&env); } @@ -1459,7 +1459,7 @@ virCommandAddEnvPassCommon(virCommandPtr cmd) if (virCommandHasError(cmd)) return; =20 - ignore_value(VIR_RESIZE_N(cmd->env, cmd->maxenv, cmd->nenv, 9)); + VIR_RESIZE_N(cmd->env, cmd->maxenv, cmd->nenv, 9); =20 virCommandAddEnvPair(cmd, "LC_ALL", "C"); =20 @@ -1479,7 +1479,7 @@ virCommandAddEnvXDG(virCommandPtr cmd, const char *ba= seDir) if (virCommandHasError(cmd)) return; =20 - ignore_value(VIR_RESIZE_N(cmd->env, cmd->maxenv, cmd->nenv, 3)); + VIR_RESIZE_N(cmd->env, cmd->maxenv, cmd->nenv, 3); =20 virCommandAddEnvFormat(cmd, "XDG_DATA_HOME=3D%s/%s", baseDir, ".local/share"); @@ -1509,7 +1509,7 @@ virCommandAddArg(virCommandPtr cmd, const char *val) } =20 /* Arg plus trailing NULL. */ - ignore_value(VIR_RESIZE_N(cmd->args, cmd->maxargs, cmd->nargs, 1 + 1)); + VIR_RESIZE_N(cmd->args, cmd->maxargs, cmd->nargs, 1 + 1); =20 cmd->args[cmd->nargs++] =3D g_strdup(val); } @@ -1535,7 +1535,7 @@ virCommandAddArgBuffer(virCommandPtr cmd, virBufferPt= r buf) str =3D g_strdup(""); =20 /* Arg plus trailing NULL. */ - ignore_value(VIR_RESIZE_N(cmd->args, cmd->maxargs, cmd->nargs, 1 + 1)); + VIR_RESIZE_N(cmd->args, cmd->maxargs, cmd->nargs, 1 + 1); =20 cmd->args[cmd->nargs] =3D g_steal_pointer(&str); cmd->nargs++; @@ -1564,7 +1564,7 @@ virCommandAddArgFormat(virCommandPtr cmd, const char = *format, ...) va_end(list); =20 /* Arg plus trailing NULL. */ - ignore_value(VIR_RESIZE_N(cmd->args, cmd->maxargs, cmd->nargs, 1 + 1)); + VIR_RESIZE_N(cmd->args, cmd->maxargs, cmd->nargs, 1 + 1); =20 cmd->args[cmd->nargs++] =3D arg; } @@ -1611,7 +1611,7 @@ virCommandAddArgSet(virCommandPtr cmd, const char *co= nst*vals) narg++; =20 /* narg plus trailing NULL. */ - ignore_value(VIR_RESIZE_N(cmd->args, cmd->maxargs, cmd->nargs, narg + = 1)); + VIR_RESIZE_N(cmd->args, cmd->maxargs, cmd->nargs, narg + 1); =20 narg =3D 0; while (vals[narg] !=3D NULL) { @@ -1644,7 +1644,7 @@ virCommandAddArgList(virCommandPtr cmd, ...) va_end(list); =20 /* narg plus trailing NULL. */ - ignore_value(VIR_RESIZE_N(cmd->args, cmd->maxargs, cmd->nargs, narg + = 1)); + VIR_RESIZE_N(cmd->args, cmd->maxargs, cmd->nargs, narg + 1); =20 va_start(list, cmd); while (1) { diff --git a/src/util/virfile.c b/src/util/virfile.c index 180f2af405..56d6e0605e 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -3123,8 +3123,7 @@ virFileOpenTty(int *ttyprimary, char **ttyName, int r= awmode) 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) - goto cleanup; + VIR_RESIZE_N(name, len, len, len); } if (rc !=3D 0) { errno =3D rc; diff --git a/src/util/virfirewall.c b/src/util/virfirewall.c index 0dc0cecd53..dd3e104dbe 100644 --- a/src/util/virfirewall.c +++ b/src/util/virfirewall.c @@ -262,10 +262,7 @@ void virFirewallFree(virFirewallPtr firewall) =20 #define ADD_ARG(rule, str) \ do { \ - ignore_value(VIR_RESIZE_N(rule->args, \ - rule->argsAlloc, \ - rule->argsLen, 1)); \ - \ + VIR_RESIZE_N(rule->args, rule->argsAlloc, rule->argsLen, 1); \ rule->args[rule->argsLen++] =3D g_strdup(str); \ } while (0) =20 diff --git a/src/util/virnetlink.c b/src/util/virnetlink.c index cfb86550a5..c26c03de32 100644 --- a/src/util/virnetlink.c +++ b/src/util/virnetlink.c @@ -1146,9 +1146,8 @@ virNetlinkEventAddClient(virNetlinkEventHandleCallbac= k handleCB, if (srv->handlesCount =3D=3D srv->handlesAlloc) { VIR_DEBUG("Used %zu handle slots, adding at least %d more", srv->handlesAlloc, NETLINK_EVENT_ALLOC_EXTENT); - if (VIR_RESIZE_N(srv->handles, srv->handlesAlloc, - srv->handlesCount, NETLINK_EVENT_ALLOC_EXTENT) < = 0) - goto error; + VIR_RESIZE_N(srv->handles, srv->handlesAlloc, + srv->handlesCount, NETLINK_EVENT_ALLOC_EXTENT); } r =3D srv->handlesCount++; =20 @@ -1167,7 +1166,7 @@ virNetlinkEventAddClient(virNetlinkEventHandleCallbac= k handleCB, VIR_DEBUG("added client to loop slot: %d. with macaddr ptr=3D%p", r, m= acaddr); =20 ret =3D nextWatch++; - error: + virNetlinkEventServerUnlock(srv); return ret; } diff --git a/src/util/virtypedparam-public.c b/src/util/virtypedparam-publi= c.c index 91603cfe1c..4cb54f7ab1 100644 --- a/src/util/virtypedparam-public.c +++ b/src/util/virtypedparam-public.c @@ -446,8 +446,7 @@ virTypedParamsAddInt(virTypedParameterPtr *params, =20 virResetLastError(); =20 - if (VIR_RESIZE_N(*params, max, n, 1) < 0) - goto error; + VIR_RESIZE_N(*params, max, n, 1); *maxparams =3D max; =20 if (virTypedParameterAssign(*params + n, name, @@ -493,8 +492,7 @@ virTypedParamsAddUInt(virTypedParameterPtr *params, =20 virResetLastError(); =20 - if (VIR_RESIZE_N(*params, max, n, 1) < 0) - goto error; + VIR_RESIZE_N(*params, max, n, 1); *maxparams =3D max; =20 if (virTypedParameterAssign(*params + n, name, @@ -540,8 +538,7 @@ virTypedParamsAddLLong(virTypedParameterPtr *params, =20 virResetLastError(); =20 - if (VIR_RESIZE_N(*params, max, n, 1) < 0) - goto error; + VIR_RESIZE_N(*params, max, n, 1); *maxparams =3D max; =20 if (virTypedParameterAssign(*params + n, name, @@ -587,8 +584,7 @@ virTypedParamsAddULLong(virTypedParameterPtr *params, =20 virResetLastError(); =20 - if (VIR_RESIZE_N(*params, max, n, 1) < 0) - goto error; + VIR_RESIZE_N(*params, max, n, 1); *maxparams =3D max; =20 if (virTypedParameterAssign(*params + n, name, @@ -634,8 +630,7 @@ virTypedParamsAddDouble(virTypedParameterPtr *params, =20 virResetLastError(); =20 - if (VIR_RESIZE_N(*params, max, n, 1) < 0) - goto error; + VIR_RESIZE_N(*params, max, n, 1); *maxparams =3D max; =20 if (virTypedParameterAssign(*params + n, name, @@ -681,8 +676,7 @@ virTypedParamsAddBoolean(virTypedParameterPtr *params, =20 virResetLastError(); =20 - if (VIR_RESIZE_N(*params, max, n, 1) < 0) - goto error; + VIR_RESIZE_N(*params, max, n, 1); *maxparams =3D max; =20 if (virTypedParameterAssign(*params + n, name, @@ -731,8 +725,7 @@ virTypedParamsAddString(virTypedParameterPtr *params, =20 virResetLastError(); =20 - if (VIR_RESIZE_N(*params, max, n, 1) < 0) - goto error; + VIR_RESIZE_N(*params, max, n, 1); *maxparams =3D max; =20 str =3D g_strdup(value); @@ -823,8 +816,7 @@ virTypedParamsAddFromString(virTypedParameterPtr *param= s, =20 virResetLastError(); =20 - if (VIR_RESIZE_N(*params, max, n, 1) < 0) - goto error; + VIR_RESIZE_N(*params, max, n, 1); *maxparams =3D max; =20 if (virTypedParameterAssignFromStr(*params + n, name, type, value) < 0) diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c index c4c26a1183..1b89233012 100644 --- a/src/util/virtypedparam.c +++ b/src/util/virtypedparam.c @@ -77,8 +77,7 @@ virTypedParamsValidate(virTypedParameterPtr params, int n= params, ...) name =3D va_arg(ap, const char *); while (name) { type =3D va_arg(ap, int); - if (VIR_RESIZE_N(keys, nkeysalloc, nkeys, 1) < 0) - goto cleanup; + VIR_RESIZE_N(keys, nkeysalloc, nkeys, 1); =20 if (virStrcpyStatic(keys[nkeys].field, name) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -758,8 +757,7 @@ virTypedParamSetNameVPrintf(virTypedParameterPtr par, static virTypedParameterPtr virTypedParamListExtend(virTypedParamListPtr list) { - if (VIR_RESIZE_N(list->par, list->par_alloc, list->npar, 1) < 0) - return NULL; + VIR_RESIZE_N(list->par, list->par_alloc, list->npar, 1); =20 list->npar++; =20 diff --git a/src/util/viruri.c b/src/util/viruri.c index 1e8808ddc6..90594fce5e 100644 --- a/src/util/viruri.c +++ b/src/util/viruri.c @@ -45,8 +45,7 @@ virURIParamAppend(virURIPtr uri, pname =3D g_strdup(name); pvalue =3D g_strdup(value); =20 - if (VIR_RESIZE_N(uri->params, uri->paramsAlloc, uri->paramsCount, 1) <= 0) - goto error; + VIR_RESIZE_N(uri->params, uri->paramsAlloc, uri->paramsCount, 1); =20 uri->params[uri->paramsCount].name =3D pname; uri->params[uri->paramsCount].value =3D pvalue; @@ -54,11 +53,6 @@ virURIParamAppend(virURIPtr uri, uri->paramsCount++; =20 return 0; - - error: - VIR_FREE(pname); - VIR_FREE(pvalue); - return -1; } =20 =20 diff --git a/src/util/virutil.c b/src/util/virutil.c index 118ceec0db..3f49a469e5 100644 --- a/src/util/virutil.c +++ b/src/util/virutil.c @@ -618,8 +618,7 @@ virGetUserEnt(uid_t uid, char **name, gid_t *group, cha= r **dir, char **shell, bo * The given name or uid was not found. */ while ((rc =3D getpwuid_r(uid, &pwbuf, strbuf, strbuflen, &pw)) =3D=3D= ERANGE) { - if (VIR_RESIZE_N(strbuf, strbuflen, strbuflen, strbuflen) < 0) - goto cleanup; + VIR_RESIZE_N(strbuf, strbuflen, strbuflen, strbuflen); } =20 if (rc !=3D 0) { @@ -687,10 +686,7 @@ static char *virGetGroupEnt(gid_t gid) * The given name or gid was not found. */ while ((rc =3D getgrgid_r(gid, &grbuf, strbuf, strbuflen, &gr)) =3D=3D= ERANGE) { - if (VIR_RESIZE_N(strbuf, strbuflen, strbuflen, strbuflen) < 0) { - VIR_FREE(strbuf); - return NULL; - } + VIR_RESIZE_N(strbuf, strbuflen, strbuflen, strbuflen); } if (rc !=3D 0 || gr =3D=3D NULL) { if (rc !=3D 0) { @@ -765,8 +761,7 @@ virGetUserIDByName(const char *name, uid_t *uid, bool m= issing_ok) strbuf =3D g_new0(char, strbuflen); =20 while ((rc =3D getpwnam_r(name, &pwbuf, strbuf, strbuflen, &pw)) =3D= =3D ERANGE) { - if (VIR_RESIZE_N(strbuf, strbuflen, strbuflen, strbuflen) < 0) - goto cleanup; + VIR_RESIZE_N(strbuf, strbuflen, strbuflen, strbuflen); } =20 if (!pw) { @@ -846,8 +841,7 @@ virGetGroupIDByName(const char *name, gid_t *gid, bool = missing_ok) strbuf =3D g_new0(char, strbuflen); =20 while ((rc =3D getgrnam_r(name, &grbuf, strbuf, strbuflen, &gr)) =3D= =3D ERANGE) { - if (VIR_RESIZE_N(strbuf, strbuflen, strbuflen, strbuflen) < 0) - goto cleanup; + VIR_RESIZE_N(strbuf, strbuflen, strbuflen, strbuflen); } =20 if (!gr) { diff --git a/tests/viralloctest.c b/tests/viralloctest.c index 0867be8ce1..4794fd7f93 100644 --- a/tests/viralloctest.c +++ b/tests/viralloctest.c @@ -214,8 +214,7 @@ testResizeArray(const void *opaque G_GNUC_UNUSED) t[i].b =3D 20; } =20 - if (VIR_RESIZE_N(t, at, nt, 8) < 0) - goto cleanup; + VIR_RESIZE_N(t, at, nt, 8); =20 if (testCheckNonNull(t) < 0) goto cleanup; --=20 2.31.0 From nobody Sun Apr 28 04:45:17 2024 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=1616197063; cv=none; d=zohomail.com; s=zohoarc; b=YfdvDoqWP8VEngjdzYAL9IJ1RnVY8OBsvGwtR0/CjJ5mQeM7Ro9K0Vpd06uxw6An0BbofIruOHR+Cnetn4tDjQx895EuErIlWJaKJRn2IDeYws6OZETv/wnVrnLYH+GtVo7xbCbnvze2Oo9C62xcCGMQBQ+VleIXRl6qeuThKAM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616197063; 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=u+CZd/vBadVFjzwc367zQwujkMAOD85Us2Va6JDOYz0=; b=S0s0WgH1S2rJKSCSE9tpmESOXC1sHPmU9swqXze2XzzCUihcE//W5VGdi6JsqC84M1pndi/PpUH8S/X4v8ybZrXNOTbgKDNxpPIy6mT9d7OpgGC2WYAhaU4KnTd0nl98JUFK5XYTweBnIcTq9ukRuEyNzsS8KLlGJHGFWswgAG8= 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 1616197063644924.5211536613643; Fri, 19 Mar 2021 16:37:43 -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-213-Dwdz7jsgPvqaL2rk39ApRA-1; Fri, 19 Mar 2021 19:37:39 -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 A0D04108BD06; Fri, 19 Mar 2021 23:37:33 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7B64D2915F; Fri, 19 Mar 2021 23:37:33 +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 42647180B450; Fri, 19 Mar 2021 23:37:33 +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 12JNbCn0029427 for ; Fri, 19 Mar 2021 19:37:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8E7CB5C1D1; Fri, 19 Mar 2021 23:37:12 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.40.194.173]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 618E55C1BB for ; Fri, 19 Mar 2021 23:37:08 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 6F145244032; Sat, 20 Mar 2021 00:37:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616197062; 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=u+CZd/vBadVFjzwc367zQwujkMAOD85Us2Va6JDOYz0=; b=OMXGRHRQ/cNATCMYgvCLhTeEKRa1TIqQ/7o93CaxFGjW1n/qDD3L5ExIZM07AGFmZ/I7To dU9xniMOi5NPNs2aSwFnqzCMF6AXzcTtSJGEKyV1Cz3nVQV9pDC1xjnCD3RP2n07dJQ8ib hR74h+xIebGuDZfnkW6hBoO8Umf6dR8= X-MC-Unique: Dwdz7jsgPvqaL2rk39ApRA-1 From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH 3/7] util: Make virResizeN return void Date: Sat, 20 Mar 2021 00:37:02 +0100 Message-Id: <91f528d027c549f4430de5fdc34b373f9ae05146.1616196713.git.jdenemar@redhat.com> 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiri Denemark Reviewed-by: Michal Privoznik --- src/util/viralloc.c | 17 +++++++++-------- src/util/viralloc.h | 4 ++-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/util/viralloc.c b/src/util/viralloc.c index 1317537c8a..cd770eb601 100644 --- a/src/util/viralloc.c +++ b/src/util/viralloc.c @@ -98,13 +98,13 @@ int virExpandN(void *ptrptr, * failure, 'ptrptr' and 'allocptr' are not changed. Any newly * allocated memory in 'ptrptr' is zero-filled. * - * Returns zero on success, aborts on OOM + * Aborts on OOM */ -int virResizeN(void *ptrptr, - size_t size, - size_t *allocptr, - size_t count, - size_t add) +void virResizeN(void *ptrptr, + size_t size, + size_t *allocptr, + size_t count, + size_t add) { size_t delta; =20 @@ -112,12 +112,13 @@ int virResizeN(void *ptrptr, abort(); =20 if (count + add <=3D *allocptr) - return 0; + return; =20 delta =3D count + add - *allocptr; if (delta < *allocptr / 2) delta =3D *allocptr / 2; - return virExpandN(ptrptr, size, allocptr, delta); + + virExpandN(ptrptr, size, allocptr, delta); } =20 /** diff --git a/src/util/viralloc.h b/src/util/viralloc.h index d656d4ba0e..878c9485cf 100644 --- a/src/util/viralloc.h +++ b/src/util/viralloc.h @@ -38,7 +38,7 @@ int virReallocN(void *ptrptr, size_t size, size_t count) ATTRIBUTE_NONNULL(1); int virExpandN(void *ptrptr, size_t size, size_t *count, size_t add) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3); -int virResizeN(void *ptrptr, size_t size, size_t *alloc, size_t count, siz= e_t desired) +void virResizeN(void *ptrptr, size_t size, size_t *alloc, size_t count, si= ze_t desired) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3); void virShrinkN(void *ptrptr, size_t size, size_t *count, size_t toremove) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3); @@ -102,7 +102,7 @@ int virDeleteElementsN(void *ptrptr, size_t size, size_= t at, size_t *countptr, * * This macro is safe to use on arguments with side effects. * - * Returns 0 on success, aborts on OOM + * Aborts on OOM */ #define VIR_RESIZE_N(ptr, alloc, count, add) \ virResizeN(&(ptr), sizeof(*(ptr)), &(alloc), count, add) --=20 2.31.0 From nobody Sun Apr 28 04:45:17 2024 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=1616197066; cv=none; d=zohomail.com; s=zohoarc; b=Zd85sdpWl7dr/ZsLBsx0YzIC0RObYu5abZZhjS5SFHR5+1Kl8TCcawARNM/p6YHW+FvvnmhGpNHYAejBavNIA+wj0gY3Ialxu+ga/q5qQGJtrnyeDoDKf7gfOrdgj7/sl/M5KVmgxKJaUhpg3fJ3tEpHIZPWZEA1Vi/X3l4jXD8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616197066; 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=5qSIGB/AW2O3mv7xmQsgpXp7HcnV/hbTz2xii9JDsB0=; b=a12OpJfgeLnfpbStULyFyIJF2d/A/Ez7BNP7cxaRC5udZao/TPWoKjjAWmSz2rnNdsHkbQON4YGEQaG1kxzO/MYacRYCmX1KWQ4Cywwnl5Jh8UKh0mOZp+L00GhOmukYJnua4maiHg7ohqhPqR4fYWUSfDdQTaGkRDYeQFjkvIQ= 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 1616197066696313.7686034102202; Fri, 19 Mar 2021 16:37:46 -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-99-gXsRbwlfMQKqD6yLYBglyg-1; Fri, 19 Mar 2021 19:37:42 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B9A269120F; Fri, 19 Mar 2021 23:37:36 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 90E061001B2C; Fri, 19 Mar 2021 23:37:36 +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 53F951802137; Fri, 19 Mar 2021 23:37:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 12JNbCfs029432 for ; Fri, 19 Mar 2021 19:37:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id A284F2BFE2; Fri, 19 Mar 2021 23:37:12 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.40.194.173]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F17B663B8C for ; Fri, 19 Mar 2021 23:37:08 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 727A0244033; Sat, 20 Mar 2021 00:37:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616197065; 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=5qSIGB/AW2O3mv7xmQsgpXp7HcnV/hbTz2xii9JDsB0=; b=bcdZ8Xw0LOJi6c20FOTUd8TGwM3KE3lgTpDPS8+B7IFipr446cGNIxkhRIYUC2selD75hd /lD0XmMukcXy63fuP0D3QfX+WwqCy6ON/iSon4kmM8xoRqbpex0DncaFMauqgFzbba3YVU xkXxRQ9TX2iqgIICLcQanS4g43fR8d4= X-MC-Unique: gXsRbwlfMQKqD6yLYBglyg-1 From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH 4/7] Do not check return value of VIR_EXPAND_N Date: Sat, 20 Mar 2021 00:37:03 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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.84 on 10.5.11.22 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiri Denemark Reviewed-by: Michal Privoznik --- src/access/viraccessdriverstack.c | 3 +- src/conf/backup_conf.c | 3 +- src/conf/capabilities.c | 4 +- src/conf/domain_addr.c | 6 +-- src/conf/domain_conf.c | 3 +- src/conf/nwfilter_conf.c | 6 +-- src/conf/nwfilter_params.c | 8 +--- src/esx/esx_driver.c | 4 +- src/hyperv/hyperv_wmi.c | 3 +- src/hypervisor/domain_driver.c | 3 +- src/hypervisor/virclosecallbacks.c | 2 +- src/libxl/libxl_conf.c | 9 ++-- src/libxl/xen_common.c | 6 +-- src/locking/lock_driver_lockd.c | 4 +- src/lxc/lxc_controller.c | 18 ++------ src/lxc/lxc_native.c | 33 +++++---------- src/qemu/qemu_agent.c | 7 +--- src/qemu/qemu_capabilities.c | 3 +- src/qemu/qemu_conf.c | 6 +-- src/rpc/virnetclient.c | 16 +------ src/rpc/virnetdaemon.c | 3 +- src/rpc/virnetlibsshsession.c | 8 +--- src/rpc/virnetserver.c | 19 ++------- src/rpc/virnetsocket.c | 3 +- src/rpc/virnetsshsession.c | 8 +--- src/storage/storage_backend_rbd.c | 3 +- .../storage_file_backend_gluster.c | 3 +- .../storage_source_backingstore.c | 3 +- src/util/vircommand.c | 2 +- src/util/virfile.c | 14 ++----- src/util/virfirewall.c | 3 +- src/util/virlockspace.c | 7 +--- src/util/virprocess.c | 17 +------- src/util/virresctrl.c | 42 ++++++++----------- src/util/virstring.c | 6 +-- src/util/virsysinfo.c | 34 ++++----------- src/util/virsystemd.c | 3 +- src/util/virthreadpool.c | 3 +- src/util/virtypedparam.c | 3 +- src/vbox/vbox_snapshot_conf.c | 29 ++++--------- tests/qemudomaincheckpointxml2xmltest.c | 3 +- tests/qemumonitortestutils.c | 12 ++---- tests/securityselinuxlabeltest.c | 7 +--- tests/viralloctest.c | 3 +- tools/virsh-domain.c | 27 +++--------- 45 files changed, 106 insertions(+), 306 deletions(-) diff --git a/src/access/viraccessdriverstack.c b/src/access/viraccessdriver= stack.c index 238caef115..0f0858e96e 100644 --- a/src/access/viraccessdriverstack.c +++ b/src/access/viraccessdriverstack.c @@ -40,8 +40,7 @@ int virAccessDriverStackAppend(virAccessManagerPtr manage= r, { virAccessDriverStackPrivatePtr priv =3D virAccessManagerGetPrivateData= (manager); =20 - if (VIR_EXPAND_N(priv->managers, priv->managersLen, 1) < 0) - return -1; + VIR_EXPAND_N(priv->managers, priv->managersLen, 1); =20 priv->managers[priv->managersLen-1] =3D child; =20 diff --git a/src/conf/backup_conf.c b/src/conf/backup_conf.c index ba58b2e322..2d6d2d99f4 100644 --- a/src/conf/backup_conf.c +++ b/src/conf/backup_conf.c @@ -554,8 +554,7 @@ virDomainBackupAlignDisks(virDomainBackupDefPtr def, backup_all =3D true; =20 ndisks =3D def->ndisks; - if (VIR_EXPAND_N(def->disks, def->ndisks, dom->ndisks - def->ndisks) <= 0) - return -1; + VIR_EXPAND_N(def->disks, def->ndisks, dom->ndisks - def->ndisks); =20 for (i =3D 0; i < dom->ndisks; i++) { virDomainBackupDiskDefPtr backupdisk =3D NULL; diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index 14f0d48930..bc9035afae 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -580,9 +580,7 @@ virCapabilitiesHostSecModelAddBaseLabel(virCapsHostSecM= odelPtr secmodel, if (type =3D=3D NULL || label =3D=3D NULL) return -1; =20 - if (VIR_EXPAND_N(secmodel->labels, secmodel->nlabels, 1) < 0) - return -1; - + VIR_EXPAND_N(secmodel->labels, secmodel->nlabels, 1); secmodel->labels[secmodel->nlabels - 1].type =3D g_strdup(type); secmodel->labels[secmodel->nlabels - 1].label =3D g_strdup(label); =20 diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c index 8b927689f8..9167b489d1 100644 --- a/src/conf/domain_addr.c +++ b/src/conf/domain_addr.c @@ -728,8 +728,7 @@ virDomainPCIAddressSetGrow(virDomainPCIAddressSetPtr ad= drs, =20 i =3D addrs->nbuses; =20 - if (VIR_EXPAND_N(addrs->buses, addrs->nbuses, add) < 0) - return -1; + VIR_EXPAND_N(addrs->buses, addrs->nbuses, add); =20 if (needDMIToPCIBridge) { /* first of the new buses is dmi-to-pci-bridge, the @@ -1985,8 +1984,7 @@ virDomainUSBAddressSetAddController(virDomainUSBAddre= ssSetPtr addrs, return 0; =20 if (addrs->nbuses <=3D cont->idx) { - if (VIR_EXPAND_N(addrs->buses, addrs->nbuses, cont->idx - addrs->n= buses + 1) < 0) - goto cleanup; + VIR_EXPAND_N(addrs->buses, addrs->nbuses, cont->idx - addrs->nbuse= s + 1); } else if (addrs->buses[cont->idx]) { virReportError(VIR_ERR_XML_ERROR, _("Duplicate USB controllers with index %u"), diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 7671050134..afbd6fc7c1 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2001,8 +2001,7 @@ virDomainDefSetVcpusMax(virDomainDefPtr def, return 0; =20 if (def->maxvcpus < maxvcpus) { - if (VIR_EXPAND_N(def->vcpus, def->maxvcpus, maxvcpus - def->maxvcp= us) < 0) - return -1; + VIR_EXPAND_N(def->vcpus, def->maxvcpus, maxvcpus - def->maxvcpus); =20 for (i =3D oldmax; i < def->maxvcpus; i++) { if (!(def->vcpus[i] =3D virDomainVcpuDefNew(xmlopt))) diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c index fbb87b7acf..3cc45394c0 100644 --- a/src/conf/nwfilter_conf.c +++ b/src/conf/nwfilter_conf.c @@ -381,11 +381,7 @@ virNWFilterRuleDefAddVar(virNWFilterRuleDefPtr nwf, } } =20 - if (VIR_EXPAND_N(nwf->varAccess, nwf->nVarAccess, 1) < 0) { - virNWFilterVarAccessFree(varAccess); - return -1; - } - + VIR_EXPAND_N(nwf->varAccess, nwf->nVarAccess, 1); nwf->varAccess[nwf->nVarAccess - 1] =3D varAccess; item->varAccess =3D varAccess; =20 diff --git a/src/conf/nwfilter_params.c b/src/conf/nwfilter_params.c index 5fa5d4fedb..825c151284 100644 --- a/src/conf/nwfilter_params.c +++ b/src/conf/nwfilter_params.c @@ -221,9 +221,7 @@ virNWFilterVarValueAddValue(virNWFilterVarValuePtr val,= char *value) break; =20 case NWFILTER_VALUE_TYPE_ARRAY: - if (VIR_EXPAND_N(val->u.array.values, - val->u.array.nValues, 1) < 0) - return -1; + VIR_EXPAND_N(val->u.array.values, val->u.array.nValues, 1); val->u.array.values[val->u.array.nValues - 1] =3D value; rc =3D 0; break; @@ -374,9 +372,7 @@ virNWFilterVarCombIterAddVariable(virNWFilterVarCombIte= rEntryPtr cie, } } =20 - if (VIR_EXPAND_N(cie->varNames, cie->nVarNames, 1) < 0) - return -1; - + VIR_EXPAND_N(cie->varNames, cie->nVarNames, 1); cie->varNames[cie->nVarNames - 1] =3D varName; =20 return 0; diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 9d73bc6de8..21705ef6e3 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -5144,9 +5144,7 @@ esxDomainInterfaceAddresses(virDomainPtr domain, continue; } =20 - if (VIR_EXPAND_N(ifaces_ret, ifaces_count, 1) < 0) - goto cleanup; - + VIR_EXPAND_N(ifaces_ret, ifaces_count, 1); ifaces_ret[ifaces_count - 1] =3D g_new0(virDomainInterface, 1); =20 iface =3D ifaces_ret[ifaces_count - 1]; diff --git a/src/hyperv/hyperv_wmi.c b/src/hyperv/hyperv_wmi.c index 2a898cdf03..6271e85cc6 100644 --- a/src/hyperv/hyperv_wmi.c +++ b/src/hyperv/hyperv_wmi.c @@ -189,8 +189,7 @@ static inline int hypervCheckParams(hypervInvokeParamsListPtr params) { if (params->nbParams + 1 > params->nbAvailParams) { - if (VIR_EXPAND_N(params->params, params->nbAvailParams, 5) < 0) - return -1; + VIR_EXPAND_N(params->params, params->nbAvailParams, 5); } =20 return 0; diff --git a/src/hypervisor/domain_driver.c b/src/hypervisor/domain_driver.c index ef5803ec2a..b861e0ef9b 100644 --- a/src/hypervisor/domain_driver.c +++ b/src/hypervisor/domain_driver.c @@ -161,8 +161,7 @@ virDomainDriverMergeBlkioDevice(virBlkioDevicePtr *dest= _array, if (!found) { if (!src->weight && !src->riops && !src->wiops && !src->rbps &= & !src->wbps) continue; - if (VIR_EXPAND_N(*dest_array, *dest_size, 1) < 0) - return -1; + VIR_EXPAND_N(*dest_array, *dest_size, 1); dest =3D &(*dest_array)[*dest_size - 1]; =20 if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WEIGHT)) { diff --git a/src/hypervisor/virclosecallbacks.c b/src/hypervisor/vircloseca= llbacks.c index 1fd4dd7adf..542dd61d01 100644 --- a/src/hypervisor/virclosecallbacks.c +++ b/src/hypervisor/virclosecallbacks.c @@ -262,7 +262,7 @@ virCloseCallbacksGetOne(void *payload, if (data->conn !=3D closeDef->conn || !closeDef->cb) return 0; =20 - ignore_value(VIR_EXPAND_N(data->list->entries, data->list->nentries, 1= )); + VIR_EXPAND_N(data->list->entries, data->list->nentries, 1); =20 memcpy(data->list->entries[data->list->nentries - 1].uuid, uuid, VIR_UUID_BUFLEN); diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index 4b6a7e6096..5ee15d42e3 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -651,8 +651,7 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, continue; =20 #ifdef LIBXL_HAVE_BUILDINFO_USBDEVICE_LIST - if (VIR_EXPAND_N(b_info->u.hvm.usbdevice_list, nusbdevice, 1) = < 0) - return -1; + VIR_EXPAND_N(b_info->u.hvm.usbdevice_list, nusbdevice, 1); #else nusbdevice++; if (nusbdevice > 1) { @@ -685,10 +684,8 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, =20 #ifdef LIBXL_HAVE_BUILDINFO_USBDEVICE_LIST /* NULL-terminate usbdevice_list */ - if (nusbdevice > 0 && - VIR_EXPAND_N(b_info->u.hvm.usbdevice_list, nusbdevice, 1) < 0)= { - return -1; - } + if (nusbdevice > 0) + VIR_EXPAND_N(b_info->u.hvm.usbdevice_list, nusbdevice, 1); #endif } else if (pvh) { b_info->cmdline =3D g_strdup(def->os.cmdline); diff --git a/src/libxl/xen_common.c b/src/libxl/xen_common.c index ac71b2d084..835f48ec42 100644 --- a/src/libxl/xen_common.c +++ b/src/libxl/xen_common.c @@ -552,8 +552,7 @@ xenParseHypervisorFeatures(virConfPtr conf, virDomainDe= fPtr def) return -1; =20 if (strval) { - if (VIR_EXPAND_N(def->clock.timers, def->clock.ntimers, 1) < 0) - return -1; + VIR_EXPAND_N(def->clock.timers, def->clock.ntimers, 1); =20 timer =3D g_new0(virDomainTimerDef, 1); timer->name =3D VIR_DOMAIN_TIMER_NAME_TSC; @@ -625,8 +624,7 @@ xenParseHypervisorFeatures(virConfPtr conf, virDomainDe= fPtr def) return -1; =20 if (val !=3D -1) { - if (VIR_EXPAND_N(def->clock.timers, def->clock.ntimers, 1) < 0) - return -1; + VIR_EXPAND_N(def->clock.timers, def->clock.ntimers, 1); =20 timer =3D g_new0(virDomainTimerDef, 1); timer->name =3D VIR_DOMAIN_TIMER_NAME_HPET; diff --git a/src/locking/lock_driver_lockd.c b/src/locking/lock_driver_lock= d.c index a1deb55788..6137e94e3c 100644 --- a/src/locking/lock_driver_lockd.c +++ b/src/locking/lock_driver_lockd.c @@ -641,9 +641,7 @@ static int virLockManagerLockDaemonAddResource(virLockM= anagerPtr lock, goto cleanup; } =20 - if (VIR_EXPAND_N(priv->resources, priv->nresources, 1) < 0) - goto cleanup; - + VIR_EXPAND_N(priv->resources, priv->nresources, 1); priv->resources[priv->nresources-1].lockspace =3D g_steal_pointer(&new= Lockspace); priv->resources[priv->nresources-1].name =3D g_steal_pointer(&newName); =20 diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index 9b7cd6408d..9c4ff5e107 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -321,8 +321,7 @@ static void virLXCControllerFree(virLXCControllerPtr ct= rl) static int virLXCControllerAddConsole(virLXCControllerPtr ctrl, int hostFd) { - if (VIR_EXPAND_N(ctrl->consoles, ctrl->nconsoles, 1) < 0) - return -1; + VIR_EXPAND_N(ctrl->consoles, ctrl->nconsoles, 1); ctrl->consoles[ctrl->nconsoles-1].daemon =3D ctrl->daemon; ctrl->consoles[ctrl->nconsoles-1].hostFd =3D hostFd; ctrl->consoles[ctrl->nconsoles-1].hostWatch =3D -1; @@ -402,10 +401,7 @@ static int virLXCControllerGetNICIndexes(virLXCControl= lerPtr ctrl) if (virNetDevGetIndex(ctrl->def->nets[i]->ifname, &nicindex) < 0) return -1; - if (VIR_EXPAND_N(ctrl->nicindexes, - ctrl->nnicindexes, - 1) < 0) - return -1; + VIR_EXPAND_N(ctrl->nicindexes, ctrl->nnicindexes, 1); VIR_DEBUG("Index %d for %s", nicindex, ctrl->def->nets[i]->ifname); ctrl->nicindexes[ctrl->nnicindexes-1] =3D nicindex; @@ -636,10 +632,7 @@ static int virLXCControllerSetupLoopDevices(virLXCCont= rollerPtr ctrl) return -1; =20 VIR_DEBUG("Saving loop fd %d", fd); - if (VIR_EXPAND_N(ctrl->loopDevFds, ctrl->nloopDevs, 1) < 0) { - VIR_FORCE_CLOSE(fd); - return -1; - } + VIR_EXPAND_N(ctrl->loopDevFds, ctrl->nloopDevs, 1); ctrl->loopDevFds[ctrl->nloopDevs - 1] =3D fd; } else if (fs->fsdriver =3D=3D VIR_DOMAIN_FS_DRIVER_TYPE_NBD) { if (virLXCControllerSetupNBDDeviceFS(fs) < 0) @@ -694,10 +687,7 @@ static int virLXCControllerSetupLoopDevices(virLXCCont= rollerPtr ctrl) return -1; =20 VIR_DEBUG("Saving loop fd %d", fd); - if (VIR_EXPAND_N(ctrl->loopDevFds, ctrl->nloopDevs, 1) < 0) { - VIR_FORCE_CLOSE(fd); - return -1; - } + VIR_EXPAND_N(ctrl->loopDevFds, ctrl->nloopDevs, 1); ctrl->loopDevFds[ctrl->nloopDevs - 1] =3D fd; } else if (!driver || STREQ(driver, "nbd")) { if (disk->cachemode !=3D VIR_DOMAIN_DISK_CACHE_DEFAULT && diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c index 555e9acd89..36ae821dee 100644 --- a/src/lxc/lxc_native.c +++ b/src/lxc/lxc_native.c @@ -123,16 +123,13 @@ static char ** lxcStringSplit(const char *string) goto error; =20 /* Append NULL element */ - if (VIR_EXPAND_N(result, ntokens, 1) < 0) - goto error; + VIR_EXPAND_N(result, ntokens, 1); =20 for (i =3D 0; parts[i]; i++) { if (STREQ(parts[i], "")) continue; =20 - if (VIR_EXPAND_N(result, ntokens, 1) < 0) - goto error; - + VIR_EXPAND_N(result, ntokens, 1); result[ntokens - 2] =3D g_strdup(parts[i]); } =20 @@ -189,8 +186,7 @@ lxcAddFSDef(virDomainDefPtr def, if (!(fsDef =3D lxcCreateFSDef(type, src, dst, readonly, usage))) goto error; =20 - if (VIR_EXPAND_N(def->fss, def->nfss, 1) < 0) - goto error; + VIR_EXPAND_N(def->fss, def->nfss, 1); def->fss[def->nfss - 1] =3D fsDef; =20 return 0; @@ -509,8 +505,7 @@ lxcAddNetworkDefinition(virDomainDefPtr def, lxcNetwork= ParseData *data) &hostdev->source.caps.u.net.ip.nr= outes) < 0) goto error; =20 - if (VIR_EXPAND_N(def->hostdevs, def->nhostdevs, 1) < 0) - goto error; + VIR_EXPAND_N(def->hostdevs, def->nhostdevs, 1); def->hostdevs[def->nhostdevs - 1] =3D hostdev; } else { if (!(net =3D lxcCreateNetDef(data->type, data->link, data->mac, @@ -533,8 +528,7 @@ lxcAddNetworkDefinition(virDomainDefPtr def, lxcNetwork= ParseData *data) &net->guestIP.nroutes) < 0) goto error; =20 - if (VIR_EXPAND_N(def->nets, def->nnets, 1) < 0) - goto error; + VIR_EXPAND_N(def->nets, def->nnets, 1); def->nets[def->nnets - 1] =3D net; } =20 @@ -651,9 +645,7 @@ lxcNetworkGetParseDataByIndex(lxcNetworkParseDataArray = *networks, =20 /* Index was not found. So, it is time to add new * * interface and return this last position. */ - if (VIR_EXPAND_N(networks->parseData, networks->ndata, 1) < 0) - return NULL; - + VIR_EXPAND_N(networks->parseData, networks->ndata, 1); networks->parseData[ndata] =3D g_new0(lxcNetworkParseData, 1); networks->parseData[ndata]->index =3D index; =20 @@ -696,9 +688,7 @@ lxcNetworkGetParseDataByIndexLegacy(lxcNetworkParseData= Array *networks, if (elem =3D=3D VIR_LXC_NETWORK_CONFIG_TYPE) { /* Index was not found. So, it is time to add new * * interface and return this last position. */ - if (VIR_EXPAND_N(networks->parseData, networks->ndata, 1) < 0) - return NULL; - + VIR_EXPAND_N(networks->parseData, networks->ndata, 1); networks->parseData[ndata] =3D g_new0(lxcNetworkParseData, 1); networks->parseData[ndata]->index =3D networks->ndata; =20 @@ -858,12 +848,10 @@ lxcIdmapWalkCallback(const char *name, virConfValuePt= r value, void *data) } =20 if (type =3D=3D 'u') { - if (VIR_EXPAND_N(def->idmap.uidmap, def->idmap.nuidmap, 1) < 0) - return -1; + VIR_EXPAND_N(def->idmap.uidmap, def->idmap.nuidmap, 1); idmap =3D &def->idmap.uidmap[def->idmap.nuidmap - 1]; } else if (type =3D=3D 'g') { - if (VIR_EXPAND_N(def->idmap.gidmap, def->idmap.ngidmap, 1) < 0) - return -1; + VIR_EXPAND_N(def->idmap.gidmap, def->idmap.ngidmap, 1); idmap =3D &def->idmap.gidmap[def->idmap.ngidmap - 1]; } else { return -1; @@ -1017,8 +1005,7 @@ lxcBlkioDeviceWalkCallback(const char *name, virConfV= aluePtr value, void *data) device =3D &def->blkio.devices[i]; } if (!device) { - if (VIR_EXPAND_N(def->blkio.devices, def->blkio.ndevices, 1) < 0) - goto cleanup; + VIR_EXPAND_N(def->blkio.devices, def->blkio.ndevices, 1); device =3D &def->blkio.devices[def->blkio.ndevices - 1]; device->path =3D path; path =3D NULL; diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index 787a7bb41c..fa37d284b3 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -2160,8 +2160,7 @@ qemuAgentGetInterfaceAddresses(virDomainInterfacePtr = **ifaces_ret, =20 /* If the hash table doesn't contain this iface, add it */ if (!iface) { - if (VIR_EXPAND_N(*ifaces_ret, *ifaces_count, 1) < 0) - return -1; + VIR_EXPAND_N(*ifaces_ret, *ifaces_count, 1); =20 iface =3D g_new0(virDomainInterface, 1); (*ifaces_ret)[*ifaces_count - 1] =3D iface; @@ -2191,9 +2190,7 @@ qemuAgentGetInterfaceAddresses(virDomainInterfacePtr = **ifaces_ret, /* If current iface already exists, continue with the count */ addrs_count =3D iface->naddrs; =20 - if (VIR_EXPAND_N(iface->addrs, addrs_count, - virJSONValueArraySize(ip_addr_arr)) < 0) - return -1; + VIR_EXPAND_N(iface->addrs, addrs_count, virJSONValueArraySize(ip_addr_= arr)); =20 for (j =3D 0; j < virJSONValueArraySize(ip_addr_arr); j++) { virJSONValuePtr ip_addr_obj =3D virJSONValueArrayGet(ip_addr_arr, = j); diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 08bd0e13ce..4ab694de76 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -2166,8 +2166,7 @@ virQEMUCapsAddCPUDefinitions(virQEMUCapsPtr qemuCaps, if (defs) { start =3D defs->ncpus; =20 - if (VIR_EXPAND_N(defs->cpus, defs->ncpus, count) < 0) - return -1; + VIR_EXPAND_N(defs->cpus, defs->ncpus, count); } else { start =3D 0; =20 diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 2bbc75024c..d652bf22b1 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1597,11 +1597,7 @@ qemuSharedDeviceEntryInsert(virQEMUDriverPtr driver, * recorded in the table. */ if (!qemuSharedDeviceEntryDomainExists(entry, name, NULL)) { - if (VIR_EXPAND_N(entry->domains, entry->ref, 1) < 0) { - /* entry is owned by the hash table here */ - entry =3D NULL; - goto error; - } + VIR_EXPAND_N(entry->domains, entry->ref, 1); entry->domains[entry->ref - 1] =3D g_strdup(name); } } else { diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c index edd65941ac..2de5cfe4b6 100644 --- a/src/rpc/virnetclient.c +++ b/src/rpc/virnetclient.c @@ -1070,17 +1070,11 @@ int virNetClientAddProgram(virNetClientPtr client, { virObjectLock(client); =20 - if (VIR_EXPAND_N(client->programs, client->nprograms, 1) < 0) - goto error; - + VIR_EXPAND_N(client->programs, client->nprograms, 1); client->programs[client->nprograms-1] =3D virObjectRef(prog); =20 virObjectUnlock(client); return 0; - - error: - virObjectUnlock(client); - return -1; } =20 =20 @@ -1089,17 +1083,11 @@ int virNetClientAddStream(virNetClientPtr client, { virObjectLock(client); =20 - if (VIR_EXPAND_N(client->streams, client->nstreams, 1) < 0) - goto error; - + VIR_EXPAND_N(client->streams, client->nstreams, 1); client->streams[client->nstreams-1] =3D virObjectRef(st); =20 virObjectUnlock(client); return 0; - - error: - virObjectUnlock(client); - return -1; } =20 =20 diff --git a/src/rpc/virnetdaemon.c b/src/rpc/virnetdaemon.c index 14bc9e1335..1f4a2db04f 100644 --- a/src/rpc/virnetdaemon.c +++ b/src/rpc/virnetdaemon.c @@ -657,8 +657,7 @@ virNetDaemonAddSignalHandler(virNetDaemonPtr dmn, if (virNetDaemonSignalSetup(dmn) < 0) goto error; =20 - if (VIR_EXPAND_N(dmn->signals, dmn->nsignals, 1) < 0) - goto error; + VIR_EXPAND_N(dmn->signals, dmn->nsignals, 1); =20 sigdata =3D g_new0(virNetDaemonSignal, 1); =20 diff --git a/src/rpc/virnetlibsshsession.c b/src/rpc/virnetlibsshsession.c index 2dc8cc8911..e08e0c1392 100644 --- a/src/rpc/virnetlibsshsession.c +++ b/src/rpc/virnetlibsshsession.c @@ -182,16 +182,10 @@ virNetLibsshSessionAuthMethodNew(virNetLibsshSessionP= tr sess) =20 auth =3D g_new0(virNetLibsshAuthMethod, 1); =20 - if (VIR_EXPAND_N(sess->auths, sess->nauths, 1) < 0) - goto error; - + VIR_EXPAND_N(sess->auths, sess->nauths, 1); sess->auths[sess->nauths - 1] =3D auth; =20 return auth; - - error: - VIR_FREE(auth); - return NULL; } =20 /* string representation of public key of remote server */ diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c index 2b849465c3..93d55fa906 100644 --- a/src/rpc/virnetserver.c +++ b/src/rpc/virnetserver.c @@ -290,8 +290,7 @@ int virNetServerAddClient(virNetServerPtr srv, if (virNetServerClientInit(client) < 0) goto error; =20 - if (VIR_EXPAND_N(srv->clients, srv->nclients, 1) < 0) - goto error; + VIR_EXPAND_N(srv->clients, srv->nclients, 1); srv->clients[srv->nclients-1] =3D virObjectRef(client); =20 virObjectLock(client); @@ -620,9 +619,7 @@ int virNetServerAddService(virNetServerPtr srv, { virObjectLock(srv); =20 - if (VIR_EXPAND_N(srv->services, srv->nservices, 1) < 0) - goto error; - + VIR_EXPAND_N(srv->services, srv->nservices, 1); srv->services[srv->nservices-1] =3D virObjectRef(svc); =20 virNetServerServiceSetDispatcher(svc, @@ -631,10 +628,6 @@ int virNetServerAddService(virNetServerPtr srv, =20 virObjectUnlock(srv); return 0; - - error: - virObjectUnlock(srv); - return -1; } =20 =20 @@ -787,17 +780,11 @@ int virNetServerAddProgram(virNetServerPtr srv, { virObjectLock(srv); =20 - if (VIR_EXPAND_N(srv->programs, srv->nprograms, 1) < 0) - goto error; - + VIR_EXPAND_N(srv->programs, srv->nprograms, 1); srv->programs[srv->nprograms-1] =3D virObjectRef(prog); =20 virObjectUnlock(srv); return 0; - - error: - virObjectUnlock(srv); - return -1; } =20 int virNetServerSetTLSContext(virNetServerPtr srv, diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c index 872b8a3c46..0b4e21c3c9 100644 --- a/src/rpc/virnetsocket.c +++ b/src/rpc/virnetsocket.c @@ -440,8 +440,7 @@ int virNetSocketNewListenTCP(const char *nodename, =20 VIR_DEBUG("%p f=3D%d f=3D%d", &addr, runp->ai_family, addr.data.sa= .sa_family); =20 - if (VIR_EXPAND_N(socks, nsocks, 1) < 0) - goto error; + VIR_EXPAND_N(socks, nsocks, 1); =20 if (!(socks[nsocks-1] =3D virNetSocketNew(&addr, NULL, false, fd, = -1, 0, false))) goto error; diff --git a/src/rpc/virnetsshsession.c b/src/rpc/virnetsshsession.c index f42aed3f62..a42549dcf4 100644 --- a/src/rpc/virnetsshsession.c +++ b/src/rpc/virnetsshsession.c @@ -175,16 +175,10 @@ virNetSSHSessionAuthMethodNew(virNetSSHSessionPtr ses= s) =20 auth =3D g_new0(virNetSSHAuthMethod, 1); =20 - if (VIR_EXPAND_N(sess->auths, sess->nauths, 1) < 0) - goto error; - + VIR_EXPAND_N(sess->auths, sess->nauths, 1); sess->auths[sess->nauths - 1] =3D auth; =20 return auth; - - error: - VIR_FREE(auth); - return NULL; } =20 /* keyboard interactive authentication callback */ diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backen= d_rbd.c index 2804759557..33dda27087 100644 --- a/src/storage/storage_backend_rbd.c +++ b/src/storage/storage_backend_rbd.c @@ -649,8 +649,7 @@ virStorageBackendRBDGetVolNames(virStorageBackendRBDSta= tePtr ptr) name +=3D strlen(name) + 1; } =20 - if (VIR_EXPAND_N(names, nnames, 1) < 0) - goto error; + VIR_EXPAND_N(names, nnames, 1); =20 return names; =20 diff --git a/src/storage_file/storage_file_backend_gluster.c b/src/storage_= file/storage_file_backend_gluster.c index 8c7a583886..06ba99bfe3 100644 --- a/src/storage_file/storage_file_backend_gluster.c +++ b/src/storage_file/storage_file_backend_gluster.c @@ -279,8 +279,7 @@ virStorageFileBackendGlusterReadlinkCallback(const char= *path, return 1; =20 realloc: - if (VIR_EXPAND_N(buf, bufsiz, 256) < 0) - return -1; + VIR_EXPAND_N(buf, bufsiz, 256); =20 if ((ret =3D glfs_readlink(priv->vol, path, buf, bufsiz)) < 0) { virReportSystemError(errno, diff --git a/src/storage_file/storage_source_backingstore.c b/src/storage_f= ile/storage_source_backingstore.c index 5e2db3d390..bac5a043e5 100644 --- a/src/storage_file/storage_source_backingstore.c +++ b/src/storage_file/storage_source_backingstore.c @@ -146,8 +146,7 @@ virStorageSourceRBDAddHost(virStorageSourcePtr src, size_t skip; g_auto(GStrv) parts =3D NULL; =20 - if (VIR_EXPAND_N(src->hosts, src->nhosts, 1) < 0) - return -1; + VIR_EXPAND_N(src->hosts, src->nhosts, 1); =20 if ((port =3D strchr(hostport, ']'))) { /* ipv6, strip brackets */ diff --git a/src/util/vircommand.c b/src/util/vircommand.c index d647463f35..29c17454d8 100644 --- a/src/util/vircommand.c +++ b/src/util/vircommand.c @@ -228,7 +228,7 @@ virCommandFDSet(virCommandPtr cmd, if (virCommandFDIsSet(cmd, fd)) return; =20 - ignore_value(VIR_EXPAND_N(cmd->passfd, cmd->npassfd, 1)); + VIR_EXPAND_N(cmd->passfd, cmd->npassfd, 1); =20 cmd->passfd[cmd->npassfd - 1].fd =3D fd; cmd->passfd[cmd->npassfd - 1].flags =3D flags; diff --git a/src/util/virfile.c b/src/util/virfile.c index 56d6e0605e..c0730f6641 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -2010,7 +2010,6 @@ virFileGetMountSubtreeImpl(const char *mtabpath, FILE *procmnt; struct mntent mntent; char mntbuf[1024]; - int ret =3D -1; char **mounts =3D NULL; size_t nmounts =3D 0; =20 @@ -2031,8 +2030,7 @@ virFileGetMountSubtreeImpl(const char *mtabpath, mntent.mnt_dir[strlen(prefix)] =3D=3D '/'))) continue; =20 - if (VIR_EXPAND_N(mounts, nmounts, nmounts ? 1 : 2) < 0) - goto cleanup; + VIR_EXPAND_N(mounts, nmounts, nmounts ? 1 : 2); mounts[nmounts - 2] =3D g_strdup(mntent.mnt_dir); } =20 @@ -2042,13 +2040,8 @@ virFileGetMountSubtreeImpl(const char *mtabpath, =20 *mountsret =3D mounts; *nmountsret =3D nmounts ? nmounts - 1 : 0; - ret =3D 0; - - cleanup: - if (ret < 0) - g_strfreev(mounts); endmntent(procmnt); - return ret; + return 0; } #else /* ! defined WITH_MNTENT_H && defined WITH_GETMNTENT_R */ static int @@ -3548,8 +3541,7 @@ virFileFindHugeTLBFS(virHugeTLBFSPtr *ret_fs, if (STRNEQ(mb.mnt_type, "hugetlbfs")) continue; =20 - if (VIR_EXPAND_N(fs, nfs, 1) < 0) - goto cleanup; + VIR_EXPAND_N(fs, nfs, 1); =20 tmp =3D &fs[nfs - 1]; =20 diff --git a/src/util/virfirewall.c b/src/util/virfirewall.c index dd3e104dbe..eee191ff23 100644 --- a/src/util/virfirewall.c +++ b/src/util/virfirewall.c @@ -510,8 +510,7 @@ void virFirewallStartTransaction(virFirewallPtr firewal= l, group =3D virFirewallGroupNew(); group->actionFlags =3D flags; =20 - ignore_value(VIR_EXPAND_N(firewall->groups, - firewall->ngroups, 1)); + VIR_EXPAND_N(firewall->groups, firewall->ngroups, 1); firewall->groups[firewall->ngroups - 1] =3D group; firewall->currentGroup =3D firewall->ngroups - 1; } diff --git a/src/util/virlockspace.c b/src/util/virlockspace.c index 0d6cff3707..5e6d3ea428 100644 --- a/src/util/virlockspace.c +++ b/src/util/virlockspace.c @@ -214,9 +214,7 @@ virLockSpaceResourceNew(virLockSpacePtr lockspace, } res->lockHeld =3D true; =20 - if (VIR_EXPAND_N(res->owners, res->nOwners, 1) < 0) - goto error; - + VIR_EXPAND_N(res->owners, res->nOwners, 1); res->owners[res->nOwners-1] =3D owner; =20 return res; @@ -583,8 +581,7 @@ int virLockSpaceAcquireResource(virLockSpacePtr lockspa= ce, if ((res->flags & VIR_LOCK_SPACE_ACQUIRE_SHARED) && (flags & VIR_LOCK_SPACE_ACQUIRE_SHARED)) { =20 - if (VIR_EXPAND_N(res->owners, res->nOwners, 1) < 0) - goto cleanup; + VIR_EXPAND_N(res->owners, res->nOwners, 1); res->owners[res->nOwners-1] =3D owner; =20 goto done; diff --git a/src/util/virprocess.c b/src/util/virprocess.c index 8428c91182..924fc65b50 100644 --- a/src/util/virprocess.c +++ b/src/util/virprocess.c @@ -653,7 +653,6 @@ int virProcessGetNamespaces(pid_t pid, size_t *nfdlist, int **fdlist) { - int ret =3D -1; size_t i =3D 0; const char *ns[] =3D { "user", "ipc", "uts", "net", "pid", "mnt" }; =20 @@ -667,24 +666,12 @@ int virProcessGetNamespaces(pid_t pid, nsfile =3D g_strdup_printf("/proc/%llu/ns/%s", (long long)pid, ns[= i]); =20 if ((fd =3D open(nsfile, O_RDONLY)) >=3D 0) { - if (VIR_EXPAND_N(*fdlist, *nfdlist, 1) < 0) { - VIR_FORCE_CLOSE(fd); - goto cleanup; - } - + VIR_EXPAND_N(*fdlist, *nfdlist, 1); (*fdlist)[(*nfdlist)-1] =3D fd; } } =20 - ret =3D 0; - - cleanup: - if (ret < 0) { - for (i =3D 0; i < *nfdlist; i++) - VIR_FORCE_CLOSE((*fdlist)[i]); - VIR_FREE(*fdlist); - } - return ret; + return 0; } =20 =20 diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index 0460be8d3a..8458db96bc 100644 --- a/src/util/virresctrl.c +++ b/src/util/virresctrl.c @@ -608,10 +608,9 @@ virResctrlGetCacheInfo(virResctrlInfoPtr resctrl, if (rv < 0) goto cleanup; =20 - if (resctrl->nlevels <=3D level && + if (resctrl->nlevels <=3D level) VIR_EXPAND_N(resctrl->levels, resctrl->nlevels, - level - resctrl->nlevels + 1) < 0) - goto cleanup; + level - resctrl->nlevels + 1); =20 if (!resctrl->levels[level]) { virResctrlInfoPerTypePtr *types =3D NULL; @@ -932,8 +931,7 @@ virResctrlInfoGetCache(virResctrlInfoPtr resctrl, i_type->max_cache_id++; } =20 - if (VIR_EXPAND_N(*controls, *ncontrols, 1) < 0) - goto error; + VIR_EXPAND_N(*controls, *ncontrols, 1); (*controls)[*ncontrols - 1] =3D g_new0(virResctrlInfoPerCache, 1); memcpy((*controls)[*ncontrols - 1], &i_type->control, sizeof(i_typ= e->control)); } @@ -1098,9 +1096,8 @@ virResctrlAllocGetType(virResctrlAllocPtr alloc, { virResctrlAllocPerLevelPtr a_level =3D NULL; =20 - if (alloc->nlevels <=3D level && - VIR_EXPAND_N(alloc->levels, alloc->nlevels, level - alloc->nlevels= + 1) < 0) - return NULL; + if (alloc->nlevels <=3D level) + VIR_EXPAND_N(alloc->levels, alloc->nlevels, level - alloc->nlevels= + 1); =20 if (!alloc->levels[level]) { virResctrlAllocPerTypePtr *types =3D NULL; @@ -1132,10 +1129,9 @@ virResctrlAllocUpdateMask(virResctrlAllocPtr alloc, if (!a_type) return -1; =20 - if (a_type->nmasks <=3D cache && + if (a_type->nmasks <=3D cache) VIR_EXPAND_N(a_type->masks, a_type->nmasks, - cache - a_type->nmasks + 1) < 0) - return -1; + cache - a_type->nmasks + 1); =20 if (!a_type->masks[cache]) a_type->masks[cache] =3D virBitmapNewCopy(mask); @@ -1156,10 +1152,9 @@ virResctrlAllocUpdateSize(virResctrlAllocPtr alloc, if (!a_type) return -1; =20 - if (a_type->nsizes <=3D cache && + if (a_type->nsizes <=3D cache) VIR_EXPAND_N(a_type->sizes, a_type->nsizes, - cache - a_type->nsizes + 1) < 0) - return -1; + cache - a_type->nsizes + 1); =20 if (!a_type->sizes[cache]) a_type->sizes[cache] =3D g_new0(unsigned long long, 1); @@ -1316,10 +1311,9 @@ virResctrlAllocSetMemoryBandwidth(virResctrlAllocPtr= alloc, alloc->mem_bw =3D mem_bw; } =20 - if (mem_bw->nbandwidths <=3D id && + if (mem_bw->nbandwidths <=3D id) VIR_EXPAND_N(mem_bw->bandwidths, mem_bw->nbandwidths, - id - mem_bw->nbandwidths + 1) < 0) - return -1; + id - mem_bw->nbandwidths + 1); =20 if (mem_bw->bandwidths[id]) { virReportError(VIR_ERR_XML_ERROR, @@ -1469,9 +1463,9 @@ virResctrlAllocParseProcessMemoryBandwidth(virResctrl= InfoPtr resctrl, "memory bandwidth node '%u'"), id); return -1; } - if (alloc->mem_bw->nbandwidths <=3D id && + if (alloc->mem_bw->nbandwidths <=3D id) { VIR_EXPAND_N(alloc->mem_bw->bandwidths, alloc->mem_bw->nbandwidths, - id - alloc->mem_bw->nbandwidths + 1) < 0) { + id - alloc->mem_bw->nbandwidths + 1); return -1; } if (!alloc->mem_bw->bandwidths[id]) @@ -1856,9 +1850,8 @@ virResctrlAllocNewFromInfo(virResctrlInfoPtr info) if (info->membw_info) { ret->mem_bw =3D g_new0(virResctrlAllocMemBW, 1); =20 - if (VIR_EXPAND_N(ret->mem_bw->bandwidths, ret->mem_bw->nbandwidths, - info->membw_info->max_id + 1) < 0) - goto error; + VIR_EXPAND_N(ret->mem_bw->bandwidths, ret->mem_bw->nbandwidths, + info->membw_info->max_id + 1); =20 for (i =3D 0; i < ret->mem_bw->nbandwidths; i++) { ret->mem_bw->bandwidths[i] =3D g_new0(unsigned int, 1); @@ -2146,10 +2139,9 @@ virResctrlAllocCopyMemBW(virResctrlAllocPtr dst, =20 dst_bw =3D dst->mem_bw; =20 - if (src_bw->nbandwidths > dst_bw->nbandwidths && + if (src_bw->nbandwidths > dst_bw->nbandwidths) VIR_EXPAND_N(dst_bw->bandwidths, dst_bw->nbandwidths, - src_bw->nbandwidths - dst_bw->nbandwidths) < 0) - return -1; + src_bw->nbandwidths - dst_bw->nbandwidths); =20 for (i =3D 0; i < src_bw->nbandwidths; i++) { if (dst_bw->bandwidths[i]) diff --git a/src/util/virstring.c b/src/util/virstring.c index 1d6141b5c1..07594292bb 100644 --- a/src/util/virstring.c +++ b/src/util/virstring.c @@ -691,8 +691,7 @@ virStringSearch(const char *str, /* '*matches' must always be NULL terminated in every iteration * of the loop, so start by allocating 1 element */ - if (VIR_EXPAND_N(*matches, nmatches, 1) < 0) - goto cleanup; + VIR_EXPAND_N(*matches, nmatches, 1); =20 while ((nmatches - 1) < max_matches) { g_autoptr(GMatchInfo) info =3D NULL; @@ -702,8 +701,7 @@ virStringSearch(const char *str, if (!g_regex_match(regex, str, 0, &info)) break; =20 - if (VIR_EXPAND_N(*matches, nmatches, 1) < 0) - goto cleanup; + VIR_EXPAND_N(*matches, nmatches, 1); =20 match =3D g_match_info_fetch(info, 1); =20 diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c index 1c8193cc58..df1cf59709 100644 --- a/src/util/virsysinfo.c +++ b/src/util/virsysinfo.c @@ -276,8 +276,7 @@ virSysinfoParsePPCProcessor(const char *base, virSysinf= oDefPtr ret) eol =3D strchr(base, '\n'); cur =3D strchr(base, ':') + 1; =20 - if (VIR_EXPAND_N(ret->processor, ret->nprocessor, 1) < 0) - return -1; + VIR_EXPAND_N(ret->processor, ret->nprocessor, 1); processor =3D &ret->processor[ret->nprocessor - 1]; =20 virSkipSpaces(&cur); @@ -409,8 +408,7 @@ virSysinfoParseARMProcessor(const char *base, virSysinf= oDefPtr ret) eol =3D strchr(base, '\n'); cur =3D strchr(base, ':') + 1; =20 - if (VIR_EXPAND_N(ret->processor, ret->nprocessor, 1) < 0) - goto error; + VIR_EXPAND_N(ret->processor, ret->nprocessor, 1); processor =3D &ret->processor[ret->nprocessor - 1]; =20 virSkipSpaces(&cur); @@ -425,10 +423,6 @@ virSysinfoParseARMProcessor(const char *base, virSysin= foDefPtr ret) =20 VIR_FREE(processor_type); return 0; - - error: - VIR_FREE(processor_type); - return -1; } =20 /* virSysinfoRead for ARMv7 @@ -544,8 +538,7 @@ virSysinfoParseS390Processor(const char *base, virSysin= foDefPtr ret) while ((tmp_base =3D strstr(tmp_base, "processor ")) && (tmp_base =3D virSysinfoParseS390Line(tmp_base, "processor ", &procline))) { - if (VIR_EXPAND_N(ret->processor, ret->nprocessor, 1) < 0) - goto error; + VIR_EXPAND_N(ret->processor, ret->nprocessor, 1); processor =3D &ret->processor[ret->nprocessor - 1]; processor->processor_manufacturer =3D g_strdup(manufacturer); if (!virSysinfoParseS390Delimited(procline, "version", @@ -770,7 +763,6 @@ virSysinfoParseX86BaseBoard(const char *base, virSysinfoBaseBoardDefPtr *baseBoard, size_t *nbaseBoard) { - int ret =3D -1; const char *cur; char *eol =3D NULL; virSysinfoBaseBoardDefPtr boards =3D NULL; @@ -779,8 +771,7 @@ virSysinfoParseX86BaseBoard(const char *base, while (base && (cur =3D strstr(base, "Base Board Information"))) { virSysinfoBaseBoardDefPtr def; =20 - if (VIR_EXPAND_N(boards, nboards, 1) < 0) - goto cleanup; + VIR_EXPAND_N(boards, nboards, 1); =20 def =3D &boards[nboards - 1]; =20 @@ -842,13 +833,7 @@ virSysinfoParseX86BaseBoard(const char *base, =20 *nbaseBoard =3D nboards; *baseBoard =3D g_steal_pointer(&boards); - nboards =3D 0; - ret =3D 0; - cleanup: - while (nboards--) - virSysinfoBaseBoardDefClear(&boards[nboards]); - VIR_FREE(boards); - return ret; + return 0; } =20 =20 @@ -981,8 +966,7 @@ virSysinfoParseOEMStrings(const char *base, if (!eol) continue; =20 - if (VIR_EXPAND_N(strings->values, strings->nvalues, 1) < 0) - goto cleanup; + VIR_EXPAND_N(strings->values, strings->nvalues, 1); =20 /* If OEM String contains newline, dmidecode escapes it as a dot. * If this is the case then run dmidecode again to get raw string. @@ -1023,8 +1007,7 @@ virSysinfoParseX86Processor(const char *base, virSysi= nfoDefPtr ret) base =3D tmp_base; eol =3D NULL; =20 - if (VIR_EXPAND_N(ret->processor, ret->nprocessor, 1) < 0) - return -1; + VIR_EXPAND_N(ret->processor, ret->nprocessor, 1); processor =3D &ret->processor[ret->nprocessor - 1]; =20 if ((cur =3D strstr(base, "Socket Designation: ")) !=3D NULL) { @@ -1124,8 +1107,7 @@ virSysinfoParseX86Memory(const char *base, virSysinfo= DefPtr ret) base =3D tmp_base; eol =3D NULL; =20 - if (VIR_EXPAND_N(ret->memory, ret->nmemory, 1) < 0) - return -1; + VIR_EXPAND_N(ret->memory, ret->nmemory, 1); memory =3D &ret->memory[ret->nmemory - 1]; =20 if ((cur =3D strstr(base, "Size: ")) !=3D NULL) { diff --git a/src/util/virsystemd.c b/src/util/virsystemd.c index c22f2df866..cf22edaa0a 100644 --- a/src/util/virsystemd.c +++ b/src/util/virsystemd.c @@ -738,8 +738,7 @@ virSystemdActivationAddFD(virSystemdActivationPtr act, return 0; } =20 - if (VIR_EXPAND_N(ent->fds, ent->nfds, 1) < 0) - return -1; + VIR_EXPAND_N(ent->fds, ent->nfds, 1); =20 VIR_DEBUG("Record extra FD %d with name %s", fd, name); ent->fds[ent->nfds - 1] =3D fd; diff --git a/src/util/virthreadpool.c b/src/util/virthreadpool.c index 942cfa48b1..42549c4892 100644 --- a/src/util/virthreadpool.c +++ b/src/util/virthreadpool.c @@ -183,8 +183,7 @@ virThreadPoolExpand(virThreadPoolPtr pool, size_t gain,= bool priority) size_t i =3D 0; struct virThreadPoolWorkerData *data =3D NULL; =20 - if (VIR_EXPAND_N(*workers, *curWorkers, gain) < 0) - return -1; + VIR_EXPAND_N(*workers, *curWorkers, gain); =20 for (i =3D 0; i < gain; i++) { g_autofree char *name =3D NULL; diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c index 1b89233012..018d504433 100644 --- a/src/util/virtypedparam.c +++ b/src/util/virtypedparam.c @@ -328,8 +328,7 @@ virTypedParamsReplaceString(virTypedParameterPtr *param= s, } old =3D param->value.s; } else { - if (VIR_EXPAND_N(*params, n, 1) < 0) - return -1; + VIR_EXPAND_N(*params, n, 1); param =3D *params + n - 1; } =20 diff --git a/src/vbox/vbox_snapshot_conf.c b/src/vbox/vbox_snapshot_conf.c index 4f12d2ebfa..f9637a65ab 100644 --- a/src/vbox/vbox_snapshot_conf.c +++ b/src/vbox/vbox_snapshot_conf.c @@ -472,8 +472,7 @@ virVBoxSnapshotConfAllChildren(virVBoxSnapshotConfHardD= iskPtr disk, =20 for (i =3D 0; i < disk->nchildren; i++) { tempSize =3D virVBoxSnapshotConfAllChildren(disk->children[i], &te= mpList); - if (VIR_EXPAND_N(ret, returnSize, tempSize) < 0) - goto error; + VIR_EXPAND_N(ret, returnSize, tempSize); =20 for (j =3D 0; j < tempSize; j++) ret[returnSize - tempSize + j] =3D tempList[j]; @@ -481,17 +480,10 @@ virVBoxSnapshotConfAllChildren(virVBoxSnapshotConfHar= dDiskPtr disk, VIR_FREE(tempList); } =20 - if (VIR_EXPAND_N(ret, returnSize, 1) < 0) - goto error; - + VIR_EXPAND_N(ret, returnSize, 1); ret[returnSize - 1] =3D disk; *list =3D ret; return returnSize; - - error: - VIR_FREE(tempList); - VIR_FREE(ret); - return 0; } =20 void @@ -785,9 +777,7 @@ virVBoxSnapshotConfAddSnapshotToXmlMachine(virVBoxSnaps= hotConfSnapshotPtr snapsh _("Unable to find the snapshot %s"), snapshotPa= rentName); return -1; } - if (VIR_EXPAND_N(parentSnapshot->children, parentSnapshot->nchildr= en, 1) < 0) - return -1; - + VIR_EXPAND_N(parentSnapshot->children, parentSnapshot->nchildren, = 1); parentSnapshot->children[parentSnapshot->nchildren - 1] =3D snapsh= ot; } =20 @@ -829,9 +819,7 @@ virVBoxSnapshotConfAddHardDiskToMediaRegistry(virVBoxSn= apshotConfHardDiskPtr har return -1; } /* Hard disk found */ - if (VIR_EXPAND_N(parentDisk->children, parentDisk->nchildren, 1) < 0) - return -1; - + VIR_EXPAND_N(parentDisk->children, parentDisk->nchildren, 1); parentDisk->children[parentDisk->nchildren - 1] =3D hardDisk; if (hardDisk->parent =3D=3D NULL) hardDisk->parent =3D parentDisk; @@ -1395,8 +1383,7 @@ virVBoxSnapshotConfDiskListToOpen(virVBoxSnapshotConf= MachinePtr machine, ret[returnSize - 1] =3D hardDisk; =20 while (hardDisk->parent !=3D NULL) { - if (VIR_EXPAND_N(ret, returnSize, 1) < 0) - return 0; + VIR_EXPAND_N(ret, returnSize, 1); ret[returnSize - 1] =3D hardDisk->parent; hardDisk =3D hardDisk->parent; } @@ -1424,8 +1411,7 @@ virVBoxSnapshotConfRemoveFakeDisks(virVBoxSnapshotCon= fMachinePtr machine) =20 for (i =3D 0; i < machine->mediaRegistry->ndisks; i++) { tempSize =3D virVBoxSnapshotConfAllChildren(machine->mediaRegistry= ->disks[i], &tempList); - if (VIR_EXPAND_N(diskList, diskSize, tempSize) < 0) - goto cleanup; + VIR_EXPAND_N(diskList, diskSize, tempSize); =20 for (j =3D 0; j < tempSize; j++) diskList[diskSize - tempSize + j] =3D tempList[j]; @@ -1475,8 +1461,7 @@ virVBoxSnapshotConfDiskIsInMediaRegistry(virVBoxSnaps= hotConfMachinePtr machine, =20 for (i =3D 0; i < machine->mediaRegistry->ndisks; i++) { tempSize =3D virVBoxSnapshotConfAllChildren(machine->mediaRegistry= ->disks[i], &tempList); - if (VIR_EXPAND_N(diskList, diskSize, tempSize) < 0) - goto cleanup; + VIR_EXPAND_N(diskList, diskSize, tempSize); =20 for (j =3D 0; j < tempSize; j++) diskList[diskSize - tempSize + j] =3D tempList[j]; diff --git a/tests/qemudomaincheckpointxml2xmltest.c b/tests/qemudomainchec= kpointxml2xmltest.c index 8b4b75d753..efa6aff2cb 100644 --- a/tests/qemudomaincheckpointxml2xmltest.c +++ b/tests/qemudomaincheckpointxml2xmltest.c @@ -68,8 +68,7 @@ testCompareXMLToXMLFiles(const char *inxml, if (flags & TEST_VDA_BITMAP) { virDomainCheckpointDiskDefPtr disk; =20 - if (VIR_EXPAND_N(def->disks, def->ndisks, 1) < 0) - return -1; + VIR_EXPAND_N(def->disks, def->ndisks, 1); disk =3D &def->disks[0]; if (disk->bitmap) return -1; diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c index ae3fcf9311..227b78d527 100644 --- a/tests/qemumonitortestutils.c +++ b/tests/qemumonitortestutils.c @@ -117,8 +117,7 @@ qemuMonitorTestAddResponse(qemuMonitorTestPtr test, =20 if (have < want) { size_t need =3D want - have; - if (VIR_EXPAND_N(test->outgoing, test->outgoingCapacity, need) < 0) - return -1; + VIR_EXPAND_N(test->outgoing, test->outgoingCapacity, need); } =20 want -=3D 2; @@ -283,10 +282,7 @@ qemuMonitorTestIO(virNetSocketPtr sock, char *t1, *t2; =20 if ((test->incomingCapacity - test->incomingLength) < 1024) { - if (VIR_EXPAND_N(test->incoming, test->incomingCapacity, 1024)= < 0) { - err =3D true; - goto cleanup; - } + VIR_EXPAND_N(test->incoming, test->incomingCapacity, 1024); } =20 if ((ret =3D virNetSocketRead(sock, @@ -868,9 +864,7 @@ qemuMonitorTestAddItemParams(qemuMonitorTestPtr test, } =20 i =3D data->nargs; - if (VIR_EXPAND_N(data->args, data->nargs, 1)) - goto error; - + VIR_EXPAND_N(data->args, data->nargs, 1); data->args[i].argname =3D g_strdup(argname); data->args[i].argval =3D g_strdup(argval); } diff --git a/tests/securityselinuxlabeltest.c b/tests/securityselinuxlabelt= est.c index b1bf6e0f95..def88e3950 100644 --- a/tests/securityselinuxlabeltest.c +++ b/tests/securityselinuxlabeltest.c @@ -144,12 +144,7 @@ testSELinuxLoadFileList(const char *testname, *tmp =3D '\0'; } =20 - if (VIR_EXPAND_N(*files, *nfiles, 1) < 0) { - VIR_FREE(file); - VIR_FREE(context); - goto cleanup; - } - + VIR_EXPAND_N(*files, *nfiles, 1); (*files)[(*nfiles)-1].file =3D file; (*files)[(*nfiles)-1].context =3D context; } diff --git a/tests/viralloctest.c b/tests/viralloctest.c index 4794fd7f93..5e27aa51c0 100644 --- a/tests/viralloctest.c +++ b/tests/viralloctest.c @@ -133,8 +133,7 @@ testExpandArray(const void *opaque G_GNUC_UNUSED) t[i].b =3D 20; } =20 - if (VIR_EXPAND_N(t, nt, 5) < 0) - goto cleanup; + VIR_EXPAND_N(t, nt, 5); =20 if (testCheckNonNull(t) < 0) goto cleanup; diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 7db88f700a..f5e98a19f8 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -4068,10 +4068,7 @@ cmdStartGetFDs(vshControl *ctl, vshError(ctl, _("Unable to parse FD number '%s'"), fdlist[i]); goto error; } - if (VIR_EXPAND_N(fds, nfds, 1) < 0) { - vshError(ctl, "%s", _("Unable to allocate FD list")); - goto error; - } + VIR_EXPAND_N(fds, nfds, 1); fds[nfds - 1] =3D fd; } =20 @@ -10055,16 +10052,10 @@ cmdLxcEnterNamespace(vshControl *ctl, const vshCm= d *cmd) setlabel =3D false; =20 while ((opt =3D vshCommandOptArgv(ctl, cmd, opt))) { - if (VIR_EXPAND_N(cmdargv, ncmdargv, 1) < 0) { - vshError(ctl, _("%s: %d: failed to allocate argv"), - __FILE__, __LINE__); - } + VIR_EXPAND_N(cmdargv, ncmdargv, 1); cmdargv[ncmdargv-1] =3D opt->data; } - if (VIR_EXPAND_N(cmdargv, ncmdargv, 1) < 0) { - vshError(ctl, _("%s: %d: failed to allocate argv"), - __FILE__, __LINE__); - } + VIR_EXPAND_N(cmdargv, ncmdargv, 1); cmdargv[ncmdargv - 1] =3D NULL; =20 if ((nfdlist =3D virDomainLxcOpenNamespace(dom, &fdlist, 0)) < 0) @@ -13956,11 +13947,7 @@ cmdDomFSFreeze(vshControl *ctl, const vshCmd *cmd) return false; =20 while ((opt =3D vshCommandOptArgv(ctl, cmd, opt))) { - if (VIR_EXPAND_N(mountpoints, nmountpoints, 1) < 0) { - vshError(ctl, _("%s: %d: failed to allocate mountpoints"), - __FILE__, __LINE__); - goto cleanup; - } + VIR_EXPAND_N(mountpoints, nmountpoints, 1); mountpoints[nmountpoints-1] =3D opt->data; } =20 @@ -14009,11 +13996,7 @@ cmdDomFSThaw(vshControl *ctl, const vshCmd *cmd) return false; =20 while ((opt =3D vshCommandOptArgv(ctl, cmd, opt))) { - if (VIR_EXPAND_N(mountpoints, nmountpoints, 1) < 0) { - vshError(ctl, _("%s: %d: failed to allocate mountpoints"), - __FILE__, __LINE__); - goto cleanup; - } + VIR_EXPAND_N(mountpoints, nmountpoints, 1); mountpoints[nmountpoints-1] =3D opt->data; } =20 --=20 2.31.0 From nobody Sun Apr 28 04:45:17 2024 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=1616197049; cv=none; d=zohomail.com; s=zohoarc; b=Vtfm8KBvvUKwL4vZCoJ63S1R3seLljILcnRzthc7IWkeeJ3aNfGH2K3mNcXzxB90TT7Lkcd+G25zGV0Em1n8TN1YQSJZvwAvAwRQNs+UgiQMAn45nzOYI49NKchMCwPTVjbX5axo1OyIqPZTRMau4qI0xHBa7JnHq77IUFNogaA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616197049; 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=ayPZ7uIJeLxD9+4D2GBPyeFc9WATqdWmKO15VrBGrME=; b=CsGcMXMlposMxvDWynffU40rkTbCAIavQuIc20pYy3LdZQ65mQquNJzwW9hhH1oKYupvNHEYZhHROcuTiKI9uDwpqe2jZRre+8lCMA6T4tL9j2b9PTNlh30lUCqMQJbTRlfFbf9Y1Fk0N2LBHLJYG1kD9RipoNV3ukCr6tl9TOc= 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 1616197049226740.6692058853572; Fri, 19 Mar 2021 16:37:29 -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-499-pkp3XCBwOTqdI8DkQ_0z1g-1; Fri, 19 Mar 2021 19:37:26 -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 E6A96911EA; Fri, 19 Mar 2021 23:37:19 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A3A855DAA5; Fri, 19 Mar 2021 23:37:19 +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 A5C9E1809C84; Fri, 19 Mar 2021 23:37:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 12JNbDBj029439 for ; Fri, 19 Mar 2021 19:37:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id D83E318966; Fri, 19 Mar 2021 23:37:13 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.40.194.173]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AB7CB5054E for ; Fri, 19 Mar 2021 23:37:13 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 74428244034; Sat, 20 Mar 2021 00:37:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616197048; 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=ayPZ7uIJeLxD9+4D2GBPyeFc9WATqdWmKO15VrBGrME=; b=EQROc9EsHvK/J4qeoAMwkrdgaUvPiNS1YriqDwOgvSZwE5VVL0xAC5kKM1kI0UjPjjWRvd XXM4rCa8FV2jf94aDov+IYi26OJy1DScvFwqwuQ5D/mu+7ABob+o6/Sv+idIycCloGaAYi uuth4nnKIUQxDsfKmzINYKFrl5VMPyM= X-MC-Unique: pkp3XCBwOTqdI8DkQ_0z1g-1 From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH 5/7] util: Make virExpandN return void Date: Sat, 20 Mar 2021 00:37:04 +0100 Message-Id: <66f2bdb7c4722e201435ad11af1f5b34d6359cba.1616196713.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiri Denemark Reviewed-by: Michal Privoznik --- src/util/viralloc.c | 14 ++++++-------- src/util/viralloc.h | 4 ++-- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/util/viralloc.c b/src/util/viralloc.c index cd770eb601..81f5ba9a09 100644 --- a/src/util/viralloc.c +++ b/src/util/viralloc.c @@ -66,12 +66,12 @@ int virReallocN(void *ptrptr, * allocated memory. On failure, 'ptrptr' and 'countptr' are not * changed. Any newly allocated memory in 'ptrptr' is zero-filled. * - * Returns zero on success, aborts on OOM + * Aborts on OOM */ -int virExpandN(void *ptrptr, - size_t size, - size_t *countptr, - size_t add) +void virExpandN(void *ptrptr, + size_t size, + size_t *countptr, + size_t add) { if (*countptr + add < *countptr) abort(); @@ -80,7 +80,6 @@ int virExpandN(void *ptrptr, abort(); memset(*(char **)ptrptr + (size * *countptr), 0, size * add); *countptr +=3D add; - return 0; } =20 /** @@ -192,8 +191,7 @@ virInsertElementsN(void *ptrptr, size_t size, size_t at, if (inPlace) { *countptr +=3D add; } else { - if (virExpandN(ptrptr, size, countptr, add) < 0) - abort(); + virExpandN(ptrptr, size, countptr, add); } =20 /* memory was successfully re-allocated. Move up all elements from diff --git a/src/util/viralloc.h b/src/util/viralloc.h index 878c9485cf..6051c91913 100644 --- a/src/util/viralloc.h +++ b/src/util/viralloc.h @@ -36,7 +36,7 @@ /* Don't call these directly - use the macros below */ int virReallocN(void *ptrptr, size_t size, size_t count) ATTRIBUTE_NONNULL(1); -int virExpandN(void *ptrptr, size_t size, size_t *count, size_t add) +void virExpandN(void *ptrptr, size_t size, size_t *count, size_t add) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3); void virResizeN(void *ptrptr, size_t size, size_t *alloc, size_t count, si= ze_t desired) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3); @@ -78,7 +78,7 @@ int virDeleteElementsN(void *ptrptr, size_t size, size_t = at, size_t *countptr, * * This macro is safe to use on arguments with side effects. * - * Returns 0 on success, aborts on OOM + * Aborts on OOM */ #define VIR_EXPAND_N(ptr, count, add) virExpandN(&(ptr), sizeof(*(ptr)), &= (count), add) =20 --=20 2.31.0 From nobody Sun Apr 28 04:45:17 2024 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=1616197071; cv=none; d=zohomail.com; s=zohoarc; b=fqHEmOLKps81/JRyv6z7j6zQ5Lw0YVMYbqD9tyA1rYt/l3ngeKxiSjcBC1X29ZFgcj7gTkMx5zLsE2ZwLSGyYyVXM0rkcrXdl09PKoyw+gQBUP1cDtYNKYG8AivheGmXtCrgUEU0RdjCVgVvHyPWEcHf/4seleDItZhmRitVask= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616197071; 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=afFCR6lf9jecsKdCCx/rfHxIy2CNWSJUW0n1XQkL4l4=; b=lDihFDUyDmFkuGh4iz2g8TWiiGIA5EmGZVI/aua5Gx/Plcu51gyPGcq4HjXZ2kCl6XZh82Z2XSMbo2nPm6wL5kq9YKnmpBhR5InOtdIJTUKfJCilcevmB61pQ51y476IlieGak4RaSQFTa0Hm1l5qmuZHuJlo0S1tcMOlJHYcXg= 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 1616197071802686.7916064034977; Fri, 19 Mar 2021 16:37:51 -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-489-XDJVP8sfMCOzJtURqkZLuw-1; Fri, 19 Mar 2021 19:37:47 -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 A3492180FCB5; Fri, 19 Mar 2021 23:37:41 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7D2245D9C6; Fri, 19 Mar 2021 23:37:41 +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 416B71800662; Fri, 19 Mar 2021 23:37:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 12JNbHZg029473 for ; Fri, 19 Mar 2021 19:37:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9B3E11001B2C; Fri, 19 Mar 2021 23:37:17 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.40.194.173]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E8CB910013D6 for ; Fri, 19 Mar 2021 23:37:13 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 775F4244035; Sat, 20 Mar 2021 00:37:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616197070; 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=afFCR6lf9jecsKdCCx/rfHxIy2CNWSJUW0n1XQkL4l4=; b=MWw8vZtP5boc6HrjD++YqA8qOXN3ZouQT+g0+4t7RfSS53tIfKF6P6SO/Uj1q7sTWMNuC4 2pwcmOXIOrjrhAR8xZ5SUy58mx5E2gY/kc9yD2U/SfhmVqNHwTa9INyqTn3JH9mDOW4HCj r0zW5ykfkVayc/sngRBlpmOa8XNj1Ic= X-MC-Unique: XDJVP8sfMCOzJtURqkZLuw-1 From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH 6/7] Do not check return value of VIR_REALLOC_N Date: Sat, 20 Mar 2021 00:37:05 +0100 Message-Id: <232cf0dbb24ef8491f4cce99f216d2abfe8189e7.1616196713.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiri Denemark Reviewed-by: Michal Privoznik --- src/bhyve/bhyve_parse_command.c | 8 +++--- src/conf/capabilities.c | 3 +-- src/conf/domain_conf.c | 11 ++++---- src/conf/storage_conf.c | 3 +-- src/conf/virinterfaceobj.c | 2 +- src/conf/virnetworkobj.c | 4 +-- src/conf/virnodedeviceobj.c | 2 +- src/conf/virsecretobj.c | 2 +- src/conf/virstorageobj.c | 2 +- src/esx/esx_stream.c | 3 +-- src/interface/interface_backend_netcf.c | 2 +- src/interface/interface_backend_udev.c | 2 +- src/libxl/libxl_capabilities.c | 3 +-- src/libxl/libxl_conf.c | 14 ++++------ src/libxl/libxl_driver.c | 15 ++++------- src/qemu/qemu_agent.c | 4 +-- src/qemu/qemu_firmware.c | 5 ++-- src/qemu/qemu_hotplug.c | 36 +++++++++---------------- src/qemu/qemu_monitor.c | 4 +-- src/qemu/qemu_monitor_json.c | 12 ++------- src/qemu/qemu_process.c | 25 ++--------------- src/rpc/virnetclient.c | 3 +-- src/rpc/virnetmessage.c | 12 +++------ src/storage/storage_backend_disk.c | 4 +-- src/storage/storage_backend_logical.c | 3 +-- src/storage/storage_backend_rbd.c | 3 +-- src/util/virarptable.c | 3 +-- src/util/vircommand.c | 5 ++-- src/util/virdnsmasq.c | 13 +++------ src/util/virfile.c | 5 +--- src/util/virjson.c | 13 +++------ src/util/virnuma.c | 14 +++++----- src/util/virstring.c | 3 +-- src/util/virsysinfo.c | 3 +-- src/vbox/vbox_common.c | 4 +-- tests/domaincapstest.c | 8 ++---- tests/qemublocktest.c | 3 +-- tests/viralloctest.c | 9 +++---- tools/virsh-console.c | 22 ++++++--------- tools/virt-login-shell-helper.c | 3 +-- tools/vsh.c | 6 ++--- 41 files changed, 96 insertions(+), 205 deletions(-) diff --git a/src/bhyve/bhyve_parse_command.c b/src/bhyve/bhyve_parse_comman= d.c index 8d9a21e671..70f5ac42a0 100644 --- a/src/bhyve/bhyve_parse_command.c +++ b/src/bhyve/bhyve_parse_command.c @@ -219,8 +219,8 @@ bhyveCommandLineToArgv(const char *nativeConfig, * Otherwise, later argument lists may be assigned to _argv without * freeing the earlier ones. */ if (!_bhyve_argv && STREQ(arglist[0], "/usr/sbin/bhyve")) { - if ((VIR_REALLOC_N(_bhyve_argv, args_count + 1) < 0) - || (!bhyve_argc)) + VIR_REALLOC_N(_bhyve_argv, args_count + 1); + if (!bhyve_argc) goto error; for (j =3D 0; j < args_count; j++) _bhyve_argv[j] =3D arglist[j]; @@ -228,8 +228,8 @@ bhyveCommandLineToArgv(const char *nativeConfig, *bhyve_argc =3D args_count-1; VIR_FREE(arglist); } else if (!_loader_argv) { - if ((VIR_REALLOC_N(_loader_argv, args_count + 1) < 0) - || (!loader_argc)) + VIR_REALLOC_N(_loader_argv, args_count + 1); + if (!loader_argc) goto error; for (j =3D 0; j < args_count; j++) _loader_argv[j] =3D arglist[j]; diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index bc9035afae..573ac4e975 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -1476,8 +1476,7 @@ virCapabilitiesGetNUMASiblingInfo(int node, tmp_size++; } =20 - if (VIR_REALLOC_N(tmp, tmp_size) < 0) - goto cleanup; + VIR_REALLOC_N(tmp, tmp_size); =20 *nsiblings =3D tmp_size; *siblings =3D g_steal_pointer(&tmp); diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index afbd6fc7c1..95602ae57e 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -3433,8 +3433,7 @@ virDomainIOThreadIDDefArrayInit(virDomainDefPtr def, def->iothreadids[i]->iothread_id)); =20 /* resize array */ - if (VIR_REALLOC_N(def->iothreadids, iothreads) < 0) - return -1; + VIR_REALLOC_N(def->iothreadids, iothreads); =20 /* Populate iothreadids[] using the set bit number from thrmap */ while (def->niothreadids < iothreads) { @@ -17587,7 +17586,8 @@ virDomainChrPreAlloc(virDomainDefPtr vmdef, &arrPtr, &cntPtr) < 0) return -1; =20 - return VIR_REALLOC_N(*arrPtr, *cntPtr + 1); + VIR_REALLOC_N(*arrPtr, *cntPtr + 1); + return 0; } =20 void @@ -21442,8 +21442,9 @@ virDomainDefParseXML(xmlDocPtr xml, /* analysis of the host devices */ if ((n =3D virXPathNodeSet("./devices/hostdev", ctxt, &nodes)) < 0) goto error; - if (n && VIR_REALLOC_N(def->hostdevs, def->nhostdevs + n) < 0) - goto error; + if (n > 0) + VIR_REALLOC_N(def->hostdevs, def->nhostdevs + n); + for (i =3D 0; i < n; i++) { virDomainHostdevDefPtr hostdev; =20 diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 2e07c81f8a..310a062ee7 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -1787,8 +1787,7 @@ virStoragePoolSourceListNewSource(virStoragePoolSourc= eListPtr list) { virStoragePoolSourcePtr source; =20 - if (VIR_REALLOC_N(list->sources, list->nsources + 1) < 0) - return NULL; + VIR_REALLOC_N(list->sources, list->nsources + 1); =20 source =3D &list->sources[list->nsources++]; memset(source, 0, sizeof(*source)); diff --git a/src/conf/virinterfaceobj.c b/src/conf/virinterfaceobj.c index 00180cd36e..cc990a05cd 100644 --- a/src/conf/virinterfaceobj.c +++ b/src/conf/virinterfaceobj.c @@ -329,7 +329,7 @@ virInterfaceObjListExport(virConnectPtr conn, =20 if (data.ifaces) { /* trim the array to the final size */ - ignore_value(VIR_REALLOC_N(data.ifaces, data.nifaces + 1)); + VIR_REALLOC_N(data.ifaces, data.nifaces + 1); *ifaces =3D data.ifaces; data.ifaces =3D NULL; } diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c index 6ff6c63218..47739718a7 100644 --- a/src/conf/virnetworkobj.c +++ b/src/conf/virnetworkobj.c @@ -1428,7 +1428,7 @@ virNetworkObjListExport(virConnectPtr conn, =20 if (data.nets) { /* trim the array to the final size */ - ignore_value(VIR_REALLOC_N(data.nets, data.nnets + 1)); + VIR_REALLOC_N(data.nets, data.nnets + 1); *nets =3D data.nets; data.nets =3D NULL; } @@ -1816,7 +1816,7 @@ virNetworkObjPortListExport(virNetworkPtr net, =20 if (data.ports) { /* trim the array to the final size */ - ignore_value(VIR_REALLOC_N(data.ports, data.nports + 1)); + VIR_REALLOC_N(data.ports, data.nports + 1); *ports =3D data.ports; data.ports =3D NULL; } diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c index c9bda77b2e..ecae3d0479 100644 --- a/src/conf/virnodedeviceobj.c +++ b/src/conf/virnodedeviceobj.c @@ -958,7 +958,7 @@ virNodeDeviceObjListExport(virConnectPtr conn, goto cleanup; =20 if (data.devices) { - ignore_value(VIR_REALLOC_N(data.devices, data.ndevices + 1)); + VIR_REALLOC_N(data.devices, data.ndevices + 1); *devices =3D data.devices; } =20 diff --git a/src/conf/virsecretobj.c b/src/conf/virsecretobj.c index fd27bb1f01..a15a288371 100644 --- a/src/conf/virsecretobj.c +++ b/src/conf/virsecretobj.c @@ -598,7 +598,7 @@ virSecretObjListExport(virConnectPtr conn, =20 if (data.secrets) { /* trim the array to the final size */ - ignore_value(VIR_REALLOC_N(data.secrets, data.nsecrets + 1)); + VIR_REALLOC_N(data.secrets, data.nsecrets + 1); *secrets =3D data.secrets; } =20 diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c index 69c2c2da36..0e27b0ca65 100644 --- a/src/conf/virstorageobj.c +++ b/src/conf/virstorageobj.c @@ -2089,7 +2089,7 @@ virStoragePoolObjListExport(virConnectPtr conn, =20 if (data.pools) { /* trim the array to the final size */ - ignore_value(VIR_REALLOC_N(data.pools, data.nPools + 1)); + VIR_REALLOC_N(data.pools, data.nPools + 1); *pools =3D data.pools; } =20 diff --git a/src/esx/esx_stream.c b/src/esx/esx_stream.c index e4e67a01bb..5b20804bb1 100644 --- a/src/esx/esx_stream.c +++ b/src/esx/esx_stream.c @@ -136,8 +136,7 @@ esxVI_CURL_WriteStream(char *input, size_t size, size_t= nmemb, void *userdata) } else if (input_remaining > backlog_remaining) { priv->backlog_size +=3D input_remaining - backlog_remaining; =20 - if (VIR_REALLOC_N(priv->backlog, priv->backlog_size) < 0) - return 0; + VIR_REALLOC_N(priv->backlog, priv->backlog_size); } =20 memcpy(priv->backlog + priv->backlog_used, input + input_used, diff --git a/src/interface/interface_backend_netcf.c b/src/interface/interf= ace_backend_netcf.c index 7c0edfae63..54a141eaa9 100644 --- a/src/interface/interface_backend_netcf.c +++ b/src/interface/interface_backend_netcf.c @@ -714,7 +714,7 @@ netcfConnectListAllInterfaces(virConnectPtr conn, =20 if (tmp_iface_objs) { /* trim the array to the final size */ - ignore_value(VIR_REALLOC_N(tmp_iface_objs, niface_objs + 1)); + VIR_REALLOC_N(tmp_iface_objs, niface_objs + 1); *ifaces =3D g_steal_pointer(&tmp_iface_objs); } =20 diff --git a/src/interface/interface_backend_udev.c b/src/interface/interfa= ce_backend_udev.c index b6809a45f3..d5bd7c8b18 100644 --- a/src/interface/interface_backend_udev.c +++ b/src/interface/interface_backend_udev.c @@ -393,7 +393,7 @@ udevConnectListAllInterfaces(virConnectPtr conn, =20 /* Trim the array to its final size */ if (ifaces) { - ignore_value(VIR_REALLOC_N(ifaces_list, count + 1)); + VIR_REALLOC_N(ifaces_list, count + 1); *ifaces =3D g_steal_pointer(&ifaces_list); } =20 diff --git a/src/libxl/libxl_capabilities.c b/src/libxl/libxl_capabilities.c index 10e5d46cdd..8faca38cbc 100644 --- a/src/libxl/libxl_capabilities.c +++ b/src/libxl/libxl_capabilities.c @@ -285,8 +285,7 @@ libxlCapsInitNuma(libxl_ctx *ctx, virCapsPtr caps) if (nr_cpus_node[node] =3D=3D 1) { cpus[node] =3D g_new0(virCapsHostNUMACellCPU, 1); } else { - if (VIR_REALLOC_N(cpus[node], nr_cpus_node[node]) < 0) - goto cleanup; + VIR_REALLOC_N(cpus[node], nr_cpus_node[node]); } =20 /* Mapping between what libxl tells and what libvirt wants */ diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index 5ee15d42e3..90528d4765 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -1751,9 +1751,10 @@ libxlDriverConfigNew(void) #ifdef DEFAULT_LOADER_NVRAM if (virFirmwareParseList(DEFAULT_LOADER_NVRAM, &cfg->firmwares, - &cfg->nfirmwares) < 0) - goto error; - + &cfg->nfirmwares) < 0) { + virObjectUnref(cfg); + return NULL; + } #else cfg->firmwares =3D g_new0(virFirmwarePtr, 1); cfg->nfirmwares =3D 1; @@ -1762,8 +1763,7 @@ libxlDriverConfigNew(void) #endif =20 /* Always add hvmloader to firmwares */ - if (VIR_REALLOC_N(cfg->firmwares, cfg->nfirmwares + 1) < 0) - goto error; + VIR_REALLOC_N(cfg->firmwares, cfg->nfirmwares + 1); cfg->nfirmwares++; cfg->firmwares[cfg->nfirmwares - 1] =3D g_new0(virFirmware, 1); cfg->firmwares[cfg->nfirmwares - 1]->name =3D g_strdup(LIBXL_FIRMWARE_= DIR "/hvmloader"); @@ -1773,10 +1773,6 @@ libxlDriverConfigNew(void) cfg->keepAliveCount =3D 5; =20 return cfg; - - error: - virObjectUnref(cfg); - return NULL; } =20 int diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index e3d769b5d9..830634b2bd 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -3054,8 +3054,7 @@ libxlDomainAttachDeviceDiskLive(virDomainObjPtr vm, v= irDomainDeviceDefPtr dev) goto cleanup; } =20 - if (VIR_REALLOC_N(vm->def->disks, vm->def->ndisks+1) < 0) - goto cleanup; + VIR_REALLOC_N(vm->def->disks, vm->def->ndisks+1); =20 if (libxlMakeDisk(l_disk, &x_disk) < 0) goto cleanup; @@ -3122,8 +3121,7 @@ libxlDomainAttachHostPCIDevice(libxlDriverPrivatePtr = driver, goto cleanup; } =20 - if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1) < 0) - goto cleanup; + VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1); =20 if (virHostdevPreparePCIDevices(hostdev_mgr, LIBXL_DRIVER_INTERNAL_NAM= E, vm->def->name, vm->def->uuid, @@ -3190,8 +3188,7 @@ libxlDomainAttachControllerDevice(libxlDriverPrivateP= tr driver, goto cleanup; } =20 - if (VIR_REALLOC_N(vm->def->controllers, vm->def->ncontrollers + 1) < 0) - goto cleanup; + VIR_REALLOC_N(vm->def->controllers, vm->def->ncontrollers + 1); =20 if (libxlMakeUSBController(controller, &usbctrl) < 0) goto cleanup; @@ -3259,8 +3256,7 @@ libxlDomainAttachHostUSBDevice(libxlDriverPrivatePtr = driver, } } =20 - if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1) < 0) - goto cleanup; + VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1); =20 if (virHostdevPrepareUSBDevices(hostdev_mgr, LIBXL_DRIVER_INTERNAL_NAM= E, vm->def->name, &hostdev, 1, 0) < 0) @@ -3403,8 +3399,7 @@ libxlDomainAttachNetDevice(libxlDriverPrivatePtr driv= er, libxl_device_nic_init(&nic); =20 /* preallocate new slot for device */ - if (VIR_REALLOC_N(vm->def->nets, vm->def->nnets + 1) < 0) - goto cleanup; + VIR_REALLOC_N(vm->def->nets, vm->def->nnets + 1); =20 /* If appropriate, grab a physical device from the configured * network's pool of devices, or resolve bridge device name diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index fa37d284b3..02793edd02 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -456,9 +456,7 @@ qemuAgentIORead(qemuAgentPtr agent) QEMU_AGENT_MAX_RESPONSE); return -1; } - if (VIR_REALLOC_N(agent->buffer, - agent->bufferLength + 1024) < 0) - return -1; + VIR_REALLOC_N(agent->buffer, agent->bufferLength + 1024); agent->bufferLength +=3D 1024; avail +=3D 1024; } diff --git a/src/qemu/qemu_firmware.c b/src/qemu/qemu_firmware.c index eb33441272..a211d2fb36 100644 --- a/src/qemu/qemu_firmware.c +++ b/src/qemu/qemu_firmware.c @@ -1464,9 +1464,8 @@ qemuFirmwareGetSupported(const char *machine, } } =20 - if (fws && !*fws && nfirmwares && - VIR_REALLOC_N(*fws, 0) < 0) - return -1; + if (fws && !*fws && nfirmwares) + VIR_REALLOC_N(*fws, 0); =20 for (i =3D 0; i < nfirmwares; i++) qemuFirmwareFree(firmwares[i]); diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index a66354426d..58d2abb862 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -737,8 +737,7 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver, if (!(devstr =3D qemuBuildDiskDeviceStr(vm->def, disk, 0, priv->qemuCa= ps))) goto cleanup; =20 - if (VIR_REALLOC_N(vm->def->disks, vm->def->ndisks + 1) < 0) - goto cleanup; + VIR_REALLOC_N(vm->def->disks, vm->def->ndisks + 1); =20 if (qemuHotplugAttachManagedPR(driver, vm, disk->src, QEMU_ASYNC_JOB_N= ONE) < 0) goto cleanup; @@ -880,8 +879,7 @@ int qemuDomainAttachControllerDevice(virQEMUDriverPtr d= river, if (!devstr) goto cleanup; =20 - if (VIR_REALLOC_N(vm->def->controllers, vm->def->ncontrollers+1) < 0) - goto cleanup; + VIR_REALLOC_N(vm->def->controllers, vm->def->ncontrollers+1); =20 qemuDomainObjEnterMonitor(driver, vm); =20 @@ -1198,8 +1196,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, virErrorPtr save_err =3D NULL; =20 /* preallocate new slot for device */ - if (VIR_REALLOC_N(vm->def->nets, vm->def->nnets + 1) < 0) - goto cleanup; + VIR_REALLOC_N(vm->def->nets, vm->def->nnets + 1); =20 /* If appropriate, grab a physical device from the configured * network's pool of devices, or resolve bridge device name @@ -1604,8 +1601,7 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver, g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); unsigned int flags =3D 0; =20 - if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1) < 0) - return -1; + VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1); =20 if (!cfg->relaxedACS) flags |=3D VIR_HOSTDEV_STRICT_ACS_CHECK; @@ -1938,8 +1934,7 @@ int qemuDomainAttachRedirdevDevice(virQEMUDriverPtr d= river, if (!(devstr =3D qemuBuildRedirdevDevStr(def, redirdev, priv->qemuCaps= ))) goto cleanup; =20 - if (VIR_REALLOC_N(def->redirdevs, def->nredirdevs+1) < 0) - goto cleanup; + VIR_REALLOC_N(def->redirdevs, def->nredirdevs+1); =20 if (qemuDomainAddChardevTLSObjects(driver, vm, redirdev->source, redirdev->info.alias, charAlias, @@ -2286,8 +2281,7 @@ qemuDomainAttachRNGDevice(virQEMUDriverPtr driver, goto cleanup; =20 /* preallocate space for the device definition */ - if (VIR_REALLOC_N(vm->def->rngs, vm->def->nrngs + 1) < 0) - goto cleanup; + VIR_REALLOC_N(vm->def->rngs, vm->def->nrngs + 1); =20 if (qemuDomainEnsureVirtioAddress(&releaseaddr, vm, &dev, "rng") < 0) return -1; @@ -2569,8 +2563,7 @@ qemuDomainAttachHostUSBDevice(virQEMUDriverPtr driver, if (!(devstr =3D qemuBuildUSBHostdevDevStr(vm->def, hostdev, priv->qem= uCaps))) goto cleanup; =20 - if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs+1) < 0) - goto cleanup; + VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs+1); =20 qemuDomainObjEnterMonitor(driver, vm); ret =3D qemuMonitorAddDevice(priv->mon, devstr); @@ -2662,8 +2655,7 @@ qemuDomainAttachHostSCSIDevice(virQEMUDriverPtr drive= r, if (!(devstr =3D qemuBuildSCSIHostdevDevStr(vm->def, hostdev, backenda= lias))) goto cleanup; =20 - if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1) < 0) - goto cleanup; + VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1); =20 qemuDomainObjEnterMonitor(driver, vm); =20 @@ -2774,8 +2766,7 @@ qemuDomainAttachSCSIVHostDevice(virQEMUDriverPtr driv= er, vhostfdName))) goto cleanup; =20 - if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1) < 0) - goto cleanup; + VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1); =20 qemuDomainObjEnterMonitor(driver, vm); =20 @@ -2877,8 +2868,7 @@ qemuDomainAttachMediatedDevice(virQEMUDriverPtr drive= r, priv->qemuCaps))) goto cleanup; =20 - if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1) < 0) - goto cleanup; + VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1); =20 if (qemuDomainAdjustMaxMemLockHostdev(vm, hostdev) < 0) goto cleanup; @@ -3006,8 +2996,7 @@ qemuDomainAttachShmemDevice(virQEMUDriverPtr driver, =20 qemuDomainPrepareShmemChardev(shmem); =20 - if (VIR_REALLOC_N(vm->def->shmems, vm->def->nshmems + 1) < 0) - return -1; + VIR_REALLOC_N(vm->def->shmems, vm->def->nshmems + 1); =20 if ((shmem->info.type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE || shmem->info.type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) && @@ -3209,8 +3198,7 @@ qemuDomainAttachInputDevice(virQEMUDriverPtr driver, goto cleanup; teardownlabel =3D true; =20 - if (VIR_REALLOC_N(vm->def->inputs, vm->def->ninputs + 1) < 0) - goto cleanup; + VIR_REALLOC_N(vm->def->inputs, vm->def->ninputs + 1); =20 qemuDomainObjEnterMonitor(driver, vm); =20 diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index c43c6f180e..3760349450 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -474,9 +474,7 @@ qemuMonitorIORead(qemuMonitorPtr mon) QEMU_MONITOR_MAX_RESPONSE); return -1; } - if (VIR_REALLOC_N(mon->buffer, - mon->bufferLength + 1024) < 0) - return -1; + VIR_REALLOC_N(mon->buffer, mon->bufferLength + 1024); mon->bufferLength +=3D 1024; avail +=3D 1024; } diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 5e7f425495..c87a4c6ed1 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -659,12 +659,8 @@ qemuMonitorJSONParseKeywords(const char *str, } =20 if (keywordAlloc =3D=3D keywordCount) { - if (VIR_REALLOC_N(keywords, keywordAlloc + 10) < 0 || - VIR_REALLOC_N(values, keywordAlloc + 10) < 0) { - VIR_FREE(keyword); - VIR_FREE(value); - goto error; - } + VIR_REALLOC_N(keywords, keywordAlloc + 10); + VIR_REALLOC_N(values, keywordAlloc + 10); keywordAlloc +=3D 10; } =20 @@ -679,10 +675,6 @@ qemuMonitorJSONParseKeywords(const char *str, *retvalues =3D values; *retnkeywords =3D keywordCount; return 0; - - error: - qemuMonitorJSONParseKeywordsFree(keywordCount, keywords, values); - return -1; } =20 =20 diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index b86afe4daa..fedd1f56b1 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -1073,7 +1073,6 @@ qemuProcessHandleGraphics(qemuMonitorPtr mon G_GNUC_U= NUSED, virDomainEventGraphicsAddressPtr localAddr =3D NULL; virDomainEventGraphicsAddressPtr remoteAddr =3D NULL; virDomainEventGraphicsSubjectPtr subject =3D NULL; - size_t i; =20 localAddr =3D g_new0(virDomainEventGraphicsAddress, 1); localAddr->family =3D localFamily; @@ -1087,15 +1086,13 @@ qemuProcessHandleGraphics(qemuMonitorPtr mon G_GNUC= _UNUSED, =20 subject =3D g_new0(virDomainEventGraphicsSubject, 1); if (x509dname) { - if (VIR_REALLOC_N(subject->identities, subject->nidentity+1) < 0) - goto error; + VIR_REALLOC_N(subject->identities, subject->nidentity+1); subject->nidentity++; subject->identities[subject->nidentity - 1].type =3D g_strdup("x50= 9dname"); subject->identities[subject->nidentity - 1].name =3D g_strdup(x509= dname); } if (saslUsername) { - if (VIR_REALLOC_N(subject->identities, subject->nidentity+1) < 0) - goto error; + VIR_REALLOC_N(subject->identities, subject->nidentity+1); subject->nidentity++; subject->identities[subject->nidentity - 1].type =3D g_strdup("sas= lUsername"); subject->identities[subject->nidentity - 1].name =3D g_strdup(sasl= Username); @@ -1108,24 +1105,6 @@ qemuProcessHandleGraphics(qemuMonitorPtr mon G_GNUC_= UNUSED, virObjectEventStateQueue(driver->domainEventState, event); =20 return 0; - - error: - VIR_FREE(localAddr->service); - VIR_FREE(localAddr->node); - VIR_FREE(localAddr); - - VIR_FREE(remoteAddr->service); - VIR_FREE(remoteAddr->node); - VIR_FREE(remoteAddr); - - for (i =3D 0; i < subject->nidentity; i++) { - VIR_FREE(subject->identities[i].type); - VIR_FREE(subject->identities[i].name); - } - VIR_FREE(subject->identities); - VIR_FREE(subject); - - return -1; } =20 static int diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c index 2de5cfe4b6..1ac6bc08de 100644 --- a/src/rpc/virnetclient.c +++ b/src/rpc/virnetclient.c @@ -1154,8 +1154,7 @@ virNetClientCallDispatchReply(virNetClientPtr client) return -1; } =20 - if (VIR_REALLOC_N(thecall->msg->buffer, client->msg.bufferLength) < 0) - return -1; + VIR_REALLOC_N(thecall->msg->buffer, client->msg.bufferLength); =20 memcpy(thecall->msg->buffer, client->msg.buffer, client->msg.bufferLen= gth); memcpy(&thecall->msg->header, &client->msg.header, sizeof(client->msg.= header)); diff --git a/src/rpc/virnetmessage.c b/src/rpc/virnetmessage.c index 9f7334ae4c..f2b8526817 100644 --- a/src/rpc/virnetmessage.c +++ b/src/rpc/virnetmessage.c @@ -152,8 +152,7 @@ int virNetMessageDecodeLength(virNetMessagePtr msg) /* Extend our declared buffer length and carry on reading the header + payload */ msg->bufferLength +=3D len; - if (VIR_REALLOC_N(msg->buffer, msg->bufferLength) < 0) - goto cleanup; + VIR_REALLOC_N(msg->buffer, msg->bufferLength); =20 VIR_DEBUG("Got length, now need %zu total (%u more)", msg->bufferLength, len); @@ -229,8 +228,7 @@ int virNetMessageEncodeHeader(virNetMessagePtr msg) unsigned int len =3D 0; =20 msg->bufferLength =3D VIR_NET_MESSAGE_INITIAL + VIR_NET_MESSAGE_LEN_MA= X; - if (VIR_REALLOC_N(msg->buffer, msg->bufferLength) < 0) - return ret; + VIR_REALLOC_N(msg->buffer, msg->bufferLength); msg->bufferOffset =3D 0; =20 /* Format the header. */ @@ -370,8 +368,7 @@ int virNetMessageEncodePayload(virNetMessagePtr msg, =20 msg->bufferLength =3D newlen + VIR_NET_MESSAGE_LEN_MAX; =20 - if (VIR_REALLOC_N(msg->buffer, msg->bufferLength) < 0) - goto error; + VIR_REALLOC_N(msg->buffer, msg->bufferLength); =20 xdrmem_create(&xdr, msg->buffer + msg->bufferOffset, msg->bufferLength - msg->bufferOffset, XDR_ENCODE); @@ -454,8 +451,7 @@ int virNetMessageEncodePayloadRaw(virNetMessagePtr msg, =20 msg->bufferLength =3D msg->bufferOffset + len; =20 - if (VIR_REALLOC_N(msg->buffer, msg->bufferLength) < 0) - return -1; + VIR_REALLOC_N(msg->buffer, msg->bufferLength); =20 VIR_DEBUG("Increased message buffer length =3D %zu", msg->bufferLe= ngth); } diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backe= nd_disk.c index af90f3fc45..49747cb7c9 100644 --- a/src/storage/storage_backend_disk.c +++ b/src/storage/storage_backend_disk.c @@ -235,9 +235,7 @@ virStorageBackendDiskMakeFreeExtent(virStoragePoolObjPt= r pool, virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); virStoragePoolSourceDevicePtr dev =3D &def->source.devices[0]; =20 - if (VIR_REALLOC_N(dev->freeExtents, - dev->nfreeExtent + 1) < 0) - return -1; + VIR_REALLOC_N(dev->freeExtents, dev->nfreeExtent + 1); =20 memset(dev->freeExtents + dev->nfreeExtent, 0, diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_ba= ckend_logical.c index ead3dab4fd..3e65318188 100644 --- a/src/storage/storage_backend_logical.c +++ b/src/storage/storage_backend_logical.c @@ -447,8 +447,7 @@ virStorageBackendLogicalFindPoolSourcesFunc(char **cons= t groups, thisSource->name =3D g_steal_pointer(&vgname); } =20 - if (VIR_REALLOC_N(thisSource->devices, thisSource->ndevice + 1) !=3D 0) - return -1; + VIR_REALLOC_N(thisSource->devices, thisSource->ndevice + 1); =20 dev =3D &thisSource->devices[thisSource->ndevice]; thisSource->ndevice++; diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backen= d_rbd.c index 33dda27087..871304d0d3 100644 --- a/src/storage/storage_backend_rbd.c +++ b/src/storage/storage_backend_rbd.c @@ -583,8 +583,7 @@ virStorageBackendRBDGetVolNames(virStorageBackendRBDSta= tePtr ptr) size_t i; =20 while (true) { - if (VIR_REALLOC_N(images, nimages) < 0) - goto error; + VIR_REALLOC_N(images, nimages); =20 rc =3D rbd_list2(ptr->ioctx, images, &nimages); if (rc >=3D 0) diff --git a/src/util/virarptable.c b/src/util/virarptable.c index dfe3ebee5b..6abf5b454a 100644 --- a/src/util/virarptable.c +++ b/src/util/virarptable.c @@ -114,9 +114,8 @@ virArpTableGet(void) if (tb[NDA_DST]) { g_autofree char *ipstr =3D NULL; virSocketAddr virAddr; - if (VIR_REALLOC_N(table->t, num + 1) < 0) - goto cleanup; =20 + VIR_REALLOC_N(table->t, num + 1); table->n =3D num + 1; =20 addr =3D RTA_DATA(tb[NDA_DST]); diff --git a/src/util/vircommand.c b/src/util/vircommand.c index 29c17454d8..eb70f8cf85 100644 --- a/src/util/vircommand.c +++ b/src/util/vircommand.c @@ -1742,7 +1742,7 @@ virCommandSetSendBuffer(virCommandPtr cmd, } =20 i =3D virCommandGetNumSendBuffers(cmd); - ignore_value(VIR_REALLOC_N(cmd->sendBuffers, i + 1)); + VIR_REALLOC_N(cmd->sendBuffers, i + 1); =20 cmd->sendBuffers[i].fd =3D pipefd[1]; cmd->sendBuffers[i].buffer =3D g_steal_pointer(&localbuf); @@ -2250,8 +2250,7 @@ virCommandProcessIO(virCommandPtr cmd) else errfd =3D -1; } else { - if (VIR_REALLOC_N(*buf, *len + done + 1) < 0) - goto cleanup; + VIR_REALLOC_N(*buf, *len + done + 1); memcpy(*buf + *len, data, done); *len +=3D done; } diff --git a/src/util/virdnsmasq.c b/src/util/virdnsmasq.c index 3913114eca..fa59954997 100644 --- a/src/util/virdnsmasq.c +++ b/src/util/virdnsmasq.c @@ -105,8 +105,7 @@ addnhostsAdd(dnsmasqAddnHostsfile *addnhostsfile, } =20 if (idx < 0) { - if (VIR_REALLOC_N(addnhostsfile->hosts, addnhostsfile->nhosts + 1)= < 0) - goto error; + VIR_REALLOC_N(addnhostsfile->hosts, addnhostsfile->nhosts + 1); =20 idx =3D addnhostsfile->nhosts; addnhostsfile->hosts[idx].hostnames =3D g_new0(char *, 1); @@ -117,8 +116,7 @@ addnhostsAdd(dnsmasqAddnHostsfile *addnhostsfile, addnhostsfile->nhosts++; } =20 - if (VIR_REALLOC_N(addnhostsfile->hosts[idx].hostnames, addnhostsfile->= hosts[idx].nhostnames + 1) < 0) - goto error; + VIR_REALLOC_N(addnhostsfile->hosts[idx].hostnames, addnhostsfile->host= s[idx].nhostnames + 1); =20 addnhostsfile->hosts[idx].hostnames[addnhostsfile->hosts[idx].nhostnam= es] =3D g_strdup(name); =20 @@ -127,10 +125,6 @@ addnhostsAdd(dnsmasqAddnHostsfile *addnhostsfile, addnhostsfile->hosts[idx].nhostnames++; =20 return 0; - - error: - VIR_FREE(ipstr); - return -1; } =20 static dnsmasqAddnHostsfile * @@ -297,8 +291,7 @@ hostsfileAdd(dnsmasqHostsfile *hostsfile, g_autofree char *ipstr =3D NULL; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 - if (VIR_REALLOC_N(hostsfile->hosts, hostsfile->nhosts + 1) < 0) - return -1; + VIR_REALLOC_N(hostsfile->hosts, hostsfile->nhosts + 1); =20 if (!(ipstr =3D virSocketAddrFormat(ip))) return -1; diff --git a/src/util/virfile.c b/src/util/virfile.c index c0730f6641..93fac200cc 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -1346,10 +1346,7 @@ saferead_lim(int fd, size_t max_len, size_t *length) if (alloc < size + BUFSIZ + 1) alloc =3D size + BUFSIZ + 1; =20 - if (VIR_REALLOC_N(buf, alloc) < 0) { - save_errno =3D errno; - break; - } + VIR_REALLOC_N(buf, alloc); } =20 /* Ensure that (size + requested <=3D max_len); */ diff --git a/src/util/virjson.c b/src/util/virjson.c index f2a6024db6..9eb4dc4f18 100644 --- a/src/util/virjson.c +++ b/src/util/virjson.c @@ -779,9 +779,7 @@ virJSONValueArrayAppend(virJSONValuePtr array, return -1; } =20 - if (VIR_REALLOC_N(array->data.array.values, - array->data.array.nvalues + 1) < 0) - return -1; + VIR_REALLOC_N(array->data.array.values, array->data.array.nvalues + 1); =20 array->data.array.values[array->data.array.nvalues] =3D g_steal_pointe= r(value); array->data.array.nvalues++; @@ -1697,10 +1695,7 @@ virJSONParserHandleStartMap(void *ctx) if (virJSONParserInsertValue(parser, &value) < 0) return 0; =20 - if (VIR_REALLOC_N(parser->state, - parser->nstate + 1) < 0) { - return 0; - } + VIR_REALLOC_N(parser->state, parser->nstate + 1); =20 parser->state[parser->nstate].value =3D tmp; parser->state[parser->nstate].key =3D NULL; @@ -1745,9 +1740,7 @@ virJSONParserHandleStartArray(void *ctx) if (virJSONParserInsertValue(parser, &value) < 0) return 0; =20 - if (VIR_REALLOC_N(parser->state, - parser->nstate + 1) < 0) - return 0; + VIR_REALLOC_N(parser->state, parser->nstate + 1); =20 parser->state[parser->nstate].value =3D tmp; parser->state[parser->nstate].key =3D NULL; diff --git a/src/util/virnuma.c b/src/util/virnuma.c index a05e4ac72c..6c194b54d1 100644 --- a/src/util/virnuma.c +++ b/src/util/virnuma.c @@ -795,10 +795,9 @@ virNumaGetPages(int node, &page_avail, &page_free) < 0) return -1; =20 - if (VIR_REALLOC_N(tmp_size, ntmp + 1) < 0 || - VIR_REALLOC_N(tmp_avail, ntmp + 1) < 0 || - VIR_REALLOC_N(tmp_free, ntmp + 1) < 0) - return -1; + VIR_REALLOC_N(tmp_size, ntmp + 1); + VIR_REALLOC_N(tmp_avail, ntmp + 1); + VIR_REALLOC_N(tmp_free, ntmp + 1); =20 tmp_size[ntmp] =3D page_size; tmp_avail[ntmp] =3D page_avail; @@ -814,10 +813,9 @@ virNumaGetPages(int node, return -1; =20 /* Now append the ordinary system pages */ - if (VIR_REALLOC_N(tmp_size, ntmp + 1) < 0 || - VIR_REALLOC_N(tmp_avail, ntmp + 1) < 0 || - VIR_REALLOC_N(tmp_free, ntmp + 1) < 0) - return -1; + VIR_REALLOC_N(tmp_size, ntmp + 1); + VIR_REALLOC_N(tmp_avail, ntmp + 1); + VIR_REALLOC_N(tmp_free, ntmp + 1); =20 if (virNumaGetPageInfo(node, system_page_size, huge_page_sum, &tmp_avail[ntmp], &tmp_free[ntmp]) < 0) diff --git a/src/util/virstring.c b/src/util/virstring.c index 07594292bb..7749eb2db5 100644 --- a/src/util/virstring.c +++ b/src/util/virstring.c @@ -78,8 +78,7 @@ virStringListMerge(char ***dst, dst_len =3D g_strv_length(*dst); src_len =3D g_strv_length(*src); =20 - if (VIR_REALLOC_N(*dst, dst_len + src_len + 1) < 0) - return -1; + VIR_REALLOC_N(*dst, dst_len + src_len + 1); =20 for (i =3D 0; i <=3D src_len; i++) (*dst)[i + dst_len] =3D (*src)[i]; diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c index df1cf59709..2ddbc1ac17 100644 --- a/src/util/virsysinfo.c +++ b/src/util/virsysinfo.c @@ -827,8 +827,7 @@ virSysinfoParseX86BaseBoard(const char *base, if (nboards =3D=3D 0) { VIR_FREE(boards); } else { - /* This is safe, as we can be only shrinking the memory */ - ignore_value(VIR_REALLOC_N(boards, nboards)); + VIR_REALLOC_N(boards, nboards); } =20 *nbaseBoard =3D nboards; diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 69b99317f2..2ac22120d8 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -7560,9 +7560,7 @@ vboxConnectListAllDomains(virConnectPtr conn, } =20 if (doms) { - /* safe to ignore, new size will be equal or less than - * previous allocation */ - ignore_value(VIR_REALLOC_N(doms, count + 1)); + VIR_REALLOC_N(doms, count + 1); *domains =3D g_steal_pointer(&doms); } =20 diff --git a/tests/domaincapstest.c b/tests/domaincapstest.c index 65d9f4c635..f913346331 100644 --- a/tests/domaincapstest.c +++ b/tests/domaincapstest.c @@ -30,22 +30,18 @@ static int G_GNUC_NULL_TERMINATED fillStringValues(virDomainCapsStringValuesPtr values, ...) { - int ret =3D 0; va_list list; const char *str; =20 va_start(list, values); while ((str =3D va_arg(list, const char *))) { - if (VIR_REALLOC_N(values->values, values->nvalues + 1) < 0) { - ret =3D -1; - break; - } + VIR_REALLOC_N(values->values, values->nvalues + 1); values->values[values->nvalues] =3D g_strdup(str); values->nvalues++; } va_end(list); =20 - return ret; + return 0; } #endif /* WITH_QEMU || WITH_BHYVE */ =20 diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c index bbfcfee92d..5cc7c27ebe 100644 --- a/tests/qemublocktest.c +++ b/tests/qemublocktest.c @@ -316,8 +316,7 @@ testQemuDiskXMLToProps(const void *opaque) return -1; } =20 - if (VIR_REALLOC_N(data->images, data->nimages + 1) < 0) - return -1; + VIR_REALLOC_N(data->images, data->nimages + 1); =20 data->images[data->nimages].formatprops =3D g_steal_pointer(&forma= tProps); data->images[data->nimages].storageprops =3D g_steal_pointer(&stor= ageProps); diff --git a/tests/viralloctest.c b/tests/viralloctest.c index 5e27aa51c0..1dc11dce7b 100644 --- a/tests/viralloctest.c +++ b/tests/viralloctest.c @@ -60,8 +60,7 @@ testReallocArray(const void *opaque G_GNUC_UNUSED) t[i].b =3D 20; } =20 - if (VIR_REALLOC_N(t, nt + 5) < 0) - goto cleanup; + VIR_REALLOC_N(t, nt + 5); =20 if (testCheckNonNull(t) < 0) goto cleanup; @@ -74,8 +73,7 @@ testReallocArray(const void *opaque G_GNUC_UNUSED) } } =20 - if (VIR_REALLOC_N(t, nt) < 0) - goto cleanup; + VIR_REALLOC_N(t, nt); =20 if (testCheckNonNull(t) < 0) goto cleanup; @@ -88,8 +86,7 @@ testReallocArray(const void *opaque G_GNUC_UNUSED) } } =20 - if (VIR_REALLOC_N(t, nt - 5) < 0) - goto cleanup; + VIR_REALLOC_N(t, nt - 5); =20 if (testCheckNonNull(t) < 0) goto cleanup; diff --git a/tools/virsh-console.c b/tools/virsh-console.c index 4e9bdb67e1..39e38e5959 100644 --- a/tools/virsh-console.c +++ b/tools/virsh-console.c @@ -167,11 +167,8 @@ virConsoleEventOnStream(virStreamPtr st, int got; =20 if (avail < 1024) { - if (VIR_REALLOC_N(con->streamToTerminal.data, - con->streamToTerminal.length + 1024) < 0) { - virConsoleShutdown(con, false); - goto cleanup; - } + VIR_REALLOC_N(con->streamToTerminal.data, + con->streamToTerminal.length + 1024); con->streamToTerminal.length +=3D 1024; avail +=3D 1024; } @@ -212,8 +209,8 @@ virConsoleEventOnStream(virStreamPtr st, =20 avail =3D con->terminalToStream.length - con->terminalToStream.off= set; if (avail > 1024) { - ignore_value(VIR_REALLOC_N(con->terminalToStream.data, - con->terminalToStream.offset + 1024= )); + VIR_REALLOC_N(con->terminalToStream.data, + con->terminalToStream.offset + 1024); con->terminalToStream.length =3D con->terminalToStream.offset = + 1024; } } @@ -251,11 +248,8 @@ virConsoleEventOnStdin(int watch G_GNUC_UNUSED, int got; =20 if (avail < 1024) { - if (VIR_REALLOC_N(con->terminalToStream.data, - con->terminalToStream.length + 1024) < 0) { - virConsoleShutdown(con, false); - goto cleanup; - } + VIR_REALLOC_N(con->terminalToStream.data, + con->terminalToStream.length + 1024); con->terminalToStream.length +=3D 1024; avail +=3D 1024; } @@ -340,8 +334,8 @@ virConsoleEventOnStdout(int watch G_GNUC_UNUSED, =20 avail =3D con->streamToTerminal.length - con->streamToTerminal.off= set; if (avail > 1024) { - ignore_value(VIR_REALLOC_N(con->streamToTerminal.data, - con->streamToTerminal.offset + 1024= )); + VIR_REALLOC_N(con->streamToTerminal.data, + con->streamToTerminal.offset + 1024); con->streamToTerminal.length =3D con->streamToTerminal.offset = + 1024; } } diff --git a/tools/virt-login-shell-helper.c b/tools/virt-login-shell-helpe= r.c index 1ac02bed00..f848056386 100644 --- a/tools/virt-login-shell-helper.c +++ b/tools/virt-login-shell-helper.c @@ -335,8 +335,7 @@ main(int argc, char **argv) } =20 if (cmdstr) { - if (VIR_REALLOC_N(shargv, shargvlen + 3) < 0) - goto cleanup; + VIR_REALLOC_N(shargv, shargvlen + 3); shargv[shargvlen++] =3D g_strdup("-c"); shargv[shargvlen++] =3D g_strdup(cmdstr); shargv[shargvlen] =3D NULL; diff --git a/tools/vsh.c b/tools/vsh.c index 8fb033249e..1ffc13d443 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -2582,8 +2582,7 @@ vshReadlineCommandGenerator(void) if (cmds[cmd_list_index].flags & VSH_CMD_FLAG_ALIAS) continue; =20 - if (VIR_REALLOC_N(ret, ret_size + 2) < 0) - return NULL; + VIR_REALLOC_N(ret, ret_size + 2); =20 ret[ret_size] =3D g_strdup(name); ret_size++; @@ -2630,8 +2629,7 @@ vshReadlineOptionsGenerator(const vshCmdDef *cmd, if (exists) continue; =20 - if (VIR_REALLOC_N(ret, ret_size + 2) < 0) - return NULL; + VIR_REALLOC_N(ret, ret_size + 2); =20 ret[ret_size] =3D g_strdup_printf("--%s", name); ret_size++; --=20 2.31.0 From nobody Sun Apr 28 04:45:17 2024 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=1616197049; cv=none; d=zohomail.com; s=zohoarc; b=NoAf4VyAfHFrmae86IIHddYvBsMkRW4HNy6ntkTysv9/sLegu/gpC4vcqlFxglAuzFDY4Pugy5koxmqLZ6Wb5dkXBbBoLTtJJsYIf4B46T75ihXTrn7YQwmynNv/yD8EdNJs5TAzuCsLJh9ZVRMLy420qDuu5F7zuTybp9A//uI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616197049; 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=xU8PPcibSqp0Wik72ixSub0/ibl+I974HDFOnL1RX0A=; b=ZPMVLVpZUAOiI1v5fEIMomppvdA1KnerOSfEPUPniFkrlShKAPCqvdWArGY7apZd5bHRiqrEfOrFa0/YxK3R+A06BU7vgrQ0H77YkfdjY0B7YolU9yAyUr7cS1++K5MfxaAicKYv2kUqMBdw8VmanpqLTPXflmVe/Fqrv5Z24aw= 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 1616197049087385.5123043569241; Fri, 19 Mar 2021 16:37:29 -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-465-xShrIQyfNu-mx1BhJtGu9w-1; Fri, 19 Mar 2021 19:37:25 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A95EB881282; Fri, 19 Mar 2021 23:37:19 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5CF3E59446; Fri, 19 Mar 2021 23:37:19 +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 3F4AE1809C83; Fri, 19 Mar 2021 23:37:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 12JNbD0V029438 for ; Fri, 19 Mar 2021 19:37:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id D839439A64; Fri, 19 Mar 2021 23:37:13 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.40.194.173]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AB8B82BFE2 for ; Fri, 19 Mar 2021 23:37:13 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 79673244036; Sat, 20 Mar 2021 00:37:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616197048; 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=xU8PPcibSqp0Wik72ixSub0/ibl+I974HDFOnL1RX0A=; b=WCseDPihTyNiQAH3+9W5WQf0fh+nzG2jsTqADUcUscNxUvANst/FRsuZ0E5vczQnrddUDj 6o8/mAZZPlTaTIRQLadosUuyYty/ILARb1NTjtD5cejWIZjDejlSYT1RJAkUl2XLa1S5Hw u1cVCFAoo+S1V3+lk+q5GXSx+PxItD4= X-MC-Unique: xShrIQyfNu-mx1BhJtGu9w-1 From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH 7/7] util: Make virReallocN return void Date: Sat, 20 Mar 2021 00:37:06 +0100 Message-Id: <5553c92d621de742b3ac2828aa2659a2459c7d87.1616196713.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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.11 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiri Denemark Reviewed-by: Michal Privoznik --- src/util/viralloc.c | 13 +++++-------- src/util/viralloc.h | 4 ++-- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/util/viralloc.c b/src/util/viralloc.c index 81f5ba9a09..cd7ae9e7d1 100644 --- a/src/util/viralloc.c +++ b/src/util/viralloc.c @@ -45,12 +45,11 @@ VIR_LOG_INIT("util.alloc"); * * Returns zero on success, aborts on OOM */ -int virReallocN(void *ptrptr, - size_t size, - size_t count) +void virReallocN(void *ptrptr, + size_t size, + size_t count) { *(void **)ptrptr =3D g_realloc_n(*(void**)ptrptr, size, count); - return 0; } =20 /** @@ -76,8 +75,7 @@ void virExpandN(void *ptrptr, if (*countptr + add < *countptr) abort(); =20 - if (virReallocN(ptrptr, size, *countptr + add) < 0) - abort(); + virReallocN(ptrptr, size, *countptr + add); memset(*(char **)ptrptr + (size * *countptr), 0, size * add); *countptr +=3D add; } @@ -136,8 +134,7 @@ void virResizeN(void *ptrptr, void virShrinkN(void *ptrptr, size_t size, size_t *countptr, size_t toremo= ve) { if (toremove < *countptr) { - if (virReallocN(ptrptr, size, *countptr -=3D toremove) < 0) - abort(); + virReallocN(ptrptr, size, *countptr -=3D toremove); } else { g_free(*((void **)ptrptr)); *((void **)ptrptr) =3D NULL; diff --git a/src/util/viralloc.h b/src/util/viralloc.h index 6051c91913..553d2951cf 100644 --- a/src/util/viralloc.h +++ b/src/util/viralloc.h @@ -34,7 +34,7 @@ */ =20 /* Don't call these directly - use the macros below */ -int virReallocN(void *ptrptr, size_t size, size_t count) +void virReallocN(void *ptrptr, size_t size, size_t count) ATTRIBUTE_NONNULL(1); void virExpandN(void *ptrptr, size_t size, size_t *count, size_t add) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3); @@ -61,7 +61,7 @@ int virDeleteElementsN(void *ptrptr, size_t size, size_t = at, size_t *countptr, * * This macro is safe to use on arguments with side effects. * - * Returns 0 on success, aborts on OOM + * Aborts on OOM */ #define VIR_REALLOC_N(ptr, count) virReallocN(&(ptr), sizeof(*(ptr)), (cou= nt)) =20 --=20 2.31.0