From nobody Sat Feb 7 11:05:16 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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=1609764937; cv=none; d=zohomail.com; s=zohoarc; b=SvMdowYKY2Tefc//OHrhMnMbZXWYoi2H95K0Iex5oXL+vJpfVwhrBZ7lNImsZXJVv5g7JraaPzy16BJGT1PPRXx/5AECo0wu5E181NVL3Y+lLrDxw8yqwLf2zeuxiWkv0ObBULnCCrFpcLYin627L6+n8/yNStE9zjSoKLw03tE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609764937; 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=QUKfVeV4vfUQe3XNg2GhBwCpSLHlaiNhrse3+AV82io=; b=AsAvDEJreGCv7GtjOcunnNyR5jtgKrqxhgX3q9wptUAnD1kNKX1LpVs+jL5vBcXJdpjvNur8vSKyFzWDnkppIqg2BhWl88EARjUBtEQOsD7TjBbzBsY6PS7Fr1jXb1A3F1srUWT1rdORyOZqSI11BjMXBrhFLUD10qcLN9ZmyQc= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 160976493759825.627639917640863; Mon, 4 Jan 2021 04:55:37 -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-535-o3vzMvwMOAuSaYvCtiO9Cw-1; Mon, 04 Jan 2021 07:55:33 -0500 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 3B4D51054F8E; Mon, 4 Jan 2021 12:55:25 +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 158F010023AE; Mon, 4 Jan 2021 12:55:25 +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 D238A50033; Mon, 4 Jan 2021 12:55:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 104CtMOC014262 for ; Mon, 4 Jan 2021 07:55:22 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3E973111F6; Mon, 4 Jan 2021 12:55:22 +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 369C89D498 for ; Mon, 4 Jan 2021 12:55:22 +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 BA765800B3B for ; Mon, 4 Jan 2021 12:55:21 +0000 (UTC) Received: from mail-qk1-f177.google.com (mail-qk1-f177.google.com [209.85.222.177]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-574-QBWf3U1zNO-eJ_xGfiakHw-1; Mon, 04 Jan 2021 07:55:19 -0500 Received: by mail-qk1-f177.google.com with SMTP id d14so23149166qkc.13 for ; Mon, 04 Jan 2021 04:55:19 -0800 (PST) Received: from rekt.ibmuc.com ([2804:431:c7c6:ca55:7a5d:da5b:906f:bedd]) by smtp.gmail.com with ESMTPSA id m64sm2342866qkb.90.2021.01.04.04.55.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Jan 2021 04:55:18 -0800 (PST) X-MC-Unique: o3vzMvwMOAuSaYvCtiO9Cw-1 X-MC-Unique: QBWf3U1zNO-eJ_xGfiakHw-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=QUKfVeV4vfUQe3XNg2GhBwCpSLHlaiNhrse3+AV82io=; b=Y7eEFkOo+vqFKK9MSOyK1fXE/il4jozowb8V5SHwMSPU2o/S7cFc47kTy0B1gsHLKS 4nnH4S2Ha85gumU7PThthNQSId0GAMnk00kOX4cGN7/tUJRrzB1s7aj5Xr4ZM+I2FSkg FC927veQu7dJ55c1MwcqM86qq8uv2LNh4hwGKtqrFejYHYTbY/DCGdpnfOsH3jHjSm7K ebj0cuBlouZfPuFooZamLs5qeRgL5PJJakIerygGgeuLsCI0UXMjoQKqxA3Wi2qwrHIB XWDRUztdSgiDpGkeB3j2an3FArYTS/rNctfp1v7Ye4KoBOw1XFMCqcSj/u8xxRfU2/4a Qytw== X-Gm-Message-State: AOAM533225eMmPkILHmDbkceFnwT5r2gN0nYJzSizl91vaqb/c2jQEE/ YgHvgsYy/giYYUEPZwJEHOmvMqlhsmF+qQ== X-Google-Smtp-Source: ABdhPJzjBl01ENET/yhP7k9dB9rY+vMAXbOcuIR19jDw8NV0kpn441y3yv3Jo/y75bp0Yeckefg7vA== X-Received: by 2002:a37:9b42:: with SMTP id d63mr71331760qke.449.1609764919181; Mon, 04 Jan 2021 04:55:19 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH 13/20] virsh-domain.c: modernize cmdDetachDevice() Date: Mon, 4 Jan 2021 09:54:37 -0300 Message-Id: <20210104125444.200536-14-danielhb413@gmail.com> In-Reply-To: <20210104125444.200536-1-danielhb413@gmail.com> References: <20210104125444.200536-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.79 on 10.11.54.5 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.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 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 --- 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 1ef9b8d606..a8a0f1d3cc 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