From nobody Mon Feb 9 20:32:47 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=1632496895; cv=none; d=zohomail.com; s=zohoarc; b=BUoRvhaNAV2n8s+npoIkTnCp+jLDVWICcq6WARcAjTQJfOKrb18ligSoQ2Fu4w39G6NsSRk750cM8oofWCak9KeKU9H5ryGWvi4FvZXhkhTH2uZYXST81UYXm6PJ/EFMqXxSRyTNL+jn8cdpy6rVU7GQn9/hLgXe6JTyLO5wrng= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632496895; 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=mu+mvOf2tdvYKTknijX3SW/CrArsgaoHnQ4GiPBeuCA=; b=Z62arzrY4Xgpu1ydqf8J0roLDzWnx+lj5UnjBfRiGivNwA8G6n5jGCrXMQ0ktwwHdmi+2AoHCplXkbKVLYp45EWA4jElMJZA2wVsLiaMMbZz1PddYN+9XSzo7s2UO8ApRSrZG2YN8sKNa2tA1wl9wCRTBTHobwP3Lhg+SVpjv/M= 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 163249689582362.92658276271254; Fri, 24 Sep 2021 08:21:35 -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-159-YPz3fAUoNLuQ2K2GmJN7IA-1; Fri, 24 Sep 2021 11:21:33 -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 D186A18D6A32; Fri, 24 Sep 2021 15:21:27 +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 A9C711803B; Fri, 24 Sep 2021 15:21:27 +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 7934D1806D02; Fri, 24 Sep 2021 15:21:27 +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 18OFIN1o026637 for ; Fri, 24 Sep 2021 11:18:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id D67B41803B; Fri, 24 Sep 2021 15:18:23 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.43.2.78]) by smtp.corp.redhat.com (Postfix) with ESMTP id 152C51800D for ; Fri, 24 Sep 2021 15:18:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632496894; 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=mu+mvOf2tdvYKTknijX3SW/CrArsgaoHnQ4GiPBeuCA=; b=JwFJJpVmdlPN2hAGZR4YLIQ2Ffa6rQ+fOV8NuRyRmGOhgPTKCWnoxQT2egKTefJCQqQTy0 rFvJSp3SiP4YKQa8KFDggsnBl73GA5I/3++hiucdPbUNaD92tTHIoyZK13Hi3T5NIJ4kde VFriSQHuKy0kmKyISv3ppweTCJ4YY20= X-MC-Unique: YPz3fAUoNLuQ2K2GmJN7IA-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH v2 6/7] virsh: domain: remove 'ret' variable and use 'count' instead Date: Fri, 24 Sep 2021 17:17:49 +0200 Message-Id: <71748b6e562bbc67099042299429de5282556782.1632495763.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.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: 1632496898090100001 Content-Type: text/plain; charset="utf-8" This patch also includes use of an early return in case of an error. I think the changes make the functions more readable. Signed-off-by: Kristina Hanicova --- tools/virsh-domain.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 3c496d845a..94ed786751 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -13608,10 +13608,10 @@ static bool cmdDomFSFreeze(vshControl *ctl, const vshCmd *cmd) { g_autoptr(virshDomain) dom =3D NULL; - int ret =3D -1; const vshCmdOpt *opt =3D NULL; g_autofree const char **mountpoints =3D NULL; size_t nmountpoints =3D 0; + int count =3D 0; =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -13621,16 +13621,13 @@ cmdDomFSFreeze(vshControl *ctl, const vshCmd *cmd) mountpoints[nmountpoints-1] =3D opt->data; } =20 - ret =3D virDomainFSFreeze(dom, mountpoints, nmountpoints, 0); - if (ret < 0) { + if ((count =3D virDomainFSFreeze(dom, mountpoints, nmountpoints, 0)) <= 0) { vshError(ctl, _("Unable to freeze filesystems")); - goto cleanup; + return false; } =20 - vshPrintExtra(ctl, _("Froze %d filesystem(s)\n"), ret); - - cleanup: - return ret >=3D 0; + vshPrintExtra(ctl, _("Froze %d filesystem(s)\n"), count); + return true; } =20 static const vshCmdInfo info_domfsthaw[] =3D { @@ -13656,10 +13653,10 @@ static bool cmdDomFSThaw(vshControl *ctl, const vshCmd *cmd) { g_autoptr(virshDomain) dom =3D NULL; - int ret =3D -1; const vshCmdOpt *opt =3D NULL; g_autofree const char **mountpoints =3D NULL; size_t nmountpoints =3D 0; + int count =3D 0; =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -13669,16 +13666,13 @@ cmdDomFSThaw(vshControl *ctl, const vshCmd *cmd) mountpoints[nmountpoints-1] =3D opt->data; } =20 - ret =3D virDomainFSThaw(dom, mountpoints, nmountpoints, 0); - if (ret < 0) { + if ((count =3D virDomainFSThaw(dom, mountpoints, nmountpoints, 0)) < 0= ) { vshError(ctl, _("Unable to thaw filesystems")); - goto cleanup; + return false; } =20 - vshPrintExtra(ctl, _("Thawed %d filesystem(s)\n"), ret); - - cleanup: - return ret >=3D 0; + vshPrintExtra(ctl, _("Thawed %d filesystem(s)\n"), count); + return true; } =20 static const vshCmdInfo info_domfsinfo[] =3D { --=20 2.31.1