From nobody Mon Feb 9 10:32:31 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=1646229363; cv=none; d=zohomail.com; s=zohoarc; b=ep6rfk3Rk3UIlZOiKNNklhBDOsMTF2d7L3ya27i3+9t9uXfXIFSSryHvYv9jaILnmMWNr1bKpFP4lZmsy7rvE2mxiNlUEzz29ZeJm1g+E76IRrJVODIk9mekaWRMyxSf8I6pw/xxtZ980ZpkgjAhrR3zFdvkqHJ+ZNZ+fxxSJJg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646229363; 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=IT/cmEMO9I0M1v2SBhd0OSMQjNJwZRvhZnF2VjfUB7o=; b=RYr9gwbpyh8tKvqSOD/NASAhlhf19XTyWejSiuVBB7/kXyF2GUp+61p5pc7GHDJTs8oCvRUuTsuj96TxVNS3XfZTG3V/Gl51H3hnmBo6thU6GDS9gMNDuqEKMsQu/EZgR4DjzW2mGwy10V3oevPpKZAwhUcsLsmtOItqJAA5Us4= 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 1646229363292911.7626488286328; Wed, 2 Mar 2022 05:56:03 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-421-hXbf5Gw3M8ym0d0LKSFztw-1; Wed, 02 Mar 2022 08:56:00 -0500 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 C0B721091DA1; Wed, 2 Mar 2022 13:55:55 +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 A05B37C0F5; Wed, 2 Mar 2022 13:55:55 +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 719BD1807D62; Wed, 2 Mar 2022 13:55:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 222DtXMH017404 for ; Wed, 2 Mar 2022 08:55:33 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3E2EC8359C; Wed, 2 Mar 2022 13:55:33 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8D9DF8359B for ; Wed, 2 Mar 2022 13:55:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646229362; 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=IT/cmEMO9I0M1v2SBhd0OSMQjNJwZRvhZnF2VjfUB7o=; b=SZjyyfn0/HUzXyJMpppG/blujBOYzRmxaIbm8PgKo3whBR0FOiFCtqx9yIGqvPE5znmKEY RhmObPu+DXiYoaikiqvADCa0xO/axJAibpzkNLVL0WyFd/IQpx1bz5IocAX2GhqyWB7Ucr C0+2Em1DOHzrDZyIrDTDgB0JmD2TSPE= X-MC-Unique: hXbf5Gw3M8ym0d0LKSFztw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 02/23] virsh: cmdStart: Rewrite ternary operator use to standard if conditions Date: Wed, 2 Mar 2022 14:55:01 +0100 Message-Id: <756a37ae960f53e31f8364b98c981a7d86edef9d.1646229193.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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: 1646229364497100007 Content-Type: text/plain; charset="utf-8" Rewrite the invocation of the virDomainCreate(WithFiles/Flags) APIs based on the arguments into if-else instead of (nested) ternary operators. Signed-off-by: Peter Krempa --- tools/virsh-domain.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 6f0c063438..4c90f40f86 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -4104,10 +4104,15 @@ cmdStart(vshControl *ctl, const vshCmd *cmd) /* We can emulate force boot, even for older servers that reject it. = */ if (flags & VIR_DOMAIN_START_FORCE_BOOT) { - if ((nfds ? - virDomainCreateWithFiles(dom, nfds, fds, flags) : - virDomainCreateWithFlags(dom, flags)) =3D=3D 0) + if (nfds > 0) { + rc =3D virDomainCreateWithFiles(dom, nfds, fds, flags); + } else { + rc =3D virDomainCreateWithFlags(dom, flags); + } + + if (rc =3D=3D 0) goto started; + if (last_error->code !=3D VIR_ERR_NO_SUPPORT && last_error->code !=3D VIR_ERR_INVALID_ARG) { vshReportError(ctl); @@ -4128,9 +4133,15 @@ cmdStart(vshControl *ctl, const vshCmd *cmd) } /* Prefer older API unless we have to pass a flag. */ - if ((nfds ? virDomainCreateWithFiles(dom, nfds, fds, flags) : - (flags ? virDomainCreateWithFlags(dom, flags) - : virDomainCreate(dom))) < 0) { + if (nfds > 0) { + rc =3D virDomainCreateWithFiles(dom, nfds, fds, flags); + } else if (flags !=3D 0) { + rc =3D virDomainCreateWithFlags(dom, flags); + } else { + rc =3D virDomainCreate(dom); + } + + if (rc < 0) { vshError(ctl, _("Failed to start domain '%s'"), virDomainGetName(d= om)); return false; } --=20 2.35.1