From nobody Mon Feb 9 14:31:20 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; 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=1632441025; cv=none; d=zohomail.com; s=zohoarc; b=S4tOiFGi831mQNk4RPXngrDI5FoLMIWO/IHRwDsGlnCIS8jQDidqtovoA+VN1zUuCS9HU7jpEGYDEXeiYzC6YslE0NnEKE1BQtqqNzsBb6/TunbGkjMImlzUR6sB+tHaRnlNf8HOzR/8X2RnhN2CBGDZxpLN/ArjNX/rz/NSXLQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632441025; 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=uUJCSEixCojQWMHoQfVfC6ED1AVoYrndp8O8cQ/TWqM=; b=HocpvEfelBka9TmaHn4sXnjy+qSZvovLJPFrPh+b94Dlgg18rtF2OKuaOYDFiUXSMlD0HpUFY+EESNTQI+rg+/7NsKuuMm5dizvTDNrb706Gv4f13bui3eqDK3w6qiUoFJ4kOwgImsxMNBpjlPI0BHFm0WEcUqeRLH8TXTr6r4Q= 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) 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 1632441025889753.4142815977439; Thu, 23 Sep 2021 16:50:25 -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-533-GH4WeHO4PlCy5I6Rc4N0qA-1; Thu, 23 Sep 2021 19:50:23 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7B5E31808305; Thu, 23 Sep 2021 23:50:18 +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 588D460936; Thu, 23 Sep 2021 23:50:18 +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 02A7A180BAD2; Thu, 23 Sep 2021 23:50:18 +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 18NNnMVC013684 for ; Thu, 23 Sep 2021 19:49:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id 75C196788C; Thu, 23 Sep 2021 23:49:22 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.40.192.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 360407621D for ; Thu, 23 Sep 2021 23:49:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632441024; 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=uUJCSEixCojQWMHoQfVfC6ED1AVoYrndp8O8cQ/TWqM=; b=NbibqLZW7QrxpIcHNZ/us0LVHkllFoMw1oKEsc9tNsc02JR09pR6wpV+yc3kfBzrNdzS0s sv2Mi+A/6pGoBJ21X/2gB3QdJd/ZER3If5AN4nHz/gA++s7hS4qRWjIxfTyAI+JphEV7T6 YrhgoMfYzbzg9l8pRRZTAc1BW0thuZE= X-MC-Unique: GH4WeHO4PlCy5I6Rc4N0qA-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH v2 1/4] virsh: remove variable 'ret' and use early return if possible Date: Fri, 24 Sep 2021 01:49:08 +0200 Message-Id: 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.13 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) X-ZM-MESSAGEID: 1632441027384100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Kristina Hanicova Reviewed-by: Michal Privoznik --- tools/virsh-host.c | 15 +++++-------- tools/virsh-interface.c | 50 ++++++++++++++++++----------------------- tools/virsh-network.c | 30 ++++++++++++------------- tools/virsh-nodedev.c | 32 ++++++++++---------------- tools/virsh-nwfilter.c | 15 ++++++------- 5 files changed, 60 insertions(+), 82 deletions(-) diff --git a/tools/virsh-host.c b/tools/virsh-host.c index e6ed4a26ce..b602696704 100644 --- a/tools/virsh-host.c +++ b/tools/virsh-host.c @@ -1243,7 +1243,6 @@ static bool cmdCPUBaseline(vshControl *ctl, const vshCmd *cmd) { const char *from =3D NULL; - bool ret =3D false; g_autofree char *result =3D NULL; g_auto(GStrv) list =3D NULL; unsigned int flags =3D 0; @@ -1260,16 +1259,12 @@ cmdCPUBaseline(vshControl *ctl, const vshCmd *cmd) if (!(list =3D vshExtractCPUDefXMLs(ctl, from))) return false; =20 - result =3D virConnectBaselineCPU(priv->conn, (const char **)list, - g_strv_length(list), - flags); - - if (result) { - vshPrint(ctl, "%s", result); - ret =3D true; - } + if (!(result =3D virConnectBaselineCPU(priv->conn, (const char **)list, + g_strv_length(list), flags))) + return false; =20 - return ret; + vshPrint(ctl, "%s", result); + return true; } =20 /* diff --git a/tools/virsh-interface.c b/tools/virsh-interface.c index 46af45c97b..4bcc59b580 100644 --- a/tools/virsh-interface.c +++ b/tools/virsh-interface.c @@ -535,7 +535,6 @@ cmdInterfaceDefine(vshControl *ctl, const vshCmd *cmd) { virInterfacePtr iface; const char *from =3D NULL; - bool ret =3D true; g_autofree char *buffer =3D NULL; unsigned int flags =3D 0; virshControl *priv =3D ctl->privData; @@ -549,17 +548,15 @@ cmdInterfaceDefine(vshControl *ctl, const vshCmd *cmd) if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) return false; =20 - iface =3D virInterfaceDefineXML(priv->conn, buffer, flags); - - if (iface !=3D NULL) { - vshPrintExtra(ctl, _("Interface %s defined from %s\n"), - virInterfaceGetName(iface), from); - virInterfaceFree(iface); - } else { + if (!(iface =3D virInterfaceDefineXML(priv->conn, buffer, flags))) { vshError(ctl, _("Failed to define interface from %s"), from); - ret =3D false; + return false; } - return ret; + + vshPrintExtra(ctl, _("Interface %s defined from %s\n"), + virInterfaceGetName(iface), from); + virInterfaceFree(iface); + return true; } =20 /* @@ -584,21 +581,20 @@ static bool cmdInterfaceUndefine(vshControl *ctl, const vshCmd *cmd) { virInterfacePtr iface; - bool ret =3D true; const char *name; =20 if (!(iface =3D virshCommandOptInterface(ctl, cmd, &name))) return false; =20 - if (virInterfaceUndefine(iface) =3D=3D 0) { - vshPrintExtra(ctl, _("Interface %s undefined\n"), name); - } else { + if (virInterfaceUndefine(iface) < 0) { vshError(ctl, _("Failed to undefine interface %s"), name); - ret =3D false; + virInterfaceFree(iface); + return false; } =20 + vshPrintExtra(ctl, _("Interface %s undefined\n"), name); virInterfaceFree(iface); - return ret; + return true; } =20 /* @@ -623,21 +619,20 @@ static bool cmdInterfaceStart(vshControl *ctl, const vshCmd *cmd) { virInterfacePtr iface; - bool ret =3D true; const char *name; =20 if (!(iface =3D virshCommandOptInterface(ctl, cmd, &name))) return false; =20 - if (virInterfaceCreate(iface, 0) =3D=3D 0) { - vshPrintExtra(ctl, _("Interface %s started\n"), name); - } else { + if (virInterfaceCreate(iface, 0) < 0) { vshError(ctl, _("Failed to start interface %s"), name); - ret =3D false; + virInterfaceFree(iface); + return false; } =20 + vshPrintExtra(ctl, _("Interface %s started\n"), name); virInterfaceFree(iface); - return ret; + return true; } =20 /* @@ -662,21 +657,20 @@ static bool cmdInterfaceDestroy(vshControl *ctl, const vshCmd *cmd) { virInterfacePtr iface; - bool ret =3D true; const char *name; =20 if (!(iface =3D virshCommandOptInterface(ctl, cmd, &name))) return false; =20 - if (virInterfaceDestroy(iface, 0) =3D=3D 0) { - vshPrintExtra(ctl, _("Interface %s destroyed\n"), name); - } else { + if (virInterfaceDestroy(iface, 0) < 0) { vshError(ctl, _("Failed to destroy interface %s"), name); - ret =3D false; + virInterfaceFree(iface); + return false; } =20 + vshPrintExtra(ctl, _("Interface %s destroyed\n"), name); virInterfaceFree(iface); - return ret; + return false; } =20 /* diff --git a/tools/virsh-network.c b/tools/virsh-network.c index 8651265909..198993ac33 100644 --- a/tools/virsh-network.c +++ b/tools/virsh-network.c @@ -209,7 +209,6 @@ cmdNetworkCreate(vshControl *ctl, const vshCmd *cmd) { virNetworkPtr network; const char *from =3D NULL; - bool ret =3D true; g_autofree char *buffer =3D NULL; unsigned int flags =3D 0; virshControl *priv =3D ctl->privData; @@ -228,15 +227,15 @@ cmdNetworkCreate(vshControl *ctl, const vshCmd *cmd) else network =3D virNetworkCreateXML(priv->conn, buffer); =20 - if (network !=3D NULL) { - vshPrintExtra(ctl, _("Network %s created from %s\n"), - virNetworkGetName(network), from); - virNetworkFree(network); - } else { + if (!network) { vshError(ctl, _("Failed to create network from %s"), from); - ret =3D false; + return false; } - return ret; + + vshPrintExtra(ctl, _("Network %s created from %s\n"), + virNetworkGetName(network), from); + virNetworkFree(network); + return true; } =20 /* @@ -267,7 +266,6 @@ cmdNetworkDefine(vshControl *ctl, const vshCmd *cmd) { virNetworkPtr network; const char *from =3D NULL; - bool ret =3D true; g_autofree char *buffer =3D NULL; unsigned int flags =3D 0; virshControl *priv =3D ctl->privData; @@ -286,15 +284,15 @@ cmdNetworkDefine(vshControl *ctl, const vshCmd *cmd) else network =3D virNetworkDefineXML(priv->conn, buffer); =20 - if (network !=3D NULL) { - vshPrintExtra(ctl, _("Network %s defined from %s\n"), - virNetworkGetName(network), from); - virNetworkFree(network); - } else { + if (!network) { vshError(ctl, _("Failed to define network from %s"), from); - ret =3D false; + return false; } - return ret; + + vshPrintExtra(ctl, _("Network %s defined from %s\n"), + virNetworkGetName(network), from); + virNetworkFree(network); + return true; } =20 /* diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c index f1b4eb94bf..f72359121f 100644 --- a/tools/virsh-nodedev.c +++ b/tools/virsh-nodedev.c @@ -57,7 +57,6 @@ cmdNodeDeviceCreate(vshControl *ctl, const vshCmd *cmd) { virNodeDevicePtr dev =3D NULL; const char *from =3D NULL; - bool ret =3D true; g_autofree char *buffer =3D NULL; virshControl *priv =3D ctl->privData; =20 @@ -67,18 +66,15 @@ cmdNodeDeviceCreate(vshControl *ctl, const vshCmd *cmd) if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) return false; =20 - dev =3D virNodeDeviceCreateXML(priv->conn, buffer, 0); - - if (dev !=3D NULL) { - vshPrintExtra(ctl, _("Node device %s created from %s\n"), - virNodeDeviceGetName(dev), from); - virNodeDeviceFree(dev); - } else { + if (!(dev =3D virNodeDeviceCreateXML(priv->conn, buffer, 0))) { vshError(ctl, _("Failed to create node device from %s"), from); - ret =3D false; + return false; } =20 - return ret; + vshPrintExtra(ctl, _("Node device %s created from %s\n"), + virNodeDeviceGetName(dev), from); + virNodeDeviceFree(dev); + return true; } =20 =20 @@ -1077,7 +1073,6 @@ cmdNodeDeviceDefine(vshControl *ctl, const vshCmd *cm= d G_GNUC_UNUSED) { virNodeDevice *dev =3D NULL; const char *from =3D NULL; - bool ret =3D true; g_autofree char *buffer =3D NULL; virshControl *priv =3D ctl->privData; =20 @@ -1087,18 +1082,15 @@ cmdNodeDeviceDefine(vshControl *ctl, const vshCmd *= cmd G_GNUC_UNUSED) if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) return false; =20 - dev =3D virNodeDeviceDefineXML(priv->conn, buffer, 0); - - if (dev !=3D NULL) { - vshPrintExtra(ctl, _("Node device '%s' defined from '%s'\n"), - virNodeDeviceGetName(dev), from); - virNodeDeviceFree(dev); - } else { + if (!(dev =3D virNodeDeviceDefineXML(priv->conn, buffer, 0))) { vshError(ctl, _("Failed to define node device from '%s'"), from); - ret =3D false; + return false; } =20 - return ret; + vshPrintExtra(ctl, _("Node device '%s' defined from '%s'\n"), + virNodeDeviceGetName(dev), from); + virNodeDeviceFree(dev); + return true; } =20 =20 diff --git a/tools/virsh-nwfilter.c b/tools/virsh-nwfilter.c index 77f211d031..33164f623f 100644 --- a/tools/virsh-nwfilter.c +++ b/tools/virsh-nwfilter.c @@ -515,7 +515,6 @@ cmdNWFilterBindingCreate(vshControl *ctl, const vshCmd = *cmd) { virNWFilterBindingPtr binding; const char *from =3D NULL; - bool ret =3D true; char *buffer; unsigned int flags =3D 0; virshControl *priv =3D ctl->privData; @@ -532,15 +531,15 @@ cmdNWFilterBindingCreate(vshControl *ctl, const vshCm= d *cmd) binding =3D virNWFilterBindingCreateXML(priv->conn, buffer, flags); VIR_FREE(buffer); =20 - if (binding !=3D NULL) { - vshPrintExtra(ctl, _("Network filter binding on %s created from %s= \n"), - virNWFilterBindingGetPortDev(binding), from); - virNWFilterBindingFree(binding); - } else { + if (!binding) { vshError(ctl, _("Failed to create network filter from %s"), from); - ret =3D false; + return false; } - return ret; + + vshPrintExtra(ctl, _("Network filter binding on %s created from %s\n"), + virNWFilterBindingGetPortDev(binding), from); + virNWFilterBindingFree(binding); + return true; } =20 =20 --=20 2.31.1 From nobody Mon Feb 9 14:31:20 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; 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=1632441029; cv=none; d=zohomail.com; s=zohoarc; b=DoCNlIwDW1oow1RRcHd2h8rfiXRMRSr9ipEVliGRkjrxeF2ZMj4FX5qcYND23tHn1Cd1QhLXi73xq0Nzj/i8/M1mqQGJpY8wet8Dhz4q1D9tnDWZwXI+WacXvECpYOXzAtEpzSCjYMTtaGq9WiowbSrIJdx9ex05IdTAgHGxnqU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632441029; 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=UR02Y3LCSq6Rh0RG/92SgTWyq6uPk0abbgDZpG/v8eM=; b=Fh3YdZibuo7jjRt99wJFGKlRa8XzDU7Ks/TbHIVqR3DovwGZ1puqaIbfOO5n2/66oVwQsxCqMe1Zqpysor7BMX3Xnd92AdpwtUPHj+j6w1M67SUmVUUioO/DvHROtE/0bco6a4pganRESakH4LVvx+icf+wfRGDIVhhorHlDx1U= 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) 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 1632441029294454.32272326315683; Thu, 23 Sep 2021 16:50: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-567-DryT0FgGPi2lbHOVzitHoQ-1; Thu, 23 Sep 2021 19:50:26 -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 8621E802B9E; Thu, 23 Sep 2021 23:50:21 +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 69C9D1017E36; Thu, 23 Sep 2021 23:50:21 +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 375944E590; Thu, 23 Sep 2021 23:50:21 +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 18NNnSPo013697 for ; Thu, 23 Sep 2021 19:49:28 -0400 Received: by smtp.corp.redhat.com (Postfix) id 76F3D1800D; Thu, 23 Sep 2021 23:49:28 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.40.192.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5F7F2171FF for ; Thu, 23 Sep 2021 23:49:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632441028; 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=UR02Y3LCSq6Rh0RG/92SgTWyq6uPk0abbgDZpG/v8eM=; b=P10dfcQ9PWs8diAFnUt2MIrnMziw0WnlFE+KAqKNhMe+m2lcCb18drQYtwziRMQePV29ZH 4/5bRWFRIl5MSk0b2pH2HudXLmS8J7pHvVRLKDUQ8F4nunqNK/PVO57YwvLwWv8M6IP4nj 8DxJVZvoN1X3IaJ/wRohol4Xk+nv7BI= X-MC-Unique: DryT0FgGPi2lbHOVzitHoQ-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH v2 2/4] virsh: remove variable 'ret' in cmdVersion() Date: Fri, 24 Sep 2021 01:49:09 +0200 Message-Id: <8392978ea37616319f2cf56580aba6de714ae01d.1632440795.git.khanicov@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.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) X-ZM-MESSAGEID: 1632441031752100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Kristina Hanicova Reviewed-by: Michal Privoznik --- tools/virsh-host.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/tools/virsh-host.c b/tools/virsh-host.c index b602696704..6f306fffe3 100644 --- a/tools/virsh-host.c +++ b/tools/virsh-host.c @@ -1350,7 +1350,6 @@ cmdVersion(vshControl *ctl, const vshCmd *cmd G_GNUC_= UNUSED) unsigned long includeVersion; unsigned long apiVersion; unsigned long daemonVersion; - int ret; unsigned int major; unsigned int minor; unsigned int rel; @@ -1370,8 +1369,7 @@ cmdVersion(vshControl *ctl, const vshCmd *cmd G_GNUC_= UNUSED) vshPrint(ctl, _("Compiled against library: libvirt %d.%d.%d\n"), major, minor, rel); =20 - ret =3D virGetVersion(&libVersion, hvType, &apiVersion); - if (ret < 0) { + if (virGetVersion(&libVersion, hvType, &apiVersion) < 0) { vshError(ctl, "%s", _("failed to get the library version")); return false; } @@ -1389,8 +1387,7 @@ cmdVersion(vshControl *ctl, const vshCmd *cmd G_GNUC_= UNUSED) vshPrint(ctl, _("Using API: %s %d.%d.%d\n"), hvType, major, minor, rel); =20 - ret =3D virConnectGetVersion(priv->conn, &hvVersion); - if (ret < 0) { + if (virConnectGetVersion(priv->conn, &hvVersion) < 0) { vshError(ctl, "%s", _("failed to get the hypervisor version")); return false; } @@ -1408,8 +1405,7 @@ cmdVersion(vshControl *ctl, const vshCmd *cmd G_GNUC_= UNUSED) } =20 if (vshCommandOptBool(cmd, "daemon")) { - ret =3D virConnectGetLibVersion(priv->conn, &daemonVersion); - if (ret < 0) { + if (virConnectGetLibVersion(priv->conn, &daemonVersion) < 0) { vshError(ctl, "%s", _("failed to get the daemon version")); } else { major =3D daemonVersion / 1000000; --=20 2.31.1 From nobody Mon Feb 9 14:31:20 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1632440979; cv=none; d=zohomail.com; s=zohoarc; b=X1RSzUedHn8YQc7Bo/FbJrO+ATAJlIpTOxtCM0eK2S+6rENnfp4caRzw7hiuKDXX1nWPNVDv8tRwXu3FOkAYtlaUcExJ3Th6aCQo28eFSlHjT0i/vKbcjQyDhrSpgs4I0A3bmK/KIyQIBWlGB77k9dgUAOysxIywPw2AspQznR4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632440979; 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=CxNoV6golWcJNJwlKTUdhQbNoS9He7iLrr/AI0y/yuQ=; b=aVccPT/X3rNPJP0J0OrbqWuwOxWeTAGxBx3Tk8MuNbxpX5GScxHTZBhbitHKBMR6DSHt/wosMxUk+pB76YKGfZuWzkvEz+xocODf7vawY+oa5i1sIDQ8yyBx/cdSRJF/pGiMoGWFNcvxWl8y4NMMLc8P75fM1iKP/0Tp2mVM7DA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1632440979493448.2487993882404; Thu, 23 Sep 2021 16:49: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-162-wSDBzJKvOZ6uc2urKVBhXQ-1; Thu, 23 Sep 2021 19:49:36 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 601CD1019988; Thu, 23 Sep 2021 23:49:32 +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 4407560936; Thu, 23 Sep 2021 23:49:32 +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 123C71806D02; Thu, 23 Sep 2021 23:49:32 +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 18NNnUno013705 for ; Thu, 23 Sep 2021 19:49:30 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3CD561800D; Thu, 23 Sep 2021 23:49:30 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.40.192.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4A60C171FF for ; Thu, 23 Sep 2021 23:49:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632440978; 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=CxNoV6golWcJNJwlKTUdhQbNoS9He7iLrr/AI0y/yuQ=; b=Scy9eqU7POJsTRg9db9/kmvQ/7d6PBNP2A/mmJBvmdxae1j4R2lAXzeq5dIeJDOIw41dU0 lsH0GdLGw1IFE5dsEa0w9iFtS+oTy2Yla3mEcMOwOxzyBK5Zoe/xhhghEyWVdapqK+YTKd xwnFRDog/z/lN+YE4aQaOJUzFyAsmdw= X-MC-Unique: wSDBzJKvOZ6uc2urKVBhXQ-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH v2 3/4] virsh: remove variable 'ret' and 'inactive' Date: Fri, 24 Sep 2021 01:49:10 +0200 Message-Id: <861e3cf7ef53ca5c5c354067f73e9b2d51cbe8c9.1632440795.git.khanicov@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.13 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) X-ZM-MESSAGEID: 1632440980504100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Kristina Hanicova Reviewed-by: Michal Privoznik --- tools/virsh-interface.c | 15 ++++++--------- tools/virsh-network.c | 17 ++++++----------- 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/tools/virsh-interface.c b/tools/virsh-interface.c index 4bcc59b580..f402119b68 100644 --- a/tools/virsh-interface.c +++ b/tools/virsh-interface.c @@ -485,26 +485,23 @@ static bool cmdInterfaceDumpXML(vshControl *ctl, const vshCmd *cmd) { virInterfacePtr iface; - bool ret =3D true; g_autofree char *dump =3D NULL; unsigned int flags =3D 0; - bool inactive =3D vshCommandOptBool(cmd, "inactive"); =20 - if (inactive) + if (vshCommandOptBool(cmd, "inactive")) flags |=3D VIR_INTERFACE_XML_INACTIVE; =20 if (!(iface =3D virshCommandOptInterface(ctl, cmd, NULL))) return false; =20 - dump =3D virInterfaceGetXMLDesc(iface, flags); - if (dump !=3D NULL) { - vshPrint(ctl, "%s", dump); - } else { - ret =3D false; + if (!(dump =3D virInterfaceGetXMLDesc(iface, flags))) { + virInterfaceFree(iface); + return false; } =20 + vshPrint(ctl, "%s", dump); virInterfaceFree(iface); - return ret; + return true; } =20 /* diff --git a/tools/virsh-network.c b/tools/virsh-network.c index 198993ac33..1442210278 100644 --- a/tools/virsh-network.c +++ b/tools/virsh-network.c @@ -360,28 +360,23 @@ static bool cmdNetworkDumpXML(vshControl *ctl, const vshCmd *cmd) { virNetworkPtr network; - bool ret =3D true; g_autofree char *dump =3D NULL; unsigned int flags =3D 0; - int inactive; =20 if (!(network =3D virshCommandOptNetwork(ctl, cmd, NULL))) return false; =20 - inactive =3D vshCommandOptBool(cmd, "inactive"); - if (inactive) + if (vshCommandOptBool(cmd, "inactive")) flags |=3D VIR_NETWORK_XML_INACTIVE; =20 - dump =3D virNetworkGetXMLDesc(network, flags); - - if (dump !=3D NULL) { - vshPrint(ctl, "%s", dump); - } else { - ret =3D false; + if (!(dump =3D virNetworkGetXMLDesc(network, flags))) { + virNetworkFree(network); + return false; } =20 + vshPrint(ctl, "%s", dump); virNetworkFree(network); - return ret; + return true; } =20 /* --=20 2.31.1 From nobody Mon Feb 9 14:31:20 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1632441031; cv=none; d=zohomail.com; s=zohoarc; b=fT3SBvNxtpAVy9noaBEdVNOixU3UPQx6pQq9IJEd6ftlpi/4FrUtd7fIJcQgiAFHKUPxmCuNWyqL/bYJ0mQ3MgUOGZDieuCsGptTaDzj9sTYi86LyK/yC8rKXlPHblYN9adkA97OMH4VGYLi71RZIJJpUXyiqu7XeOvCTNmnJ6I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632441031; 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=rkYQM8qvw0QlJfQoQFGN2K+EcqN+OkMERcZaX6ibmvA=; b=hn2TCcJASbDgHWPYjYPAnJ2aKkOOD76Vd6DGMxtGDASTlnVt+t0vrJWR5S5+VWNBzpAxT+6OVdDUaJECO6reU/dgWI1DNcf1dn9IHcTfevxfvXUvam58QXVq/DoBx6ZaUngqU6+KF9RyP0mtZ65ns3CNrvfZS5mV2T0/0IED0wo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1632441031696333.0873269143202; Thu, 23 Sep 2021 16:50:31 -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-382-Xs6ImRlWM0eH62bRVoDoVA-1; Thu, 23 Sep 2021 19:50:28 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5224210151E2; Thu, 23 Sep 2021 23:50:24 +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 34F87171FF; Thu, 23 Sep 2021 23:50:24 +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 08912181A1D0; Thu, 23 Sep 2021 23:50:24 +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 18NNnV2T013722 for ; Thu, 23 Sep 2021 19:49:31 -0400 Received: by smtp.corp.redhat.com (Postfix) id D47811800D; Thu, 23 Sep 2021 23:49:31 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.40.192.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id E5C55171FF for ; Thu, 23 Sep 2021 23:49:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632441030; 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=rkYQM8qvw0QlJfQoQFGN2K+EcqN+OkMERcZaX6ibmvA=; b=gkioXt9IG89hC18MJCyTtFN/eXWaTaUANNBCRXaa0U5cpAn98NdV598UKdvTZUuz2JjfH1 SHXBFGG/ZyQQSvnkKFWArf4693Y8CWAxMLsGfH30BuEmMRVSAI/C0+trZIYnVuDDiQQXeE DXSxtHt1zSvYhALqS3BwBtHALFXueA8= X-MC-Unique: Xs6ImRlWM0eH62bRVoDoVA-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH v2 4/4] virsh: util: remove 'else' branch after return Date: Fri, 24 Sep 2021 01:49:11 +0200 Message-Id: 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.16 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) X-ZM-MESSAGEID: 1632441033677100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Kristina Hanicova Reviewed-by: Michal Privoznik --- tools/virsh-util.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/virsh-util.c b/tools/virsh-util.c index 19cd0bcb99..fb74514b3c 100644 --- a/tools/virsh-util.c +++ b/tools/virsh-util.c @@ -137,8 +137,7 @@ virshDomainState(vshControl *ctl, /* fall back to virDomainGetInfo if virDomainGetState is not supported= */ if (virDomainGetInfo(dom, &info) < 0) return -1; - else - return info.state; + return info.state; } =20 =20 --=20 2.31.1