From nobody Sun Feb 8 05:54:49 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 15328069069191011.2822000089348; Sat, 28 Jul 2018 12:41:46 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 0468EC04B31C; Sat, 28 Jul 2018 19:41:45 +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 AA5A51073049; Sat, 28 Jul 2018 19:41:44 +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 4C7E524F56; Sat, 28 Jul 2018 19:41:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6SJfU76021014 for ; Sat, 28 Jul 2018 15:41:30 -0400 Received: by smtp.corp.redhat.com (Postfix) id C86F73001A5A; Sat, 28 Jul 2018 19:41:30 +0000 (UTC) Received: from mx1.redhat.com (ext-mx19.extmail.prod.ext.phx2.redhat.com [10.5.110.48]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C03883001A65 for ; Sat, 28 Jul 2018 19:41:27 +0000 (UTC) Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 259AC307D84A for ; Sat, 28 Jul 2018 19:41:27 +0000 (UTC) Received: by mail-pf1-f193.google.com with SMTP id j8-v6so2879163pff.6 for ; Sat, 28 Jul 2018 12:41:27 -0700 (PDT) Received: from centos.localdomain ([49.32.98.239]) by smtp.gmail.com with ESMTPSA id m26-v6sm20270426pfi.102.2018.07.28.12.41.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 28 Jul 2018 12:41:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=CE253mAFU/kXPfvjrB9gVytj4AI8T7X5GJWf6vbDx64=; b=YH/srhdwBDzeS0ygK97ATLSveKll0d6U2ncUkKX9xBAE4/9y6TwVDcV6rSDeR3vmkp 0+sKFCI8xHuPcDdG2B6+0EcR1p9L5DALsREc8ac/dFSE9UrwqAsaij/tXLe9Rl9VutL6 oglXLgRNeC5YHyPY5dyJdqIhnUwhAtxqoKssm1+MWQCIw+tWOZUw/+BoN3gmgGXlMbAR tYZCFjRjZLc1Wq5zioMticl+Nwl8pwMARvhSdDTMdZldkm/B+o9Mmgyax3JQYm8RFp12 rdNqb2hL2YS5OcGs/eW6qVK3NcQBrkIUy9jf+qwG790kKrszeBwmocLjOwWAttJV5yWL o5UQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=CE253mAFU/kXPfvjrB9gVytj4AI8T7X5GJWf6vbDx64=; b=L4tvyEC1ydkRo0GD/Dymg4ZkNEtlKZxOnCHY+xCEygrvHlUhxbsmloX9USrM9a7GiU COBV+NnBq4dcqduCN/ClQDz5S5HRJdazW2d2+5sdQQSPdnybALzvVf+wIZzrQfeA0MxO ZAaTIPGfVdApmRZK/BVKY9mpQsS9MFsvRtus1DWXkdG60QVEBYd++GOPUXpnu50iwEmq gsGV3l8qHEL4gHF98PNNLr7CWRoqdEQdK/vX//gkprHReU//shh98lReUsUfDPYcNppt X9bUL0nvbsmmEgAk2Mz8j1K1BsC3h8ph2cyxG3N/QavEybahTa8pZEx8r4VaXHKixjnq ZYYQ== X-Gm-Message-State: AOUpUlElll4ixWHSCKRYF7YORr60QCIkd5rUQMGFujUQmtcD0zmEK0ND UJX4haeMJTf4GWIciVAGESyRWqEy X-Google-Smtp-Source: AAOMgpfIO3RxYBElM4E3R0XV+zpfvjvDCBsOmFOkZICw40oUkjm8oPMLpyZVjvojuZs1Uus7U/r5fA== X-Received: by 2002:a62:34c4:: with SMTP id b187-v6mr11607808pfa.15.1532806886455; Sat, 28 Jul 2018 12:41:26 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sat, 28 Jul 2018 23:31:40 +0530 Message-Id: <1532800907-29115-26-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1532800907-29115-1-git-send-email-skrtbhtngr@gmail.com> References: <1532800907-29115-1-git-send-email-skrtbhtngr@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Sat, 28 Jul 2018 19:41:27 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Sat, 28 Jul 2018 19:41:27 +0000 (UTC) for IP:'209.85.210.193' DOMAIN:'mail-pf1-f193.google.com' HELO:'mail-pf1-f193.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.13 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS) 209.85.210.193 mail-pf1-f193.google.com 209.85.210.193 mail-pf1-f193.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.48 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 25/32] util: numa: use VIR_AUTOPTR for aggregate types 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Sat, 28 Jul 2018 19:41:45 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" By making use of GNU C's cleanup attribute handled by the VIR_AUTOPTR macro for declaring aggregate pointer variables, majority of the calls to *Free functions can be dropped, which in turn leads to getting rid of most of our cleanup sections. Signed-off-by: Sukrit Bhatnagar --- src/util/virnuma.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/src/util/virnuma.c b/src/util/virnuma.c index 841c7cb..fde46ec 100644 --- a/src/util/virnuma.c +++ b/src/util/virnuma.c @@ -57,7 +57,7 @@ char * virNumaGetAutoPlacementAdvice(unsigned short vcpus, unsigned long long balloon) { - virCommandPtr cmd =3D NULL; + VIR_AUTOPTR(virCommand) cmd =3D NULL; char *output =3D NULL; =20 cmd =3D virCommandNewArgList(NUMAD, "-w", NULL); @@ -71,7 +71,6 @@ virNumaGetAutoPlacementAdvice(unsigned short vcpus, _("Failed to query numad for the " "advisory nodeset")); =20 - virCommandFree(cmd); return output; } #else /* !HAVE_NUMAD */ @@ -252,41 +251,38 @@ int virNumaGetNodeCPUs(int node, virBitmapPtr *cpus) { + VIR_AUTOPTR(virBitmap) cpumap =3D NULL; VIR_AUTOFREE(unsigned long *) mask =3D NULL; VIR_AUTOFREE(unsigned long *) allonesmask =3D NULL; - virBitmapPtr cpumap =3D NULL; int ncpus =3D 0; int max_n_cpus =3D virNumaGetMaxCPUs(); int mask_n_bytes =3D max_n_cpus / 8; size_t i; - int ret =3D -1; =20 *cpus =3D NULL; =20 if (VIR_ALLOC_N(mask, mask_n_bytes / sizeof(*mask)) < 0) - goto cleanup; + return -1; =20 if (VIR_ALLOC_N(allonesmask, mask_n_bytes / sizeof(*mask)) < 0) - goto cleanup; + return -1; =20 memset(allonesmask, 0xff, mask_n_bytes); =20 /* The first time this returns -1, ENOENT if node doesn't exist... */ if (numa_node_to_cpus(node, mask, mask_n_bytes) < 0) { VIR_WARN("NUMA topology for cell %d is not available, ignoring", n= ode); - ret =3D -2; - goto cleanup; + return -2; } =20 /* second, third... times it returns an all-1's mask */ if (memcmp(mask, allonesmask, mask_n_bytes) =3D=3D 0) { VIR_DEBUG("NUMA topology for cell %d is invalid, ignoring", node); - ret =3D -2; - goto cleanup; + return -2; } =20 if (!(cpumap =3D virBitmapNew(max_n_cpus))) - goto cleanup; + return -1; =20 for (i =3D 0; i < max_n_cpus; i++) { if (MASK_CPU_ISSET(mask, i)) { @@ -295,14 +291,8 @@ virNumaGetNodeCPUs(int node, } } =20 - *cpus =3D cpumap; - cpumap =3D NULL; - ret =3D ncpus; - - cleanup: - virBitmapFree(cpumap); - - return ret; + VIR_STEAL_PTR(*cpus, cpumap); + return ncpus; } # undef MASK_CPU_ISSET # undef n_bits --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list