From nobody Mon Feb 9 00:56:21 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1632409728; cv=none; d=zohomail.com; s=zohoarc; b=gfdgkqcbAjNeTfZ/qMkJ2GCh00R9j0ffOheJ92IBeHDtP33x2Yd0J6jiOMzzeO7DbFOdY4/4wGmBUdu2qWY/k2g1J0X3nkzfDzOssiQA0K9XqdW2CQjBzGA8TKgDv2+/YoJwm2yFKTwpz0LoGScw4kpC5VUxLmvAV9o/76lWiho= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632409728; 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=o7EievYVY90JhfjRQcjb/9Y7xUY0oL8gcVXICzT8yCk=; b=aXzoWJ0G1T7bv3yOPIMMiWv3j7UbFgVE3+TQXBitgFQkuG5bmRljayuVLcMlR2Q1k5xz0uuOxIikLXxNpXTXSeUTAmrvK1REiSjG5KM759tPhnsjnmY/lgGHkNHwtG5uncY4Jwl4Y4t6Jkyu+cDjPwpp7xtibvDhEV7eOhkD8H0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 163240972869673.6040225837512; Thu, 23 Sep 2021 08:08:48 -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-25-zN0mK268M_S0zz6FtwfHdw-1; Thu, 23 Sep 2021 11:08:45 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 58AB89126F; Thu, 23 Sep 2021 15:08: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 3B837652A5; Thu, 23 Sep 2021 15:08: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 CE1281806D03; Thu, 23 Sep 2021 15:08:31 +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 18NF8Np3030580 for ; Thu, 23 Sep 2021 11:08:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id 285B1171FF; Thu, 23 Sep 2021 15:08:23 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.43.2.78]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8D8245F707 for ; Thu, 23 Sep 2021 15:08:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632409727; 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=o7EievYVY90JhfjRQcjb/9Y7xUY0oL8gcVXICzT8yCk=; b=Gk5O7CFcalQrjVEAImDflezv2MSUDukgNybuWVeK7CMsI4VsNK5+2qGVxU3gXcmzarVIYe vo7OnRcD+otOZFbFYWuk55XnNsKllFvOXTJKmhDiGO8s4Ayz6qHA4HDbQCe7h483hhG/3J rorkzkfnN+adnUwSWsJ0rgb0xx6KafU= X-MC-Unique: zN0mK268M_S0zz6FtwfHdw-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 3/5] virsh: domain: change the way functions return bool value Date: Thu, 23 Sep 2021 17:08:02 +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.11 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: 1632409729828100001 Content-Type: text/plain; charset="utf-8" This patch changes the way functions return bool value from pattern: if (functionCall() < 0) return false; return true; into a more readable and modern way of direct return: return functionCall() =3D=3D 0; I know that not everybody will agree this is more readable so I am open to discussion and I leave merging this patch up to the reviewer. Signed-off-by: Kristina Hanicova --- tools/virsh-domain.c | 114 ++++++++++--------------------------------- 1 file changed, 26 insertions(+), 88 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 3232463485..ec427443c4 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -765,7 +765,6 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd) return false; } =20 - vshPrintExtra(ctl, "%s", _("Disk attached successfully\n")); return true; } @@ -1432,7 +1431,6 @@ cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd) goto save_error; } =20 - if (nparams =3D=3D 0) { if (virDomainGetBlockIoTune(dom, NULL, NULL, &nparams, flags) !=3D= 0) { vshError(ctl, "%s", @@ -2673,10 +2671,7 @@ virshBlockJobSetSpeed(vshControl *ctl, if (vshBlockJobOptionBandwidth(ctl, cmd, bytes, &bandwidth) < 0) return false; =20 - if (virDomainBlockJobSetSpeed(dom, path, bandwidth, flags) < 0) - return false; - - return true; + return virDomainBlockJobSetSpeed(dom, path, bandwidth, flags) =3D=3D 0; } =20 =20 @@ -2693,10 +2688,7 @@ virshBlockJobAbort(virDomainPtr dom, if (pivot) flags |=3D VIR_DOMAIN_BLOCK_JOB_ABORT_PIVOT; =20 - if (virDomainBlockJobAbort(dom, path, flags) < 0) - return false; - - return true; + return virDomainBlockJobAbort(dom, path, flags) =3D=3D 0; } =20 =20 @@ -3010,10 +3002,8 @@ cmdRunConsole(vshControl *ctl, virDomainPtr dom, vshPrintExtra(ctl, " (Ctrl + %c)", priv->escapeChar[1]); vshPrintExtra(ctl, "\n"); fflush(stdout); - if (virshRunConsole(ctl, dom, name, flags) =3D=3D 0) - return true; =20 - return false; + return virshRunConsole(ctl, dom, name, flags) =3D=3D 0; } =20 static bool @@ -7079,15 +7069,10 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd) return false; =20 /* use old API without any explicit flags */ - if (flags =3D=3D VIR_DOMAIN_AFFECT_CURRENT && !current) { - if (virDomainPinVcpu(dom, vcpu, cpumap, cpumaplen) !=3D 0) - return false; - } else { - if (virDomainPinVcpuFlags(dom, vcpu, cpumap, cpumaplen, flags) != =3D 0) - return false; - } + if (flags =3D=3D VIR_DOMAIN_AFFECT_CURRENT && !current) + return virDomainPinVcpu(dom, vcpu, cpumap, cpumaplen) =3D=3D 0; =20 - return true; + return virDomainPinVcpuFlags(dom, vcpu, cpumap, cpumaplen, flags) =3D= =3D 0; } =20 /* @@ -7184,10 +7169,7 @@ cmdEmulatorPin(vshControl *ctl, const vshCmd *cmd) if (flags =3D=3D -1) flags =3D VIR_DOMAIN_AFFECT_LIVE; =20 - if (virDomainPinEmulator(dom, cpumap, cpumaplen, flags) !=3D 0) - return false; - - return true; + return virDomainPinEmulator(dom, cpumap, cpumaplen, flags) =3D=3D 0; } =20 /* @@ -7270,15 +7252,10 @@ cmdSetvcpus(vshControl *ctl, const vshCmd *cmd) } =20 /* none of the options were specified */ - if (!current && flags =3D=3D 0) { - if (virDomainSetVcpus(dom, count) !=3D 0) - return false; - } else { - if (virDomainSetVcpusFlags(dom, count, flags) < 0) - return false; - } + if (!current && flags =3D=3D 0) + return virDomainSetVcpus(dom, count) =3D=3D 0; =20 - return true; + return virDomainSetVcpusFlags(dom, count, flags) =3D=3D 0; } =20 =20 @@ -7439,10 +7416,7 @@ cmdSetvcpu(vshControl *ctl, const vshCmd *cmd) if (enable) state =3D 1; =20 - if (virDomainSetVcpu(dom, vcpulist, state, flags) < 0) - return false; - - return true; + return virDomainSetVcpu(dom, vcpulist, state, flags) =3D=3D 0; } =20 =20 @@ -7493,10 +7467,7 @@ cmdDomblkthreshold(vshControl *ctl, const vshCmd *cm= d) if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 - if (virDomainSetBlockThreshold(dom, dev, threshold, 0) < 0) - return false; - - return true; + return virDomainSetBlockThreshold(dom, dev, threshold, 0) =3D=3D 0; } =20 =20 @@ -7656,11 +7627,8 @@ cmdIOThreadPin(vshControl *ctl, const vshCmd *cmd) if (!(cpumap =3D virshParseCPUList(ctl, &cpumaplen, cpulist, maxcpu))) return false; =20 - if (virDomainPinIOThread(dom, iothread_id, - cpumap, cpumaplen, flags) !=3D 0) - return false; - - return true; + return virDomainPinIOThread(dom, iothread_id, cpumap, + cpumaplen, flags) =3D=3D 0; } =20 /* @@ -7717,10 +7685,7 @@ cmdIOThreadAdd(vshControl *ctl, const vshCmd *cmd) return false; } =20 - if (virDomainAddIOThread(dom, iothread_id, flags) < 0) - return false; - - return true; + return virDomainAddIOThread(dom, iothread_id, flags) =3D=3D 0; } =20 =20 @@ -7877,15 +7842,13 @@ cmdIOThreadDel(vshControl *ctl, const vshCmd *cmd) =20 if (vshCommandOptInt(ctl, cmd, "id", &iothread_id) < 0) return false; + if (iothread_id <=3D 0) { vshError(ctl, _("Invalid IOThread id value: '%d'"), iothread_id); return false; } =20 - if (virDomainDelIOThread(dom, iothread_id, flags) < 0) - return false; - - return true; + return virDomainDelIOThread(dom, iothread_id, flags) =3D=3D 0; } =20 /* @@ -8593,10 +8556,7 @@ cmdInjectNMI(vshControl *ctl, const vshCmd *cmd) if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 - if (virDomainInjectNMI(dom, 0) < 0) - return false; - - return true; + return virDomainInjectNMI(dom, 0) =3D=3D 0; } =20 /* @@ -8693,10 +8653,7 @@ cmdSendKey(vshControl *ctl, const vshCmd *cmd) count++; } =20 - if (virDomainSendKey(dom, codeset, holdtime, keycodes, count, 0) < 0) - return false; - - return true; + return virDomainSendKey(dom, codeset, holdtime, keycodes, count, 0) = =3D=3D 0; } =20 /* @@ -8788,10 +8745,7 @@ cmdSendProcessSignal(vshControl *ctl, const vshCmd *= cmd) return false; } =20 - if (virDomainSendProcessSignal(dom, pid_value, signum, 0) < 0) - return false; - - return true; + return virDomainSendProcessSignal(dom, pid_value, signum, 0) =3D=3D 0; } =20 /* @@ -8862,10 +8816,7 @@ cmdSetmem(vshControl *ctl, const vshCmd *cmd) return false; kibibytes =3D VIR_DIV_UP(bytes, 1024); =20 - if (virDomainSetMemoryFlags(dom, kibibytes, flags) < 0) - return false; - - return true; + return virDomainSetMemoryFlags(dom, kibibytes, flags) =3D=3D 0; } =20 /* @@ -11118,10 +11069,7 @@ cmdMigrateSetMaxSpeed(vshControl *ctl, const vshCm= d *cmd) if (vshCommandOptBool(cmd, "postcopy")) flags |=3D VIR_DOMAIN_MIGRATE_MAX_SPEED_POSTCOPY; =20 - if (virDomainMigrateSetMaxSpeed(dom, bandwidth, flags) < 0) - return false; - - return true; + return virDomainMigrateSetMaxSpeed(dom, bandwidth, flags) =3D=3D 0; } =20 /* @@ -11194,10 +11142,7 @@ cmdMigratePostCopy(vshControl *ctl, const vshCmd *= cmd) if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 - if (virDomainMigrateStartPostCopy(dom, 0) < 0) - return false; - - return true; + return virDomainMigrateStartPostCopy(dom, 0) =3D=3D 0; } =20 /* @@ -13801,10 +13746,7 @@ cmdGuestAgentTimeout(vshControl *ctl, const vshCmd= *cmd) if (vshCommandOptInt(ctl, cmd, "timeout", &timeout) < 0) return false; =20 - if (virDomainAgentSetResponseTimeout(dom, timeout, flags) < 0) - return false; - - return true; + return virDomainAgentSetResponseTimeout(dom, timeout, flags) =3D=3D 0; } =20 /* @@ -14032,12 +13974,8 @@ cmdSetUserSSHKeys(vshControl *ctl, const vshCmd *c= md) } } =20 - if (virDomainAuthorizedSSHKeysSet(dom, user, - (const char **) keys, nkeys, flags) = < 0) { - return false; - } - - return true; + return virDomainAuthorizedSSHKeysSet(dom, user, (const char **) keys, + nkeys, flags) =3D=3D 0; } =20 =20 --=20 2.31.1