From nobody Sun Feb 8 19:02:54 2026 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; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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=1610999705; cv=none; d=zohomail.com; s=zohoarc; b=bi9ffDQ8sf4ZXEtraP193vBDiIb0WnYKcAFLkmnhhb67XYcnhmvT56E69vk5CVIpYal+13UCA93OpnipDYeEyDGJ97hAKxf7+kC5wv0qhUF4i7xZn2+AVX6uh2M26KAVrtWrkZhYgHtdPkrW1L3QiSmiVmY5vALpsyRTQ0F+jHM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610999705; 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=9mWesCcSlIeAhjIb4IgM1f6nY5aoZZbIIKE5Q5olxps=; b=hp77giSecSweBfRD+IMBlESrJI09DNDpmDO/k1J5Qz5uOzmq3YiCrOqslKgD716ZMQbPZEqJM2UUrj9lcHheyDZ1IZoo5MDkj0XmyEMoCFRTICScl7QVt7X1XboeDh3jBE+T1ce4bFbJEmi+PPbt2zWuOJtSKLfwGkoeod5zuww= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1610999705236587.0547005484996; Mon, 18 Jan 2021 11:55:05 -0800 (PST) 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-Vgj89nn8NheXJY4JMjuqqA-1; Mon, 18 Jan 2021 14:54:40 -0500 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 0A6E91005513; Mon, 18 Jan 2021 19:54:30 +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 DEB225D9D3; Mon, 18 Jan 2021 19:54:29 +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 A954F50039; Mon, 18 Jan 2021 19:54:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 10IJs9Qx032539 for ; Mon, 18 Jan 2021 14:54:09 -0500 Received: by smtp.corp.redhat.com (Postfix) id B04C91111439; Mon, 18 Jan 2021 19:54:09 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AC63A1111434 for ; Mon, 18 Jan 2021 19:54:09 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.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 98450800161 for ; Mon, 18 Jan 2021 19:54:09 +0000 (UTC) Received: from mail-qt1-f175.google.com (mail-qt1-f175.google.com [209.85.160.175]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-410-yIelGElyNPifMO_f1JAX_w-1; Mon, 18 Jan 2021 14:54:07 -0500 Received: by mail-qt1-f175.google.com with SMTP id h19so12087533qtq.13 for ; Mon, 18 Jan 2021 11:54:07 -0800 (PST) Received: from rekt.ibmuc.com ([2804:431:c7c7:a75a:cb34:ba60:6de6:be1d]) by smtp.gmail.com with ESMTPSA id 16sm11309085qkf.112.2021.01.18.11.54.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Jan 2021 11:54:06 -0800 (PST) X-MC-Unique: Vgj89nn8NheXJY4JMjuqqA-1 X-MC-Unique: yIelGElyNPifMO_f1JAX_w-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=9mWesCcSlIeAhjIb4IgM1f6nY5aoZZbIIKE5Q5olxps=; b=rAfGEnxa8ofOZHSiYjoXxUiqNgoaVOO5qvGlh4py6Ik8y8o3A8p78OUox4VDNqnTQZ 8OWUCOrfRoMISXdexZAczi63iDXvJlNTcmpcL7xSWNsoG+PllWuWuSb3aHCiwT96z+CS btupOWwLOoALChL+q7EZszykbwKTbUOSdomvUlP00OC6tU98zrXU8VvJCDW1wrngGFDr +NneWlkKLq67Z2DUg7Ni7GrbG6QdQCozoxPU9ijZlN3IKMdzMfUfLi2hl0hxEs750v5N AxIgtzfEC2pzMlVuaON1guopBHUwqUkKX0gC2V1rBb29SZ6pfUx7POsHIkINbeDrn8d6 XpKA== X-Gm-Message-State: AOAM533D39sP0UcSCiQzZB64m0iNqazPftYANubqvoSdmaApPRuBFpQ0 KksFrBgqFldyCpMrrBuUCbmIN/5HuaypIw== X-Google-Smtp-Source: ABdhPJx6pgigkbwMvo9GkU+fpYfwaa48TH2SHsW5GUoi4rD2UpJMNx/V0wVthpT0+SBQQZ0WHas+QA== X-Received: by 2002:ac8:4553:: with SMTP id z19mr1209915qtn.278.1610999647048; Mon, 18 Jan 2021 11:54:07 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH RESEND 13/20] virsh-domain.c: modernize cmdDetachDevice() Date: Mon, 18 Jan 2021 16:53:29 -0300 Message-Id: <20210118195336.2090823-14-danielhb413@gmail.com> In-Reply-To: <20210118195336.2090823-1-danielhb413@gmail.com> References: <20210118195336.2090823-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 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.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 Content-Type: text/plain; charset="utf-8" Use g_auto* pointers to avoid the need of a 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 Reviewed-by: Laine Stump --- tools/virsh-domain.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 2bb136333f..b32529f073 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -11953,11 +11953,10 @@ static const vshCmdOptDef opts_detach_device[] = =3D { static bool cmdDetachDevice(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom =3D NULL; + g_autoptr(virshDomain) dom =3D NULL; const char *from =3D NULL; - char *buffer =3D NULL; + g_autofree char *buffer =3D NULL; int ret; - bool funcRet =3D false; bool current =3D vshCommandOptBool(cmd, "current"); bool config =3D vshCommandOptBool(cmd, "config"); bool live =3D vshCommandOptBool(cmd, "live"); @@ -11982,11 +11981,11 @@ cmdDetachDevice(vshControl *ctl, const vshCmd *cm= d) flags |=3D VIR_DOMAIN_AFFECT_LIVE; =20 if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) - goto cleanup; + return false; =20 if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) { vshReportError(ctl); - goto cleanup; + return false; } =20 if (flags !=3D 0 || current) @@ -11996,16 +11995,11 @@ cmdDetachDevice(vshControl *ctl, const vshCmd *cm= d) =20 if (ret < 0) { vshError(ctl, _("Failed to detach device from %s"), from); - goto cleanup; + return false; } =20 vshPrintExtra(ctl, "%s", _("Device detached successfully\n")); - funcRet =3D true; - - cleanup: - VIR_FREE(buffer); - virshDomainFree(dom); - return funcRet; + return true; } =20 =20 --=20 2.26.2