From nobody Sun Feb 8 11:25:52 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1593209473; cv=none; d=zohomail.com; s=zohoarc; b=SvUon8NMyp5dt4MfyJH7BAcZVDgmLlHKcU3CcOSSF5Jtt3K7t9yXJSJazG8S6jx/xbsxl+G5VVuVhdXFkMYJGmPCBLdYhJ3sWclh/pHOWaqgMRU4bn0hh+6X7krWRqHNti+SKvbdL0SyNCaFdrbyqBitFGg+OyqJKe42jcGWYQk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593209473; h=Content-Type:Content-Transfer-Encoding:Cc: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=tDwtzMZlQHXwMMbLqN+IrkaqeO/9dejfByqcoxwzzPg=; b=UJq/f+Xakv2U/khlsZCqfcVSOLgr6usMeNFR590CYO/elF/PO0d/z6XCZlai38PjvMFXQIr6K6QMX+367d8pyjeFSgWoZTN2toHHgIFYkbIndxhbkN5Bi+NGYp+WtoTdvyY2KZrKm85da3vrdNsv7fyhyDvBkmDTyZEpSUgqYaY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1593209473081137.05235927221122; Fri, 26 Jun 2020 15:11:13 -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-475-trwxQxRIPvK0S0Yd2NDKow-1; Fri, 26 Jun 2020 18:11:09 -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 ED495804002; Fri, 26 Jun 2020 22:11:03 +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 CB40919D61; Fri, 26 Jun 2020 22:11:03 +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 51DB81809543; Fri, 26 Jun 2020 22:11:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 05QMB2pr015674 for ; Fri, 26 Jun 2020 18:11:02 -0400 Received: by smtp.corp.redhat.com (Postfix) id A7F8520110C7; Fri, 26 Jun 2020 22:11:02 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9F474201ECD3 for ; Fri, 26 Jun 2020 22:11:02 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 16D44185A78B for ; Fri, 26 Jun 2020 22:11:02 +0000 (UTC) Received: from mail-qk1-f196.google.com (mail-qk1-f196.google.com [209.85.222.196]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-181-ReoO0atNMkWdWzcubLnUpg-1; Fri, 26 Jun 2020 18:10:59 -0400 Received: by mail-qk1-f196.google.com with SMTP id k18so10229305qke.4 for ; Fri, 26 Jun 2020 15:10:59 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c7:4951:b792:3278:7364:91bd]) by smtp.gmail.com with ESMTPSA id v10sm7159090qtk.14.2020.06.26.15.10.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2020 15:10:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593209471; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=tDwtzMZlQHXwMMbLqN+IrkaqeO/9dejfByqcoxwzzPg=; b=cfDog/9zcs64fqySecFL8ZWXXCq34SnJa/pt3sZrSVrXtjI09rH7U/mjetrDkHZ9lGA9+L u4rj10Oc195AftIRiGjrtdF6lAiA8ZGvQUg3vG0cNZB2ug9D1XoknxNZGOjQTpvKYKunXm gElPqJyg6KXEZE0qUJ+6Vjt1gNFD6eY= X-MC-Unique: trwxQxRIPvK0S0Yd2NDKow-1 X-MC-Unique: ReoO0atNMkWdWzcubLnUpg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tDwtzMZlQHXwMMbLqN+IrkaqeO/9dejfByqcoxwzzPg=; b=n661rA2URbDHj5A9j4lsGt7w1SRzrrR/00SfPlB59KkUzaQsV9ppNlE0KNxsNXxZ0O 5Uoa2rEpNHSdl9AEkZcEbW0H5YDKva/3IdCFZwx67Xi7Rps+zCmRIhzjvIxrRP7K8EzR ZkpwCHtR5DVytjiPY7vFO0altlVsM4MsivifvUdku5rmjEZeStwtn29ixDsNPkQlz3LJ k+sRkwcFFQCxTEUdqg0g4yxDf2cCKGpr1zex4ZE6iaG4fXI0f/Xe73PCQ3znKSyDJ6Qb 6AF/4IL72fStr9YQObq+tr1IGgM72G2exlftXhcy+bDmCM/IugVDlNLP9+GzY8jnVk70 O8Xw== X-Gm-Message-State: AOAM532RLzP/ksd0KR8J0Udn9T0hjIYn09Ck6XVgcP51wBBLn1batnWS CmToHgA83zEMlYdMQPS1PuyaG9kz X-Google-Smtp-Source: ABdhPJxoS6t01F3TvOjY5e3atI6LmPVYfjWxR0LHlauuhLaoARLRCPdza1DprtEZX75lhUMu6uNXOw== X-Received: by 2002:ae9:c006:: with SMTP id u6mr4762344qkk.375.1593209458855; Fri, 26 Jun 2020 15:10:58 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH 4/7] virsh-domain.c: modernize cmdVcpuinfo() Date: Fri, 26 Jun 2020 19:10:41 -0300 Message-Id: <20200626221044.631749-5-danielhb413@gmail.com> In-Reply-To: <20200626221044.631749-1-danielhb413@gmail.com> References: <20200626221044.631749-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza 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 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" Use g_auto* pointers to avoid the need for the cleanup label. The type of the pointer 'virDomainPtr dom' was changed to its alias 'virshDomainPtr' to allow the use of g_autoptr(). Signed-off-by: Daniel Henrique Barboza --- tools/virsh-domain.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 23d41a4ddf..cfae42eda9 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -6928,12 +6928,11 @@ static bool cmdVcpuinfo(vshControl *ctl, const vshCmd *cmd) { virDomainInfo info; - virDomainPtr dom; - virVcpuInfoPtr cpuinfo =3D NULL; - unsigned char *cpumaps =3D NULL; + g_autoptr(virshDomain) dom =3D NULL; + g_autofree virVcpuInfoPtr cpuinfo =3D NULL; + g_autofree unsigned char *cpumaps =3D NULL; int ncpus, maxcpu; size_t cpumaplen; - bool ret =3D false; bool pretty =3D vshCommandOptBool(cmd, "pretty"); int n; virshControlPtr priv =3D ctl->privData; @@ -6942,10 +6941,10 @@ cmdVcpuinfo(vshControl *ctl, const vshCmd *cmd) return false; =20 if ((maxcpu =3D virshNodeGetCPUCount(priv->conn)) < 0) - goto cleanup; + return false; =20 if (virDomainGetInfo(dom, &info) !=3D 0) - goto cleanup; + return false; =20 cpuinfo =3D vshMalloc(ctl, sizeof(virVcpuInfo)*info.nrVirtCpu); cpumaplen =3D VIR_CPU_MAPLEN(maxcpu); @@ -6955,13 +6954,12 @@ cmdVcpuinfo(vshControl *ctl, const vshCmd *cmd) cpuinfo, info.nrVirtCpu, cpumaps, cpumaplen)) < 0) { if (info.state !=3D VIR_DOMAIN_SHUTOFF) - goto cleanup; + return false; =20 vshResetLibvirtError(); =20 /* for offline VMs we can return pinning information */ - ret =3D virshVcpuinfoInactive(ctl, dom, maxcpu, pretty); - goto cleanup; + return virshVcpuinfoInactive(ctl, dom, maxcpu, pretty); } =20 for (n =3D 0; n < ncpus; n++) { @@ -6979,19 +6977,13 @@ cmdVcpuinfo(vshControl *ctl, const vshCmd *cmd) =20 if (virshVcpuinfoPrintAffinity(ctl, VIR_GET_CPUMAP(cpumaps, cpumap= len, n), maxcpu, pretty) < 0) - goto cleanup; + return false; =20 if (n < (ncpus - 1)) vshPrint(ctl, "\n"); } =20 - ret =3D true; - - cleanup: - VIR_FREE(cpumaps); - VIR_FREE(cpuinfo); - virshDomainFree(dom); - return ret; + return true; } =20 /* --=20 2.26.2