From nobody Thu May 9 02:37:02 2024 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=1648819667; cv=none; d=zohomail.com; s=zohoarc; b=dDWKtw8Xc/roNKgFEuPyTnO4wQ5Gw7C0gMCdcEmCWnKG/6QQc7TEpaa8GXtZHdA8tTnXd7nmCrNH6laTsVg2QY4es6Uxpo6/0+ODzTxohCzPYPwmOzLYI4cRSzBqzksE6TQ3g69vNsOD7KWrSFaKyVh/jQF8bl6S28IcXuP6btg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1648819667; 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=4OPnY+DTj3iyAEJUiZAY3zlHHVumIFFgYmgchCbWTrc=; b=XmUa9JyCSn1mwr+rg+COJB7AOkbygqvcaNutl2BEw7uEqWechUPn0ydU10dgi7ZhEbI2Z0mWq6pUYKbu0/Tm/d6ILIn4ebnCz2EaKoYm0R/gh/9/XrbJjrtnmpml985ZFQTgEfULtUwv7qHHfZp5139OB8DNiYQWxh36jVAtCZg= 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 164881966781045.6756090500495; Fri, 1 Apr 2022 06:27:47 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-391-GSV5WqzPOdO5MHdsuUDEPw-1; Fri, 01 Apr 2022 09:27:42 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BCD5B101AA64; Fri, 1 Apr 2022 13:27:40 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5678E400E407; Fri, 1 Apr 2022 13:27:40 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id EF8831947BBF; Fri, 1 Apr 2022 13:27:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 63E131947BBE for ; Fri, 1 Apr 2022 13:27:39 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 480C0C28103; Fri, 1 Apr 2022 13:27:39 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id E3917C28102 for ; Fri, 1 Apr 2022 13:27:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1648819666; 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=4OPnY+DTj3iyAEJUiZAY3zlHHVumIFFgYmgchCbWTrc=; b=QtveLT6sgkCfIN7zvyud+IVSYrAKCd2XgraedzdKxd7ZSOKIRyOnEoFe2nB2CZviVybg4X V51BkdNEjFuYnCPi/lRHL7UxhIYmzdKO0lov9RlYRXnyxdlXFsFsInDXtMj3G90VzkllWq CiG/svfTRUIhcNpiqu8rRkT0R5w+jRA= X-MC-Unique: GSV5WqzPOdO5MHdsuUDEPw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 1/4] tools: snapshot: remove pointless checks Date: Fri, 1 Apr 2022 15:27:33 +0200 Message-Id: <4cd038e3bd655c42a4fd6d9928ce78141a28d222.1648819564.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1648819669100100003 There's no need to check whether a flag is not set just to set it in that case. Signed-off-by: J=C3=A1n Tomko --- tools/virsh-snapshot.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c index 9ed64313af..7cd76f39e2 100644 --- a/tools/virsh-snapshot.c +++ b/tools/virsh-snapshot.c @@ -1292,10 +1292,9 @@ virshSnapshotListCollect(vshControl *ctl, virDomainP= tr dom, if (filter_fallback) { /* Older API didn't filter on status or location, but the * information is available in domain XML. */ - if (!(orig_flags & VIR_DOMAIN_SNAPSHOT_FILTERS_STATUS)) - orig_flags |=3D VIR_DOMAIN_SNAPSHOT_FILTERS_STATUS; - if (!(orig_flags & VIR_DOMAIN_SNAPSHOT_FILTERS_LOCATION)) - orig_flags |=3D VIR_DOMAIN_SNAPSHOT_FILTERS_LOCATION; + orig_flags |=3D VIR_DOMAIN_SNAPSHOT_FILTERS_STATUS; + orig_flags |=3D VIR_DOMAIN_SNAPSHOT_FILTERS_LOCATION; + for (i =3D 0; i < snaplist->nsnaps; i++) { switch (virshSnapshotFilter(ctl, snaplist->snaps[i].snap, orig_flags)) { --=20 2.34.1 From nobody Thu May 9 02:37:02 2024 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=1648819684; cv=none; d=zohomail.com; s=zohoarc; b=ColPqf83Yn5WEj/xK2x4+Be7HTfAmXw3zhSo70cW3P/Hlk6MVeD74FvXq8Ee71SE9hI5SpdDPlBm4K+6T2bgiKU9ZNBlKfS5G2UAUXBzH21kgS5GHm2A9YNG/ByseMGdAC5CWSp2iJwD604zmSR/FSB+oYLe3hYdgkZvqI/gvHE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1648819684; 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=+qZaRWU0w+OarfW+acqgq4u/N++3fi1j2OB54MtuoD4=; b=hI28VzJVd64WUn3rc7XuJK2GeScDW9CZcii7lUN5roDL45rKypGtyR+9z4TCeuGs2eXtAMaKXdTKvesCSLFjiZjd8qOxGV1hALN9CpUAxnkRP5WOlM0K4wu2YPtNZbIs70eJtiLA268FfD1PPh0vwZxuh9HQBSWBGoM0JDCG5hE= 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 164881968474036.48882770364662; Fri, 1 Apr 2022 06:28:04 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-261-o-p685rBPl2XvoScB8RGKg-1; Fri, 01 Apr 2022 09:27:45 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5638B1C0785E; Fri, 1 Apr 2022 13:27:42 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0EE8C42CFDD; Fri, 1 Apr 2022 13:27:42 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 888171940359; Fri, 1 Apr 2022 13:27:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 047901940340 for ; Fri, 1 Apr 2022 13:27:40 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id DAC3DC28103; Fri, 1 Apr 2022 13:27:39 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id 82880C28102 for ; Fri, 1 Apr 2022 13:27:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1648819683; 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=+qZaRWU0w+OarfW+acqgq4u/N++3fi1j2OB54MtuoD4=; b=UxJCpd5qOXMKZMkReHmOI8acNQp7+FARgAyZijgi9I819P5v7T0ogC14DKNGyIj/kzocz+ 3wz8SGJbw5TH/JvEWhcyjnfdWbz/Xx+AB9GlLVuDvrZnIWCnCdHz1yZFTsM0vxTTlGtxAf 2isurSoqP7KTEYn895zHsDYKellxWAA= X-MC-Unique: o-p685rBPl2XvoScB8RGKg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 2/4] src: introduce VIR_UNLESS and VIR_ELSIF Date: Fri, 1 Apr 2022 15:27:34 +0200 Message-Id: <910da92f63ff1e6e97e46853823dd3f5886ef331.1648819564.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1648819685265100001 Inspired by executable line noise, introduce more readable alternatives to if (!(expr)) and else if Signed-off-by: J=C3=A1n Tomko --- src/internal.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/internal.h b/src/internal.h index 4cfb022b41..f8ca751014 100644 --- a/src/internal.h +++ b/src/internal.h @@ -548,3 +548,6 @@ enum { # define fprintf(fh, ...) g_fprintf(fh, __VA_ARGS__) =20 #endif /* VIR_NO_GLIB_STDIO */ + +#define VIR_UNLESS(e) if (!(e)) +#define VIR_ELSIF else if --=20 2.34.1 From nobody Thu May 9 02:37:02 2024 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=1648819690; cv=none; d=zohomail.com; s=zohoarc; b=Ye3KTfinHNLX82scijZrMBOnVdrq35Mx/2JXkz5Ko/4HKXFYjdf3GQASox4S8mUB/2B8SygGn6xenVfu8OrjibBfs4QVkZ4L/QGwuTvClbkE+Y/LSPo+pTXFpMYgLwwTqLgvTMYP7n0+Q1q16w2buqGS/EveZUEFAhlPkGXOZwo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1648819690; 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=s94pV4tcTAeZhyPPbraMkdljoevQ6mQSQ/qN/OAv7Hg=; b=kMHucTAt/lUbvD1sUEnT2wxkBzfUs7dcTNtTTbiL7JIWmOuuP+4yMGS4iiWDC7QTcK+iMj3uFM0dxY0zDWRCAsdP/5FbuwaaryTmOTeYUZy59R+4s/PxNMjK04UlvDvKgzp2AAbYVywqB7GRTyv3t+pIq4yViSUjH3Hx3WgvBpo= 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 1648819689973952.4861073467583; Fri, 1 Apr 2022 06:28:09 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-270-bvfL735gP7STsQzGv2QV8g-1; Fri, 01 Apr 2022 09:27:45 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CFC75803D77; Fri, 1 Apr 2022 13:27:42 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id A218642CFD9; Fri, 1 Apr 2022 13:27:42 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D8B3D1940344; Fri, 1 Apr 2022 13:27:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 3CFCE1949761 for ; Fri, 1 Apr 2022 13:27:41 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 1DE55C28104; Fri, 1 Apr 2022 13:27:41 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id 270A6C28102 for ; Fri, 1 Apr 2022 13:27:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1648819688; 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=s94pV4tcTAeZhyPPbraMkdljoevQ6mQSQ/qN/OAv7Hg=; b=KsnPJuwjqDBOvWAiz+ae8ISt+wxiHmVc9GOoDdLpTtWL8koaH+XXiuWuHWRXZo5INpFOng j7TZbmjmBi0/oWlIEjGYFdaQYwbVvlVfEkXRJDTVCYDNUSlqOtSN/yiHa45i8JA4e5jSnY QXfapclBy+lagmyLB8sdMyZ6UUxXsJQ= X-MC-Unique: bvfL735gP7STsQzGv2QV8g-1 X-Original-To: libvir-list@listman.corp.redhat.com From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 3/4] tools: use VIR_UNLESS more Date: Fri, 1 Apr 2022 15:27:35 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1648819691426100001 Demonstrate the elegance of the macro. Signed-off-by: J=C3=A1n Tomko --- tools/virsh-backup.c | 8 +- tools/virsh-checkpoint.c | 28 +- tools/virsh-completer-checkpoint.c | 2 +- tools/virsh-completer-domain.c | 30 +- tools/virsh-completer-host.c | 12 +- tools/virsh-completer-network.c | 4 +- tools/virsh-completer-snapshot.c | 2 +- tools/virsh-completer-volume.c | 4 +- tools/virsh-console.c | 20 +- tools/virsh-domain-event.c | 6 +- tools/virsh-domain-monitor.c | 68 ++--- tools/virsh-domain.c | 432 ++++++++++++++--------------- tools/virsh-edit.c | 10 +- tools/virsh-host.c | 42 +-- tools/virsh-interface.c | 88 +++--- tools/virsh-network.c | 70 ++--- tools/virsh-nodedev.c | 48 ++-- tools/virsh-nwfilter.c | 32 +-- tools/virsh-pool.c | 62 ++--- tools/virsh-secret.c | 30 +- tools/virsh-snapshot.c | 102 +++---- tools/virsh-util.c | 32 +-- tools/virsh-volume.c | 70 ++--- tools/virsh.c | 16 +- tools/virt-admin.c | 44 +-- tools/virt-host-validate-ch.c | 2 +- tools/virt-host-validate-common.c | 22 +- tools/virt-host-validate-qemu.c | 4 +- tools/virt-login-shell-helper.c | 16 +- tools/virt-pki-query-dn.c | 2 +- tools/vsh-table.c | 14 +- tools/vsh.c | 102 +++---- 32 files changed, 712 insertions(+), 712 deletions(-) diff --git a/tools/virsh-backup.c b/tools/virsh-backup.c index 7bac1923a6..7e13eb841c 100644 --- a/tools/virsh-backup.c +++ b/tools/virsh-backup.c @@ -68,13 +68,13 @@ cmdBackupBegin(vshControl *ctl, if (vshCommandOptBool(cmd, "reuse-external")) flags |=3D VIR_DOMAIN_BACKUP_BEGIN_REUSE_EXTERNAL; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (vshCommandOptStringReq(ctl, cmd, "backupxml", &backup_from) < 0) return false; =20 - if (!backup_from) { + VIR_UNLESS (backup_from) { backup_buffer =3D g_strdup(""); } else { if (virFileReadAll(backup_from, VSH_MAX_XML_FILE, &backup_buffer) = < 0) { @@ -125,10 +125,10 @@ cmdBackupDumpXML(vshControl *ctl, g_autoptr(virshDomain) dom =3D NULL; g_autofree char *xml =3D NULL; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 - if (!(xml =3D virDomainBackupGetXMLDesc(dom, 0))) + VIR_UNLESS ((xml =3D virDomainBackupGetXMLDesc(dom, 0))) return false; =20 vshPrint(ctl, "%s", xml); diff --git a/tools/virsh-checkpoint.c b/tools/virsh-checkpoint.c index 8ad37ece69..fd8cd8827f 100644 --- a/tools/virsh-checkpoint.c +++ b/tools/virsh-checkpoint.c @@ -55,7 +55,7 @@ virshCheckpointCreate(vshControl *ctl, return false; =20 name =3D virDomainCheckpointGetName(checkpoint); - if (!name) { + VIR_UNLESS (name) { vshError(ctl, "%s", _("Could not get checkpoint name")); return false; } @@ -124,12 +124,12 @@ cmdCheckpointCreate(vshControl *ctl, if (vshCommandOptBool(cmd, "quiesce")) flags |=3D VIR_DOMAIN_CHECKPOINT_CREATE_QUIESCE; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (vshCommandOptStringReq(ctl, cmd, "xmlfile", &from) < 0) return false; - if (!from) { + VIR_UNLESS (from) { buffer =3D g_strdup(""); } else { if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) { @@ -239,7 +239,7 @@ cmdCheckpointCreateAs(vshControl *ctl, if (vshCommandOptBool(cmd, "quiesce")) flags |=3D VIR_DOMAIN_CHECKPOINT_CREATE_QUIESCE; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (vshCommandOptStringReq(ctl, cmd, "name", &name) < 0 || @@ -298,7 +298,7 @@ virshLookupCheckpoint(vshControl *ctl, vshError(ctl, _("--%s is required"), arg); return -1; } - if (!*chk) { + VIR_UNLESS (*chk) { vshReportError(ctl); return -1; } @@ -344,7 +344,7 @@ cmdCheckpointEdit(vshControl *ctl, unsigned int getxml_flags =3D VIR_DOMAIN_CHECKPOINT_XML_SECURE; unsigned int define_flags =3D VIR_DOMAIN_CHECKPOINT_CREATE_REDEFINE; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (virshLookupCheckpoint(ctl, cmd, "checkpointname", dom, @@ -513,7 +513,7 @@ virshCheckpointListFree(struct virshCheckpointList *che= ckpointlist) { size_t i; =20 - if (!checkpointlist) + VIR_UNLESS (checkpointlist) return; if (checkpointlist->chks) { for (i =3D 0; i < checkpointlist->nchks; i++) { @@ -535,7 +535,7 @@ virshChkSorter(const void *a, =20 if (sa->chk && !sb->chk) return -1; - if (!sa->chk) + VIR_UNLESS (sa->chk) return sb->chk !=3D NULL; =20 return vshStrcasecmp(virDomainCheckpointGetName(sa->chk), @@ -726,7 +726,7 @@ cmdCheckpointList(vshControl *ctl, flags |=3D VIR_DOMAIN_CHECKPOINT_LIST_ROOTS; =20 if (vshCommandOptBool(cmd, "descendants")) { - if (!from) { + VIR_UNLESS (from) { vshError(ctl, "%s", _("--descendants requires --from")); return false; @@ -784,10 +784,10 @@ cmdCheckpointList(vshControl *ctl, continue; } =20 - if (!(doc =3D virDomainCheckpointGetXMLDesc(checkpoint, 0))) + VIR_UNLESS ((doc =3D virDomainCheckpointGetXMLDesc(checkpoint, 0))) continue; =20 - if (!(xml =3D virXMLParseStringCtxt(doc, _("(domain_checkpoint)"),= &ctxt))) + VIR_UNLESS ((xml =3D virXMLParseStringCtxt(doc, _("(domain_checkpo= int)"), &ctxt))) continue; =20 if (parent) @@ -874,14 +874,14 @@ cmdCheckpointDumpXML(vshControl *ctl, if (vshCommandOptBool(cmd, "size")) flags |=3D VIR_DOMAIN_CHECKPOINT_XML_SIZE; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (virshLookupCheckpoint(ctl, cmd, "checkpointname", dom, &checkpoint, &name) < 0) return false; =20 - if (!(xml =3D virDomainCheckpointGetXMLDesc(checkpoint, flags))) + VIR_UNLESS ((xml =3D virDomainCheckpointGetXMLDesc(checkpoint, flags))) return false; =20 vshPrint(ctl, "%s", xml); @@ -931,7 +931,7 @@ cmdCheckpointParent(vshControl *ctl, =20 if (virshGetCheckpointParent(ctl, checkpoint, &parent) < 0) return false; - if (!parent) { + VIR_UNLESS (parent) { vshError(ctl, _("checkpoint '%s' has no parent"), name); return false; } diff --git a/tools/virsh-completer-checkpoint.c b/tools/virsh-completer-che= ckpoint.c index b6d6c93e85..48d01e6aa6 100644 --- a/tools/virsh-completer-checkpoint.c +++ b/tools/virsh-completer-checkpoint.c @@ -43,7 +43,7 @@ virshCheckpointNameCompleter(vshControl *ctl, if (!priv->conn || virConnectIsAlive(priv->conn) <=3D 0) return NULL; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return NULL; =20 if ((ncheckpoints =3D virDomainListAllCheckpoints(dom, &checkpoints, diff --git a/tools/virsh-completer-domain.c b/tools/virsh-completer-domain.c index d4c877cd04..620a3a8ddb 100644 --- a/tools/virsh-completer-domain.c +++ b/tools/virsh-completer-domain.c @@ -177,7 +177,7 @@ virshDomainInterfaceCompleter(vshControl *ctl, =20 /* In case we are dealing with inactive domain XML there's no * . Offer MAC addresses then. */ - if (!(tmp[i] =3D virXPathString("string(./mac/@address)", ctxt))) + VIR_UNLESS ((tmp[i] =3D virXPathString("string(./mac/@address)", c= txt))) return NULL; } =20 @@ -214,7 +214,7 @@ virshDomainDiskTargetCompleter(vshControl *ctl, =20 for (i =3D 0; i < ndisks; i++) { ctxt->node =3D disks[i]; - if (!(tmp[i] =3D virXPathString("string(./target/@dev)", ctxt))) + VIR_UNLESS ((tmp[i] =3D virXPathString("string(./target/@dev)", ct= xt))) return NULL; } =20 @@ -233,7 +233,7 @@ virshDomainDiskTargetListCompleter(vshControl *ctl, if (vshCommandOptStringQuiet(ctl, cmd, argname, &curval) < 0) return NULL; =20 - if (!targets) + VIR_UNLESS (targets) return NULL; =20 return virshCommaStringListComplete(curval, (const char **) targets); @@ -276,7 +276,7 @@ virshDomainBlockjobBaseTopCompleteDisk(const char *targ= et, for (i =3D 0; i < nindexlist; i++) { g_autofree char *idx =3D virXMLPropString(indexlist[i], "index"); =20 - if (!idx) + VIR_UNLESS (idx) continue; =20 ret =3D g_slist_prepend(ret, g_strdup_printf("%s[%s]", target, idx= )); @@ -335,7 +335,7 @@ virshDomainBlockjobBaseTopCompleter(vshControl *ctl, =20 ctxt->node =3D disks[i]; =20 - if (!(disktarget =3D virXPathString("string(./target/@dev)", ctxt)= )) + VIR_UNLESS ((disktarget =3D virXPathString("string(./target/@dev)"= , ctxt))) return NULL; =20 if (path && STRNEQ(path, disktarget)) @@ -446,7 +446,7 @@ virshDomainDeviceAliasCompleter(vshControl *ctl, tmp =3D g_new0(char *, naliases + 1); =20 for (i =3D 0; i < naliases; i++) { - if (!(tmp[i] =3D virXMLPropString(aliases[i], "name"))) + VIR_UNLESS ((tmp[i] =3D virXMLPropString(aliases[i], "name"))) return NULL; } =20 @@ -561,7 +561,7 @@ virshDomainIOThreadIdCompleter(vshControl *ctl, =20 virCheckFlags(0, NULL); =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return NULL; =20 if ((rc =3D virDomainGetIOThreadInfo(dom, &info, flags)) < 0) @@ -592,7 +592,7 @@ virshDomainVcpuCompleter(vshControl *ctl, =20 virCheckFlags(0, NULL); =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return NULL; =20 if (virshDomainGetXMLFromDom(ctl, dom, VIR_DOMAIN_XML_INACTIVE, @@ -627,7 +627,7 @@ virshDomainVcpulistCompleter(vshControl *ctl, =20 virCheckFlags(0, NULL); =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return NULL; =20 if (vshCommandOptStringQuiet(ctl, cmd, "vcpulist", &vcpuid) < 0) @@ -698,7 +698,7 @@ virshDomainVcpulistViaAgentCompleter(vshControl *ctl, =20 virCheckFlags(0, NULL); =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return NULL; =20 if (vshCommandOptStringQuiet(ctl, cmd, "cpulist", &vcpuid) < 0) @@ -729,7 +729,7 @@ virshDomainVcpulistViaAgentCompleter(vshControl *ctl, goto cleanup; =20 onlineVcpuStr =3D vshGetTypedParamValue(ctl, ¶ms[1]); - if (!(onlineVcpus =3D virBitmapParseUnlimited(onlineVcpuStr))) + VIR_UNLESS ((onlineVcpus =3D virBitmapParseUnlimited(onlineVcpuStr= ))) goto cleanup; =20 if (virBitmapToData(onlineVcpus, &onlineVcpumap, &dummy) < 0) @@ -738,7 +738,7 @@ virshDomainVcpulistViaAgentCompleter(vshControl *ctl, if (enable) { offlinableVcpuStr =3D vshGetTypedParamValue(ctl, ¶ms[2]); =20 - if (!(offlinableVcpus =3D virBitmapParseUnlimited(offlinableVc= puStr))) + VIR_UNLESS ((offlinableVcpus =3D virBitmapParseUnlimited(offli= nableVcpuStr))) goto cleanup; =20 if (virBitmapToData(offlinableVcpus, &offlinableVcpumap, &dumm= y) < 0) @@ -937,13 +937,13 @@ virshKeycodeNameCompleter(vshControl *ctl, break; } =20 - if (!names) + VIR_UNLESS (names) return NULL; =20 tmp =3D g_new0(char *, len + 1); =20 for (i =3D 0; i < len; i++) { - if (!names[i]) + VIR_UNLESS (names[i]) continue; =20 tmp[j] =3D g_strdup(names[i]); @@ -971,7 +971,7 @@ virshDomainFSMountpointsCompleter(vshControl *ctl, =20 virCheckFlags(0, NULL); =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return NULL; =20 rc =3D virDomainGetFSInfo(dom, &info, 0); diff --git a/tools/virsh-completer-host.c b/tools/virsh-completer-host.c index cbdc3f0d49..3b4da7fb78 100644 --- a/tools/virsh-completer-host.c +++ b/tools/virsh-completer-host.c @@ -71,10 +71,10 @@ virshAllocpagesPagesizeCompleter(vshControl *ctl, if (!priv->conn || virConnectIsAlive(priv->conn) <=3D 0) return NULL; =20 - if (!(cap_xml =3D virConnectGetCapabilities(priv->conn))) + VIR_UNLESS ((cap_xml =3D virConnectGetCapabilities(priv->conn))) return NULL; =20 - if (!(doc =3D virXMLParseStringCtxt(cap_xml, _("capabilities"), &ctxt)= )) + VIR_UNLESS ((doc =3D virXMLParseStringCtxt(cap_xml, _("capabilities"),= &ctxt))) return NULL; =20 if (cellno && vshCommandOptStringQuiet(ctl, cmd, "cellno", &cellnum) >= 0) { @@ -91,7 +91,7 @@ virshAllocpagesPagesizeCompleter(vshControl *ctl, tmp =3D g_new0(char *, npages + 1); =20 for (i =3D 0; i < npages; i++) { - if (!(tmp[i] =3D virshPagesizeNodeToString(pages[i]))) + VIR_UNLESS ((tmp[i] =3D virshPagesizeNodeToString(pages[i]))) return NULL; } =20 @@ -118,10 +118,10 @@ virshCellnoCompleter(vshControl *ctl, if (!priv->conn || virConnectIsAlive(priv->conn) <=3D 0) return NULL; =20 - if (!(cap_xml =3D virConnectGetCapabilities(priv->conn))) + VIR_UNLESS ((cap_xml =3D virConnectGetCapabilities(priv->conn))) return NULL; =20 - if (!(doc =3D virXMLParseStringCtxt(cap_xml, _("capabilities"), &ctxt)= )) + VIR_UNLESS ((doc =3D virXMLParseStringCtxt(cap_xml, _("capabilities"),= &ctxt))) return NULL; =20 ncells =3D virXPathNodeSet("/capabilities/host/topology/cells/cell", c= txt, &cells); @@ -131,7 +131,7 @@ virshCellnoCompleter(vshControl *ctl, tmp =3D g_new0(char *, ncells + 1); =20 for (i =3D 0; i < ncells; i++) { - if (!(tmp[i] =3D virXMLPropString(cells[i], "id"))) + VIR_UNLESS ((tmp[i] =3D virXMLPropString(cells[i], "id"))) return NULL; } =20 diff --git a/tools/virsh-completer-network.c b/tools/virsh-completer-networ= k.c index 839d71e961..6629e4422f 100644 --- a/tools/virsh-completer-network.c +++ b/tools/virsh-completer-network.c @@ -103,7 +103,7 @@ virshNetworkPortUUIDCompleter(vshControl *ctl, if (!priv->conn || virConnectIsAlive(priv->conn) <=3D 0) return NULL; =20 - if (!(net =3D virshCommandOptNetwork(ctl, cmd, NULL))) + VIR_UNLESS ((net =3D virshCommandOptNetwork(ctl, cmd, NULL))) return NULL; =20 if ((nports =3D virNetworkListAllPorts(net, &ports, flags)) < 0) @@ -195,7 +195,7 @@ virshNetworkDhcpMacCompleter(vshControl *ctl, if (!priv->conn || virConnectIsAlive(priv->conn) <=3D 0) return NULL; =20 - if (!(network =3D virshCommandOptNetwork(ctl, cmd, NULL))) + VIR_UNLESS ((network =3D virshCommandOptNetwork(ctl, cmd, NULL))) return NULL; =20 if ((nleases =3D virNetworkGetDHCPLeases(network, NULL, &leases, flags= )) < 0) diff --git a/tools/virsh-completer-snapshot.c b/tools/virsh-completer-snaps= hot.c index 535841cf2e..de6aad4530 100644 --- a/tools/virsh-completer-snapshot.c +++ b/tools/virsh-completer-snapshot.c @@ -45,7 +45,7 @@ virshSnapshotNameCompleter(vshControl *ctl, if (!priv->conn || virConnectIsAlive(priv->conn) <=3D 0) return NULL; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return NULL; =20 if ((rc =3D virDomainListAllSnapshots(dom, &snapshots, flags)) < 0) diff --git a/tools/virsh-completer-volume.c b/tools/virsh-completer-volume.c index a1ebadccac..276765c8e2 100644 --- a/tools/virsh-completer-volume.c +++ b/tools/virsh-completer-volume.c @@ -47,7 +47,7 @@ virshStorageVolNameCompleter(vshControl *ctl, if (!priv->conn || virConnectIsAlive(priv->conn) <=3D 0) return NULL; =20 - if (!(pool =3D virshCommandOptPool(ctl, cmd, "pool", NULL))) + VIR_UNLESS ((pool =3D virshCommandOptPool(ctl, cmd, "pool", NULL))) return NULL; =20 if ((rc =3D virStoragePoolListAllVolumes(pool, &vols, flags)) < 0) @@ -91,7 +91,7 @@ virshStorageVolKeyCompleter(vshControl *ctl, return NULL; =20 list =3D virshStoragePoolListCollect(ctl, VIR_CONNECT_LIST_STORAGE_POO= LS_ACTIVE); - if (!list) + VIR_UNLESS (list) goto cleanup; =20 for (i =3D 0; i < list->npools; i++) { diff --git a/tools/virsh-console.c b/tools/virsh-console.c index b8780c714d..66c447c762 100644 --- a/tools/virsh-console.c +++ b/tools/virsh-console.c @@ -82,7 +82,7 @@ static void virConsoleDispose(void *obj); static int virConsoleOnceInit(void) { - if (!VIR_CLASS_NEW(virConsole, virClassForObjectLockable())) + VIR_UNLESS (VIR_CLASS_NEW(virConsole, virClassForObjectLockable())) return -1; =20 return 0; @@ -129,7 +129,7 @@ virConsoleShutdown(virConsole *con, virEventRemoveHandle(con->stdoutWatch); con->stdinWatch =3D -1; con->stdoutWatch =3D -1; - if (!con->quit) { + VIR_UNLESS (con->quit) { con->quit =3D true; virCondSignal(&con->cond); } @@ -157,7 +157,7 @@ virConsoleEventOnStream(virStreamPtr st, virObjectLock(con); =20 /* we got late event after console was shutdown */ - if (!con->st) + VIR_UNLESS (con->st) goto cleanup; =20 if (events & VIR_STREAM_EVENT_READABLE) { @@ -213,7 +213,7 @@ virConsoleEventOnStream(virStreamPtr st, con->terminalToStream.length =3D con->terminalToStream.offset = + 1024; } } - if (!con->terminalToStream.offset) + VIR_UNLESS (con->terminalToStream.offset) virStreamEventUpdateCallback(con->st, VIR_STREAM_EVENT_READABLE); =20 @@ -238,7 +238,7 @@ virConsoleEventOnStdin(int watch G_GNUC_UNUSED, virObjectLock(con); =20 /* we got late event after console was shutdown */ - if (!con->st) + VIR_UNLESS (con->st) goto cleanup; =20 if (events & VIR_EVENT_HANDLE_READABLE) { @@ -309,7 +309,7 @@ virConsoleEventOnStdout(int watch G_GNUC_UNUSED, virObjectLock(con); =20 /* we got late event after console was shutdown */ - if (!con->st) + VIR_UNLESS (con->st) goto cleanup; =20 if (events & VIR_EVENT_HANDLE_WRITABLE && @@ -339,7 +339,7 @@ virConsoleEventOnStdout(int watch G_GNUC_UNUSED, } } =20 - if (!con->streamToTerminal.offset) + VIR_UNLESS (con->streamToTerminal.offset) virEventUpdateHandle(con->stdoutWatch, 0); =20 if (events & VIR_EVENT_HANDLE_ERROR) { @@ -367,7 +367,7 @@ virConsoleNew(void) if (virConsoleInitialize() < 0) return NULL; =20 - if (!(con =3D virObjectLockableNew(virConsoleClass))) + VIR_UNLESS ((con =3D virObjectLockableNew(virConsoleClass))) return NULL; =20 if (virCondInit(&con->cond) < 0) { @@ -424,7 +424,7 @@ virshRunConsole(vshControl *ctl, if (vshTTYMakeRaw(ctl, true) < 0) goto resettty; =20 - if (!(con =3D virConsoleNew())) + VIR_UNLESS ((con =3D virConsoleNew())) goto resettty; =20 virObjectLock(con); @@ -441,7 +441,7 @@ virshRunConsole(vshControl *ctl, con->escapeChar =3D virshGetEscapeChar(priv->escapeChar); con->st =3D virStreamNew(virDomainGetConnect(dom), VIR_STREAM_NONBLOCK); - if (!con->st) + VIR_UNLESS (con->st) goto cleanup; =20 if (virDomainOpenConsole(dom, dev_name, con->st, flags) < 0) diff --git a/tools/virsh-domain-event.c b/tools/virsh-domain-event.c index 1a2f1cb6e0..3403f48483 100644 --- a/tools/virsh-domain-event.c +++ b/tools/virsh-domain-event.c @@ -299,7 +299,7 @@ virshEventPrint(virshDomEventData *data, { g_autofree char *msg =3D NULL; =20 - if (!(msg =3D virBufferContentAndReset(buf))) + VIR_UNLESS ((msg =3D virBufferContentAndReset(buf))) return; =20 if (!data->loop && *data->count) @@ -317,7 +317,7 @@ virshEventPrint(virshDomEventData *data, } =20 (*data->count)++; - if (!data->loop) + VIR_UNLESS (data->loop) vshEventDone(data->ctl); } =20 @@ -944,7 +944,7 @@ cmdEvent(vshControl *ctl, const vshCmd *cmd) goto cleanup; =20 if (vshCommandOptBool(cmd, "domain")) { - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) goto cleanup; } =20 diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index 246e8a16c0..e66383af05 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -88,7 +88,7 @@ virshGetDomainDescription(vshControl *ctl, virDomainPtr d= om, bool title, else desc =3D virXPathString("string(./description[1])", ctxt); =20 - if (!desc) + VIR_UNLESS (desc) desc =3D g_strdup(""); =20 return desc; @@ -311,7 +311,7 @@ cmdDomMemStat(vshControl *ctl, const vshCmd *cmd) if (live) flags |=3D VIR_DOMAIN_AFFECT_LIVE; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, &name))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, &name))) return false; =20 /* If none of the options were specified and we're active @@ -456,7 +456,7 @@ cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd) =20 VSH_EXCLUSIVE_OPTIONS("all", "device"); =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 all =3D vshCommandOptBool(cmd, "all"); @@ -480,7 +480,7 @@ cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd) =20 /* title */ table =3D vshTableNew(_("Target"), _("Capacity"), _("Allocation"),= _("Physical"), NULL); - if (!table) + VIR_UNLESS (table) return false; =20 for (i =3D 0; i < ndisks; i++) { @@ -517,7 +517,7 @@ cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd) memset(&info, 0, sizeof(info)); } =20 - if (!cmdDomblkinfoGet(&info, &cap, &alloc, &phy, human)) + VIR_UNLESS (cmdDomblkinfoGet(&info, &cap, &alloc, &phy, human)) return false; if (vshTableRowAppend(table, target, cap, alloc, phy, NULL) < = 0) return false; @@ -533,7 +533,7 @@ cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd) if (virDomainGetBlockInfo(dom, device, &info, 0) < 0) return false; =20 - if (!cmdDomblkinfoGet(&info, &cap, &alloc, &phy, human)) + VIR_UNLESS (cmdDomblkinfoGet(&info, &cap, &alloc, &phy, human)) return false; vshPrint(ctl, "%-15s %s\n", _("Capacity:"), cap); vshPrint(ctl, "%-15s %s\n", _("Allocation:"), alloc); @@ -598,7 +598,7 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd) else table =3D vshTableNew(_("Target"), _("Source"), NULL); =20 - if (!table) + VIR_UNLESS (table) return false; =20 for (i =3D 0; i < ndisks; i++) { @@ -619,7 +619,7 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd) } =20 target =3D virXPathString("string(./target/@dev)", ctxt); - if (!target) { + VIR_UNLESS (target) { vshError(ctl, "unable to query block list"); return false; } @@ -705,7 +705,7 @@ cmdDomiflist(vshControl *ctl, const vshCmd *cmd) =20 table =3D vshTableNew(_("Interface"), _("Type"), _("Source"), _("Model"), _("MAC"), NULL); - if (!table) + VIR_UNLESS (table) return false; =20 for (i =3D 0; i < ninterfaces; i++) { @@ -854,7 +854,7 @@ cmdDomControl(vshControl *ctl, const vshCmd *cmd) g_autoptr(virshDomain) dom =3D NULL; virDomainControlInfo info; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (virDomainGetControlInfo(dom, &info, 0) < 0) @@ -957,7 +957,7 @@ cmdDomblkstat(vshControl *ctl, const vshCmd *cmd) size_t i; bool human =3D vshCommandOptBool(cmd, "human"); /* human readable outp= ut */ =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, &name))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, &name))) return false; =20 /* device argument is optional now. if it's missing, supply empty @@ -967,7 +967,7 @@ cmdDomblkstat(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptStringReq(ctl, cmd, "device", &device) < 0) return false; =20 - if (!device) + VIR_UNLESS (device) device =3D ""; =20 rc =3D virDomainBlockStatsFlags(dom, device, NULL, &nparams, 0); @@ -1018,7 +1018,7 @@ cmdDomblkstat(vshControl *ctl, const vshCmd *cmd) for (i =3D 0; domblkstat_output[i].field !=3D NULL; i++) { g_autofree char *value =3D NULL; =20 - if (!(par =3D virTypedParamsGet(params, nparams, + VIR_UNLESS ((par =3D virTypedParamsGet(params, nparams, domblkstat_output[i].field))) continue; =20 @@ -1035,7 +1035,7 @@ cmdDomblkstat(vshControl *ctl, const vshCmd *cmd) field =3D domblkstat_output[i].legacy; =20 /* use the provided spelling if no translation is available */ - if (!field) + VIR_UNLESS (field) field =3D domblkstat_output[i].field; =20 vshPrint(ctl, "%s %-*s %s\n", device, @@ -1046,7 +1046,7 @@ cmdDomblkstat(vshControl *ctl, const vshCmd *cmd) for (i =3D 0; i < nparams; i++) { g_autofree char *value =3D NULL; =20 - if (!*params[i].field) + VIR_UNLESS (*params[i].field) continue; =20 value =3D vshGetTypedParamValue(ctl, params+i); @@ -1089,7 +1089,7 @@ cmdDomIfstat(vshControl *ctl, const vshCmd *cmd) const char *name =3D NULL, *device =3D NULL; virDomainInterfaceStatsStruct stats; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, &name))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, &name))) return false; =20 if (vshCommandOptStringReq(ctl, cmd, "interface", &device) < 0) @@ -1155,7 +1155,7 @@ cmdDomBlkError(vshControl *ctl, const vshCmd *cmd) int count; bool ret =3D false; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if ((count =3D virDomainGetDiskErrors(dom, NULL, 0, 0)) < 0) @@ -1223,7 +1223,7 @@ cmdDominfo(vshControl *ctl, const vshCmd *cmd) virshControl *priv =3D ctl->privData; g_auto(GStrv) messages =3D NULL; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 id =3D virDomainGetID(dom); @@ -1277,7 +1277,7 @@ cmdDominfo(vshControl *ctl, const vshCmd *cmd) vshPrint(ctl, "%-15s %s\n", _("Persistent:"), persistent ? _("yes"= ) : _("no")); =20 /* Check and display whether the domain autostarts or not */ - if (!virDomainGetAutostart(dom, &autostart)) { + VIR_UNLESS (virDomainGetAutostart(dom, &autostart)) { vshPrint(ctl, "%-15s %s\n", _("Autostart:"), autostart ? _("enable") : _("disable")); } @@ -1359,7 +1359,7 @@ cmdDomstate(vshControl *ctl, const vshCmd *cmd) bool showReason =3D vshCommandOptBool(cmd, "reason"); int state, reason; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if ((state =3D virshDomainState(ctl, dom, &reason)) < 0) @@ -1428,7 +1428,7 @@ cmdDomTime(vshControl *ctl, const vshCmd *cmd) VSH_EXCLUSIVE_OPTIONS("time", "sync"); VSH_EXCLUSIVE_OPTIONS("now", "sync"); =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 rv =3D vshCommandOptLongLong(ctl, cmd, "time", &seconds); @@ -1499,7 +1499,7 @@ virshDomainSorter(const void *a, const void *b) if (*da && !*db) return -1; =20 - if (!*da) + VIR_UNLESS (*da) return *db !=3D NULL; =20 ida =3D virDomainGetID(*da); @@ -1636,14 +1636,14 @@ virshDomainListCollect(vshControl *ctl, unsigned in= t flags) =20 /* get active domains */ for (i =3D 0; i < nids; i++) { - if (!(dom =3D virDomainLookupByID(priv->conn, ids[i]))) + VIR_UNLESS ((dom =3D virDomainLookupByID(priv->conn, ids[i]))) continue; list->domains[list->ndomains++] =3D dom; } =20 /* get inactive domains */ for (i =3D 0; i < nnames; i++) { - if (!(dom =3D virDomainLookupByName(priv->conn, names[i]))) + VIR_UNLESS ((dom =3D virDomainLookupByName(priv->conn, names[i]))) continue; list->domains[list->ndomains++] =3D dom; } @@ -1760,7 +1760,7 @@ virshDomainListCollect(vshControl *ctl, unsigned int = flags) for (i =3D 0; nnames !=3D -1 && i < nnames; i++) VIR_FREE(names[i]); =20 - if (!success) { + VIR_UNLESS (success) { g_clear_pointer(&list, virshDomainListFree); } =20 @@ -1920,7 +1920,7 @@ cmdList(vshControl *ctl, const vshCmd *cmd) if (!optUUID && !optName && !optID) optTable =3D true; =20 - if (!(list =3D virshDomainListCollect(ctl, flags))) + VIR_UNLESS ((list =3D virshDomainListCollect(ctl, flags))) goto cleanup; =20 /* print table header in legacy mode */ @@ -1930,7 +1930,7 @@ cmdList(vshControl *ctl, const vshCmd *cmd) else table =3D vshTableNew(_("Id"), _("Name"), _("State"), NULL); =20 - if (!table) + VIR_UNLESS (table) goto cleanup; } =20 @@ -1958,7 +1958,7 @@ cmdList(vshControl *ctl, const vshCmd *cmd) if (optTitle) { g_autofree char *title =3D NULL; =20 - if (!(title =3D virshGetDomainDescription(ctl, dom, true, = 0))) + VIR_UNLESS ((title =3D virshGetDomainDescription(ctl, dom,= true, 0))) goto cleanup; if (vshTableRowAppend(table, id_buf, virDomainGetName(dom), @@ -2131,7 +2131,7 @@ virshDomainStatsPrintRecord(vshControl *ctl G_GNUC_UN= USED, for (i =3D 0; i < record->nparams; i++) { g_autofree char *param =3D NULL; =20 - if (!(param =3D vshGetTypedParamValue(ctl, record->params + i))) + VIR_UNLESS ((param =3D vshGetTypedParamValue(ctl, record->params += i))) return false; =20 vshPrint(ctl, " %s=3D%s\n", record->params[i].field, param); @@ -2223,7 +2223,7 @@ cmdDomstats(vshControl *ctl, const vshCmd *cmd) ndoms =3D 1; =20 while ((opt =3D vshCommandOptArgv(ctl, cmd, opt))) { - if (!(dom =3D virshLookupDomainBy(ctl, opt->data, + VIR_UNLESS ((dom =3D virshLookupDomainBy(ctl, opt->data, VIRSH_BYID | VIRSH_BYUUID | VIRSH_BYNAME))) goto cleanup; @@ -2247,7 +2247,7 @@ cmdDomstats(vshControl *ctl, const vshCmd *cmd) =20 next =3D records; while (*next) { - if (!virshDomainStatsPrintRecord(ctl, *next, raw)) + VIR_UNLESS (virshDomainStatsPrintRecord(ctl, *next, raw)) goto cleanup; =20 if (*(++next)) @@ -2319,7 +2319,7 @@ cmdDomIfAddr(vshControl *ctl, const vshCmd *cmd) return false; } =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if ((ifaces_count =3D virDomainInterfaceAddresses(dom, &ifaces, source= , 0)) < 0) { @@ -2340,7 +2340,7 @@ cmdDomIfAddr(vshControl *ctl, const vshCmd *cmd) continue; =20 /* When the interface has no IP address */ - if (!iface->naddrs) { + VIR_UNLESS (iface->naddrs) { vshPrint(ctl, " %-10s %-17s %-12s %s\n", iface->name, iface->hwaddr ? iface->hwaddr : "N/A", "N/A", "N/A"); @@ -2366,7 +2366,7 @@ cmdDomIfAddr(vshControl *ctl, const vshCmd *cmd) =20 ip_addr_str =3D virBufferContentAndReset(&buf); =20 - if (!ip_addr_str) + VIR_UNLESS (ip_addr_str) ip_addr_str =3D g_strdup(""); =20 /* Don't repeat interface name */ diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index d5fd8be7c3..bbebd8fd72 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -125,7 +125,7 @@ virshAddressParse(const char *str, g_autofree char *type =3D g_strdup(str); char *a =3D strchr(type, ':'); =20 - if (!a) + VIR_UNLESS (a) return -1; =20 *a =3D '\0'; @@ -248,7 +248,7 @@ virshFetchPassFdsList(vshControl *ctl, if (vshCommandOptStringQuiet(ctl, cmd, "pass-fds", &fdopt) <=3D 0) return 0; =20 - if (!(fdlist =3D g_strsplit(fdopt, ",", -1))) { + VIR_UNLESS ((fdlist =3D g_strsplit(fdopt, ",", -1))) { vshError(ctl, _("Unable to split FD list '%s'"), fdopt); return -1; } @@ -290,14 +290,14 @@ virshDomainDefine(virConnectPtr conn, const char *xml= , unsigned int flags) { virDomainPtr dom; =20 - if (!flags) + VIR_UNLESS (flags) return virDomainDefineXML(conn, xml); =20 dom =3D virDomainDefineXMLFlags(conn, xml, flags); /* If validate is the only flag, just drop it and * try again. */ - if (!dom) { + VIR_UNLESS (dom) { if ((virGetLastErrorCode() =3D=3D VIR_ERR_NO_SUPPORT) && (flags =3D=3D VIR_DOMAIN_DEFINE_VALIDATE)) dom =3D virDomainDefineXML(conn, xml); @@ -385,7 +385,7 @@ cmdAttachDevice(vshControl *ctl, const vshCmd *cmd) if (live) flags |=3D VIR_DOMAIN_AFFECT_LIVE; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) @@ -791,7 +791,7 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd) return true; } =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (persistent && @@ -918,7 +918,7 @@ virshParseRateStr(vshControl *ctl, g_auto(GStrv) tok =3D NULL; size_t ntok; =20 - if (!(tok =3D g_strsplit(rateStr, ",", 0))) + VIR_UNLESS ((tok =3D g_strsplit(rateStr, ",", 0))) return -1; =20 if ((ntok =3D g_strv_length(tok)) > 4) { @@ -1126,7 +1126,7 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd) return true; } =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (persistent && @@ -1177,7 +1177,7 @@ cmdAutostart(vshControl *ctl, const vshCmd *cmd) const char *name; int autostart; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, &name))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, &name))) return false; =20 autostart =3D !vshCommandOptBool(cmd, "disable"); @@ -1412,7 +1412,7 @@ cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd) if (live) flags |=3D VIR_DOMAIN_AFFECT_LIVE; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, &name))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, &name))) goto cleanup; =20 if (vshCommandOptStringReq(ctl, cmd, "device", &disk) < 0) @@ -1604,7 +1604,7 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd) if (live) flags |=3D VIR_DOMAIN_AFFECT_LIVE; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if ((rv =3D vshCommandOptInt(ctl, cmd, "weight", &weight)) < 0) { @@ -1853,7 +1853,7 @@ virshBlockJobWaitFree(virshBlockJobWaitData *data) { virshControl *priv =3D NULL; =20 - if (!data) + VIR_UNLESS (data) return; =20 priv =3D data->ctl->privData; @@ -1903,7 +1903,7 @@ virshBlockJobWait(virshBlockJobWaitData *data) virDomainBlockJobInfo info, last; int result; =20 - if (!data) + VIR_UNLESS (data) return 0; =20 if (data->async_abort) @@ -2144,7 +2144,7 @@ cmdBlockcommit(vshControl *ctl, const vshCmd *cmd) if (timeout) blocking =3D true; =20 - if (!blocking) { + VIR_UNLESS (blocking) { if (verbose) { vshError(ctl, "%s", _("--verbose requires at least one of --ti= meout, " "--wait, --pivot, or --keep-overlay")); @@ -2161,7 +2161,7 @@ cmdBlockcommit(vshControl *ctl, const vshCmd *cmd) if (async) abort_flags |=3D VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (blocking && @@ -2172,7 +2172,7 @@ cmdBlockcommit(vshControl *ctl, const vshCmd *cmd) if (virDomainBlockCommit(dom, path, base, top, bandwidth, flags) < 0) goto cleanup; =20 - if (!blocking) { + VIR_UNLESS (blocking) { if (active) vshPrintExtra(ctl, "%s", _("Active Block Commit started")); else @@ -2402,12 +2402,12 @@ cmdBlockcopy(vshControl *ctl, const vshCmd *cmd) VSH_EXCLUSIVE_OPTIONS_VAR(blockdev, xml); VSH_EXCLUSIVE_OPTIONS_VAR(pivot, finish); =20 - if (!dest && !xml) { + VIR_UNLESS (dest && !xml) { vshError(ctl, "%s", _("need either --dest or --xml")); return false; } =20 - if (!blocking) { + VIR_UNLESS (blocking) { if (verbose) { vshError(ctl, "%s", _("--verbose requires at least one of --ti= meout, " "--wait, --pivot, or --finish")); @@ -2421,7 +2421,7 @@ cmdBlockcopy(vshControl *ctl, const vshCmd *cmd) } } =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) goto cleanup; =20 if (blocking && @@ -2442,7 +2442,7 @@ cmdBlockcopy(vshControl *ctl, const vshCmd *cmd) if (bandwidth || granularity || buf_size) { params =3D g_new0(virTypedParameter, 3); if (bandwidth) { - if (!bytes) { + VIR_UNLESS (bytes) { /* bandwidth is ulong MiB/s, but the typed parameter is * ullong bytes/s; make sure we don't overflow */ unsigned long long limit =3D MIN(ULONG_MAX, ULLONG_MAX= >> 20); @@ -2473,7 +2473,7 @@ cmdBlockcopy(vshControl *ctl, const vshCmd *cmd) goto cleanup; } =20 - if (!xmlstr) { + VIR_UNLESS (xmlstr) { g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; g_auto(virBuffer) attrBuf =3D VIR_BUFFER_INITIALIZER; g_auto(virBuffer) childBuf =3D VIR_BUFFER_INITIALIZER; @@ -2508,7 +2508,7 @@ cmdBlockcopy(vshControl *ctl, const vshCmd *cmd) goto cleanup; } =20 - if (!blocking) { + VIR_UNLESS (blocking) { vshPrintExtra(ctl, "%s", _("Block Copy started")); ret =3D true; goto cleanup; @@ -2658,7 +2658,7 @@ virshBlockJobInfo(vshControl *ctl, return false; speed =3D info.bandwidth; /* Scale to bytes/s unless in raw mode */ - if (!raw) { + VIR_UNLESS (raw) { speed <<=3D 20; if (speed >> 20 !=3D info.bandwidth) { vshError(ctl, _("overflow in converting %ld MiB/s to bytes= \n"), @@ -2669,7 +2669,7 @@ virshBlockJobInfo(vshControl *ctl, } =20 if (rc =3D=3D 0) { - if (!raw) + VIR_UNLESS (raw) vshPrintExtra(ctl, _("No current block job for %s"), path); return true; } @@ -2764,7 +2764,7 @@ cmdBlockjob(vshControl *ctl, const vshCmd *cmd) VSH_EXCLUSIVE_OPTIONS_VAR(bytes, pivot); VSH_EXCLUSIVE_OPTIONS_VAR(bytes, async); =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 /* XXX Allow path to be optional to list info on all devices at once */ @@ -2869,7 +2869,7 @@ cmdBlockpull(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "keep-relative")) flags |=3D VIR_DOMAIN_BLOCK_REBASE_RELATIVE; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (blocking && @@ -2891,7 +2891,7 @@ cmdBlockpull(vshControl *ctl, const vshCmd *cmd) goto cleanup; } =20 - if (!blocking) { + VIR_UNLESS (blocking) { vshPrintExtra(ctl, "%s", _("Block Pull started")); ret =3D true; goto cleanup; @@ -2974,7 +2974,7 @@ cmdBlockresize(vshControl *ctl, const vshCmd *cmd) else flags |=3D VIR_DOMAIN_BLOCK_RESIZE_BYTES; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (virDomainBlockResize(dom, path, size, flags) < 0) { @@ -3036,7 +3036,7 @@ cmdRunConsole(vshControl *ctl, virDomainPtr dom, return false; } =20 - if (!isatty(STDIN_FILENO)) { + VIR_UNLESS (isatty(STDIN_FILENO)) { vshError(ctl, "%s", _("Cannot run interactive console without a co= ntrolling TTY")); return false; } @@ -3062,7 +3062,7 @@ cmdConsole(vshControl *ctl, const vshCmd *cmd) unsigned int flags =3D 0; const char *name =3D NULL; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (vshCommandOptStringReq(ctl, cmd, "devname", &name) < 0) /* sc_proh= ibit_devname */ @@ -3131,7 +3131,7 @@ cmdDomIfSetLink(vshControl *ctl, const vshCmd *cmd) xmlNodePtr cur =3D NULL; g_autofree char *xml_buf =3D NULL; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (vshCommandOptStringReq(ctl, cmd, "interface", &iface) < 0 || @@ -3208,20 +3208,20 @@ cmdDomIfSetLink(vshControl *ctl, const vshCmd *cmd) cur =3D cur->next; } =20 - if (!cur) { + VIR_UNLESS (cur) { /* element not found, add one */ cur =3D xmlNewChild(obj->nodesetval->nodeTab[i], NULL, BAD_CAST "link", NULL); - if (!cur) + VIR_UNLESS (cur) return false; =20 if (xmlNewProp(cur, BAD_CAST "state", BAD_CAST state) =3D=3D NULL) return false; } =20 - if (!(xml_buf =3D virXMLNodeToString(xml, obj->nodesetval->nodeTab[i])= )) { + VIR_UNLESS ((xml_buf =3D virXMLNodeToString(xml, obj->nodesetval->node= Tab[i]))) { vshSaveLibvirtError(); vshError(ctl, _("Failed to create XML")); return false; @@ -3298,7 +3298,7 @@ cmdDomIftune(vshControl *ctl, const vshCmd *cmd) if (live) flags |=3D VIR_DOMAIN_AFFECT_LIVE; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, &name))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, &name))) return false; =20 if (vshCommandOptStringReq(ctl, cmd, "interface", &device) < 0) @@ -3458,7 +3458,7 @@ cmdSuspend(vshControl *ctl, const vshCmd *cmd) g_autoptr(virshDomain) dom =3D NULL; const char *name; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, &name))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, &name))) return false; =20 if (virDomainSuspend(dom) !=3D 0) { @@ -3513,7 +3513,7 @@ cmdDomPMSuspend(vshControl *ctl, const vshCmd *cmd) int suspendTarget; unsigned long long duration =3D 0; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, &name))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, &name))) return false; =20 if (vshCommandOptULongLong(ctl, cmd, "duration", &duration) < 0) @@ -3566,7 +3566,7 @@ cmdDomPMWakeup(vshControl *ctl, const vshCmd *cmd) const char *name; unsigned int flags =3D 0; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, &name))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, &name))) return false; =20 if (virDomainPMWakeup(dom, flags) < 0) { @@ -3719,7 +3719,7 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd) if (keep_nvram) flags |=3D VIR_DOMAIN_UNDEFINE_KEEP_NVRAM; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, &name))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, &name))) return false; =20 /* Do some flag manipulation. The goal here is to disable bits @@ -3729,7 +3729,7 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd) if ((running =3D virDomainIsActive(dom)) < 0) goto error; =20 - if (!running) { + VIR_UNLESS (running) { /* Undefine with snapshots only fails for inactive domains, * and managed save only exists on inactive domains; if * running, then we don't want to remove anything. */ @@ -3763,7 +3763,7 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd) } } } - if (!has_managed_save) { + VIR_UNLESS (has_managed_save) { flags &=3D ~VIR_DOMAIN_UNDEFINE_MANAGED_SAVE; managed_save_safe =3D true; } @@ -3810,7 +3810,7 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd) ctxt->node =3D vol_nodes[i]; =20 /* get volume source and target paths */ - if (!(target =3D virXPathString("string(./target/@dev)", ctxt)= )) + VIR_UNLESS ((target =3D virXPathString("string(./target/@dev)"= , ctxt))) goto error; =20 if (!(source =3D virXPathString("string(" @@ -3834,21 +3834,21 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd) break; } } - if (!found) + VIR_UNLESS (found) continue; } =20 if (pool) { g_autoptr(virshStoragePool) storagepool =3D NULL; =20 - if (!source) { + VIR_UNLESS (source) { vshError(ctl, _("Missing storage volume name for disk '%s'"= ), target); continue; } =20 - if (!(storagepool =3D virStoragePoolLookupByName(priv->con= n, + VIR_UNLESS ((storagepool =3D virStoragePoolLookupByName(pr= iv->conn, pool))) { vshError(ctl, _("Storage pool '%s' for volume '%s' not foun= d."), @@ -3863,7 +3863,7 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd) vol.vol =3D virStorageVolLookupByPath(priv->conn, source); } =20 - if (!vol.vol) { + VIR_UNLESS (vol.vol) { vshError(ctl, _("Storage volume '%s'(%s) is not managed by libv= irt. " "Remove it manually.\n"), target, source); @@ -3914,7 +3914,7 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd) /* The new API is unsupported or unsafe; fall back to doing things * piecewise. */ if (has_managed_save) { - if (!managed_save) { + VIR_UNLESS (managed_save) { vshError(ctl, "%s", _("Refusing to undefine while domain managed save " "image exists")); @@ -4062,7 +4062,7 @@ cmdStart(vshControl *ctl, const vshCmd *cmd) size_t nfds =3D 0; g_autofree int *fds =3D NULL; =20 - if (!(dom =3D virshCommandOptDomainBy(ctl, cmd, NULL, + VIR_UNLESS ((dom =3D virshCommandOptDomainBy(ctl, cmd, NULL, VIRSH_BYNAME | VIRSH_BYUUID))) return false; =20 @@ -4219,7 +4219,7 @@ doSave(void *opaque) if (vshCommandOptStringReq(ctl, cmd, "xml", &xmlfile) < 0) goto out; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, &name))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, &name))) goto out; =20 if (xmlfile && @@ -4309,7 +4309,7 @@ virshWatchProgress(gpointer opaque) vshTTYDisableInterrupt(data->ctl); data->jobStarted =3D true; =20 - if (!data->verbose) { + VIR_UNLESS (data->verbose) { vshDebug(data->ctl, VSH_ERR_DEBUG, "watchJob: job started, disabling callback\n"); return G_SOURCE_REMOVE; @@ -4469,7 +4469,7 @@ cmdSave(vshControl *ctl, const vshCmd *cmd) .ret =3D -1, }; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, &name))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, &name))) return false; =20 if (vshCommandOptStringReq(ctl, cmd, "file", &to) < 0) @@ -4489,7 +4489,7 @@ cmdSave(vshControl *ctl, const vshCmd *cmd) =20 virThreadJoin(&workerThread); =20 - if (!data.ret) + VIR_UNLESS (data.ret) vshPrintExtra(ctl, _("\nDomain '%s' saved to %s\n"), name, to); =20 return !data.ret; @@ -4536,7 +4536,7 @@ cmdSaveImageDumpxml(vshControl *ctl, const vshCmd *cm= d) return false; =20 xml =3D virDomainSaveImageGetXMLDesc(priv->conn, file, flags); - if (!xml) + VIR_UNLESS (xml) return false; =20 vshPrint(ctl, "%s", xml); @@ -4746,7 +4746,7 @@ doManagedsave(void *opaque) if (vshCommandOptBool(cmd, "paused")) flags |=3D VIR_DOMAIN_SAVE_PAUSED; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, &name))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, &name))) goto out; =20 if (virDomainManagedSave(dom, flags) < 0) { @@ -4779,7 +4779,7 @@ cmdManagedSave(vshControl *ctl, const vshCmd *cmd) .ret =3D -1, }; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, &name))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, &name))) return false; =20 if (vshCommandOptBool(cmd, "verbose")) @@ -4796,7 +4796,7 @@ cmdManagedSave(vshControl *ctl, const vshCmd *cmd) =20 virThreadJoin(&workerThread); =20 - if (!data.ret) + VIR_UNLESS (data.ret) vshPrintExtra(ctl, _("\nDomain '%s' state saved by libvirt\n"), na= me); =20 return !data.ret; @@ -4827,7 +4827,7 @@ cmdManagedSaveRemove(vshControl *ctl, const vshCmd *c= md) const char *name; int hassave; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, &name))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, &name))) return false; =20 hassave =3D virDomainHasManagedSaveImage(dom, 0); @@ -4950,10 +4950,10 @@ cmdManagedSaveDumpxml(vshControl *ctl, const vshCmd= *cmd) if (vshCommandOptBool(cmd, "security-info")) flags |=3D VIR_DOMAIN_XML_SECURE; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 - if (!(xml =3D virDomainManagedSaveGetXMLDesc(dom, flags))) + VIR_UNLESS ((xml =3D virDomainManagedSaveGetXMLDesc(dom, flags))) return false; =20 vshPrint(ctl, "%s", xml); @@ -5013,7 +5013,7 @@ cmdManagedSaveDefine(vshControl *ctl, const vshCmd *c= md) if (virFileReadAll(xmlfile, VSH_MAX_XML_FILE, &xml) < 0) return false; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (virDomainManagedSaveDefineXML(dom, xml, flags) < 0) { @@ -5109,7 +5109,7 @@ cmdSchedInfoUpdate(vshControl *ctl, const vshCmd *cmd, while ((opt =3D vshCommandOptArgv(ctl, cmd, opt))) { g_autofree char *set_field =3D g_strdup(opt->data); =20 - if (!(set_val =3D strchr(set_field, '=3D'))) { + VIR_UNLESS ((set_val =3D strchr(set_field, '=3D'))) { vshError(ctl, "%s", _("Invalid syntax for --set, " "expecting name=3Dvalue")); goto cleanup; @@ -5181,18 +5181,18 @@ cmdSchedinfo(vshControl *ctl, const vshCmd *cmd) else queryflags =3D flags; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 /* Print SchedulerType */ - if (!(schedulertype =3D virDomainGetSchedulerType(dom, &nparams))) { + VIR_UNLESS ((schedulertype =3D virDomainGetSchedulerType(dom, &nparams= ))) { vshPrint(ctl, "%-15s: %s\n", _("Scheduler"), _("Unknown")); goto cleanup; } =20 vshPrint(ctl, "%-15s: %s\n", _("Scheduler"), schedulertype); =20 - if (!nparams) + VIR_UNLESS (nparams) goto cleanup; =20 params =3D g_new0(virTypedParameter, nparams); @@ -5417,7 +5417,7 @@ doDump(void *opaque) if (vshCommandOptStringReq(ctl, cmd, "file", &to) < 0) goto out; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, &name))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, &name))) goto out; =20 if (vshCommandOptBool(cmd, "live")) @@ -5432,7 +5432,7 @@ doDump(void *opaque) flags |=3D VIR_DUMP_MEMORY_ONLY; =20 if (vshCommandOptBool(cmd, "format")) { - if (!(flags & VIR_DUMP_MEMORY_ONLY)) { + VIR_UNLESS ((flags & VIR_DUMP_MEMORY_ONLY)) { vshError(ctl, "%s", _("--format only works with --memory-only"= )); goto out; } @@ -5485,7 +5485,7 @@ cmdDump(vshControl *ctl, const vshCmd *cmd) .ret =3D -1, }; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, &name))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, &name))) return false; =20 if (vshCommandOptStringReq(ctl, cmd, "file", &to) < 0) @@ -5548,7 +5548,7 @@ virshGenFileName(vshControl *ctl, virDomainPtr dom, c= onst char *mime) g_autofree char *nowstr =3D NULL; const char *ext =3D NULL; =20 - if (!dom) { + VIR_UNLESS (dom) { vshError(ctl, "%s", _("Invalid domain supplied")); return NULL; } @@ -5588,20 +5588,20 @@ cmdScreenshot(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptUInt(ctl, cmd, "screen", &screen) < 0) return false; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, &name))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, &name))) return false; =20 - if (!(st =3D virStreamNew(priv->conn, 0))) + VIR_UNLESS ((st =3D virStreamNew(priv->conn, 0))) goto cleanup; =20 mime =3D virDomainScreenshot(dom, st, screen, flags); - if (!mime) { + VIR_UNLESS (mime) { vshError(ctl, _("could not take a screenshot of %s"), name); goto cleanup; } =20 - if (!file) { - if (!(file =3D virshGenFileName(ctl, dom, mime))) + VIR_UNLESS (file) { + VIR_UNLESS ((file =3D virshGenFileName(ctl, dom, mime))) goto cleanup; generated =3D true; } @@ -5733,7 +5733,7 @@ cmdSetLifecycleAction(vshControl *ctl, const vshCmd *= cmd) } action =3D tmpVal; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (virDomainSetLifecycleAction(dom, type, action, flags) < 0) { @@ -5794,7 +5794,7 @@ cmdSetUserPassword(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptStringReq(ctl, cmd, "password", &password) < 0) return false; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, &name))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, &name))) return false; =20 if (virDomainSetUserPassword(dom, user, password, flags) < 0) @@ -5827,7 +5827,7 @@ cmdResume(vshControl *ctl, const vshCmd *cmd) g_autoptr(virshDomain) dom =3D NULL; const char *name; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, &name))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, &name))) return false; =20 if (virDomainResume(dom) !=3D 0) { @@ -5903,7 +5903,7 @@ cmdShutdown(vshControl *ctl, const vshCmd *cmd) tmp++; } =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, &name))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, &name))) return false; =20 if (flags) @@ -5983,7 +5983,7 @@ cmdReboot(vshControl *ctl, const vshCmd *cmd) tmp++; } =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, &name))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, &name))) return false; =20 if (virDomainReboot(dom, flags) !=3D 0) { @@ -6019,7 +6019,7 @@ cmdReset(vshControl *ctl, const vshCmd *cmd) g_autoptr(virshDomain) dom =3D NULL; const char *name; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, &name))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, &name))) return false; =20 if (virDomainReset(dom, 0) !=3D 0) { @@ -6161,7 +6161,7 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd) =20 VSH_REQUIRE_OPTION("keep-completed", "completed"); =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (vshCommandOptBool(cmd, "completed")) @@ -6475,7 +6475,7 @@ cmdDomjobabort(vshControl *ctl, const vshCmd *cmd) { g_autoptr(virshDomain) dom =3D NULL; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (virDomainAbortJob(dom) < 0) @@ -6631,7 +6631,7 @@ cmdVcpucount(vshControl *ctl, const vshCmd *cmd) if (guest) flags |=3D VIR_DOMAIN_VCPU_GUEST; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (all) { @@ -6703,7 +6703,7 @@ virshVcpuinfoPrintAffinity(vshControl *ctl, =20 vshPrint(ctl, "%-15s ", _("CPU Affinity:")); if (pretty) { - if (!(str =3D virBitmapDataFormat(cpumap, VIR_CPU_MAPLEN(maxcpu)))) + VIR_UNLESS ((str =3D virBitmapDataFormat(cpumap, VIR_CPU_MAPLEN(ma= xcpu)))) return -1; vshPrint(ctl, _("%s (out of %d)"), str, maxcpu); } else { @@ -6796,7 +6796,7 @@ virshVcpuinfoInactive(vshControl *ctl, ssize_t nextvcpu =3D -1; bool first =3D true; =20 - if (!(vcpus =3D virshDomainGetVcpuBitmap(ctl, dom, true))) + VIR_UNLESS ((vcpus =3D virshDomainGetVcpuBitmap(ctl, dom, true))) return false; =20 cpumaplen =3D VIR_CPU_MAPLEN(maxcpu); @@ -6808,7 +6808,7 @@ virshVcpuinfoInactive(vshControl *ctl, return false; =20 while ((nextvcpu =3D virBitmapNextSetBit(vcpus, nextvcpu)) >=3D 0) { - if (!first) + VIR_UNLESS (first) vshPrint(ctl, "\n"); first =3D false; =20 @@ -6840,7 +6840,7 @@ cmdVcpuinfo(vshControl *ctl, const vshCmd *cmd) int n; virshControl *priv =3D ctl->privData; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if ((maxcpu =3D virshNodeGetCPUCount(priv->conn)) < 0) @@ -6931,7 +6931,7 @@ virshPrintPinInfo(vshControl *ctl, { g_autofree char *str =3D NULL; =20 - if (!(str =3D virBitmapDataFormat(cpumap, cpumaplen))) + VIR_UNLESS ((str =3D virBitmapDataFormat(cpumap, cpumaplen))) return false; =20 vshPrint(ctl, "%s", str); @@ -6983,7 +6983,7 @@ virshVcpuPinQuery(vshControl *ctl, if ((ncpus =3D virDomainGetVcpuPinInfo(dom, ncpus, cpumap, cpumaplen, flags)) >=3D 0) { table =3D vshTableNew(_("VCPU"), _("CPU Affinity"), NULL); - if (!table) + VIR_UNLESS (table) return false; =20 for (i =3D 0; i < ncpus; i++) { @@ -6992,7 +6992,7 @@ virshVcpuPinQuery(vshControl *ctl, if (got_vcpu && i !=3D vcpu) continue; =20 - if (!(pinInfo =3D virBitmapDataFormat(VIR_GET_CPUMAP(cpumap, c= pumaplen, i), + VIR_UNLESS ((pinInfo =3D virBitmapDataFormat(VIR_GET_CPUMAP(cp= umap, cpumaplen, i), cpumaplen))) return false; =20 @@ -7068,7 +7068,7 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptStringReq(ctl, cmd, "cpulist", &cpulist) < 0) return false; =20 - if (!cpulist) + VIR_UNLESS (cpulist) VSH_EXCLUSIVE_OPTIONS_VAR(live, config); =20 if ((got_vcpu =3D vshCommandOptUInt(ctl, cmd, "vcpu", &vcpu)) < 0) @@ -7083,16 +7083,16 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd) if ((maxcpu =3D virshNodeGetCPUCount(priv->conn)) < 0) return false; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 /* Query mode: show CPU affinity information then exit.*/ - if (!cpulist) { + VIR_UNLESS (cpulist) { return virshVcpuPinQuery(ctl, dom, vcpu, got_vcpu, maxcpu, flags); } =20 /* Pin mode: pinning specified vcpu to specified physical cpus */ - if (!(cpumap =3D virshParseCPUList(ctl, &cpumaplen, cpulist, maxcpu))) + VIR_UNLESS ((cpumap =3D virshParseCPUList(ctl, &cpumaplen, cpulist, ma= xcpu))) return false; =20 /* use old API without any explicit flags */ @@ -7160,7 +7160,7 @@ cmdEmulatorPin(vshControl *ctl, const vshCmd *cmd) if (!current && !live && !config) flags =3D -1; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (vshCommandOptStringReq(ctl, cmd, "cpulist", &cpulist) < 0) { @@ -7195,7 +7195,7 @@ cmdEmulatorPin(vshControl *ctl, const vshCmd *cmd) } =20 /* Pin mode: pinning emulator threads to specified physical cpus */ - if (!(cpumap =3D virshParseCPUList(ctl, &cpumaplen, cpulist, maxcpu))) + VIR_UNLESS ((cpumap =3D virshParseCPUList(ctl, &cpumaplen, cpulist, ma= xcpu))) return false; =20 if (flags =3D=3D -1) @@ -7275,7 +7275,7 @@ cmdSetvcpus(vshControl *ctl, const vshCmd *cmd) if (hotpluggable) flags |=3D VIR_DOMAIN_VCPU_HOTPLUGGABLE; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (vshCommandOptUInt(ctl, cmd, "count", &count) < 0) @@ -7357,7 +7357,7 @@ cmdGuestvcpus(vshControl *ctl, const vshCmd *cmd) return false; } =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (enable) @@ -7450,7 +7450,7 @@ cmdSetvcpu(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptStringReq(ctl, cmd, "vcpulist", &vcpulist)) return false; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (enable) @@ -7507,7 +7507,7 @@ cmdDomblkthreshold(vshControl *ctl, const vshCmd *cmd) &threshold, 1, ULLONG_MAX) < 0) return false; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (virDomainSetBlockThreshold(dom, dev, threshold, 0) < 0) @@ -7560,7 +7560,7 @@ cmdIOThreadInfo(vshControl *ctl, const vshCmd *cmd) if (live) flags |=3D VIR_DOMAIN_AFFECT_LIVE; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if ((rc =3D virDomainGetIOThreadInfo(dom, &info, flags)) < 0) { @@ -7576,7 +7576,7 @@ cmdIOThreadInfo(vshControl *ctl, const vshCmd *cmd) } =20 table =3D vshTableNew(_("IOThread ID"), _("CPU Affinity"), NULL); - if (!table) + VIR_UNLESS (table) goto cleanup; =20 for (i =3D 0; i < niothreads; i++) { @@ -7658,7 +7658,7 @@ cmdIOThreadPin(vshControl *ctl, const vshCmd *cmd) if (live) flags |=3D VIR_DOMAIN_AFFECT_LIVE; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (vshCommandOptUInt(ctl, cmd, "iothread", &iothread_id) < 0) @@ -7670,7 +7670,7 @@ cmdIOThreadPin(vshControl *ctl, const vshCmd *cmd) if ((maxcpu =3D virshNodeGetCPUCount(priv->conn)) < 0) return false; =20 - if (!(cpumap =3D virshParseCPUList(ctl, &cpumaplen, cpulist, maxcpu))) + VIR_UNLESS ((cpumap =3D virshParseCPUList(ctl, &cpumaplen, cpulist, ma= xcpu))) return false; =20 if (virDomainPinIOThread(dom, iothread_id, @@ -7724,7 +7724,7 @@ cmdIOThreadAdd(vshControl *ctl, const vshCmd *cmd) if (live) flags |=3D VIR_DOMAIN_AFFECT_LIVE; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (vshCommandOptInt(ctl, cmd, "id", &iothread_id) < 0) @@ -7797,7 +7797,7 @@ cmdIOThreadSet(vshControl *ctl, const vshCmd *cmd) if (live) flags |=3D VIR_DOMAIN_AFFECT_LIVE; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (vshCommandOptInt(ctl, cmd, "id", &id) < 0) @@ -7889,7 +7889,7 @@ cmdIOThreadDel(vshControl *ctl, const vshCmd *cmd) if (live) flags |=3D VIR_DOMAIN_AFFECT_LIVE; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (vshCommandOptInt(ctl, cmd, "id", &iothread_id) < 0) @@ -7965,7 +7965,7 @@ cmdCPUStats(vshControl *ctl, const vshCmd *cmd) bool ret =3D false; int rv =3D 0; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 show_total =3D vshCommandOptBool(cmd, "total"); @@ -7996,7 +7996,7 @@ cmdCPUStats(vshControl *ctl, const vshCmd *cmd) show_per_cpu =3D true; } =20 - if (!show_per_cpu) /* show total stats only */ + VIR_UNLESS (show_per_cpu) /* show total stats only */ goto do_show_total; =20 /* get number of cpus on the node */ @@ -8019,7 +8019,7 @@ cmdCPUStats(vshControl *ctl, const vshCmd *cmd) if ((nparams =3D virDomainGetCPUStats(dom, NULL, 0, 0, 1, 0)) < 0) goto failed_stats; =20 - if (!nparams) { + VIR_UNLESS (nparams) { vshPrint(ctl, "%s", _("No per-CPU stats available")); if (show_total) goto do_show_total; @@ -8048,7 +8048,7 @@ cmdCPUStats(vshControl *ctl, const vshCmd *cmd) } VIR_FREE(params); =20 - if (!show_total) { + VIR_UNLESS (show_total) { ret =3D true; goto cleanup; } @@ -8058,7 +8058,7 @@ cmdCPUStats(vshControl *ctl, const vshCmd *cmd) if ((nparams =3D virDomainGetCPUStats(dom, NULL, 0, -1, 1, 0)) < 0) goto failed_stats; =20 - if (!nparams) { + VIR_UNLESS (nparams) { vshPrint(ctl, "%s", _("No total stats available")); goto cleanup; } @@ -8168,7 +8168,7 @@ cmdCreate(vshControl *ctl, const vshCmd *cmd) else dom =3D virDomainCreateXML(priv->conn, buffer, flags); =20 - if (!dom) { + VIR_UNLESS (dom) { vshError(ctl, _("Failed to create domain from %s"), from); return false; } @@ -8228,7 +8228,7 @@ cmdDefine(vshControl *ctl, const vshCmd *cmd) dom =3D virDomainDefineXML(priv->conn, buffer); VIR_FREE(buffer); =20 - if (!dom) { + VIR_UNLESS (dom) { vshError(ctl, _("Failed to define domain from %s"), from); return false; } @@ -8268,7 +8268,7 @@ cmdDestroy(vshControl *ctl, const vshCmd *cmd) unsigned int flags =3D 0; int result; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, &name))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, &name))) return false; =20 if (vshCommandOptBool(cmd, "graceful")) @@ -8351,7 +8351,7 @@ cmdDesc(vshControl *ctl, const vshCmd *cmd) if (live) flags |=3D VIR_DOMAIN_AFFECT_LIVE; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if ((state =3D virshDomainState(ctl, dom, NULL)) < 0) @@ -8373,10 +8373,10 @@ cmdDesc(vshControl *ctl, const vshCmd *cmd) g_autofree char *descDom =3D NULL; g_autofree char *descNew =3D NULL; =20 - if (!(descDom =3D virshGetDomainDescription(ctl, dom, title, query= flags))) + VIR_UNLESS ((descDom =3D virshGetDomainDescription(ctl, dom, title= , queryflags))) return false; =20 - if (!descArg) + VIR_UNLESS (descArg) descArg =3D g_strdup(descDom); =20 if (edit) { @@ -8385,7 +8385,7 @@ cmdDesc(vshControl *ctl, const vshCmd *cmd) char *tmpstr; =20 /* Create and open the temporary file. */ - if (!(tmp =3D vshEditWriteToTempFile(ctl, descArg))) + VIR_UNLESS ((tmp =3D vshEditWriteToTempFile(ctl, descArg))) return false; =20 /* Start the editor. */ @@ -8393,7 +8393,7 @@ cmdDesc(vshControl *ctl, const vshCmd *cmd) return false; =20 /* Read back the edited file. */ - if (!(desc_edited =3D vshEditReadBackFile(ctl, tmp))) + VIR_UNLESS ((desc_edited =3D vshEditReadBackFile(ctl, tmp))) return false; =20 /* strip a possible newline at the end of file; some @@ -8435,7 +8435,7 @@ cmdDesc(vshControl *ctl, const vshCmd *cmd) =20 } else { g_autofree char *desc =3D virshGetDomainDescription(ctl, dom, titl= e, queryflags); - if (!desc) + VIR_UNLESS (desc) return false; =20 if (strlen(desc) > 0) { @@ -8502,7 +8502,7 @@ virshDomainGetEditMetadata(vshControl *ctl G_GNUC_UNU= SED, { char *ret; =20 - if (!(ret =3D virDomainGetMetadata(dom, VIR_DOMAIN_METADATA_ELEMENT, + VIR_UNLESS ((ret =3D virDomainGetMetadata(dom, VIR_DOMAIN_METADATA_ELE= MENT, uri, flags))) { vshResetLibvirtError(); ret =3D g_strdup("\n"); @@ -8538,7 +8538,7 @@ cmdMetadata(vshControl *ctl, const vshCmd *cmd) if (live) flags |=3D VIR_DOMAIN_AFFECT_LIVE; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (vshCommandOptStringReq(ctl, cmd, "uri", &uri) < 0 || @@ -8580,7 +8580,7 @@ cmdMetadata(vshControl *ctl, const vshCmd *cmd) } else { g_autofree char *data =3D NULL; /* get */ - if (!(data =3D virDomainGetMetadata(dom, VIR_DOMAIN_METADATA_ELEME= NT, + VIR_UNLESS ((data =3D virDomainGetMetadata(dom, VIR_DOMAIN_METADAT= A_ELEMENT, uri, flags))) return false; =20 @@ -8617,7 +8617,7 @@ cmdInjectNMI(vshControl *ctl, const vshCmd *cmd) { g_autoptr(virshDomain) dom =3D NULL; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (virDomainInjectNMI(dom, 0) < 0) @@ -8683,7 +8683,7 @@ cmdSendKey(vshControl *ctl, const vshCmd *cmd) int keycode; unsigned int keycodes[VIR_DOMAIN_SEND_KEY_MAX_KEYS]; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (vshCommandOptStringQuiet(ctl, cmd, "codeset", &codeset_option) <= =3D 0) @@ -8801,7 +8801,7 @@ cmdSendProcessSignal(vshControl *ctl, const vshCmd *c= md) long long pid_value; int signum; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (vshCommandOptLongLong(ctl, cmd, "pid", &pid_value) < 0) @@ -8876,7 +8876,7 @@ cmdSetmem(vshControl *ctl, const vshCmd *cmd) flags |=3D VIR_DOMAIN_AFFECT_LIVE; } =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 /* The API expects 'unsigned long' KiB, so depending on whether we @@ -8945,7 +8945,7 @@ cmdSetmaxmem(vshControl *ctl, const vshCmd *cmd) if (live) flags |=3D VIR_DOMAIN_AFFECT_LIVE; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 /* The API expects 'unsigned long' KiB, so depending on whether we @@ -9068,7 +9068,7 @@ virshGetUpdatedMemoryXML(char **updatedMemoryXML, =20 requestedSizeNode =3D virXPathNode("./target/requested", ctxt); =20 - if (!requestedSizeNode) { + VIR_UNLESS (requestedSizeNode) { vshError(ctl, _("virtio-mem device is missing ")); return -1; } @@ -9077,7 +9077,7 @@ virshGetUpdatedMemoryXML(char **updatedMemoryXML, xmlNodeSetContent(requestedSizeNode, BAD_CAST kibibytesStr); } =20 - if (!(*updatedMemoryXML =3D virXMLNodeToString(doc, mems[0]))) { + VIR_UNLESS ((*updatedMemoryXML =3D virXMLNodeToString(doc, mems[0]))) { vshSaveLibvirtError(); return -1; } @@ -9104,7 +9104,7 @@ cmdUpdateMemoryDevice(vshControl *ctl, const vshCmd *= cmd) if (live) flags |=3D VIR_DOMAIN_AFFECT_LIVE; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (virshGetUpdatedMemoryXML(&updatedMemoryXML, ctl, cmd, dom, flags) = < 0) @@ -9226,7 +9226,7 @@ cmdMemtune(vshControl *ctl, const vshCmd *cmd) if (live) flags |=3D VIR_DOMAIN_AFFECT_LIVE; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 #define PARSE_MEMTUNE_PARAM(NAME, FIELD) \ @@ -9340,7 +9340,7 @@ virshParseEventStr(const char *event, g_auto(GStrv) tok =3D NULL; GStrv next; =20 - if (!(tok =3D g_strsplit(event, ",", 0))) + VIR_UNLESS ((tok =3D g_strsplit(event, ",", 0))) return -1; =20 for (next =3D tok; *next; next++) { @@ -9395,7 +9395,7 @@ cmdPerf(vshControl *ctl, const vshCmd *cmd) vshCommandOptStringReq(ctl, cmd, "disable", &disable) < 0) return false; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (enable && virshParseEventStr(enable, true, ¶ms, @@ -9486,7 +9486,7 @@ cmdNumatune(vshControl * ctl, const vshCmd * cmd) if (live) flags |=3D VIR_DOMAIN_AFFECT_LIVE; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (vshCommandOptStringReq(ctl, cmd, "nodeset", &nodeset) < 0) @@ -9592,7 +9592,7 @@ cmdDomLaunchSecInfo(vshControl * ctl, const vshCmd * = cmd) virTypedParameterPtr params =3D NULL; bool ret =3D false; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (virDomainGetLaunchSecurityInfo(dom, ¶ms, &nparams, 0) !=3D 0) { @@ -9659,7 +9659,7 @@ cmdDomSetLaunchSecState(vshControl * ctl, const vshCm= d * cmd) int rv; bool ret =3D false; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (vshCommandOptStringReq(ctl, cmd, "secrethdr", &sechdrfile) < 0) @@ -9817,7 +9817,7 @@ cmdQemuMonitorCommandQMPWrap(vshControl *ctl, virBufferTrim(&buf, ","); virBufferAddLit(&buf, "}"); =20 - if (!(arguments =3D virJSONValueFromString(virBufferCurrentContent= (&buf)))) { + VIR_UNLESS ((arguments =3D virJSONValueFromString(virBufferCurrent= Content(&buf)))) { vshError(ctl, _("failed to wrap arguments '%s' into a QMP comm= and wrapper"), fullargs); return NULL; @@ -9852,7 +9852,7 @@ cmdQemuMonitorCommand(vshControl *ctl, const vshCmd *= cmd) VSH_EXCLUSIVE_OPTIONS("hmp", "pretty"); VSH_EXCLUSIVE_OPTIONS("hmp", "return-value"); =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (vshCommandOptBool(cmd, "hmp")) { @@ -9862,7 +9862,7 @@ cmdQemuMonitorCommand(vshControl *ctl, const vshCmd *= cmd) monitor_cmd =3D cmdQemuMonitorCommandQMPWrap(ctl, cmd); } =20 - if (!monitor_cmd) { + VIR_UNLESS (monitor_cmd) { vshSaveLibvirtError(); return NULL; } @@ -9890,13 +9890,13 @@ cmdQemuMonitorCommand(vshControl *ctl, const vshCmd= *cmd) } =20 /* print raw non-prettified result */ - if (!resultjson) { + VIR_UNLESS (resultjson) { vshPrint(ctl, "%s\n", result); return true; } =20 if (returnval) { - if (!(formatjson =3D virJSONValueObjectGet(resultjson, "return")))= { + VIR_UNLESS ((formatjson =3D virJSONValueObjectGet(resultjson, "ret= urn"))) { vshError(ctl, "'return' member missing"); return false; } @@ -9958,7 +9958,7 @@ virshEventQemuPrint(virConnectPtr conn G_GNUC_UNUSED, } =20 data->count++; - if (!data->loop) + VIR_UNLESS (data->loop) vshEventDone(data->ctl); } =20 @@ -10034,7 +10034,7 @@ cmdQemuMonitorEvent(vshControl *ctl, const vshCmd *= cmd) return false; =20 if (vshCommandOptBool(cmd, "domain")) - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) goto cleanup; =20 if (vshEventStart(ctl, timeout) < 0) @@ -10105,7 +10105,7 @@ cmdQemuAttach(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptUInt(ctl, cmd, "pid", &pid_value) <=3D 0) return false; =20 - if (!(dom =3D virDomainQemuAttach(priv->conn, pid_value, flags))) { + VIR_UNLESS ((dom =3D virDomainQemuAttach(priv->conn, pid_value, flags)= )) { vshError(ctl, _("Failed to attach to pid %u"), pid_value); return false; } @@ -10205,7 +10205,7 @@ cmdQemuAgentCommand(vshControl *ctl, const vshCmd *= cmd) } =20 result =3D virDomainQemuAgentCommand(dom, guest_agent_cmd, timeout, fl= ags); - if (!result) + VIR_UNLESS (result) goto cleanup; =20 if (vshCommandOptBool(cmd, "pretty")) { @@ -10400,10 +10400,10 @@ cmdDumpXML(vshControl *ctl, const vshCmd *cmd) if (migratable) flags |=3D VIR_DOMAIN_XML_MIGRATABLE; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 - if (!(dump =3D virDomainGetXMLDesc(dom, flags))) + VIR_UNLESS ((dump =3D virDomainGetXMLDesc(dom, flags))) return false; =20 vshPrint(ctl, "%s", dump); @@ -10456,7 +10456,7 @@ cmdDomXMLFromNative(vshControl *ctl, const vshCmd *= cmd) return false; =20 xmlData =3D virConnectDomainXMLFromNative(priv->conn, format, configDa= ta, flags); - if (!xmlData) + VIR_UNLESS (xmlData) return false; =20 vshPrint(ctl, "%s", xmlData); @@ -10522,12 +10522,12 @@ cmdDomXMLToNative(vshControl *ctl, const vshCmd *= cmd) return false; } =20 - if (!xmlData) { + VIR_UNLESS (xmlData) { vshError(ctl, "%s", _("failed to retrieve XML")); return false; } =20 - if (!(configData =3D virConnectDomainXMLToNative(priv->conn, format, x= mlData, flags))) + VIR_UNLESS ((configData =3D virConnectDomainXMLToNative(priv->conn, fo= rmat, xmlData, flags))) return false; =20 vshPrint(ctl, "%s", configData); @@ -10563,7 +10563,7 @@ cmdDomname(vshControl *ctl, const vshCmd *cmd) { g_autoptr(virshDomain) dom =3D NULL; =20 - if (!(dom =3D virshCommandOptDomainBy(ctl, cmd, NULL, + VIR_UNLESS ((dom =3D virshCommandOptDomainBy(ctl, cmd, NULL, VIRSH_BYID|VIRSH_BYUUID))) return false; =20 @@ -10602,7 +10602,7 @@ cmdDomrename(vshControl *ctl, const vshCmd *cmd) g_autoptr(virshDomain) dom =3D NULL; const char *new_name =3D NULL; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (vshCommandOptStringReq(ctl, cmd, "new-name", &new_name) < 0) @@ -10641,7 +10641,7 @@ cmdDomid(vshControl *ctl, const vshCmd *cmd) g_autoptr(virshDomain) dom =3D NULL; unsigned int id; =20 - if (!(dom =3D virshCommandOptDomainBy(ctl, cmd, NULL, + VIR_UNLESS ((dom =3D virshCommandOptDomainBy(ctl, cmd, NULL, VIRSH_BYNAME|VIRSH_BYUUID))) return false; =20 @@ -10677,7 +10677,7 @@ cmdDomuuid(vshControl *ctl, const vshCmd *cmd) g_autoptr(virshDomain) dom =3D NULL; char uuid[VIR_UUID_STRING_BUFLEN]; =20 - if (!(dom =3D virshCommandOptDomainBy(ctl, cmd, NULL, + VIR_UNLESS ((dom =3D virshCommandOptDomainBy(ctl, cmd, NULL, VIRSH_BYNAME|VIRSH_BYID))) return false; =20 @@ -10931,7 +10931,7 @@ doMigrate(void *opaque) goto out_sig; #endif /* !WIN32 */ =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) goto out; =20 if (vshCommandOptStringReq(ctl, cmd, "desturi", &desturi) < 0) @@ -11302,7 +11302,7 @@ cmdMigrate(vshControl *ctl, const vshCmd *cmd) VSH_REQUIRE_OPTION("persistent-xml", "persistent"); VSH_REQUIRE_OPTION("tls-destination", "tls"); =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (vshCommandOptBool(cmd, "verbose")) @@ -11352,7 +11352,7 @@ cmdMigrate(vshControl *ctl, const vshCmd *cmd) goto cleanup; =20 dconn =3D virshConnect(ctl, desturi, false); - if (!dconn) + VIR_UNLESS (dconn) goto cleanup; =20 data.dconn =3D dconn; @@ -11407,7 +11407,7 @@ cmdMigrateSetMaxDowntime(vshControl *ctl, const vsh= Cmd *cmd) g_autoptr(virshDomain) dom =3D NULL; unsigned long long downtime =3D 0; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (vshCommandOptULongLong(ctl, cmd, "downtime", &downtime) < 0) @@ -11446,7 +11446,7 @@ cmdMigrateGetMaxDowntime(vshControl *ctl, const vsh= Cmd *cmd) g_autoptr(virshDomain) dom =3D NULL; unsigned long long downtime; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (virDomainMigrateGetMaxDowntime(dom, &downtime, 0) < 0) @@ -11490,7 +11490,7 @@ cmdMigrateCompCache(vshControl *ctl, const vshCmd *= cmd) double value; int rc; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 rc =3D vshCommandOptULongLong(ctl, cmd, "size", &size); @@ -11545,7 +11545,7 @@ cmdMigrateSetMaxSpeed(vshControl *ctl, const vshCmd= *cmd) unsigned long bandwidth =3D 0; unsigned int flags =3D 0; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (vshCommandOptULWrap(ctl, cmd, "bandwidth", &bandwidth) < 0) @@ -11589,7 +11589,7 @@ cmdMigrateGetMaxSpeed(vshControl *ctl, const vshCmd= *cmd) unsigned long bandwidth; unsigned int flags =3D 0; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (vshCommandOptBool(cmd, "postcopy")) @@ -11627,7 +11627,7 @@ cmdMigratePostCopy(vshControl *ctl, const vshCmd *c= md) { g_autoptr(virshDomain) dom =3D NULL; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (virDomainMigrateStartPostCopy(dom, 0) < 0) @@ -11717,7 +11717,7 @@ virshGetOneDisplay(vshControl *ctl, if (!port && !tls_port && !sockpath) return NULL; =20 - if (!listen_addr) { + VIR_UNLESS (listen_addr) { g_autofree char *xpathListenAddress =3D NULL; /* The subelement address - - * *should* have been automatically backfilled into its @@ -11822,10 +11822,10 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd) =20 VSH_EXCLUSIVE_OPTIONS("all", "type"); =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 - if (!virDomainIsActive(dom)) { + VIR_UNLESS (virDomainIsActive(dom)) { vshError(ctl, _("Domain is not running")); return false; } @@ -11847,19 +11847,19 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd) if (!all && type && STRNEQ(type, scheme[iter])) continue; =20 - if (!(display =3D virshGetOneDisplay(ctl, scheme[iter], ctxt))) + VIR_UNLESS ((display =3D virshGetOneDisplay(ctl, scheme[iter], ctx= t))) continue; =20 vshPrint(ctl, "%s", display); =20 /* We got what we came for so return successfully */ ret =3D true; - if (!all) + VIR_UNLESS (all) break; vshPrint(ctl, "\n"); } =20 - if (!ret) { + VIR_UNLESS (ret) { if (type) vshError(ctl, _("No graphical display with type '%s' found"), = type); else @@ -11896,11 +11896,11 @@ cmdVNCDisplay(vshControl *ctl, const vshCmd *cmd) int port =3D 0; g_autofree char *listen_addr =3D NULL; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 /* Check if the domain is active and don't rely on -1 for this */ - if (!virDomainIsActive(dom)) { + VIR_UNLESS (virDomainIsActive(dom)) { vshError(ctl, _("Domain is not running")); return false; } @@ -11917,7 +11917,7 @@ cmdVNCDisplay(vshControl *ctl, const vshCmd *cmd) =20 listen_addr =3D virXPathString("string(/domain/devices/graphics" "[@type=3D'vnc']/@listen)", ctxt); - if (!listen_addr) { + VIR_UNLESS (listen_addr) { /* The subelement address - - * *should* have been automatically backfilled into its * parent (which we just tried to @@ -11965,7 +11965,7 @@ cmdTTYConsole(vshControl *ctl, const vshCmd *cmd) if (virshDomainGetXML(ctl, cmd, 0, &xml, &ctxt) < 0) return false; =20 - if (!(tty =3D virXPathString("string(/domain/devices/console/@tty)", c= txt))) + VIR_UNLESS ((tty =3D virXPathString("string(/domain/devices/console/@t= ty)", ctxt))) return false; =20 vshPrint(ctl, "%s\n", tty); @@ -12008,7 +12008,7 @@ cmdDomHostname(vshControl *ctl, const vshCmd *cmd) const char *sourcestr =3D NULL; int flags =3D 0; /* Use default value. Drivers can have its own defaul= t. */ =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (vshCommandOptStringReq(ctl, cmd, "source", &sourcestr) < 0) @@ -12090,7 +12090,7 @@ cmdDetachDevice(vshControl *ctl, const vshCmd *cmd) if (live) flags |=3D VIR_DOMAIN_AFFECT_LIVE; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (persistent && @@ -12165,7 +12165,7 @@ cmdDetachDeviceAlias(vshControl *ctl, const vshCmd = *cmd) if (live) flags |=3D VIR_DOMAIN_AFFECT_LIVE; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (vshCommandOptStringReq(ctl, cmd, "alias", &alias) < 0) @@ -12230,7 +12230,7 @@ cmdUpdateDevice(vshControl *ctl, const vshCmd *cmd) if (live) flags |=3D VIR_DOMAIN_AFFECT_LIVE; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) @@ -12309,7 +12309,7 @@ virshDomainDetachInterface(char *doc, int diff_mac =3D -1; size_t i; =20 - if (!(xml =3D virXMLParseStringCtxt(doc, _("(domain_definition)"), &ct= xt))) { + VIR_UNLESS ((xml =3D virXMLParseStringCtxt(doc, _("(domain_definition)= "), &ctxt))) { vshError(ctl, "%s", _("Failed to get interface information")); return false; } @@ -12328,7 +12328,7 @@ virshDomainDetachInterface(char *doc, return false; } =20 - if (!mac) { + VIR_UNLESS (mac) { matchNode =3D obj->nodesetval->nodeTab[0]; goto hit; } @@ -12341,7 +12341,7 @@ virshDomainDetachInterface(char *doc, virXMLNodeNameEqual(cur, "mac")) { g_autofree char *tmp_mac =3D virXMLPropString(cur, "addres= s"); diff_mac =3D virMacAddrCompare(tmp_mac, mac); - if (!diff_mac) { + VIR_UNLESS (diff_mac) { if (matchNode) { /* this is the 2nd match, so it's ambiguous */ vshError(ctl, _("Domain has multiple interfaces ma= tching " @@ -12356,13 +12356,13 @@ virshDomainDetachInterface(char *doc, cur =3D cur->next; } } - if (!matchNode) { + VIR_UNLESS (matchNode) { vshError(ctl, _("No interface with MAC address %s was found"), mac= ); return false; } =20 hit: - if (!(detach_xml =3D virXMLNodeToString(xml, matchNode))) { + VIR_UNLESS ((detach_xml =3D virXMLNodeToString(xml, matchNode))) { vshSaveLibvirtError(); return false; } @@ -12392,7 +12392,7 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *c= md) VSH_EXCLUSIVE_OPTIONS_VAR(current, live); VSH_EXCLUSIVE_OPTIONS_VAR(current, config); =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (vshCommandOptStringReq(ctl, cmd, "type", &type) < 0) @@ -12404,9 +12404,9 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *c= md) affect_config =3D (config || persistent); =20 if (affect_config) { - if (!(doc_config =3D virDomainGetXMLDesc(dom, VIR_DOMAIN_XML_INACT= IVE))) + VIR_UNLESS ((doc_config =3D virDomainGetXMLDesc(dom, VIR_DOMAIN_XM= L_INACTIVE))) goto cleanup; - if (!(ret =3D virshDomainDetachInterface(doc_config, + VIR_UNLESS ((ret =3D virshDomainDetachInterface(doc_config, flags | VIR_DOMAIN_AFFECT_C= ONFIG, dom, ctl, current, type, ma= c))) goto cleanup; @@ -12420,7 +12420,7 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *c= md) if (affect_live) flags |=3D VIR_DOMAIN_AFFECT_LIVE; =20 - if (!(doc_live =3D virDomainGetXMLDesc(dom, 0))) + VIR_UNLESS ((doc_live =3D virDomainGetXMLDesc(dom, 0))) goto cleanup; =20 ret =3D virshDomainDetachInterface(doc_live, flags, @@ -12428,7 +12428,7 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *c= md) } =20 cleanup: - if (!ret) { + VIR_UNLESS (ret) { vshError(ctl, "%s", _("Failed to detach interface")); } else { vshPrintExtra(ctl, "%s", _("Interface detached successfully\n")); @@ -12478,7 +12478,7 @@ virshFindDisk(const char *doc, size_t i; =20 xml =3D virXMLParseStringCtxt(doc, _("(domain_definition)"), &ctxt); - if (!xml) { + VIR_UNLESS (xml) { vshError(NULL, "%s", _("Failed to get disk information")); return NULL; } @@ -12509,7 +12509,7 @@ virshFindDisk(const char *doc, is_supported =3D true; } =20 - if (!is_supported) + VIR_UNLESS (is_supported) continue; } =20 @@ -12571,12 +12571,12 @@ virshUpdateDiskXML(xmlNodePtr disk_node, g_autofree char *startupPolicy =3D NULL; g_autofree char *source_path =3D NULL; =20 - if (!disk_node) + VIR_UNLESS (disk_node) return NULL; =20 device_type =3D virXMLPropString(disk_node, "device"); =20 - if (!(STREQ_NULLABLE(device_type, "cdrom") || + VIR_UNLESS ((STREQ_NULLABLE(device_type, "cdrom") || STREQ_NULLABLE(device_type, "floppy"))) { vshError(NULL, _("The disk device '%s' is not removable"), target); return NULL; @@ -12611,7 +12611,7 @@ virshUpdateDiskXML(xmlNodePtr disk_node, } =20 if (type =3D=3D VIRSH_UPDATE_DISK_XML_EJECT) { - if (!source) { + VIR_UNLESS (source) { vshError(NULL, _("The disk device '%s' doesn't have media"), t= arget); return NULL; } @@ -12673,12 +12673,12 @@ virshUpdateDiskXML(xmlNodePtr disk_node, * so it's more easily readable. And don't make it fatal. */ if ((tmp =3D xmlCopyNode(text_node, 0))) { - if (!xmlAddPrevSibling(target_node, tmp)) + VIR_UNLESS (xmlAddPrevSibling(target_node, tmp)) xmlFreeNode(tmp); } } =20 - if (!(ret =3D virXMLNodeToString(NULL, disk_node))) { + VIR_UNLESS ((ret =3D virXMLNodeToString(NULL, disk_node))) { vshSaveLibvirtError(); return NULL; } @@ -12745,7 +12745,7 @@ cmdDetachDisk(vshControl *ctl, const vshCmd *cmd) if (live) flags |=3D VIR_DOMAIN_AFFECT_LIVE; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (vshCommandOptStringReq(ctl, cmd, "target", &target) < 0) @@ -12756,17 +12756,17 @@ cmdDetachDisk(vshControl *ctl, const vshCmd *cmd) else doc =3D virDomainGetXMLDesc(dom, 0); =20 - if (!doc) + VIR_UNLESS (doc) goto cleanup; =20 if (persistent && virDomainIsActive(dom) =3D=3D 1) flags |=3D VIR_DOMAIN_AFFECT_LIVE; =20 - if (!(disk_node =3D virshFindDisk(doc, target, VIRSH_FIND_DISK_NORMAL)= )) + VIR_UNLESS ((disk_node =3D virshFindDisk(doc, target, VIRSH_FIND_DISK_= NORMAL))) goto cleanup; =20 - if (!(disk_xml =3D virXMLNodeToString(NULL, disk_node))) { + VIR_UNLESS ((disk_xml =3D virXMLNodeToString(NULL, disk_node))) { vshSaveLibvirtError(); goto cleanup; } @@ -12987,7 +12987,7 @@ cmdChangeMedia(vshControl *ctl, const vshCmd *cmd) if (force) flags |=3D VIR_DOMAIN_DEVICE_MODIFY_FORCE; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (vshCommandOptStringReq(ctl, cmd, "path", &path) < 0) @@ -12997,13 +12997,13 @@ cmdChangeMedia(vshControl *ctl, const vshCmd *cmd) doc =3D virDomainGetXMLDesc(dom, VIR_DOMAIN_XML_INACTIVE); else doc =3D virDomainGetXMLDesc(dom, 0); - if (!doc) + VIR_UNLESS (doc) goto cleanup; =20 - if (!(disk_node =3D virshFindDisk(doc, path, VIRSH_FIND_DISK_CHANGEABL= E))) + VIR_UNLESS ((disk_node =3D virshFindDisk(doc, path, VIRSH_FIND_DISK_CH= ANGEABLE))) goto cleanup; =20 - if (!(disk_xml =3D virshUpdateDiskXML(disk_node, source, block, path, + VIR_UNLESS ((disk_xml =3D virshUpdateDiskXML(disk_node, source, block,= path, update_type))) goto cleanup; =20 @@ -13057,7 +13057,7 @@ cmdDomFSTrim(vshControl *ctl, const vshCmd *cmd) const char *mountPoint =3D NULL; unsigned int flags =3D 0; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (vshCommandOptULongLong(ctl, cmd, "minimum", &minimum) < 0) @@ -13102,7 +13102,7 @@ cmdDomFSFreeze(vshControl *ctl, const vshCmd *cmd) size_t nmountpoints =3D 0; int count =3D 0; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 while ((opt =3D vshCommandOptArgv(ctl, cmd, opt))) { @@ -13147,7 +13147,7 @@ cmdDomFSThaw(vshControl *ctl, const vshCmd *cmd) size_t nmountpoints =3D 0; int count =3D 0; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 while ((opt =3D vshCommandOptArgv(ctl, cmd, opt))) { @@ -13190,7 +13190,7 @@ cmdDomFSInfo(vshControl *ctl, const vshCmd *cmd) size_t ninfos =3D 0; bool ret =3D false; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 rc =3D virDomainGetFSInfo(dom, &info, 0); @@ -13208,7 +13208,7 @@ cmdDomFSInfo(vshControl *ctl, const vshCmd *cmd) =20 if (info) { table =3D vshTableNew(_("Mountpoint"), _("Name"), _("Type"), _("Ta= rget"), NULL); - if (!table) + VIR_UNLESS (table) goto cleanup; =20 for (i =3D 0; i < ninfos; i++) { @@ -13274,7 +13274,7 @@ cmdGuestAgentTimeout(vshControl *ctl, const vshCmd = *cmd) int timeout =3D VIR_DOMAIN_AGENT_RESPONSE_TIMEOUT_BLOCK; const unsigned int flags =3D 0; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (vshCommandOptInt(ctl, cmd, "timeout", &timeout) < 0) @@ -13358,7 +13358,7 @@ cmdGuestInfo(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "interface")) types |=3D VIR_DOMAIN_GUEST_INFO_INTERFACES; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (virDomainGetGuestInfo(dom, types, ¶ms, &nparams, 0) < 0) @@ -13410,7 +13410,7 @@ cmdGetUserSSHKeys(vshControl *ctl, const vshCmd *cm= d) size_t i; const unsigned int flags =3D 0; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (vshCommandOptStringReq(ctl, cmd, "user", &user) < 0) @@ -13479,7 +13479,7 @@ cmdSetUserSSHKeys(vshControl *ctl, const vshCmd *cm= d) VSH_REQUIRE_OPTION("remove", "file"); VSH_EXCLUSIVE_OPTIONS("reset", "remove"); =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (vshCommandOptStringReq(ctl, cmd, "user", &user) < 0) @@ -13491,10 +13491,10 @@ cmdSetUserSSHKeys(vshControl *ctl, const vshCmd *= cmd) if (vshCommandOptBool(cmd, "remove")) { flags |=3D VIR_DOMAIN_AUTHORIZED_SSH_KEYS_SET_REMOVE; } else { - if (!vshCommandOptBool(cmd, "reset")) { + VIR_UNLESS (vshCommandOptBool(cmd, "reset")) { flags |=3D VIR_DOMAIN_AUTHORIZED_SSH_KEYS_SET_APPEND; =20 - if (!from) { + VIR_UNLESS (from) { vshError(ctl, _("Option --file is required")); return false; } @@ -13507,7 +13507,7 @@ cmdSetUserSSHKeys(vshControl *ctl, const vshCmd *cm= d) return false; } =20 - if (!(keys =3D g_strsplit(buffer, "\n", -1))) + VIR_UNLESS ((keys =3D g_strsplit(buffer, "\n", -1))) return false; =20 nkeys =3D g_strv_length(keys); @@ -13572,7 +13572,7 @@ cmdDomDirtyRateCalc(vshControl *ctl, const vshCmd *= cmd) const char *modestr =3D NULL; unsigned int flags =3D 0; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (vshCommandOptInt(ctl, cmd, "seconds", &seconds) < 0) diff --git a/tools/virsh-edit.c b/tools/virsh-edit.c index 5dc1a1fe5a..9bb053ea16 100644 --- a/tools/virsh-edit.c +++ b/tools/virsh-edit.c @@ -64,12 +64,12 @@ do { =20 /* Get the XML configuration of the object. */ doc =3D (EDIT_GET_XML); - if (!doc) + VIR_UNLESS (doc) goto edit_cleanup; =20 /* Create and open the temporary file. */ tmp =3D vshEditWriteToTempFile(ctl, doc); - if (!tmp) + VIR_UNLESS (tmp) goto edit_cleanup; =20 reedit: @@ -85,7 +85,7 @@ do { /* Read back the edited file. */ VIR_FREE(doc_edited); doc_edited =3D vshEditReadBackFile(ctl, tmp); - if (!doc_edited) + VIR_UNLESS (doc_edited) goto edit_cleanup; =20 /* Compare original XML with edited. Has it changed at all? */ @@ -101,7 +101,7 @@ do { */ VIR_FREE(doc_reread); doc_reread =3D (EDIT_GET_XML); - if (!doc_reread) + VIR_UNLESS (doc_reread) goto edit_cleanup; =20 if (STRNEQ(doc, doc_reread)) { @@ -157,7 +157,7 @@ do { VIR_FREE(tmp); } =20 - if (!edit_success) + VIR_UNLESS (edit_success) goto cleanup; =20 } while (0); diff --git a/tools/virsh-host.c b/tools/virsh-host.c index 1e83d19fa1..c537db1516 100644 --- a/tools/virsh-host.c +++ b/tools/virsh-host.c @@ -113,7 +113,7 @@ cmdDomCapabilities(vshControl *ctl, const vshCmd *cmd) =20 caps =3D virConnectGetDomainCapabilities(priv->conn, emulatorbin, arch, machine, virttype, flags); - if (!caps) { + VIR_UNLESS (caps) { vshError(ctl, "%s", _("failed to get emulator capabilities")); return false; } @@ -170,7 +170,7 @@ cmdFreecell(vshControl *ctl, const vshCmd *cmd) if (cellno && vshCommandOptInt(ctl, cmd, "cellno", &cell) < 0) return false; =20 - if (!all) { + VIR_UNLESS (all) { if (cellno) { if (virNodeGetCellsFreeMemory(priv->conn, &memory, cell, 1) != =3D 1) return false; @@ -186,12 +186,12 @@ cmdFreecell(vshControl *ctl, const vshCmd *cmd) return true; } =20 - if (!(cap_xml =3D virConnectGetCapabilities(priv->conn))) { + VIR_UNLESS ((cap_xml =3D virConnectGetCapabilities(priv->conn))) { vshError(ctl, "%s", _("unable to get node capabilities")); return false; } =20 - if (!virXMLParseStringCtxt(cap_xml, _("(capabilities)"), &ctxt)) { + VIR_UNLESS (virXMLParseStringCtxt(cap_xml, _("(capabilities)"), &ctxt)= ) { vshError(ctl, "%s", _("unable to get node capabilities")); return false; } @@ -304,17 +304,17 @@ cmdFreepages(vshControl *ctl, const vshCmd *cmd) kibibytes =3D VIR_DIV_UP(bytes, 1024); =20 if (all) { - if (!(cap_xml =3D virConnectGetCapabilities(priv->conn))) { + VIR_UNLESS ((cap_xml =3D virConnectGetCapabilities(priv->conn))) { vshError(ctl, "%s", _("unable to get node capabilities")); goto cleanup; } =20 - if (!(doc =3D virXMLParseStringCtxt(cap_xml, _("capabilities"), &c= txt))) { + VIR_UNLESS ((doc =3D virXMLParseStringCtxt(cap_xml, _("capabilitie= s"), &ctxt))) { vshError(ctl, "%s", _("unable to parse node capabilities")); goto cleanup; } =20 - if (!pagesz) { + VIR_UNLESS (pagesz) { nodes_cnt =3D virXPathNodeSet("/capabilities/host/cpu/pages", = ctxt, &nodes); =20 if (nodes_cnt <=3D 0) { @@ -387,7 +387,7 @@ cmdFreepages(vshControl *ctl, const vshCmd *cmd) } =20 } else { - if (!cellno) { + VIR_UNLESS (cellno) { vshError(ctl, "%s", _("missing cellno argument")); goto cleanup; } @@ -401,7 +401,7 @@ cmdFreepages(vshControl *ctl, const vshCmd *cmd) goto cleanup; } =20 - if (!pagesz) { + VIR_UNLESS (pagesz) { vshError(ctl, "%s", _("missing pagesize argument")); goto cleanup; } @@ -501,13 +501,13 @@ cmdAllocpages(vshControl *ctl, const vshCmd *cmd) unsigned long nodes_cnt; size_t i; =20 - if (!(cap_xml =3D virConnectGetCapabilities(priv->conn))) { + VIR_UNLESS ((cap_xml =3D virConnectGetCapabilities(priv->conn))) { vshError(ctl, "%s", _("unable to get node capabilities")); return false; } =20 xml =3D virXMLParseStringCtxt(cap_xml, _("(capabilities)"), &ctxt); - if (!xml) { + VIR_UNLESS (xml) { vshError(ctl, "%s", _("unable to get node capabilities")); return false; } @@ -579,7 +579,7 @@ cmdMaxvcpus(vshControl *ctl, const vshCmd *cmd) =20 if ((caps =3D virConnectGetDomainCapabilities(priv->conn, NULL, NULL, = NULL, type, 0))) { - if (!(xml =3D virXMLParseStringCtxt(caps, _("(domainCapabilities)"= ), &ctxt))) + VIR_UNLESS ((xml =3D virXMLParseStringCtxt(caps, _("(domainCapabil= ities)"), &ctxt))) return false; =20 ignore_value(virXPathInt("string(./vcpu[1]/@max)", ctxt, &vcpus)); @@ -675,7 +675,7 @@ cmdNodeCpuMap(vshControl *ctl, const vshCmd *cmd G_GNUC= _UNUSED) if (pretty) { g_autofree char *str =3D virBitmapDataFormat(cpumap, VIR_CPU_MAPLE= N(cpunum)); =20 - if (!str) + VIR_UNLESS (str) return false; vshPrint(ctl, "%s", str); } else { @@ -796,7 +796,7 @@ cmdNodeCpuStats(vshControl *ctl, const vshCmd *cmd) sleep(1); } =20 - if (!flag_percent) { + VIR_UNLESS (flag_percent) { for (i =3D 0; i < VIRSH_CPU_USAGE; i++) { if (present[i]) { vshPrint(ctl, "%-15s %20llu\n", _(virshCPUOutput[i]), @@ -1119,7 +1119,7 @@ vshExtractCPUDefXMLs(vshControl *ctl, =20 xmlStr =3D g_strdup_printf("%s", doc); =20 - if (!(xml =3D virXMLParseStringCtxt(xmlStr, xmlFile, &ctxt))) + VIR_UNLESS ((xml =3D virXMLParseStringCtxt(xmlStr, xmlFile, &ctxt))) return NULL; =20 n =3D virXPathNodeSet("/container/cpu|" @@ -1155,7 +1155,7 @@ vshExtractCPUDefXMLs(vshControl *ctl, } } =20 - if (!(cpus[i] =3D virXMLNodeToString(xml, nodes[i]))) { + VIR_UNLESS ((cpus[i] =3D virXMLNodeToString(xml, nodes[i]))) { vshSaveLibvirtError(); return NULL; } @@ -1209,7 +1209,7 @@ cmdCPUCompare(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) return false; =20 - if (!(cpus =3D vshExtractCPUDefXMLs(ctl, from))) + VIR_UNLESS ((cpus =3D vshExtractCPUDefXMLs(ctl, from))) return false; =20 result =3D virConnectCompareCPU(priv->conn, cpus[0], flags); @@ -1283,10 +1283,10 @@ cmdCPUBaseline(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) return false; =20 - if (!(list =3D vshExtractCPUDefXMLs(ctl, from))) + VIR_UNLESS ((list =3D vshExtractCPUDefXMLs(ctl, from))) return false; =20 - if (!(result =3D virConnectBaselineCPU(priv->conn, (const char **)list, + VIR_UNLESS ((result =3D virConnectBaselineCPU(priv->conn, (const char = **)list, g_strv_length(list), flags))) return false; =20 @@ -1629,7 +1629,7 @@ cmdHypervisorCPUCompare(vshControl *ctl, vshCommandOptStringReq(ctl, cmd, "machine", &machine) < 0) return false; =20 - if (!(cpus =3D vshExtractCPUDefXMLs(ctl, from))) + VIR_UNLESS ((cpus =3D vshExtractCPUDefXMLs(ctl, from))) return false; =20 result =3D virConnectCompareHypervisorCPU(priv->conn, emulator, arch, @@ -1738,7 +1738,7 @@ cmdHypervisorCPUBaseline(vshControl *ctl, vshCommandOptStringReq(ctl, cmd, "machine", &machine) < 0) return false; =20 - if (!(list =3D vshExtractCPUDefXMLs(ctl, from))) + VIR_UNLESS ((list =3D vshExtractCPUDefXMLs(ctl, from))) return false; =20 result =3D virConnectBaselineHypervisorCPU(priv->conn, emulator, arch, diff --git a/tools/virsh-interface.c b/tools/virsh-interface.c index 55d3532c55..2d65425a0d 100644 --- a/tools/virsh-interface.c +++ b/tools/virsh-interface.c @@ -54,7 +54,7 @@ virshCommandOptInterfaceBy(vshControl *ctl, const vshCmd = *cmd, =20 virCheckFlags(VIRSH_BYNAME | VIRSH_BYMAC, NULL); =20 - if (!optname) + VIR_UNLESS (optname) optname =3D "interface"; =20 if (vshCommandOptStringReq(ctl, cmd, optname, &n) < 0) @@ -82,7 +82,7 @@ virshCommandOptInterfaceBy(vshControl *ctl, const vshCmd = *cmd, iface =3D virInterfaceLookupByMACString(priv->conn, n); } =20 - if (!iface) + VIR_UNLESS (iface) vshError(ctl, _("failed to get interface '%s'"), n); =20 return iface; @@ -149,7 +149,7 @@ virshInterfaceSorter(const void *a, const void *b) if (*ia && !*ib) return -1; =20 - if (!*ia) + VIR_UNLESS (*ia) return *ib !=3D NULL; =20 return vshStrcasecmp(virInterfaceGetName(*ia), @@ -260,7 +260,7 @@ virshInterfaceListCollect(vshControl *ctl, =20 /* get active interfaces */ for (i =3D 0; i < nActiveIfaces; i++) { - if (!(iface =3D virInterfaceLookupByName(priv->conn, activeNames[i= ]))) { + VIR_UNLESS ((iface =3D virInterfaceLookupByName(priv->conn, active= Names[i]))) { vshResetLibvirtError(); continue; } @@ -269,7 +269,7 @@ virshInterfaceListCollect(vshControl *ctl, =20 /* get inactive interfaces */ for (i =3D 0; i < nInactiveIfaces; i++) { - if (!(iface =3D virInterfaceLookupByName(priv->conn, inactiveNames= [i]))) { + VIR_UNLESS ((iface =3D virInterfaceLookupByName(priv->conn, inacti= veNames[i]))) { vshResetLibvirtError(); continue; } @@ -301,7 +301,7 @@ virshInterfaceListCollect(vshControl *ctl, VIR_FREE(activeNames); VIR_FREE(inactiveNames); =20 - if (!success) { + VIR_UNLESS (success) { g_clear_pointer(&list, virshInterfaceListFree); } =20 @@ -352,11 +352,11 @@ cmdInterfaceList(vshControl *ctl, const vshCmd *cmd G= _GNUC_UNUSED) flags =3D VIR_CONNECT_LIST_INTERFACES_INACTIVE | VIR_CONNECT_LIST_INTERFACES_ACTIVE; =20 - if (!(list =3D virshInterfaceListCollect(ctl, flags))) + VIR_UNLESS ((list =3D virshInterfaceListCollect(ctl, flags))) return false; =20 table =3D vshTableNew(_("Name"), _("State"), _("MAC Address"), NULL); - if (!table) + VIR_UNLESS (table) goto cleanup; =20 for (i =3D 0; i < list->nifaces; i++) { @@ -407,7 +407,7 @@ cmdInterfaceName(vshControl *ctl, const vshCmd *cmd) { g_autoptr(virshInterface) iface =3D NULL; =20 - if (!(iface =3D virshCommandOptInterfaceBy(ctl, cmd, NULL, NULL, + VIR_UNLESS ((iface =3D virshCommandOptInterfaceBy(ctl, cmd, NULL, NULL, VIRSH_BYMAC))) return false; =20 @@ -443,7 +443,7 @@ cmdInterfaceMAC(vshControl *ctl, const vshCmd *cmd) { g_autoptr(virshInterface) iface =3D NULL; =20 - if (!(iface =3D virshCommandOptInterfaceBy(ctl, cmd, NULL, NULL, + VIR_UNLESS ((iface =3D virshCommandOptInterfaceBy(ctl, cmd, NULL, NULL, VIRSH_BYNAME))) return false; =20 @@ -483,10 +483,10 @@ cmdInterfaceDumpXML(vshControl *ctl, const vshCmd *cm= d) if (vshCommandOptBool(cmd, "inactive")) flags |=3D VIR_INTERFACE_XML_INACTIVE; =20 - if (!(iface =3D virshCommandOptInterface(ctl, cmd, NULL))) + VIR_UNLESS ((iface =3D virshCommandOptInterface(ctl, cmd, NULL))) return false; =20 - if (!(dump =3D virInterfaceGetXMLDesc(iface, flags))) + VIR_UNLESS ((dump =3D virInterfaceGetXMLDesc(iface, flags))) return false; =20 vshPrint(ctl, "%s", dump); @@ -534,7 +534,7 @@ cmdInterfaceDefine(vshControl *ctl, const vshCmd *cmd) if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) return false; =20 - if (!(iface =3D virInterfaceDefineXML(priv->conn, buffer, flags))) { + VIR_UNLESS ((iface =3D virInterfaceDefineXML(priv->conn, buffer, flags= ))) { vshError(ctl, _("Failed to define interface from %s"), from); return false; } @@ -568,7 +568,7 @@ cmdInterfaceUndefine(vshControl *ctl, const vshCmd *cmd) g_autoptr(virshInterface) iface =3D NULL; const char *name; =20 - if (!(iface =3D virshCommandOptInterface(ctl, cmd, &name))) + VIR_UNLESS ((iface =3D virshCommandOptInterface(ctl, cmd, &name))) return false; =20 if (virInterfaceUndefine(iface) < 0) { @@ -604,7 +604,7 @@ cmdInterfaceStart(vshControl *ctl, const vshCmd *cmd) g_autoptr(virshInterface) iface =3D NULL; const char *name; =20 - if (!(iface =3D virshCommandOptInterface(ctl, cmd, &name))) + VIR_UNLESS ((iface =3D virshCommandOptInterface(ctl, cmd, &name))) return false; =20 if (virInterfaceCreate(iface, 0) < 0) { @@ -640,7 +640,7 @@ cmdInterfaceDestroy(vshControl *ctl, const vshCmd *cmd) g_autoptr(virshInterface) iface =3D NULL; const char *name; =20 - if (!(iface =3D virshCommandOptInterface(ctl, cmd, &name))) + VIR_UNLESS ((iface =3D virshCommandOptInterface(ctl, cmd, &name))) return false; =20 if (virInterfaceDestroy(iface, 0) < 0) { @@ -806,7 +806,7 @@ cmdInterfaceBridge(vshControl *ctl, const vshCmd *cmd) virshControl *priv =3D ctl->privData; =20 /* Get a handle to the original device */ - if (!(if_handle =3D virshCommandOptInterfaceBy(ctl, cmd, "interface", + VIR_UNLESS ((if_handle =3D virshCommandOptInterfaceBy(ctl, cmd, "inter= face", &if_name, VIRSH_BYNAME)))= { goto cleanup; } @@ -830,9 +830,9 @@ cmdInterfaceBridge(vshControl *ctl, const vshCmd *cmd) nostart =3D vshCommandOptBool(cmd, "no-start"); =20 /* Get the original interface into an xmlDoc */ - if (!(if_xml =3D virInterfaceGetXMLDesc(if_handle, VIR_INTERFACE_XML_I= NACTIVE))) + VIR_UNLESS ((if_xml =3D virInterfaceGetXMLDesc(if_handle, VIR_INTERFAC= E_XML_INACTIVE))) goto cleanup; - if (!(xml_doc =3D virXMLParseStringCtxt(if_xml, + VIR_UNLESS ((xml_doc =3D virXMLParseStringCtxt(if_xml, _("(interface definition)"), &ct= xt))) { vshError(ctl, _("Failed to parse configuration of %s"), if_name); goto cleanup; @@ -840,7 +840,7 @@ cmdInterfaceBridge(vshControl *ctl, const vshCmd *cmd) top_node =3D ctxt->node; =20 /* Verify that the original device isn't already a bridge. */ - if (!(if_type =3D virXMLPropString(top_node, "type"))) { + VIR_UNLESS ((if_type =3D virXMLPropString(top_node, "type"))) { vshError(ctl, _("Existing device %s has no type"), if_name); goto cleanup; } @@ -859,7 +859,7 @@ cmdInterfaceBridge(vshControl *ctl, const vshCmd *cmd) } =20 /* Create a node under . */ - if (!(br_node =3D xmlNewChild(top_node, NULL, BAD_CAST "bridge", NULL)= )) { + VIR_UNLESS ((br_node =3D xmlNewChild(top_node, NULL, BAD_CAST "bridge"= , NULL))) { vshError(ctl, "%s", _("Failed to create bridge node in xml documen= t")); goto cleanup; } @@ -867,14 +867,14 @@ cmdInterfaceBridge(vshControl *ctl, const vshCmd *cmd) /* Set stp and delay attributes in according to the * commandline options. */ - if (!xmlSetProp(br_node, BAD_CAST "stp", BAD_CAST(stp ? "on" : "off"))= ) { + VIR_UNLESS (xmlSetProp(br_node, BAD_CAST "stp", BAD_CAST(stp ? "on" : = "off"))) { vshError(ctl, "%s", _("Failed to set stp attribute in xml document= ")); goto cleanup; } =20 if (stp) { delay_str =3D g_strdup_printf("%d", delay); - if (!xmlSetProp(br_node, BAD_CAST "delay", BAD_CAST delay_str)) { + VIR_UNLESS (xmlSetProp(br_node, BAD_CAST "delay", BAD_CAST delay_s= tr)) { vshError(ctl, _("Failed to set bridge delay %d in xml document= "), delay); goto cleanup; } @@ -883,12 +883,12 @@ cmdInterfaceBridge(vshControl *ctl, const vshCmd *cmd) /* Change the type of the outer/master interface to "bridge" and the * name to the provided bridge name. */ - if (!xmlSetProp(top_node, BAD_CAST "type", BAD_CAST "bridge")) { + VIR_UNLESS (xmlSetProp(top_node, BAD_CAST "type", BAD_CAST "bridge")) { vshError(ctl, "%s", _("Failed to set bridge interface type to 'bri= dge' in xml document")); goto cleanup; } =20 - if (!xmlSetProp(top_node, BAD_CAST "name", BAD_CAST br_name)) { + VIR_UNLESS (xmlSetProp(top_node, BAD_CAST "name", BAD_CAST br_name)) { vshError(ctl, _("Failed to set master bridge interface name to '%s= ' in xml document"), br_name); goto cleanup; @@ -897,7 +897,7 @@ cmdInterfaceBridge(vshControl *ctl, const vshCmd *cmd) /* Create an node under that uses the * original interface's type and name. */ - if (!(if_node =3D xmlNewChild(br_node, NULL, BAD_CAST "interface", NUL= L))) { + VIR_UNLESS ((if_node =3D xmlNewChild(br_node, NULL, BAD_CAST "interfac= e", NULL))) { vshError(ctl, "%s", _("Failed to create interface node under bridg= e node in xml document")); goto cleanup; } @@ -905,13 +905,13 @@ cmdInterfaceBridge(vshControl *ctl, const vshCmd *cmd) /* set the type of the attached interface to the original * if_type, and the name to the original if_name. */ - if (!xmlSetProp(if_node, BAD_CAST "type", BAD_CAST if_type)) { + VIR_UNLESS (xmlSetProp(if_node, BAD_CAST "type", BAD_CAST if_type)) { vshError(ctl, _("Failed to set new attached interface type to '%s'= in xml document"), if_type); goto cleanup; } =20 - if (!xmlSetProp(if_node, BAD_CAST "name", BAD_CAST if_name)) { + VIR_UNLESS (xmlSetProp(if_node, BAD_CAST "name", BAD_CAST if_name)) { vshError(ctl, _("Failed to set new attached interface name to '%s'= in xml document"), if_name); goto cleanup; @@ -931,7 +931,7 @@ cmdInterfaceBridge(vshControl *ctl, const vshCmd *cmd) virXMLNodeNameEqual(old, "bond") || /* bond stuff to move dow= n */ virXMLNodeNameEqual(old, "vlan"))) { /* vlan stuff to move do= wn */ xmlUnlinkNode(old); - if (!xmlAddChild(if_node, old)) { + VIR_UNLESS (xmlAddChild(if_node, old)) { vshError(ctl, _("Failed to move '%s' element in xml docume= nt"), old->name); xmlFreeNode(old); goto cleanup; @@ -951,7 +951,7 @@ cmdInterfaceBridge(vshControl *ctl, const vshCmd *cmd) /* br_xml is the new interface to define. It will automatically undefi= ne the * independent original interface. */ - if (!(br_handle =3D virInterfaceDefineXML(priv->conn, (char *) br_xml,= 0))) { + VIR_UNLESS ((br_handle =3D virInterfaceDefineXML(priv->conn, (char *) = br_xml, 0))) { vshError(ctl, _("Failed to define new bridge interface %s"), br_name); goto cleanup; @@ -961,7 +961,7 @@ cmdInterfaceBridge(vshControl *ctl, const vshCmd *cmd) br_name, if_name); =20 /* start it up unless requested not to */ - if (!nostart) { + VIR_UNLESS (nostart) { if (virInterfaceCreate(br_handle, 0) < 0) { vshError(ctl, _("Failed to start bridge interface %s"), br_nam= e); goto cleanup; @@ -1023,7 +1023,7 @@ cmdInterfaceUnbridge(vshControl *ctl, const vshCmd *c= md) virshControl *priv =3D ctl->privData; =20 /* Get a handle to the original device */ - if (!(br_handle =3D virshCommandOptInterfaceBy(ctl, cmd, "bridge", + VIR_UNLESS ((br_handle =3D virshCommandOptInterfaceBy(ctl, cmd, "bridg= e", &br_name, VIRSH_BYNAME)))= { goto cleanup; } @@ -1031,9 +1031,9 @@ cmdInterfaceUnbridge(vshControl *ctl, const vshCmd *c= md) nostart =3D vshCommandOptBool(cmd, "no-start"); =20 /* Get the bridge xml into an xmlDoc */ - if (!(br_xml =3D virInterfaceGetXMLDesc(br_handle, VIR_INTERFACE_XML_I= NACTIVE))) + VIR_UNLESS ((br_xml =3D virInterfaceGetXMLDesc(br_handle, VIR_INTERFAC= E_XML_INACTIVE))) goto cleanup; - if (!(xml_doc =3D virXMLParseStringCtxt(br_xml, + VIR_UNLESS ((xml_doc =3D virXMLParseStringCtxt(br_xml, _("(bridge interface definition)= "), &ctxt))) { vshError(ctl, _("Failed to parse configuration of %s"), br_name); @@ -1042,7 +1042,7 @@ cmdInterfaceUnbridge(vshControl *ctl, const vshCmd *c= md) top_node =3D ctxt->node; =20 /* Verify that the device really is a bridge. */ - if (!(if_type =3D virXMLPropString(top_node, "type"))) { + VIR_UNLESS ((if_type =3D virXMLPropString(top_node, "type"))) { vshError(ctl, _("Existing device %s has no type"), br_name); goto cleanup; } @@ -1054,7 +1054,7 @@ cmdInterfaceUnbridge(vshControl *ctl, const vshCmd *c= md) VIR_FREE(if_type); =20 /* verify the name in the XML matches the device name */ - if (!(if_name =3D virXMLPropString(top_node, "name")) || + VIR_UNLESS ((if_name =3D virXMLPropString(top_node, "name")) || STRNEQ(if_name, br_name)) { vshError(ctl, _("Interface name from config %s doesn't match given= supplied name %s"), if_name, br_name); @@ -1073,7 +1073,7 @@ cmdInterfaceUnbridge(vshControl *ctl, const vshCmd *c= md) goto cleanup; } =20 - if (!(if_node =3D virXPathNode("./bridge/interface", ctxt))) { + VIR_UNLESS ((if_node =3D virXPathNode("./bridge/interface", ctxt))) { vshError(ctl, "%s", _("No interface attached to bridge")); goto cleanup; } @@ -1081,23 +1081,23 @@ cmdInterfaceUnbridge(vshControl *ctl, const vshCmd = *cmd) /* Change the type and name of the bridge interface to * the type/name of the attached interface. */ - if (!(if_name =3D virXMLPropString(if_node, "name"))) { + VIR_UNLESS ((if_name =3D virXMLPropString(if_node, "name"))) { vshError(ctl, _("Device attached to bridge %s has no name"), br_na= me); goto cleanup; } =20 - if (!(if_type =3D virXMLPropString(if_node, "type"))) { + VIR_UNLESS ((if_type =3D virXMLPropString(if_node, "type"))) { vshError(ctl, _("Attached device %s has no type"), if_name); goto cleanup; } =20 - if (!xmlSetProp(top_node, BAD_CAST "type", BAD_CAST if_type)) { + VIR_UNLESS (xmlSetProp(top_node, BAD_CAST "type", BAD_CAST if_type)) { vshError(ctl, _("Failed to set interface type to '%s' in xml docum= ent"), if_type); goto cleanup; } =20 - if (!xmlSetProp(top_node, BAD_CAST "name", BAD_CAST if_name)) { + VIR_UNLESS (xmlSetProp(top_node, BAD_CAST "name", BAD_CAST if_name)) { vshError(ctl, _("Failed to set interface name to '%s' in xml docum= ent"), if_name); goto cleanup; @@ -1117,7 +1117,7 @@ cmdInterfaceUnbridge(vshControl *ctl, const vshCmd *c= md) virXMLNodeNameEqual(old, "bond") || /* bond stuff to move dow= n */ virXMLNodeNameEqual(old, "vlan"))) { /* vlan stuff to move do= wn */ xmlUnlinkNode(old); - if (!xmlAddChild(top_node, old)) { + VIR_UNLESS (xmlAddChild(top_node, old)) { vshError(ctl, _("Failed to move '%s' element in xml docume= nt"), old->name); xmlFreeNode(old); goto cleanup; @@ -1148,7 +1148,7 @@ cmdInterfaceUnbridge(vshControl *ctl, const vshCmd *c= md) =20 /* if_xml is the new interface to define. */ - if (!(if_handle =3D virInterfaceDefineXML(priv->conn, (char *) if_xml,= 0))) { + VIR_UNLESS ((if_handle =3D virInterfaceDefineXML(priv->conn, (char *) = if_xml, 0))) { vshError(ctl, _("Failed to define new interface %s"), if_name); goto cleanup; } @@ -1157,7 +1157,7 @@ cmdInterfaceUnbridge(vshControl *ctl, const vshCmd *c= md) if_name, br_name); =20 /* unless requested otherwise, undefine the bridge device */ - if (!nostart) { + VIR_UNLESS (nostart) { if (virInterfaceCreate(if_handle, 0) < 0) { vshError(ctl, _("Failed to start interface %s"), if_name); goto cleanup; diff --git a/tools/virsh-network.c b/tools/virsh-network.c index 97a160f772..a87c7b599e 100644 --- a/tools/virsh-network.c +++ b/tools/virsh-network.c @@ -96,7 +96,7 @@ virshCommandOptNetworkBy(vshControl *ctl, const vshCmd *c= md, network =3D virNetworkLookupByName(priv->conn, n); } =20 - if (!network) + VIR_UNLESS (network) vshError(ctl, _("failed to get network '%s'"), n); =20 return network; @@ -125,7 +125,7 @@ virshCommandOptNetworkPort(vshControl *ctl, const vshCm= d *cmd, cmd->def->name, optname); port =3D virNetworkPortLookupByUUIDString(net, n); =20 - if (!port) + VIR_UNLESS (port) vshError(ctl, _("failed to get network port '%s'"), n); =20 return port; @@ -160,7 +160,7 @@ cmdNetworkAutostart(vshControl *ctl, const vshCmd *cmd) const char *name; int autostart; =20 - if (!(network =3D virshCommandOptNetwork(ctl, cmd, &name))) + VIR_UNLESS ((network =3D virshCommandOptNetwork(ctl, cmd, &name))) return false; =20 autostart =3D !vshCommandOptBool(cmd, "disable"); @@ -226,7 +226,7 @@ cmdNetworkCreate(vshControl *ctl, const vshCmd *cmd) else network =3D virNetworkCreateXML(priv->conn, buffer); =20 - if (!network) { + VIR_UNLESS (network) { vshError(ctl, _("Failed to create network from %s"), from); return false; } @@ -282,7 +282,7 @@ cmdNetworkDefine(vshControl *ctl, const vshCmd *cmd) else network =3D virNetworkDefineXML(priv->conn, buffer); =20 - if (!network) { + VIR_UNLESS (network) { vshError(ctl, _("Failed to define network from %s"), from); return false; } @@ -317,7 +317,7 @@ cmdNetworkDestroy(vshControl *ctl, const vshCmd *cmd) bool ret =3D true; const char *name; =20 - if (!(network =3D virshCommandOptNetwork(ctl, cmd, &name))) + VIR_UNLESS ((network =3D virshCommandOptNetwork(ctl, cmd, &name))) return false; =20 if (virNetworkDestroy(network) =3D=3D 0) { @@ -359,13 +359,13 @@ cmdNetworkDumpXML(vshControl *ctl, const vshCmd *cmd) g_autofree char *dump =3D NULL; unsigned int flags =3D 0; =20 - if (!(network =3D virshCommandOptNetwork(ctl, cmd, NULL))) + VIR_UNLESS ((network =3D virshCommandOptNetwork(ctl, cmd, NULL))) return false; =20 if (vshCommandOptBool(cmd, "inactive")) flags |=3D VIR_NETWORK_XML_INACTIVE; =20 - if (!(dump =3D virNetworkGetXMLDesc(network, flags))) { + VIR_UNLESS ((dump =3D virNetworkGetXMLDesc(network, flags))) { return false; } =20 @@ -401,7 +401,7 @@ cmdNetworkInfo(vshControl *ctl, const vshCmd *cmd) int active =3D -1; char *bridge =3D NULL; =20 - if (!(network =3D virshCommandOptNetwork(ctl, cmd, NULL))) + VIR_UNLESS ((network =3D virshCommandOptNetwork(ctl, cmd, NULL))) return false; =20 vshPrint(ctl, "%-15s %s\n", _("Name:"), virNetworkGetName(network)); @@ -441,7 +441,7 @@ virshNetworkSorter(const void *a, const void *b) if (*na && !*nb) return -1; =20 - if (!*na) + VIR_UNLESS (*na) return *nb !=3D NULL; =20 return vshStrcasecmp(virNetworkGetName(*na), @@ -570,14 +570,14 @@ virshNetworkListCollect(vshControl *ctl, =20 /* get active networks */ for (i =3D 0; i < nActiveNets; i++) { - if (!(net =3D virNetworkLookupByName(priv->conn, names[i]))) + VIR_UNLESS ((net =3D virNetworkLookupByName(priv->conn, names[i]))) continue; list->nets[list->nnets++] =3D net; } =20 /* get inactive networks */ for (i =3D 0; i < nInactiveNets; i++) { - if (!(net =3D virNetworkLookupByName(priv->conn, names[i]))) + VIR_UNLESS ((net =3D virNetworkLookupByName(priv->conn, names[i]))) continue; list->nets[list->nnets++] =3D net; } @@ -639,7 +639,7 @@ virshNetworkListCollect(vshControl *ctl, VIR_FREE(names[i]); VIR_FREE(names); =20 - if (!success) { + VIR_UNLESS (success) { g_clear_pointer(&list, virshNetworkListFree); } =20 @@ -738,13 +738,13 @@ cmdNetworkList(vshControl *ctl, const vshCmd *cmd G_G= NUC_UNUSED) if (!optUUID && !optName) optTable =3D true; =20 - if (!(list =3D virshNetworkListCollect(ctl, flags))) + VIR_UNLESS ((list =3D virshNetworkListCollect(ctl, flags))) return false; =20 if (optTable) { table =3D vshTableNew(_("Name"), _("State"), _("Autostart"), _("Persistent"), NULL); - if (!table) + VIR_UNLESS (table) goto cleanup; } =20 @@ -817,7 +817,7 @@ cmdNetworkName(vshControl *ctl, const vshCmd *cmd) { g_autoptr(virshNetwork) network =3D NULL; =20 - if (!(network =3D virshCommandOptNetworkBy(ctl, cmd, NULL, + VIR_UNLESS ((network =3D virshCommandOptNetworkBy(ctl, cmd, NULL, VIRSH_BYUUID))) return false; =20 @@ -850,7 +850,7 @@ cmdNetworkStart(vshControl *ctl, const vshCmd *cmd) bool ret =3D true; const char *name =3D NULL; =20 - if (!(network =3D virshCommandOptNetwork(ctl, cmd, &name))) + VIR_UNLESS ((network =3D virshCommandOptNetwork(ctl, cmd, &name))) return false; =20 if (virNetworkCreate(network) =3D=3D 0) { @@ -887,7 +887,7 @@ cmdNetworkUndefine(vshControl *ctl, const vshCmd *cmd) bool ret =3D true; const char *name; =20 - if (!(network =3D virshCommandOptNetwork(ctl, cmd, &name))) + VIR_UNLESS ((network =3D virshCommandOptNetwork(ctl, cmd, &name))) return false; =20 if (virNetworkUndefine(network) =3D=3D 0) { @@ -972,7 +972,7 @@ cmdNetworkUpdate(vshControl *ctl, const vshCmd *cmd) VSH_EXCLUSIVE_OPTIONS("current", "live"); VSH_EXCLUSIVE_OPTIONS("current", "config"); =20 - if (!(network =3D virshCommandOptNetwork(ctl, cmd, NULL))) + VIR_UNLESS ((network =3D virshCommandOptNetwork(ctl, cmd, NULL))) return false; =20 if (vshCommandOptStringReq(ctl, cmd, "command", &commandStr) < 0) @@ -1085,7 +1085,7 @@ cmdNetworkUuid(vshControl *ctl, const vshCmd *cmd) g_autoptr(virshNetwork) network =3D NULL; char uuid[VIR_UUID_STRING_BUFLEN]; =20 - if (!(network =3D virshCommandOptNetworkBy(ctl, cmd, NULL, + VIR_UNLESS ((network =3D virshCommandOptNetworkBy(ctl, cmd, NULL, VIRSH_BYNAME))) return false; =20 @@ -1224,7 +1224,7 @@ vshEventLifecyclePrint(virConnectPtr conn G_GNUC_UNUS= ED, } =20 data->count++; - if (!data->loop) + VIR_UNLESS (data->loop) vshEventDone(data->ctl); } =20 @@ -1292,7 +1292,7 @@ cmdNetworkEvent(vshControl *ctl, const vshCmd *cmd) =20 if (vshCommandOptStringReq(ctl, cmd, "event", &eventName) < 0) return false; - if (!eventName) { + VIR_UNLESS (eventName) { vshError(ctl, "%s", _("either --list or --event is required= ")); return false; } @@ -1379,7 +1379,7 @@ virshNetworkDHCPLeaseSorter(const void *a, const void= *b) if (*lease1 && !*lease2) return -1; =20 - if (!*lease1) + VIR_UNLESS (*lease1) return *lease2 !=3D NULL; =20 return vshStrcasecmp((*lease1)->mac, (*lease2)->mac); @@ -1401,7 +1401,7 @@ cmdNetworkDHCPLeases(vshControl *ctl, const vshCmd *c= md) if (vshCommandOptStringReq(ctl, cmd, "mac", &mac) < 0) return false; =20 - if (!(network =3D virshCommandOptNetwork(ctl, cmd, &name))) + VIR_UNLESS ((network =3D virshCommandOptNetwork(ctl, cmd, &name))) return false; =20 if ((nleases =3D virNetworkGetDHCPLeases(network, mac, &leases, flags)= ) < 0) { @@ -1415,7 +1415,7 @@ cmdNetworkDHCPLeases(vshControl *ctl, const vshCmd *c= md) table =3D vshTableNew(_("Expiry Time"), _("MAC address"), _("Protocol"= ), _("IP address"), _("Hostname"), _("Client ID or DU= ID"), NULL); - if (!table) + VIR_UNLESS (table) goto cleanup; =20 for (i =3D 0; i < nleases; i++) { @@ -1554,10 +1554,10 @@ cmdNetworkPortDumpXML(vshControl *ctl, const vshCmd= *cmd) g_autofree char *dump =3D NULL; unsigned int flags =3D 0; =20 - if (!(network =3D virshCommandOptNetwork(ctl, cmd, NULL))) + VIR_UNLESS ((network =3D virshCommandOptNetwork(ctl, cmd, NULL))) goto cleanup; =20 - if (!(port =3D virshCommandOptNetworkPort(ctl, cmd, network, NULL))) + VIR_UNLESS ((port =3D virshCommandOptNetworkPort(ctl, cmd, network, NU= LL))) goto cleanup; =20 dump =3D virNetworkPortGetXMLDesc(port, flags); @@ -1602,10 +1602,10 @@ cmdNetworkPortDelete(vshControl *ctl, const vshCmd = *cmd) bool ret =3D true; char uuidstr[VIR_UUID_STRING_BUFLEN]; =20 - if (!(network =3D virshCommandOptNetwork(ctl, cmd, NULL))) + VIR_UNLESS ((network =3D virshCommandOptNetwork(ctl, cmd, NULL))) goto cleanup; =20 - if (!(port =3D virshCommandOptNetworkPort(ctl, cmd, network, NULL))) + VIR_UNLESS ((port =3D virshCommandOptNetworkPort(ctl, cmd, network, NU= LL))) goto cleanup; =20 if (virNetworkPortGetUUIDString(port, uuidstr) < 0) @@ -1637,7 +1637,7 @@ virshNetworkPortSorter(const void *a, const void *b) if (*na && !*nb) return -1; =20 - if (!*na) + VIR_UNLESS (*na) return *nb !=3D NULL; =20 if (virNetworkPortGetUUID(*na, uuida) < 0 || @@ -1677,7 +1677,7 @@ virshNetworkPortListCollect(vshControl *ctl, g_autoptr(virshNetwork) network =3D NULL; bool success =3D false; =20 - if (!(network =3D virshCommandOptNetwork(ctl, cmd, NULL))) + VIR_UNLESS ((network =3D virshCommandOptNetwork(ctl, cmd, NULL))) goto cleanup; =20 if ((ret =3D virNetworkListAllPorts(network, @@ -1695,7 +1695,7 @@ virshNetworkPortListCollect(vshControl *ctl, success =3D true; =20 cleanup: - if (!success) { + VIR_UNLESS (success) { g_clear_pointer(&list, virshNetworkPortListFree); } =20 @@ -1747,15 +1747,15 @@ cmdNetworkPortList(vshControl *ctl, const vshCmd *c= md) return false; } =20 - if (!optUUID) + VIR_UNLESS (optUUID) optTable =3D true; =20 - if (!(list =3D virshNetworkPortListCollect(ctl, cmd, flags))) + VIR_UNLESS ((list =3D virshNetworkPortListCollect(ctl, cmd, flags))) return false; =20 if (optTable) { table =3D vshTableNew(_("UUID"), NULL); - if (!table) + VIR_UNLESS (table) goto cleanup; } =20 diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c index d01bdf699c..68e293339f 100644 --- a/tools/virsh-nodedev.c +++ b/tools/virsh-nodedev.c @@ -67,7 +67,7 @@ cmdNodeDeviceCreate(vshControl *ctl, const vshCmd *cmd) if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) return false; =20 - if (!(dev =3D virNodeDeviceCreateXML(priv->conn, buffer, 0))) { + VIR_UNLESS ((dev =3D virNodeDeviceCreateXML(priv->conn, buffer, 0))) { vshError(ctl, _("Failed to create node device from %s"), from); return false; } @@ -129,7 +129,7 @@ vshFindNodeDevice(vshControl *ctl, const char *value) dev =3D virNodeDeviceLookupByName(priv->conn, value); } =20 - if (!dev) { + VIR_UNLESS (dev) { vshError(ctl, "%s '%s'", _("Could not find matching device"), valu= e); return NULL; } @@ -147,7 +147,7 @@ cmdNodeDeviceDestroy(vshControl *ctl, const vshCmd *cmd) return false; =20 dev =3D vshFindNodeDevice(ctl, device_value); - if (!dev) + VIR_UNLESS (dev) return false; =20 if (virNodeDeviceDestroy(dev) =3D=3D 0) { @@ -183,7 +183,7 @@ virshNodeDeviceSorter(const void *a, const void *b) if (*na && !*nb) return -1; =20 - if (!*na) + VIR_UNLESS (*na) return *nb !=3D NULL; =20 return vshStrcasecmp(virNodeDeviceGetName(*na), @@ -268,7 +268,7 @@ virshNodeDeviceListCollect(vshControl *ctl, =20 /* get the node devices */ for (i =3D 0; i < ndevices; i++) { - if (!(device =3D virNodeDeviceLookupByName(priv->conn, names[i]))) + VIR_UNLESS ((device =3D virNodeDeviceLookupByName(priv->conn, name= s[i]))) continue; list->devices[list->ndevices++] =3D device; } @@ -276,7 +276,7 @@ virshNodeDeviceListCollect(vshControl *ctl, /* truncate domains that weren't found */ deleted =3D ndevices - list->ndevices; =20 - if (!capnames) + VIR_UNLESS (capnames) goto finished; =20 /* filter the list if the list was acquired by fallback means */ @@ -313,7 +313,7 @@ virshNodeDeviceListCollect(vshControl *ctl, } } =20 - if (!match) + VIR_UNLESS (match) goto remove_entry; =20 /* the device matched all filters, it may stay */ @@ -342,7 +342,7 @@ virshNodeDeviceListCollect(vshControl *ctl, VIR_FREE(names[i]); VIR_FREE(names); =20 - if (!success) { + VIR_UNLESS (success) { g_clear_pointer(&list, virshNodeDeviceListFree); } =20 @@ -496,10 +496,10 @@ cmdNodeListDevices(vshControl *ctl, const vshCmd *cmd= G_GNUC_UNUSED) =20 if (inactive || all) flags |=3D VIR_CONNECT_LIST_NODE_DEVICES_INACTIVE; - if (!inactive) + VIR_UNLESS (inactive) flags |=3D VIR_CONNECT_LIST_NODE_DEVICES_ACTIVE; =20 - if (!(list =3D virshNodeDeviceListCollect(ctl, caps, ncaps, flags))) { + VIR_UNLESS ((list =3D virshNodeDeviceListCollect(ctl, caps, ncaps, fla= gs))) { ret =3D false; goto cleanup; } @@ -580,10 +580,10 @@ cmdNodeDeviceDumpXML(vshControl *ctl, const vshCmd *c= md) =20 device =3D vshFindNodeDevice(ctl, device_value); =20 - if (!device) + VIR_UNLESS (device) return false; =20 - if (!(xml =3D virNodeDeviceGetXMLDesc(device, 0))) + VIR_UNLESS ((xml =3D virNodeDeviceGetXMLDesc(device, 0))) return false; =20 vshPrint(ctl, "%s\n", xml); @@ -632,7 +632,7 @@ cmdNodeDeviceDetach(vshControl *ctl, const vshCmd *cmd) =20 ignore_value(vshCommandOptStringQuiet(ctl, cmd, "driver", &driverName)= ); =20 - if (!(device =3D virNodeDeviceLookupByName(priv->conn, name))) { + VIR_UNLESS ((device =3D virNodeDeviceLookupByName(priv->conn, name))) { vshError(ctl, _("Could not find matching device '%s'"), name); return false; } @@ -691,7 +691,7 @@ cmdNodeDeviceReAttach(vshControl *ctl, const vshCmd *cm= d) if (vshCommandOptStringReq(ctl, cmd, "device", &name) < 0) return false; =20 - if (!(device =3D virNodeDeviceLookupByName(priv->conn, name))) { + VIR_UNLESS ((device =3D virNodeDeviceLookupByName(priv->conn, name))) { vshError(ctl, _("Could not find matching device '%s'"), name); return false; } @@ -741,7 +741,7 @@ cmdNodeDeviceReset(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptStringReq(ctl, cmd, "device", &name) < 0) return false; =20 - if (!(device =3D virNodeDeviceLookupByName(priv->conn, name))) { + VIR_UNLESS ((device =3D virNodeDeviceLookupByName(priv->conn, name))) { vshError(ctl, _("Could not find matching device '%s'"), name); return false; } @@ -810,7 +810,7 @@ vshEventLifecyclePrint(virConnectPtr conn G_GNUC_UNUSED, } =20 data->count++; - if (!data->loop) + VIR_UNLESS (data->loop) vshEventDone(data->ctl); } =20 @@ -841,7 +841,7 @@ vshEventGenericPrint(virConnectPtr conn G_GNUC_UNUSED, } =20 data->count++; - if (!data->loop) + VIR_UNLESS (data->loop) vshEventDone(data->ctl); } =20 @@ -916,7 +916,7 @@ cmdNodeDeviceEvent(vshControl *ctl, const vshCmd *cmd) =20 if (vshCommandOptStringReq(ctl, cmd, "event", &eventName) < 0) return false; - if (!eventName) { + VIR_UNLESS (eventName) { vshError(ctl, "%s", _("either --list or --event is required= ")); return false; } @@ -940,7 +940,7 @@ cmdNodeDeviceEvent(vshControl *ctl, const vshCmd *cmd) return false; =20 if (device_value) { - if (!(dev =3D virNodeDeviceLookupByName(priv->conn, device_value))= ) { + VIR_UNLESS ((dev =3D virNodeDeviceLookupByName(priv->conn, device_= value))) { vshError(ctl, "%s '%s'", _("Could not find matching device"), device_value); goto cleanup; @@ -1012,7 +1012,7 @@ cmdNodeDeviceUndefine(vshControl *ctl, const vshCmd *= cmd G_GNUC_UNUSED) =20 dev =3D vshFindNodeDevice(ctl, device_value); =20 - if (!dev) + VIR_UNLESS (dev) return false; =20 if (virNodeDeviceUndefine(dev, 0) < 0) { @@ -1060,7 +1060,7 @@ cmdNodeDeviceDefine(vshControl *ctl, const vshCmd *cm= d G_GNUC_UNUSED) if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) return false; =20 - if (!(dev =3D virNodeDeviceDefineXML(priv->conn, buffer, 0))) { + VIR_UNLESS ((dev =3D virNodeDeviceDefineXML(priv->conn, buffer, 0))) { vshError(ctl, _("Failed to define node device from '%s'"), from); return false; } @@ -1105,7 +1105,7 @@ cmdNodeDeviceStart(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptStringReq(ctl, cmd, "device", &name) < 0) return false; =20 - if (!(device =3D virNodeDeviceLookupByName(priv->conn, name))) { + VIR_UNLESS ((device =3D virNodeDeviceLookupByName(priv->conn, name))) { vshError(ctl, _("Could not find matching device '%s'"), name); return false; } @@ -1160,7 +1160,7 @@ cmdNodeDeviceAutostart(vshControl *ctl, const vshCmd = *cmd) =20 dev =3D vshFindNodeDevice(ctl, name); =20 - if (!dev) + VIR_UNLESS (dev) return false; =20 autostart =3D !vshCommandOptBool(cmd, "disable"); @@ -1219,7 +1219,7 @@ cmdNodeDeviceInfo(vshControl *ctl, const vshCmd *cmd) =20 device =3D vshFindNodeDevice(ctl, device_value); =20 - if (!device) + VIR_UNLESS (device) return false; =20 parent =3D virNodeDeviceGetParent(device); diff --git a/tools/virsh-nwfilter.c b/tools/virsh-nwfilter.c index 5a9e57e3f5..e260a1c28d 100644 --- a/tools/virsh-nwfilter.c +++ b/tools/virsh-nwfilter.c @@ -60,7 +60,7 @@ virshCommandOptNWFilterBy(vshControl *ctl, const vshCmd *= cmd, nwfilter =3D virNWFilterLookupByName(priv->conn, n); } =20 - if (!nwfilter) + VIR_UNLESS (nwfilter) vshError(ctl, _("failed to get nwfilter '%s'"), n); =20 return nwfilter; @@ -153,7 +153,7 @@ cmdNWFilterUndefine(vshControl *ctl, const vshCmd *cmd) bool ret =3D true; const char *name; =20 - if (!(nwfilter =3D virshCommandOptNWFilter(ctl, cmd, &name))) + VIR_UNLESS ((nwfilter =3D virshCommandOptNWFilter(ctl, cmd, &name))) return false; =20 if (virNWFilterUndefine(nwfilter) =3D=3D 0) { @@ -196,7 +196,7 @@ cmdNWFilterDumpXML(vshControl *ctl, const vshCmd *cmd) bool ret =3D true; g_autofree char *dump =3D NULL; =20 - if (!(nwfilter =3D virshCommandOptNWFilter(ctl, cmd, NULL))) + VIR_UNLESS ((nwfilter =3D virshCommandOptNWFilter(ctl, cmd, NULL))) return false; =20 dump =3D virNWFilterGetXMLDesc(nwfilter, 0); @@ -218,7 +218,7 @@ virshNWFilterSorter(const void *a, const void *b) if (*fa && !*fb) return -1; =20 - if (!*fa) + VIR_UNLESS (*fa) return *fb !=3D NULL; =20 return vshStrcasecmp(virNWFilterGetName(*fa), @@ -303,7 +303,7 @@ virshNWFilterListCollect(vshControl *ctl, =20 /* get the network filters */ for (i =3D 0; i < nfilters; i++) { - if (!(filter =3D virNWFilterLookupByName(priv->conn, names[i]))) + VIR_UNLESS ((filter =3D virNWFilterLookupByName(priv->conn, names[= i]))) continue; list->filters[list->nfilters++] =3D filter; } @@ -328,7 +328,7 @@ virshNWFilterListCollect(vshControl *ctl, VIR_FREE(names[i]); VIR_FREE(names); =20 - if (!success) { + VIR_UNLESS (success) { g_clear_pointer(&list, virshNWFilterListFree); } =20 @@ -361,11 +361,11 @@ cmdNWFilterList(vshControl *ctl, const vshCmd *cmd G_= GNUC_UNUSED) struct virshNWFilterList *list =3D NULL; g_autoptr(vshTable) table =3D NULL; =20 - if (!(list =3D virshNWFilterListCollect(ctl, 0))) + VIR_UNLESS ((list =3D virshNWFilterListCollect(ctl, 0))) return false; =20 table =3D vshTableNew(_("UUID"), _("Name"), NULL); - if (!table) + VIR_UNLESS (table) goto cleanup; =20 for (i =3D 0; i < list->nfilters; i++) { @@ -471,7 +471,7 @@ virshCommandOptNWFilterBindingBy(vshControl *ctl, cmd->def->name, optname); binding =3D virNWFilterBindingLookupByPortDev(priv->conn, n); =20 - if (!binding) + VIR_UNLESS (binding) vshError(ctl, _("failed to get nwfilter binding '%s'"), n); =20 return binding; @@ -522,7 +522,7 @@ cmdNWFilterBindingCreate(vshControl *ctl, const vshCmd = *cmd) binding =3D virNWFilterBindingCreateXML(priv->conn, buffer, flags); VIR_FREE(buffer); =20 - if (!binding) { + VIR_UNLESS (binding) { vshError(ctl, _("Failed to create network filter from %s"), from); return false; } @@ -564,7 +564,7 @@ cmdNWFilterBindingDelete(vshControl *ctl, const vshCmd = *cmd) bool ret =3D true; const char *portdev; =20 - if (!(binding =3D virshCommandOptNWFilterBinding(ctl, cmd, &portdev))) + VIR_UNLESS ((binding =3D virshCommandOptNWFilterBinding(ctl, cmd, &por= tdev))) return false; =20 if (virNWFilterBindingDelete(binding) =3D=3D 0) { @@ -609,7 +609,7 @@ cmdNWFilterBindingDumpXML(vshControl *ctl, const vshCmd= *cmd) bool ret =3D true; g_autofree char *dump =3D NULL; =20 - if (!(binding =3D virshCommandOptNWFilterBinding(ctl, cmd, NULL))) + VIR_UNLESS ((binding =3D virshCommandOptNWFilterBinding(ctl, cmd, NULL= ))) return false; =20 dump =3D virNWFilterBindingGetXMLDesc(binding, 0); @@ -633,7 +633,7 @@ virshNWFilterBindingSorter(const void *a, const void *b) if (*fa && !*fb) return -1; =20 - if (!*fa) + VIR_UNLESS (*fa) return *fb !=3D NULL; =20 return vshStrcasecmp(virNWFilterBindingGetPortDev(*fa), @@ -690,7 +690,7 @@ virshNWFilterBindingListCollect(vshControl *ctl, success =3D true; =20 cleanup: - if (!success) { + VIR_UNLESS (success) { g_clear_pointer(&list, virshNWFilterBindingListFree); } =20 @@ -723,11 +723,11 @@ cmdNWFilterBindingList(vshControl *ctl, const vshCmd = *cmd G_GNUC_UNUSED) struct virshNWFilterBindingList *list =3D NULL; g_autoptr(vshTable) table =3D NULL; =20 - if (!(list =3D virshNWFilterBindingListCollect(ctl, 0))) + VIR_UNLESS ((list =3D virshNWFilterBindingListCollect(ctl, 0))) return false; =20 table =3D vshTableNew(_("Port Dev"), _("Filter"), NULL); - if (!table) + VIR_UNLESS (table) goto cleanup; =20 for (i =3D 0; i < list->nbindings; i++) { diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c index 7e7a8d511f..4026f9beb3 100644 --- a/tools/virsh-pool.c +++ b/tools/virsh-pool.c @@ -188,7 +188,7 @@ virshCommandOptPoolBy(vshControl *ctl, const vshCmd *cm= d, const char *optname, pool =3D virStoragePoolLookupByName(priv->conn, n); } =20 - if (!pool) + VIR_UNLESS (pool) vshError(ctl, _("failed to get pool '%s'"), n); =20 return pool; @@ -224,7 +224,7 @@ cmdPoolAutostart(vshControl *ctl, const vshCmd *cmd) const char *name; int autostart; =20 - if (!(pool =3D virshCommandOptPool(ctl, cmd, "pool", &name))) + VIR_UNLESS ((pool =3D virshCommandOptPool(ctl, cmd, "pool", &name))) return false; =20 autostart =3D !vshCommandOptBool(cmd, "disable"); @@ -299,7 +299,7 @@ cmdPoolCreate(vshControl *ctl, const vshCmd *cmd) if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) return false; =20 - if (!(pool =3D virStoragePoolCreateXML(priv->conn, buffer, flags))) { + VIR_UNLESS ((pool =3D virStoragePoolCreateXML(priv->conn, buffer, flag= s))) { vshError(ctl, _("Failed to create pool from %s"), from); return false; } @@ -484,7 +484,7 @@ cmdPoolCreateAs(vshControl *ctl, const vshCmd *cmd) if (no_overwrite) flags |=3D VIR_STORAGE_POOL_CREATE_WITH_BUILD_NO_OVERWRITE; =20 - if (!virshBuildPoolXML(ctl, cmd, &name, &xml)) + VIR_UNLESS (virshBuildPoolXML(ctl, cmd, &name, &xml)) return false; =20 if (printXML) { @@ -492,7 +492,7 @@ cmdPoolCreateAs(vshControl *ctl, const vshCmd *cmd) return true; } =20 - if (!(pool =3D virStoragePoolCreateXML(priv->conn, xml, flags))) { + VIR_UNLESS ((pool =3D virStoragePoolCreateXML(priv->conn, xml, flags))= ) { vshError(ctl, _("Failed to create pool %s"), name); return false; } @@ -542,7 +542,7 @@ cmdPoolDefine(vshControl *ctl, const vshCmd *cmd) if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) return false; =20 - if (!(pool =3D virStoragePoolDefineXML(priv->conn, buffer, flags))) { + VIR_UNLESS ((pool =3D virStoragePoolDefineXML(priv->conn, buffer, flag= s))) { vshError(ctl, _("Failed to define pool from %s"), from); return false; } @@ -574,7 +574,7 @@ cmdPoolDefineAs(vshControl *ctl, const vshCmd *cmd) bool printXML =3D vshCommandOptBool(cmd, "print-xml"); virshControl *priv =3D ctl->privData; =20 - if (!virshBuildPoolXML(ctl, cmd, &name, &xml)) + VIR_UNLESS (virshBuildPoolXML(ctl, cmd, &name, &xml)) return false; =20 if (printXML) { @@ -582,7 +582,7 @@ cmdPoolDefineAs(vshControl *ctl, const vshCmd *cmd) return true; } =20 - if (!(pool =3D virStoragePoolDefineXML(priv->conn, xml, 0))) { + VIR_UNLESS ((pool =3D virStoragePoolDefineXML(priv->conn, xml, 0))) { vshError(ctl, _("Failed to define pool %s"), name); return false; } @@ -620,7 +620,7 @@ cmdPoolBuild(vshControl *ctl, const vshCmd *cmd) const char *name; unsigned int flags =3D 0; =20 - if (!(pool =3D virshCommandOptPool(ctl, cmd, "pool", &name))) + VIR_UNLESS ((pool =3D virshCommandOptPool(ctl, cmd, "pool", &name))) return false; =20 if (vshCommandOptBool(cmd, "no-overwrite")) @@ -665,7 +665,7 @@ cmdPoolDestroy(vshControl *ctl, const vshCmd *cmd) bool ret =3D true; const char *name; =20 - if (!(pool =3D virshCommandOptPool(ctl, cmd, "pool", &name))) + VIR_UNLESS ((pool =3D virshCommandOptPool(ctl, cmd, "pool", &name))) return false; =20 if (virStoragePoolDestroy(pool) =3D=3D 0) { @@ -704,7 +704,7 @@ cmdPoolDelete(vshControl *ctl, const vshCmd *cmd) bool ret =3D true; const char *name; =20 - if (!(pool =3D virshCommandOptPool(ctl, cmd, "pool", &name))) + VIR_UNLESS ((pool =3D virshCommandOptPool(ctl, cmd, "pool", &name))) return false; =20 if (virStoragePoolDelete(pool, 0) =3D=3D 0) { @@ -743,7 +743,7 @@ cmdPoolRefresh(vshControl *ctl, const vshCmd *cmd) bool ret =3D true; const char *name; =20 - if (!(pool =3D virshCommandOptPool(ctl, cmd, "pool", &name))) + VIR_UNLESS ((pool =3D virshCommandOptPool(ctl, cmd, "pool", &name))) return false; =20 if (virStoragePoolRefresh(pool, 0) =3D=3D 0) { @@ -791,7 +791,7 @@ cmdPoolDumpXML(vshControl *ctl, const vshCmd *cmd) if (inactive) flags |=3D VIR_STORAGE_XML_INACTIVE; =20 - if (!(pool =3D virshCommandOptPool(ctl, cmd, "pool", NULL))) + VIR_UNLESS ((pool =3D virshCommandOptPool(ctl, cmd, "pool", NULL))) return false; =20 dump =3D virStoragePoolGetXMLDesc(pool, flags); @@ -813,7 +813,7 @@ virshStoragePoolSorter(const void *a, const void *b) if (*pa && !*pb) return -1; =20 - if (!*pa) + VIR_UNLESS (*pa) return *pb !=3D NULL; =20 return vshStrcasecmp(virStoragePoolGetName(*pa), @@ -942,14 +942,14 @@ virshStoragePoolListCollect(vshControl *ctl, =20 /* get active pools */ for (i =3D 0; i < nActivePools; i++) { - if (!(pool =3D virStoragePoolLookupByName(priv->conn, names[i]))) + VIR_UNLESS ((pool =3D virStoragePoolLookupByName(priv->conn, names= [i]))) continue; list->pools[list->npools++] =3D pool; } =20 /* get inactive pools */ for (i =3D 0; i < nInactivePools; i++) { - if (!(pool =3D virStoragePoolLookupByName(priv->conn, names[i]))) + VIR_UNLESS ((pool =3D virStoragePoolLookupByName(priv->conn, names= [i]))) continue; list->pools[list->npools++] =3D pool; } @@ -1011,7 +1011,7 @@ virshStoragePoolListCollect(vshControl *ctl, for (i =3D 0; i < nAllPools; i++) VIR_FREE(names[i]); =20 - if (!success) { + VIR_UNLESS (success) { g_clear_pointer(&list, virshStoragePoolListFree); } =20 @@ -1218,7 +1218,7 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd G_GNUC= _UNUSED) } } =20 - if (!(list =3D virshStoragePoolListCollect(ctl, flags))) + VIR_UNLESS ((list =3D virshStoragePoolListCollect(ctl, flags))) goto cleanup; =20 poolInfoTexts =3D g_new0(struct poolInfoText, list->npools); @@ -1301,7 +1301,7 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd G_GNUC= _UNUSED) */ =20 /* Output basic info then return if --details option not selected */ - if (!details) { + VIR_UNLESS (details) { if (uuid || name) { for (i =3D 0; i < list->npools; i++) { if (uuid) { @@ -1321,7 +1321,7 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd G_GNUC= _UNUSED) =20 /* Output old style header */ table =3D vshTableNew(_("Name"), _("State"), _("Autostart"), NULL); - if (!table) + VIR_UNLESS (table) goto cleanup; =20 /* Output old style pool info */ @@ -1347,7 +1347,7 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd G_GNUC= _UNUSED) /* Insert the header into table */ table =3D vshTableNew(_("Name"), _("State"), _("Autostart"), _("Persis= tent"), _("Capacity"), _("Allocation"), _("Available"), NU= LL); - if (!table) + VIR_UNLESS (table) goto cleanup; =20 /* Insert the pool info rows into table */ @@ -1562,7 +1562,7 @@ cmdPoolInfo(vshControl *ctl, const vshCmd *cmd) bool bytes =3D false; char uuid[VIR_UUID_STRING_BUFLEN]; =20 - if (!(pool =3D virshCommandOptPool(ctl, cmd, "pool", NULL))) + VIR_UNLESS ((pool =3D virshCommandOptPool(ctl, cmd, "pool", NULL))) return false; =20 bytes =3D vshCommandOptBool(cmd, "bytes"); @@ -1643,7 +1643,7 @@ cmdPoolName(vshControl *ctl, const vshCmd *cmd) { g_autoptr(virshStoragePool) pool =3D NULL; =20 - if (!(pool =3D virshCommandOptPoolBy(ctl, cmd, "pool", NULL, VIRSH_BYU= UID))) + VIR_UNLESS ((pool =3D virshCommandOptPoolBy(ctl, cmd, "pool", NULL, VI= RSH_BYUUID))) return false; =20 vshPrint(ctl, "%s\n", virStoragePoolGetName(pool)); @@ -1683,7 +1683,7 @@ cmdPoolStart(vshControl *ctl, const vshCmd *cmd) bool no_overwrite; unsigned int flags =3D 0; =20 - if (!(pool =3D virshCommandOptPool(ctl, cmd, "pool", &name))) + VIR_UNLESS ((pool =3D virshCommandOptPool(ctl, cmd, "pool", &name))) return false; =20 build =3D vshCommandOptBool(cmd, "build"); @@ -1736,7 +1736,7 @@ cmdPoolUndefine(vshControl *ctl, const vshCmd *cmd) bool ret =3D true; const char *name; =20 - if (!(pool =3D virshCommandOptPool(ctl, cmd, "pool", &name))) + VIR_UNLESS ((pool =3D virshCommandOptPool(ctl, cmd, "pool", &name))) return false; =20 if (virStoragePoolUndefine(pool) =3D=3D 0) { @@ -1774,7 +1774,7 @@ cmdPoolUuid(vshControl *ctl, const vshCmd *cmd) g_autoptr(virshStoragePool) pool =3D NULL; char uuid[VIR_UUID_STRING_BUFLEN]; =20 - if (!(pool =3D virshCommandOptPoolBy(ctl, cmd, "pool", NULL, VIRSH_BYN= AME))) + VIR_UNLESS ((pool =3D virshCommandOptPoolBy(ctl, cmd, "pool", NULL, VI= RSH_BYNAME))) return false; =20 if (virStoragePoolGetUUIDString(pool, uuid) !=3D -1) @@ -1819,7 +1819,7 @@ cmdPoolEdit(vshControl *ctl, const vshCmd *cmd) goto cleanup; =20 /* Some old daemons don't support _INACTIVE flag */ - if (!(tmp_desc =3D virStoragePoolGetXMLDesc(pool, flags))) { + VIR_UNLESS ((tmp_desc =3D virStoragePoolGetXMLDesc(pool, flags))) { if (last_error->code =3D=3D VIR_ERR_INVALID_ARG) { flags &=3D ~VIR_STORAGE_XML_INACTIVE; vshResetLibvirtError(); @@ -1908,7 +1908,7 @@ vshEventLifecyclePrint(virConnectPtr conn G_GNUC_UNUS= ED, } =20 data->count++; - if (!data->loop) + VIR_UNLESS (data->loop) vshEventDone(data->ctl); } =20 @@ -1939,7 +1939,7 @@ vshEventGenericPrint(virConnectPtr conn G_GNUC_UNUSED, } =20 data->count++; - if (!data->loop) + VIR_UNLESS (data->loop) vshEventDone(data->ctl); } =20 @@ -2013,7 +2013,7 @@ cmdPoolEvent(vshControl *ctl, const vshCmd *cmd) =20 if (vshCommandOptStringReq(ctl, cmd, "event", &eventName) < 0) return false; - if (!eventName) { + VIR_UNLESS (eventName) { vshError(ctl, "%s", _("either --list or --event is required= ")); return false; } @@ -2094,7 +2094,7 @@ cmdPoolCapabilities(vshControl *ctl, g_autofree char *caps =3D NULL; =20 caps =3D virConnectGetStoragePoolCapabilities(priv->conn, flags); - if (!caps) { + VIR_UNLESS (caps) { vshError(ctl, "%s", _("failed to get storage pool capabilities")); return false; } diff --git a/tools/virsh-secret.c b/tools/virsh-secret.c index 842647cb17..0347a2e894 100644 --- a/tools/virsh-secret.c +++ b/tools/virsh-secret.c @@ -100,7 +100,7 @@ cmdSecretDefine(vshControl *ctl, const vshCmd *cmd) if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) return false; =20 - if (!(res =3D virSecretDefineXML(priv->conn, buffer, flags))) { + VIR_UNLESS ((res =3D virSecretDefineXML(priv->conn, buffer, flags))) { vshError(ctl, _("Failed to set attributes from %s"), from); goto cleanup; } @@ -223,7 +223,7 @@ cmdSecretSetValue(vshControl *ctl, const vshCmd *cmd) VSH_EXCLUSIVE_OPTIONS("interactive", "plain"); VSH_EXCLUSIVE_OPTIONS("interactive", "file"); =20 - if (!(secret =3D virshCommandOptSecret(ctl, cmd, NULL))) + VIR_UNLESS ((secret =3D virshCommandOptSecret(ctl, cmd, NULL))) return false; =20 if (vshCommandOptStringReq(ctl, cmd, "base64", &base64) < 0) @@ -249,7 +249,7 @@ cmdSecretSetValue(vshControl *ctl, const vshCmd *cmd) vshPrint(ctl, "%s", _("Enter new value for secret:")); fflush(stdout); =20 - if (!(secret_val =3D virGetPassword())) { + VIR_UNLESS ((secret_val =3D virGetPassword())) { vshError(ctl, "%s", _("Failed to read secret")); return false; } @@ -260,7 +260,7 @@ cmdSecretSetValue(vshControl *ctl, const vshCmd *cmd) return false; } =20 - if (!plain) { + VIR_UNLESS (plain) { g_autofree char *tmp =3D g_steal_pointer(&secret_val); size_t tmp_len =3D secret_len; =20 @@ -314,10 +314,10 @@ cmdSecretGetValue(vshControl *ctl, const vshCmd *cmd) size_t value_size; bool plain =3D vshCommandOptBool(cmd, "plain"); =20 - if (!(secret =3D virshCommandOptSecret(ctl, cmd, NULL))) + VIR_UNLESS ((secret =3D virshCommandOptSecret(ctl, cmd, NULL))) return false; =20 - if (!(value =3D virSecretGetValue(secret, &value_size, 0))) + VIR_UNLESS ((value =3D virSecretGetValue(secret, &value_size, 0))) return false; =20 if (plain) { @@ -394,7 +394,7 @@ virshSecretSorter(const void *a, const void *b) if (*sa && !*sb) return -1; =20 - if (!*sa) + VIR_UNLESS (*sa) return *sb !=3D NULL; =20 virSecretGetUUIDString(*sa, uuid_sa); @@ -484,7 +484,7 @@ virshSecretListCollect(vshControl *ctl, =20 /* get the secrets */ for (i =3D 0; i < nsecrets; i++) { - if (!(secret =3D virSecretLookupByUUIDString(priv->conn, uuids[i])= )) + VIR_UNLESS ((secret =3D virSecretLookupByUUIDString(priv->conn, uu= ids[i]))) continue; list->secrets[list->nsecrets++] =3D secret; } @@ -511,7 +511,7 @@ virshSecretListCollect(vshControl *ctl, VIR_FREE(uuids); } =20 - if (!success) { + VIR_UNLESS (success) { g_clear_pointer(&list, virshSecretListFree); } =20 @@ -572,11 +572,11 @@ cmdSecretList(vshControl *ctl, const vshCmd *cmd G_GN= UC_UNUSED) if (vshCommandOptBool(cmd, "no-private")) flags |=3D VIR_CONNECT_LIST_SECRETS_NO_PRIVATE; =20 - if (!(list =3D virshSecretListCollect(ctl, flags))) + VIR_UNLESS ((list =3D virshSecretListCollect(ctl, flags))) return false; =20 table =3D vshTableNew(_("UUID"), _("Usage"), NULL); - if (!table) + VIR_UNLESS (table) goto cleanup; =20 for (i =3D 0; i < list->nsecrets; i++) { @@ -596,7 +596,7 @@ cmdSecretList(vshControl *ctl, const vshCmd *cmd G_GNUC= _UNUSED) virBufferStrcat(&buf, usageStr, " ", virSecretGetUsageID(sec), NULL); usage =3D virBufferContentAndReset(&buf); - if (!usage) + VIR_UNLESS (usage) goto cleanup; =20 if (vshTableRowAppend(table, uuid, usage, NULL) < 0) @@ -669,7 +669,7 @@ vshEventLifecyclePrint(virConnectPtr conn G_GNUC_UNUSED, } =20 data->count++; - if (!data->loop) + VIR_UNLESS (data->loop) vshEventDone(data->ctl); } =20 @@ -703,7 +703,7 @@ vshEventGenericPrint(virConnectPtr conn G_GNUC_UNUSED, } =20 data->count++; - if (!data->loop) + VIR_UNLESS (data->loop) vshEventDone(data->ctl); } =20 @@ -776,7 +776,7 @@ cmdSecretEvent(vshControl *ctl, const vshCmd *cmd) =20 if (vshCommandOptStringReq(ctl, cmd, "event", &eventName) < 0) return false; - if (!eventName) { + VIR_UNLESS (eventName) { vshError(ctl, "%s", _("either --list or --event is required= ")); return false; } diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c index 7cd76f39e2..3c0294ad68 100644 --- a/tools/virsh-snapshot.c +++ b/tools/virsh-snapshot.c @@ -65,7 +65,7 @@ virshSnapshotCreate(vshControl *ctl, virDomainPtr dom, co= nst char *buffer, vshReportError(ctl); return false; } - if (!persistent) { + VIR_UNLESS (persistent) { vshError(ctl, "%s", _("cannot halt after snapshot of transient domain")); return false; @@ -85,7 +85,7 @@ virshSnapshotCreate(vshControl *ctl, virDomainPtr dom, co= nst char *buffer, } =20 name =3D virDomainSnapshotGetName(snapshot); - if (!name) { + VIR_UNLESS (name) { vshError(ctl, "%s", _("Could not get snapshot name")); return false; } @@ -184,12 +184,12 @@ cmdSnapshotCreate(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "validate")) flags |=3D VIR_DOMAIN_SNAPSHOT_CREATE_VALIDATE; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (vshCommandOptStringReq(ctl, cmd, "xmlfile", &from) < 0) return false; - if (!from) { + VIR_UNLESS (from) { buffer =3D g_strdup(""); } else { if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) { @@ -214,7 +214,7 @@ virshParseSnapshotMemspec(vshControl *ctl, virBuffer *b= uf, const char *str) int narray; size_t i; =20 - if (!str) + VIR_UNLESS (str) return 0; =20 narray =3D vshStringToArray(str, &array); @@ -406,7 +406,7 @@ cmdSnapshotCreateAs(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "validate")) flags |=3D VIR_DOMAIN_SNAPSHOT_CREATE_VALIDATE; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (vshCommandOptStringReq(ctl, cmd, "name", &name) < 0 || @@ -475,7 +475,7 @@ virshLookupSnapshot(vshControl *ctl, const vshCmd *cmd, vshError(ctl, _("--%s or --current is required"), arg); return -1; } - if (!*snap) { + VIR_UNLESS (*snap) { vshReportError(ctl); return -1; } @@ -536,7 +536,7 @@ cmdSnapshotEdit(vshControl *ctl, const vshCmd *cmd) vshCommandOptBool(cmd, "snapshotname")) define_flags |=3D VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (virshLookupSnapshot(ctl, cmd, "snapshotname", false, dom, @@ -548,7 +548,7 @@ cmdSnapshotEdit(vshControl *ctl, const vshCmd *cmd) #define EDIT_NOT_CHANGED \ do { \ /* Depending on flags, we re-edit even if XML is unchanged. */ \ - if (!(define_flags & VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT)) { \ + VIR_UNLESS ((define_flags & VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT)) {= \ vshPrintExtra(ctl, \ _("Snapshot %s XML configuration not changed.\n"= ), \ name); \ @@ -579,7 +579,7 @@ cmdSnapshotEdit(vshControl *ctl, const vshCmd *cmd) rename_okay ? name : edited_name); goto cleanup; } - if (!rename_okay) { + VIR_UNLESS (rename_okay) { vshError(ctl, _("Must use --rename or --clone to change %s to = %s"), name, edited_name); goto cleanup; @@ -642,7 +642,7 @@ cmdSnapshotCurrent(vshControl *ctl, const vshCmd *cmd) =20 VSH_EXCLUSIVE_OPTIONS("name", "snapshotname"); =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, &domname))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, &domname))) return false; =20 if (vshCommandOptStringReq(ctl, cmd, "snapshotname", &snapshotname) < = 0) @@ -653,18 +653,18 @@ cmdSnapshotCurrent(vshControl *ctl, const vshCmd *cmd) flags =3D (VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE | VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT); =20 - if (!(snapshot =3D virDomainSnapshotLookupByName(dom, snapshotname= , 0))) + VIR_UNLESS ((snapshot =3D virDomainSnapshotLookupByName(dom, snaps= hotname, 0))) goto cleanup; =20 xml =3D virDomainSnapshotGetXMLDesc(snapshot, VIR_DOMAIN_XML_SECUR= E); - if (!xml) + VIR_UNLESS (xml) goto cleanup; =20 /* strstr is safe here, since xml came from libvirt API and not us= er */ if (strstr(xml, "disk-snapshot")) flags |=3D VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY; =20 - if (!(snapshot2 =3D virDomainSnapshotCreateXML(dom, xml, flags))) + VIR_UNLESS ((snapshot2 =3D virDomainSnapshotCreateXML(dom, xml, fl= ags))) goto cleanup; =20 vshPrintExtra(ctl, _("Snapshot %s set as current"), snapshotname); @@ -675,21 +675,21 @@ cmdSnapshotCurrent(vshControl *ctl, const vshCmd *cmd) if ((current =3D virDomainHasCurrentSnapshot(dom, 0)) < 0) goto cleanup; =20 - if (!current) { + VIR_UNLESS (current) { vshError(ctl, _("domain '%s' has no current snapshot"), domname); goto cleanup; } else { - if (!(snapshot =3D virDomainSnapshotCurrent(dom, 0))) + VIR_UNLESS ((snapshot =3D virDomainSnapshotCurrent(dom, 0))) goto cleanup; =20 if (vshCommandOptBool(cmd, "name")) { const char *name; - if (!(name =3D virDomainSnapshotGetName(snapshot))) + VIR_UNLESS ((name =3D virDomainSnapshotGetName(snapshot))) goto cleanup; =20 vshPrint(ctl, "%s", name); } else { - if (!(xml =3D virDomainSnapshotGetXMLDesc(snapshot, flags))) + VIR_UNLESS ((xml =3D virDomainSnapshotGetXMLDesc(snapshot, fla= gs))) goto cleanup; =20 vshPrint(ctl, "%s", xml); @@ -699,7 +699,7 @@ cmdSnapshotCurrent(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - if (!ret) + VIR_UNLESS (ret) vshReportError(ctl); return ret; } @@ -722,7 +722,7 @@ virshGetSnapshotParent(vshControl *ctl, virDomainSnapsh= otPtr snapshot, *parent_name =3D NULL; =20 /* Try new API, since it is faster. */ - if (!priv->useSnapshotOld) { + VIR_UNLESS (priv->useSnapshotOld) { parent =3D virDomainSnapshotGetParent(snapshot, 0); if (parent) { /* API works, and virDomainSnapshotGetName will succeed */ @@ -740,11 +740,11 @@ virshGetSnapshotParent(vshControl *ctl, virDomainSnap= shotPtr snapshot, } =20 xml =3D virDomainSnapshotGetXMLDesc(snapshot, 0); - if (!xml) + VIR_UNLESS (xml) goto cleanup; =20 xmldoc =3D virXMLParseStringCtxt(xml, _("(domain_snapshot)"), &ctxt); - if (!xmldoc) + VIR_UNLESS (xmldoc) goto cleanup; =20 *parent_name =3D virXPathString("string(/domainsnapshot/parent/name)",= ctxt); @@ -773,15 +773,15 @@ virshSnapshotFilter(vshControl *ctl, virDomainSnapsho= tPtr snapshot, g_autoptr(xmlXPathContext) ctxt =3D NULL; g_autofree char *state =3D NULL; =20 - if (!snapshot) + VIR_UNLESS (snapshot) return 1; =20 xml =3D virDomainSnapshotGetXMLDesc(snapshot, 0); - if (!xml) + VIR_UNLESS (xml) return -1; =20 xmldoc =3D virXMLParseStringCtxt(xml, _("(domain_snapshot)"), &ctxt); - if (!xmldoc) + VIR_UNLESS (xmldoc) return -1; =20 /* Libvirt 1.0.1 and newer never call this function, because the @@ -790,7 +790,7 @@ virshSnapshotFilter(vshControl *ctl, virDomainSnapshotP= tr snapshot, * the types of snapshots it could create: if state was disk-only, * the snapshot is external; all other snapshots are internal. */ state =3D virXPathString("string(/domainsnapshot/state)", ctxt); - if (!state) { + VIR_UNLESS (state) { vshError(ctl, "%s", _("unable to perform snapshot filtering")); return -1; } @@ -799,7 +799,7 @@ virshSnapshotFilter(vshControl *ctl, virDomainSnapshotP= tr snapshot, (flags & VIR_DOMAIN_SNAPSHOT_LIST_EXTERNAL)); } =20 - if (!(flags & VIR_DOMAIN_SNAPSHOT_LIST_INTERNAL)) + VIR_UNLESS ((flags & VIR_DOMAIN_SNAPSHOT_LIST_INTERNAL)) return 0; if (STREQ(state, "shutoff")) return !!(flags & VIR_DOMAIN_SNAPSHOT_LIST_INACTIVE); @@ -872,15 +872,15 @@ cmdSnapshotInfo(vshControl *ctl, const vshCmd *cmd) /* Get the XML configuration of the snapshot to determine the * state of the machine at the time of the snapshot. */ doc =3D virDomainSnapshotGetXMLDesc(snapshot, 0); - if (!doc) + VIR_UNLESS (doc) return false; =20 xmldoc =3D virXMLParseStringCtxt(doc, _("(domain_snapshot)"), &ctxt); - if (!xmldoc) + VIR_UNLESS (xmldoc) return false; =20 state =3D virXPathString("string(/domainsnapshot/state)", ctxt); - if (!state) { + VIR_UNLESS (state) { vshError(ctl, "%s", _("unexpected problem reading snapshot xml")); return false; @@ -970,7 +970,7 @@ virshSnapshotListFree(struct virshSnapshotList *snaplis= t) { size_t i; =20 - if (!snaplist) + VIR_UNLESS (snaplist) return; if (snaplist->snaps) { for (i =3D 0; i < snaplist->nsnaps; i++) { @@ -990,7 +990,7 @@ virshSnapSorter(const void *a, const void *b) =20 if (sa->snap && !sb->snap) return -1; - if (!sa->snap) + VIR_UNLESS (sa->snap) return sb->snap !=3D NULL; =20 return vshStrcasecmp(virDomainSnapshotGetName(sa->snap), @@ -1022,7 +1022,7 @@ virshSnapshotListCollect(vshControl *ctl, virDomainPt= r dom, virshControl *priv =3D ctl->privData; =20 /* Try the interface available in 0.9.13 and newer. */ - if (!priv->useSnapshotOld) { + VIR_UNLESS (priv->useSnapshotOld) { if (from) count =3D virDomainSnapshotListAllChildren(from, &snaps, flags= ); else @@ -1117,7 +1117,7 @@ virshSnapshotListCollect(vshControl *ctl, virDomainPt= r dom, */ if (from) { fromname =3D virDomainSnapshotGetName(from); - if (!fromname) { + VIR_UNLESS (fromname) { vshError(ctl, "%s", _("Could not get snapshot name")); goto cleanup; } @@ -1156,12 +1156,12 @@ virshSnapshotListCollect(vshControl *ctl, virDomain= Ptr dom, } =20 if (count < 0) { - if (!last_error) + VIR_UNLESS (last_error) vshError(ctl, _("failed to collect snapshot list")); goto cleanup; } =20 - if (!count) + VIR_UNLESS (count) goto success; =20 names =3D g_new0(char *, count); @@ -1190,7 +1190,7 @@ virshSnapshotListCollect(vshControl *ctl, virDomainPt= r dom, for (i =3D 0; i < count; i++) { snaplist->snaps[i].snap =3D virDomainSnapshotLookupByName(dom, names[i], = 0); - if (!snaplist->snaps[i].snap) + VIR_UNLESS (snaplist->snaps[i].snap) goto cleanup; } =20 @@ -1252,7 +1252,7 @@ virshSnapshotListCollect(vshControl *ctl, virDomainPt= r dom, remaining =3D true; } } - if (!changed) { + VIR_UNLESS (changed) { ret =3D g_new0(struct virshSnapshotList, 1); goto cleanup; } @@ -1269,14 +1269,14 @@ virshSnapshotListCollect(vshControl *ctl, virDomain= Ptr dom, continue; if (STREQ(snaplist->snaps[i].parent, names[j])) { found_parent =3D true; - if (!snaplist->snaps[j].parent) + VIR_UNLESS (snaplist->snaps[j].parent) VIR_FREE(snaplist->snaps[i].parent); else remaining =3D true; break; } } - if (!found_parent) { + VIR_UNLESS (found_parent) { changed =3D true; VIR_FREE(names[i]); g_clear_pointer(&snaplist->snaps[i].snap, @@ -1311,7 +1311,7 @@ virshSnapshotListCollect(vshControl *ctl, virDomainPt= r dom, } } } - if (!(orig_flags & VIR_DOMAIN_SNAPSHOT_LIST_TOPOLOGICAL)) + VIR_UNLESS ((orig_flags & VIR_DOMAIN_SNAPSHOT_LIST_TOPOLOGICAL)) qsort(snaplist->snaps, snaplist->nsnaps, sizeof(*snaplist->snaps), virshSnapSorter); snaplist->nsnaps -=3D deleted; @@ -1491,14 +1491,14 @@ cmdSnapshotList(vshControl *ctl, const vshCmd *cmd) flags |=3D VIR_DOMAIN_SNAPSHOT_LIST_DESCENDANTS; } =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if ((from || current) && virshLookupSnapshot(ctl, cmd, "from", true, dom, &start, &from_sna= p) < 0) goto cleanup; =20 - if (!(snaplist =3D virshSnapshotListCollect(ctl, dom, start, flags, tr= ee))) + VIR_UNLESS ((snaplist =3D virshSnapshotListCollect(ctl, dom, start, fl= ags, tree))) goto cleanup; =20 if (!tree && !name) { @@ -1507,7 +1507,7 @@ cmdSnapshotList(vshControl *ctl, const vshCmd *cmd) else table =3D vshTableNew(_("Name"), _("Creation Time"), _("State"= ), NULL); =20 - if (!table) + VIR_UNLESS (table) goto cleanup; } =20 @@ -1542,17 +1542,17 @@ cmdSnapshotList(vshControl *ctl, const vshCmd *cmd) continue; } =20 - if (!(doc =3D virDomainSnapshotGetXMLDesc(snapshot, 0))) + VIR_UNLESS ((doc =3D virDomainSnapshotGetXMLDesc(snapshot, 0))) continue; =20 - if (!(xml =3D virXMLParseStringCtxt(doc, _("(domain_snapshot)"), &= ctxt))) + VIR_UNLESS ((xml =3D virXMLParseStringCtxt(doc, _("(domain_snapsho= t)"), &ctxt))) continue; =20 if (parent) parent_snap =3D virXPathString("string(/domainsnapshot/parent/= name)", ctxt); =20 - if (!(state =3D virXPathString("string(/domainsnapshot/state)", ct= xt))) + VIR_UNLESS ((state =3D virXPathString("string(/domainsnapshot/stat= e)", ctxt))) continue; =20 if (virXPathLongLong("string(/domainsnapshot/creationTime)", ctxt, @@ -1626,13 +1626,13 @@ cmdSnapshotDumpXML(vshControl *ctl, const vshCmd *c= md) if (vshCommandOptStringReq(ctl, cmd, "snapshotname", &name) < 0) return false; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 - if (!(snapshot =3D virDomainSnapshotLookupByName(dom, name, 0))) + VIR_UNLESS ((snapshot =3D virDomainSnapshotLookupByName(dom, name, 0))) return false; =20 - if (!(xml =3D virDomainSnapshotGetXMLDesc(snapshot, flags))) + VIR_UNLESS ((xml =3D virDomainSnapshotGetXMLDesc(snapshot, flags))) return false; =20 vshPrint(ctl, "%s", xml); @@ -1681,7 +1681,7 @@ cmdSnapshotParent(vshControl *ctl, const vshCmd *cmd) =20 if (virshGetSnapshotParent(ctl, snapshot, &parent) < 0) return false; - if (!parent) { + VIR_UNLESS (parent) { vshError(ctl, _("snapshot '%s' has no parent"), name); return false; } diff --git a/tools/virsh-util.c b/tools/virsh-util.c index dc6ed7a86d..8b6b2501ed 100644 --- a/tools/virsh-util.c +++ b/tools/virsh-util.c @@ -63,7 +63,7 @@ virshLookupDomainInternal(vshControl *ctl, =20 vshResetLibvirtError(); =20 - if (!dom) + VIR_UNLESS (dom) vshError(ctl, _("failed to get domain '%s'"), name); =20 return dom; @@ -122,7 +122,7 @@ virshDomainState(vshControl *ctl, if (reason) *reason =3D -1; =20 - if (!priv->useGetInfo) { + VIR_UNLESS (priv->useGetInfo) { int state; if (virDomainGetState(dom, &state, reason, 0) < 0) { if (virGetLastErrorCode() =3D=3D VIR_ERR_NO_SUPPORT) @@ -255,7 +255,7 @@ virshStreamInData(virStreamPtr st G_GNUC_UNUSED, void virshDomainFree(virDomainPtr dom) { - if (!dom) + VIR_UNLESS (dom) return; =20 vshSaveLibvirtHelperError(); @@ -266,7 +266,7 @@ virshDomainFree(virDomainPtr dom) void virshDomainCheckpointFree(virDomainCheckpointPtr chk) { - if (!chk) + VIR_UNLESS (chk) return; =20 vshSaveLibvirtHelperError(); @@ -277,7 +277,7 @@ virshDomainCheckpointFree(virDomainCheckpointPtr chk) void virshDomainSnapshotFree(virDomainSnapshotPtr snap) { - if (!snap) + VIR_UNLESS (snap) return; =20 vshSaveLibvirtHelperError(); @@ -288,7 +288,7 @@ virshDomainSnapshotFree(virDomainSnapshotPtr snap) void virshInterfaceFree(virInterfacePtr iface) { - if (!iface) + VIR_UNLESS (iface) return; =20 vshSaveLibvirtHelperError(); @@ -299,7 +299,7 @@ virshInterfaceFree(virInterfacePtr iface) void virshNetworkFree(virNetworkPtr network) { - if (!network) + VIR_UNLESS (network) return; =20 vshSaveLibvirtHelperError(); @@ -310,7 +310,7 @@ virshNetworkFree(virNetworkPtr network) void virshNodeDeviceFree(virNodeDevicePtr device) { - if (!device) + VIR_UNLESS (device) return; =20 vshSaveLibvirtHelperError(); @@ -321,7 +321,7 @@ virshNodeDeviceFree(virNodeDevicePtr device) void virshNWFilterFree(virNWFilterPtr nwfilter) { - if (!nwfilter) + VIR_UNLESS (nwfilter) return; =20 vshSaveLibvirtHelperError(); @@ -332,7 +332,7 @@ virshNWFilterFree(virNWFilterPtr nwfilter) void virshSecretFree(virSecretPtr secret) { - if (!secret) + VIR_UNLESS (secret) return; =20 vshSaveLibvirtHelperError(); @@ -343,7 +343,7 @@ virshSecretFree(virSecretPtr secret) void virshStoragePoolFree(virStoragePoolPtr pool) { - if (!pool) + VIR_UNLESS (pool) return; =20 vshSaveLibvirtHelperError(); @@ -354,7 +354,7 @@ virshStoragePoolFree(virStoragePoolPtr pool) void virshStorageVolFree(virStorageVolPtr vol) { - if (!vol) + VIR_UNLESS (vol) return; =20 vshSaveLibvirtHelperError(); @@ -366,7 +366,7 @@ virshStorageVolFree(virStorageVolPtr vol) void virshStreamFree(virStreamPtr stream) { - if (!stream) + VIR_UNLESS (stream) return; =20 vshSaveLibvirtHelperError(); @@ -383,14 +383,14 @@ virshDomainGetXMLFromDom(vshControl *ctl, { g_autofree char *desc =3D NULL; =20 - if (!(desc =3D virDomainGetXMLDesc(dom, flags))) { + VIR_UNLESS ((desc =3D virDomainGetXMLDesc(dom, flags))) { vshError(ctl, _("Failed to get domain description xml")); return -1; } =20 *xml =3D virXMLParseStringCtxt(desc, _("(domain_definition)"), ctxt); =20 - if (!(*xml)) { + VIR_UNLESS ((*xml)) { vshError(ctl, _("Failed to parse domain description xml")); return -1; } @@ -409,7 +409,7 @@ virshDomainGetXML(vshControl *ctl, virDomainPtr dom; int ret; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + VIR_UNLESS ((dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return -1; =20 ret =3D virshDomainGetXMLFromDom(ctl, dom, flags, xml, ctxt); diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c index 503acda874..d877944058 100644 --- a/tools/virsh-volume.c +++ b/tools/virsh-volume.c @@ -97,7 +97,7 @@ virshCommandOptVolBy(vshControl *ctl, const vshCmd *cmd, return NULL; =20 if (p) { - if (!(pool =3D virshCommandOptPoolBy(ctl, cmd, pooloptname, name, = flags))) + VIR_UNLESS ((pool =3D virshCommandOptPoolBy(ctl, cmd, pooloptname,= name, flags))) return NULL; =20 if (virStoragePoolIsActive(pool) !=3D 1) { @@ -131,7 +131,7 @@ virshCommandOptVolBy(vshControl *ctl, const vshCmd *cmd, vol =3D virStorageVolLookupByPath(priv->conn, n); } =20 - if (!vol) { + VIR_UNLESS (vol) { if (pool || !pooloptname) vshError(ctl, _("failed to get vol '%s'"), n); else @@ -242,7 +242,7 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "prealloc-metadata")) flags |=3D VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA; =20 - if (!(pool =3D virshCommandOptPool(ctl, cmd, "pool", NULL))) + VIR_UNLESS ((pool =3D virshCommandOptPool(ctl, cmd, "pool", NULL))) return false; =20 if (vshCommandOptStringReq(ctl, cmd, "name", &name) < 0) @@ -350,7 +350,7 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd) if (printXML) { vshPrint(ctl, "%s", xml); } else { - if (!(vol =3D virStorageVolCreateXML(pool, xml, flags))) { + VIR_UNLESS ((vol =3D virStorageVolCreateXML(pool, xml, flags))) { vshError(ctl, _("Failed to create vol %s"), name); return false; } @@ -395,7 +395,7 @@ cmdVolCreate(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "prealloc-metadata")) flags |=3D VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA; =20 - if (!(pool =3D virshCommandOptPool(ctl, cmd, "pool", NULL))) + VIR_UNLESS ((pool =3D virshCommandOptPool(ctl, cmd, "pool", NULL))) return false; =20 if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) @@ -406,7 +406,7 @@ cmdVolCreate(vshControl *ctl, const vshCmd *cmd) return false; } =20 - if (!(vol =3D virStorageVolCreateXML(pool, buffer, flags))) { + VIR_UNLESS ((vol =3D virStorageVolCreateXML(pool, buffer, flags))) { vshError(ctl, _("Failed to create vol from %s"), from); return false; } @@ -459,7 +459,7 @@ cmdVolCreateFrom(vshControl *ctl, const vshCmd *cmd) g_autofree char *buffer =3D NULL; unsigned int flags =3D 0; =20 - if (!(pool =3D virshCommandOptPool(ctl, cmd, "pool", NULL))) + VIR_UNLESS ((pool =3D virshCommandOptPool(ctl, cmd, "pool", NULL))) return false; =20 if (vshCommandOptBool(cmd, "prealloc-metadata")) @@ -471,7 +471,7 @@ cmdVolCreateFrom(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) return false; =20 - if (!(inputvol =3D virshCommandOptVol(ctl, cmd, "vol", "inputpool", NU= LL))) + VIR_UNLESS ((inputvol =3D virshCommandOptVol(ctl, cmd, "vol", "inputpo= ol", NULL))) return false; =20 if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) { @@ -481,7 +481,7 @@ cmdVolCreateFrom(vshControl *ctl, const vshCmd *cmd) =20 newvol =3D virStorageVolCreateXMLFrom(pool, buffer, inputvol, flags); =20 - if (!newvol) { + VIR_UNLESS (newvol) { vshError(ctl, _("Failed to create vol from %s"), from); return false; } @@ -501,7 +501,7 @@ virshMakeCloneXML(const char *origxml, const char *newn= ame) int size; =20 doc =3D virXMLParseStringCtxt(origxml, _("(volume_definition)"), &ctxt= ); - if (!doc) + VIR_UNLESS (doc) return NULL; =20 obj =3D xmlXPathEval(BAD_CAST "/volume/name", ctxt); @@ -560,7 +560,7 @@ cmdVolClone(vshControl *ctl, const vshCmd *cmd) bool ret =3D false; unsigned int flags =3D 0; =20 - if (!(origvol =3D virshCommandOptVol(ctl, cmd, "vol", "pool", NULL))) + VIR_UNLESS ((origvol =3D virshCommandOptVol(ctl, cmd, "vol", "pool", N= ULL))) goto cleanup; =20 if (vshCommandOptBool(cmd, "prealloc-metadata")) @@ -570,7 +570,7 @@ cmdVolClone(vshControl *ctl, const vshCmd *cmd) flags |=3D VIR_STORAGE_VOL_CREATE_REFLINK; =20 origpool =3D virStoragePoolLookupByVolume(origvol); - if (!origpool) { + VIR_UNLESS (origpool) { vshError(ctl, "%s", _("failed to get parent pool")); goto cleanup; } @@ -579,11 +579,11 @@ cmdVolClone(vshControl *ctl, const vshCmd *cmd) goto cleanup; =20 origxml =3D virStorageVolGetXMLDesc(origvol, 0); - if (!origxml) + VIR_UNLESS (origxml) goto cleanup; =20 newxml =3D virshMakeCloneXML(origxml, name); - if (!newxml) { + VIR_UNLESS (newxml) { vshError(ctl, "%s", _("Failed to allocate XML buffer")); goto cleanup; } @@ -658,7 +658,7 @@ cmdVolUpload(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptULongLongWrap(ctl, cmd, "length", &length) < 0) return false; =20 - if (!(vol =3D virshCommandOptVol(ctl, cmd, "vol", "pool", &name))) + VIR_UNLESS ((vol =3D virshCommandOptVol(ctl, cmd, "vol", "pool", &name= ))) return false; =20 if (vshCommandOptStringReq(ctl, cmd, "file", &file) < 0) @@ -681,7 +681,7 @@ cmdVolUpload(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "sparse")) flags |=3D VIR_STORAGE_VOL_UPLOAD_SPARSE_STREAM; =20 - if (!(st =3D virStreamNew(priv->conn, 0))) { + VIR_UNLESS ((st =3D virStreamNew(priv->conn, 0))) { vshError(ctl, _("cannot create a new stream")); return false; } @@ -773,7 +773,7 @@ cmdVolDownload(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptULongLongWrap(ctl, cmd, "length", &length) < 0) return false; =20 - if (!(vol =3D virshCommandOptVol(ctl, cmd, "vol", "pool", &name))) + VIR_UNLESS ((vol =3D virshCommandOptVol(ctl, cmd, "vol", "pool", &name= ))) return false; =20 if (vshCommandOptStringReq(ctl, cmd, "file", &file) < 0) @@ -801,7 +801,7 @@ cmdVolDownload(vshControl *ctl, const vshCmd *cmd) cbData.fd =3D fd; cbData.isBlock =3D !!S_ISBLK(sb.st_mode); =20 - if (!(st =3D virStreamNew(priv->conn, 0))) { + VIR_UNLESS ((st =3D virStreamNew(priv->conn, 0))) { vshError(ctl, _("cannot create a new stream")); goto cleanup; } @@ -868,7 +868,7 @@ cmdVolDelete(vshControl *ctl, const vshCmd *cmd) bool delete_snapshots =3D vshCommandOptBool(cmd, "delete-snapshots"); unsigned int flags =3D 0; =20 - if (!(vol =3D virshCommandOptVol(ctl, cmd, "vol", "pool", &name))) + VIR_UNLESS ((vol =3D virshCommandOptVol(ctl, cmd, "vol", "pool", &name= ))) return false; =20 if (delete_snapshots) @@ -922,7 +922,7 @@ cmdVolWipe(vshControl *ctl, const vshCmd *cmd) int algorithm =3D VIR_STORAGE_VOL_WIPE_ALG_ZERO; int funcRet; =20 - if (!(vol =3D virshCommandOptVol(ctl, cmd, "vol", "pool", &name))) + VIR_UNLESS ((vol =3D virshCommandOptVol(ctl, cmd, "vol", "pool", &name= ))) return false; =20 if (vshCommandOptStringReq(ctl, cmd, "algorithm", &algorithm_str) < 0) @@ -1005,7 +1005,7 @@ cmdVolInfo(vshControl *ctl, const vshCmd *cmd) int rc; unsigned int flags =3D 0; =20 - if (!(vol =3D virshCommandOptVol(ctl, cmd, "vol", "pool", NULL))) + VIR_UNLESS ((vol =3D virshCommandOptVol(ctl, cmd, "vol", "pool", NULL)= )) return false; =20 vshPrint(ctl, "%-15s %s\n", _("Name:"), virStorageVolGetName(vol)); @@ -1101,7 +1101,7 @@ cmdVolResize(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "shrink")) flags |=3D VIR_STORAGE_VOL_RESIZE_SHRINK; =20 - if (!(vol =3D virshCommandOptVol(ctl, cmd, "vol", "pool", NULL))) + VIR_UNLESS ((vol =3D virshCommandOptVol(ctl, cmd, "vol", "pool", NULL)= )) return false; =20 if (vshCommandOptStringReq(ctl, cmd, "capacity", &capacityStr) < 0) @@ -1169,7 +1169,7 @@ cmdVolDumpXML(vshControl *ctl, const vshCmd *cmd) bool ret =3D true; char *dump; =20 - if (!(vol =3D virshCommandOptVol(ctl, cmd, "vol", "pool", NULL))) + VIR_UNLESS ((vol =3D virshCommandOptVol(ctl, cmd, "vol", "pool", NULL)= )) return false; =20 dump =3D virStorageVolGetXMLDesc(vol, 0); @@ -1192,7 +1192,7 @@ virshStorageVolSorter(const void *a, const void *b) if (*va && !*vb) return -1; =20 - if (!*va) + VIR_UNLESS (*va) return *vb !=3D NULL; =20 return vshStrcasecmp(virStorageVolGetName(*va), @@ -1273,7 +1273,7 @@ virshStorageVolListCollect(vshControl *ctl, =20 /* get the vols */ for (i =3D 0; i < nvols; i++) { - if (!(vol =3D virStorageVolLookupByName(pool, names[i]))) + VIR_UNLESS ((vol =3D virStorageVolLookupByName(pool, names[i]))) continue; list->vols[list->nvols++] =3D vol; } @@ -1297,7 +1297,7 @@ virshStorageVolListCollect(vshControl *ctl, VIR_FREE(names[i]); VIR_FREE(names); =20 - if (!success) { + VIR_UNLESS (success) { g_clear_pointer(&list, virshStorageVolListFree); } =20 @@ -1347,10 +1347,10 @@ cmdVolList(vshControl *ctl, const vshCmd *cmd G_GNU= C_UNUSED) g_autoptr(vshTable) table =3D NULL; =20 /* Look up the pool information given to us by the user */ - if (!(pool =3D virshCommandOptPool(ctl, cmd, "pool", NULL))) + VIR_UNLESS ((pool =3D virshCommandOptPool(ctl, cmd, "pool", NULL))) return false; =20 - if (!(list =3D virshStorageVolListCollect(ctl, pool, 0))) + VIR_UNLESS ((list =3D virshStorageVolListCollect(ctl, pool, 0))) goto cleanup; =20 if (list->nvols > 0) @@ -1396,10 +1396,10 @@ cmdVolList(vshControl *ctl, const vshCmd *cmd G_GNU= C_UNUSED) */ =20 /* Output basic info then return if --details option not selected */ - if (!details) { + VIR_UNLESS (details) { /* The old output format */ table =3D vshTableNew(_("Name"), _("Path"), NULL); - if (!table) + VIR_UNLESS (table) goto cleanup; =20 for (i =3D 0; i < list->nvols; i++) { @@ -1421,7 +1421,7 @@ cmdVolList(vshControl *ctl, const vshCmd *cmd G_GNUC_= UNUSED) =20 /* Insert the header into table */ table =3D vshTableNew(_("Name"), _("Path"), _("Type"), _("Capacity"), = _("Allocation"), NULL); - if (!table) + VIR_UNLESS (table) goto cleanup; =20 /* Insert the volume info rows into table */ @@ -1485,7 +1485,7 @@ cmdVolName(vshControl *ctl, const vshCmd *cmd) { g_autoptr(virshStorageVol) vol =3D NULL; =20 - if (!(vol =3D virshCommandOptVolBy(ctl, cmd, "vol", NULL, NULL, + VIR_UNLESS ((vol =3D virshCommandOptVolBy(ctl, cmd, "vol", NULL, NULL, VIRSH_BYUUID))) return false; =20 @@ -1523,7 +1523,7 @@ cmdVolPool(vshControl *ctl, const vshCmd *cmd) char uuid[VIR_UUID_STRING_BUFLEN]; =20 /* Use the supplied string to locate the volume */ - if (!(vol =3D virshCommandOptVolBy(ctl, cmd, "vol", NULL, NULL, + VIR_UNLESS ((vol =3D virshCommandOptVolBy(ctl, cmd, "vol", NULL, NULL, VIRSH_BYUUID))) { return false; } @@ -1572,7 +1572,7 @@ cmdVolKey(vshControl *ctl, const vshCmd *cmd) { g_autoptr(virshStorageVol) vol =3D NULL; =20 - if (!(vol =3D virshCommandOptVol(ctl, cmd, "vol", "pool", NULL))) + VIR_UNLESS ((vol =3D virshCommandOptVol(ctl, cmd, "vol", "pool", NULL)= )) return false; =20 vshPrint(ctl, "%s\n", virStorageVolGetKey(vol)); @@ -1604,7 +1604,7 @@ cmdVolPath(vshControl *ctl, const vshCmd *cmd) g_autoptr(virshStorageVol) vol =3D NULL; g_autofree char *StorageVolPath =3D NULL; =20 - if (!(vol =3D virshCommandOptVol(ctl, cmd, "vol", "pool", NULL))) + VIR_UNLESS ((vol =3D virshCommandOptVol(ctl, cmd, "vol", "pool", NULL)= )) return false; =20 if ((StorageVolPath =3D virStorageVolGetPath(vol)) =3D=3D NULL) { diff --git a/tools/virsh.c b/tools/virsh.c index f7adb90be8..bb80a1eb75 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -152,7 +152,7 @@ virshConnect(vshControl *ctl, const char *uri, bool rea= donly) if (!pkagent && err && err->domain =3D=3D VIR_FROM_POLKIT && err->code =3D=3D VIR_ERR_AUTH_UNAVAILABLE) { - if (!(pkagent =3D virPolkitAgentCreate())) + VIR_UNLESS ((pkagent =3D virPolkitAgentCreate())) goto cleanup; } else if (err && err->domain =3D=3D VIR_FROM_POLKIT && err->code =3D=3D VIR_ERR_AUTH_FAILED) { @@ -166,7 +166,7 @@ virshConnect(vshControl *ctl, const char *uri, bool rea= donly) */ } while (authfail < 5); =20 - if (!c) + VIR_UNLESS (c) goto cleanup; =20 if (interval > 0 && @@ -222,7 +222,7 @@ virshReconnect(vshControl *ctl, const char *name, bool = readonly, bool force) =20 priv->conn =3D virshConnect(ctl, name ? name : ctl->connname, readonly= ); =20 - if (!priv->conn) { + VIR_UNLESS (priv->conn) { if (disconnected) vshError(ctl, "%s", _("Failed to reconnect to the hypervisor")= ); else @@ -860,7 +860,7 @@ main(int argc, char **argv) virshCtl.escapeChar =3D "^]"; /* Same default as telnet */ ctl->privData =3D &virshCtl; =20 - if (!(progname =3D strrchr(argv[0], '/'))) + VIR_UNLESS ((progname =3D strrchr(argv[0], '/'))) progname =3D argv[0]; else progname++; @@ -890,7 +890,7 @@ main(int argc, char **argv) =20 virFileActivateDirOverrideForProg(argv[0]); =20 - if (!vshInit(ctl, cmdGroups, NULL)) + VIR_UNLESS (vshInit(ctl, cmdGroups, NULL)) exit(EXIT_FAILURE); =20 if (!virshParseArgv(ctl, argc, argv) || @@ -899,14 +899,14 @@ main(int argc, char **argv) exit(EXIT_FAILURE); } =20 - if (!ctl->connname) + VIR_UNLESS (ctl->connname) ctl->connname =3D g_strdup(getenv("VIRSH_DEFAULT_CONNECT_URI")); =20 - if (!ctl->imode) { + VIR_UNLESS (ctl->imode) { ret =3D vshCommandRun(ctl, ctl->cmd); } else { /* interactive mode */ - if (!ctl->quiet) { + VIR_UNLESS (ctl->quiet) { vshPrint(ctl, _("Welcome to %s, the virtualization interactive term= inal.\n\n"), progname); diff --git a/tools/virt-admin.c b/tools/virt-admin.c index e010763e21..d162be0155 100644 --- a/tools/virt-admin.c +++ b/tools/virt-admin.c @@ -110,7 +110,7 @@ vshAdmConnect(vshControl *ctl, unsigned int flags) =20 priv->conn =3D virAdmConnectOpen(ctl->connname, flags); =20 - if (!priv->conn) { + VIR_UNLESS (priv->conn) { if (priv->wantReconnect) vshError(ctl, "%s", _("Failed to reconnect to the admin server= ")); else @@ -134,7 +134,7 @@ vshAdmDisconnect(vshControl *ctl) int ret =3D 0; vshAdmControl *priv =3D ctl->privData; =20 - if (!priv->conn) + VIR_UNLESS (priv->conn) return ret; =20 virAdmConnectUnregisterCloseCallback(priv->conn, vshAdmCatchDisconnect= ); @@ -188,7 +188,7 @@ cmdURI(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED) vshAdmControl *priv =3D ctl->privData; =20 uri =3D virAdmConnectGetURI(priv->conn); - if (!uri) { + VIR_UNLESS (uri) { vshError(ctl, "%s", _("failed to get URI")); return false; } @@ -343,7 +343,7 @@ cmdSrvList(vshControl *ctl, const vshCmd *cmd G_GNUC_UN= USED) } =20 table =3D vshTableNew(_("Id"), _("Name"), NULL); - if (!table) + VIR_UNLESS (table) goto cleanup; =20 for (i =3D 0; i < nsrvs; i++) { @@ -411,7 +411,7 @@ cmdSrvThreadpoolInfo(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptStringReq(ctl, cmd, "server", &srvname) < 0) return false; =20 - if (!(srv =3D virAdmConnectLookupServer(priv->conn, srvname, 0))) + VIR_UNLESS ((srv =3D virAdmConnectLookupServer(priv->conn, srvname, 0)= )) goto cleanup; =20 if (virAdmServerGetThreadPoolParameters(srv, ¶ms, @@ -503,7 +503,7 @@ cmdSrvThreadpoolSet(vshControl *ctl, const vshCmd *cmd) =20 #undef PARSE_CMD_TYPED_PARAM =20 - if (!nparams) { + VIR_UNLESS (nparams) { vshError(ctl, "%s", _("At least one of options --min-workers, --max-workers, " "--priority-workers is mandatory ")); @@ -519,7 +519,7 @@ cmdSrvThreadpoolSet(vshControl *ctl, const vshCmd *cmd) goto cleanup; } =20 - if (!(srv =3D virAdmConnectLookupServer(priv->conn, srvname, 0))) + VIR_UNLESS ((srv =3D virAdmConnectLookupServer(priv->conn, srvname, 0)= )) goto cleanup; =20 if (virAdmServerSetThreadPoolParameters(srv, params, @@ -584,7 +584,7 @@ cmdSrvClientsList(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptStringReq(ctl, cmd, "server", &srvname) < 0) return false; =20 - if (!(srv =3D virAdmConnectLookupServer(priv->conn, srvname, 0))) + VIR_UNLESS ((srv =3D virAdmConnectLookupServer(priv->conn, srvname, 0)= )) goto cleanup; =20 /* Obtain a list of clients connected to server @srv */ @@ -595,7 +595,7 @@ cmdSrvClientsList(vshControl *ctl, const vshCmd *cmd) } =20 table =3D vshTableNew(_("Id"), _("Transport"), _("Connected since"), N= ULL); - if (!table) + VIR_UNLESS (table) goto cleanup; =20 for (i =3D 0; i < nclts; i++) { @@ -764,10 +764,10 @@ cmdClientDisconnect(vshControl *ctl, const vshCmd *cm= d) if (vshCommandOptULongLongWrap(ctl, cmd, "client", &id) < 0) return false; =20 - if (!(srv =3D virAdmConnectLookupServer(priv->conn, srvname, 0))) + VIR_UNLESS ((srv =3D virAdmConnectLookupServer(priv->conn, srvname, 0)= )) goto cleanup; =20 - if (!(client =3D virAdmServerLookupClient(srv, id, 0))) + VIR_UNLESS ((client =3D virAdmServerLookupClient(srv, id, 0))) goto cleanup; =20 if (virAdmClientClose(client, 0) < 0) { @@ -823,7 +823,7 @@ cmdSrvClientsInfo(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptStringReq(ctl, cmd, "server", &srvname) < 0) return false; =20 - if (!(srv =3D virAdmConnectLookupServer(priv->conn, srvname, 0))) + VIR_UNLESS ((srv =3D virAdmConnectLookupServer(priv->conn, srvname, 0)= )) goto cleanup; =20 if (virAdmServerGetClientLimits(srv, ¶ms, &nparams, 0) < 0) { @@ -910,7 +910,7 @@ cmdSrvClientsSet(vshControl *ctl, const vshCmd *cmd) =20 #undef PARSE_CMD_TYPED_PARAM =20 - if (!nparams) { + VIR_UNLESS (nparams) { vshError(ctl, "%s", _("At least one of options --max-clients, " "--max-unauth-clients is mandatory")); goto cleanup; @@ -926,7 +926,7 @@ cmdSrvClientsSet(vshControl *ctl, const vshCmd *cmd) goto cleanup; } =20 - if (!(srv =3D virAdmConnectLookupServer(priv->conn, srvname, 0))) + VIR_UNLESS ((srv =3D virAdmConnectLookupServer(priv->conn, srvname, 0)= )) goto cleanup; =20 if (virAdmServerSetClientLimits(srv, params, nparams, 0) < 0) @@ -986,7 +986,7 @@ cmdSrvUpdateTlsFiles(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptStringReq(ctl, cmd, "server", &srvname) < 0) return false; =20 - if (!(srv =3D virAdmConnectLookupServer(priv->conn, srvname, 0))) + VIR_UNLESS ((srv =3D virAdmConnectLookupServer(priv->conn, srvname, 0)= )) goto cleanup; =20 if (virAdmServerUpdateTlsFiles(srv, 0) < 0) { @@ -1112,10 +1112,10 @@ vshAdmConnectionHandler(vshControl *ctl) { vshAdmControl *priv =3D ctl->privData; =20 - if (!virAdmConnectIsAlive(priv->conn)) + VIR_UNLESS (virAdmConnectIsAlive(priv->conn)) vshAdmReconnect(ctl); =20 - if (!virAdmConnectIsAlive(priv->conn)) { + VIR_UNLESS (virAdmConnectIsAlive(priv->conn)) { vshError(ctl, "%s", _("no valid connection")); return NULL; } @@ -1157,7 +1157,7 @@ vshAdmInit(vshControl *ctl) * non-default connection, or might be 'help' which needs no * connection). */ - if (!priv->conn) { + VIR_UNLESS (priv->conn) { vshReportError(ctl); return false; } @@ -1532,7 +1532,7 @@ main(int argc, char **argv) ctl->eventPipe[1] =3D -1; ctl->privData =3D &virtAdminCtl; =20 - if (!(progname =3D strrchr(argv[0], '/'))) + VIR_UNLESS ((progname =3D strrchr(argv[0], '/'))) progname =3D argv[0]; else progname++; @@ -1562,7 +1562,7 @@ main(int argc, char **argv) =20 virFileActivateDirOverrideForProg(argv[0]); =20 - if (!vshInit(ctl, cmdGroups, NULL)) + VIR_UNLESS (vshInit(ctl, cmdGroups, NULL)) exit(EXIT_FAILURE); =20 if (!vshAdmParseArgv(ctl, argc, argv) || @@ -1571,11 +1571,11 @@ main(int argc, char **argv) exit(EXIT_FAILURE); } =20 - if (!ctl->imode) { + VIR_UNLESS (ctl->imode) { ret =3D vshCommandRun(ctl, ctl->cmd); } else { /* interactive mode */ - if (!ctl->quiet) { + VIR_UNLESS (ctl->quiet) { vshPrint(ctl, _("Welcome to %s, the administrating virtualization " "interactive terminal.\n\n"), diff --git a/tools/virt-host-validate-ch.c b/tools/virt-host-validate-ch.c index b26f82738d..8b4bb88061 100644 --- a/tools/virt-host-validate-ch.c +++ b/tools/virt-host-validate-ch.c @@ -36,7 +36,7 @@ int virHostValidateCh(void) _("Check that CPU and firmware supports virtualization " "and kvm module is loaded"); =20 - if (!(flags =3D virHostValidateGetCPUFlags())) + VIR_UNLESS ((flags =3D virHostValidateGetCPUFlags())) return -1; =20 /* Cloud-Hypervisor only supports x86_64 and aarch64 */ diff --git a/tools/virt-host-validate-common.c b/tools/virt-host-validate-c= ommon.c index 2ac96d1e19..25cd60888a 100644 --- a/tools/virt-host-validate-common.c +++ b/tools/virt-host-validate-common.c @@ -193,7 +193,7 @@ virBitmap *virHostValidateGetCPUFlags(void) FILE *fp; virBitmap *flags =3D NULL; =20 - if (!(fp =3D fopen("/proc/cpuinfo", "r"))) + VIR_UNLESS ((fp =3D fopen("/proc/cpuinfo", "r"))) return NULL; =20 flags =3D virBitmapNew(VIR_HOST_VALIDATE_CPU_FLAG_LAST); @@ -204,7 +204,7 @@ virBitmap *virHostValidateGetCPUFlags(void) g_auto(GStrv) tokens =3D NULL; GStrv next; =20 - if (!fgets(line, sizeof(line), fp)) + VIR_UNLESS (fgets(line, sizeof(line), fp)) break; =20 /* The line we're interested in is marked differently depending @@ -222,12 +222,12 @@ virBitmap *virHostValidateGetCPUFlags(void) line[strlen(line) - 1] =3D '\0'; =20 /* Skip to the separator */ - if (!(start =3D strchr(line, ':'))) + VIR_UNLESS ((start =3D strchr(line, ':'))) continue; =20 /* Split the line using " " as a delimiter. The first token * will always be ":", but that's okay */ - if (!(tokens =3D g_strsplit(start, " ", 0))) + VIR_UNLESS ((tokens =3D g_strsplit(start, " ", 0))) continue; =20 /* Go through all flags and check whether one of those we @@ -300,12 +300,12 @@ int virHostValidateCGroupControllers(const char *hvna= me, int flag =3D 1 << i; const char *cg_name =3D virCgroupControllerTypeToString(i); =20 - if (!(controllers & flag)) + VIR_UNLESS ((controllers & flag)) continue; =20 virHostMsgCheck(hvname, "for cgroup '%s' controller support", cg_n= ame); =20 - if (!virCgroupHasController(group, i)) { + VIR_UNLESS (virCgroupHasController(group, i)) { ret =3D VIR_HOST_VALIDATE_FAILURE(level); virHostMsgFail(level, "Enable '%s' in kernel Kconfig file or " "mount/enable cgroup controller in your system", @@ -378,7 +378,7 @@ int virHostValidateIOMMU(const char *hvname, * devices (which is quite usual on s390x). If there are * no PCI devices the directory is still there but is * empty. */ - if (!virDirOpen(&dir, "/sys/bus/pci/devices")) { + VIR_UNLESS (virDirOpen(&dir, "/sys/bus/pci/devices")) { virHostMsgFail(VIR_HOST_VALIDATE_NOTE, "Skipped - PCI support disabled"); return VIR_HOST_VALIDATE_FAILURE(VIR_HOST_VALIDATE_NOTE); @@ -401,7 +401,7 @@ int virHostValidateIOMMU(const char *hvname, if (stat("/sys/kernel/iommu_groups", &sb) < 0) return 0; =20 - if (!S_ISDIR(sb.st_mode)) + VIR_UNLESS (S_ISDIR(sb.st_mode)) return 0; =20 virHostMsgCheck(hvname, "%s", _("if IOMMU is enabled by kernel")); @@ -424,13 +424,13 @@ bool virHostKernelModuleIsLoaded(const char *module) FILE *fp; bool ret =3D false; =20 - if (!(fp =3D fopen("/proc/modules", "r"))) + VIR_UNLESS ((fp =3D fopen("/proc/modules", "r"))) return false; =20 do { char line[1024]; =20 - if (!fgets(line, sizeof(line), fp)) + VIR_UNLESS (fgets(line, sizeof(line), fp)) break; =20 if (STRPREFIX(line, module)) { @@ -467,7 +467,7 @@ int virHostValidateSecureGuests(const char *hvname, virHostMsgCheck(hvname, "%s", _("for secure guest support")); if (ARCH_IS_S390(arch)) { if (hasFac158) { - if (!virFileIsDir("/sys/firmware/uv")) { + VIR_UNLESS (virFileIsDir("/sys/firmware/uv")) { virHostMsgFail(level, "IBM Secure Execution not supported = by " "the currently used kernel"); return VIR_HOST_VALIDATE_FAILURE(level); diff --git a/tools/virt-host-validate-qemu.c b/tools/virt-host-validate-qem= u.c index 46ff1d2494..b79c941153 100644 --- a/tools/virt-host-validate-qemu.c +++ b/tools/virt-host-validate-qemu.c @@ -37,7 +37,7 @@ int virHostValidateQEMU(void) const char *kvmhint =3D _("Check that CPU and firmware supports virtua= lization " "and kvm module is loaded"); =20 - if (!(flags =3D virHostValidateGetCPUFlags())) + VIR_UNLESS ((flags =3D virHostValidateGetCPUFlags())) return -1; =20 switch ((int)arch) { @@ -91,7 +91,7 @@ int virHostValidateQEMU(void) if (arch =3D=3D VIR_ARCH_PPC64 || arch =3D=3D VIR_ARCH_PPC64LE) { virHostMsgCheck("QEMU", "%s", _("for PowerPC KVM module loaded")); =20 - if (!virHostKernelModuleIsLoaded("kvm_hv")) + VIR_UNLESS (virHostKernelModuleIsLoaded("kvm_hv")) virHostMsgFail(VIR_HOST_VALIDATE_WARN, _("Load kvm_hv for better performance")); else diff --git a/tools/virt-login-shell-helper.c b/tools/virt-login-shell-helpe= r.c index 0fb03da697..19ec0ea970 100644 --- a/tools/virt-login-shell-helper.c +++ b/tools/virt-login-shell-helper.c @@ -62,10 +62,10 @@ static int virLoginShellAllowedUser(virConf *conf, */ if (entry[0] =3D=3D '%') { entry++; - if (!*entry) + VIR_UNLESS (*entry) continue; for (i =3D 0; i < ngroups; i++) { - if (!(gname =3D virGetGroupName(groups[i]))) + VIR_UNLESS ((gname =3D virGetGroupName(groups[i]))) continue; if (g_pattern_match_simple(entry, gname)) { ret =3D 0; @@ -251,14 +251,14 @@ main(int argc, char **argv) gid =3D (gid_t)gidval; =20 name =3D virGetUserName(uid); - if (!name) + VIR_UNLESS (name) goto cleanup; =20 homedir =3D virGetUserDirectoryByUID(uid); - if (!homedir) + VIR_UNLESS (homedir) goto cleanup; =20 - if (!(conf =3D virConfReadFile(login_shell_path, 0))) + VIR_UNLESS ((conf =3D virConfReadFile(login_shell_path, 0))) goto cleanup; =20 if ((ngroups =3D virGetGroupList(uid, gid, &groups)) < 0) @@ -274,11 +274,11 @@ main(int argc, char **argv) goto cleanup; =20 conn =3D virConnectOpen("lxc:///system"); - if (!conn) + VIR_UNLESS (conn) goto cleanup; =20 dom =3D virDomainLookupByName(conn, name); - if (!dom) + VIR_UNLESS (dom) goto cleanup; =20 if (!virDomainIsActive(dom) && virDomainCreate(dom) < 0) { @@ -346,7 +346,7 @@ main(int argc, char **argv) * a leading '-' to indicate it is a login shell */ shcmd =3D shargv[0]; - if (!g_path_is_absolute(shcmd)) { + VIR_UNLESS (g_path_is_absolute(shcmd)) { virReportSystemError(errno, _("Shell '%s' should have absolute path"), shcmd); diff --git a/tools/virt-pki-query-dn.c b/tools/virt-pki-query-dn.c index ee3783c1b2..2dd38df29f 100644 --- a/tools/virt-pki-query-dn.c +++ b/tools/virt-pki-query-dn.c @@ -69,7 +69,7 @@ main(int argc, if (virGettextInitialize() < 0) return EXIT_FAILURE; =20 - if (!(progname =3D strrchr(argv[0], '/'))) + VIR_UNLESS ((progname =3D strrchr(argv[0], '/'))) progname =3D argv[0]; else progname++; diff --git a/tools/vsh-table.c b/tools/vsh-table.c index aa2deb8c72..67f5d24071 100644 --- a/tools/vsh-table.c +++ b/tools/vsh-table.c @@ -49,7 +49,7 @@ vshTableRowFree(vshTableRow *row) { size_t i; =20 - if (!row) + VIR_UNLESS (row) return; =20 for (i =3D 0; i < row->ncells; i++) @@ -65,7 +65,7 @@ vshTableFree(vshTable *table) { size_t i; =20 - if (!table) + VIR_UNLESS (table) return; =20 for (i =3D 0; i < table->nrows; i++) @@ -90,7 +90,7 @@ vshTableRowNew(const char *arg, va_list ap) { vshTableRow *row =3D NULL; =20 - if (!arg) { + VIR_UNLESS (arg) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Table row cannot be empty")); goto error; @@ -137,7 +137,7 @@ vshTableNew(const char *arg, ...) header =3D vshTableRowNew(arg, ap); va_end(ap); =20 - if (!header) + VIR_UNLESS (header) goto error; =20 VIR_APPEND_ELEMENT(table->rows, table->nrows, header); @@ -172,7 +172,7 @@ vshTableRowAppend(vshTable *table, const char *arg, ...) row =3D vshTableRowNew(arg, ap); va_end(ap); =20 - if (!row) + VIR_UNLESS (row) goto cleanup; =20 if (ncolumns !=3D row->ncells) { @@ -234,7 +234,7 @@ vshTableSafeEncode(const char *s, size_t *width) * Not valid multibyte sequence -- maybe it's * printable char according to the current locales. */ - if (!g_ascii_isprint(*p)) { + VIR_UNLESS (g_ascii_isprint(*p)) { g_snprintf(buf, HEX_ENCODE_LENGTH + 1, "\\x%02x", *p); buf +=3D HEX_ENCODE_LENGTH; *width +=3D HEX_ENCODE_LENGTH; @@ -295,7 +295,7 @@ vshTableGetColumnsWidths(vshTable *table, * because width of some of those characters (e.g. \t, \v, \b = ...) * cannot be counted properly */ char *tmp =3D vshTableSafeEncode(row->cells[j], &size); - if (!tmp) + VIR_UNLESS (tmp) return -1; =20 VIR_FREE(row->cells[j]); diff --git a/tools/vsh.c b/tools/vsh.c index 499794c8fc..ecd9d3fcb1 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -272,12 +272,12 @@ vshCmddefCheckInternals(vshControl *ctl, if (cmd->flags & VSH_CMD_FLAG_ALIAS) { const vshCmdDef *alias; =20 - if (!cmd->alias) { + VIR_UNLESS (cmd->alias) { vshError(ctl, _("command '%s' has inconsistent alias"), cmd->n= ame); return -1; } =20 - if (!(alias =3D vshCmddefSearch(cmd->alias))) { + VIR_UNLESS ((alias =3D vshCmddefSearch(cmd->alias))) { vshError(ctl, _("command alias '%s' is pointing to a non-exist= ent command '%s'"), cmd->name, cmd->alias); return -1; @@ -319,7 +319,7 @@ vshCmddefCheckInternals(vshControl *ctl, return -1; } =20 - if (!cmd->opts) + VIR_UNLESS (cmd->opts) return 0; =20 for (i =3D 0; cmd->opts[i].name; i++) { @@ -382,7 +382,7 @@ vshCmddefCheckInternals(vshControl *ctl, return -1; } } - if (!cmd->opts[j].name) { + VIR_UNLESS (cmd->opts[j].name) { vshError(ctl, _("alias '%s' of command '%s' has missing al= ias option"), opt->name, cmd->name); return -1; /* alias option must map to a later option name= */ @@ -398,7 +398,7 @@ vshCmddefCheckInternals(vshControl *ctl, break; =20 case VSH_OT_DATA: - if (!(opt->flags & VSH_OFLAG_REQ)) { + VIR_UNLESS ((opt->flags & VSH_OFLAG_REQ)) { vshError(ctl, _("parameter '%s' of command '%s' must use V= SH_OFLAG_REQ flag"), opt->name, cmd->name); return -1; /* OT_DATA should always be required. */ @@ -447,7 +447,7 @@ vshCmddefOptParse(const vshCmdDef *cmd, *opts_need_arg =3D 0; *opts_required =3D 0; =20 - if (!cmd->opts) + VIR_UNLESS (cmd->opts) return; =20 for (i =3D 0; cmd->opts[i].name; i++) { @@ -459,7 +459,7 @@ vshCmddefOptParse(const vshCmdDef *cmd, if (opt->type =3D=3D VSH_OT_ALIAS) continue; /* skip the alias option */ =20 - if (!(opt->flags & VSH_OFLAG_REQ_OPT)) + VIR_UNLESS ((opt->flags & VSH_OFLAG_REQ_OPT)) *opts_need_arg |=3D 1ULL << i; =20 if (opt->flags & VSH_OFLAG_REQ) @@ -533,7 +533,7 @@ vshCmddefGetData(const vshCmdDef *cmd, uint64_t *opts_n= eed_arg, size_t i; const vshCmdOptDef *opt; =20 - if (!*opts_need_arg) + VIR_UNLESS (*opts_need_arg) return NULL; =20 /* Grab least-significant set bit */ @@ -556,7 +556,7 @@ vshCommandCheckOpts(vshControl *ctl, const vshCmd *cmd,= uint64_t opts_required, size_t i; =20 opts_required &=3D ~opts_seen; - if (!opts_required) + VIR_UNLESS (opts_required) return 0; =20 for (i =3D 0; def->opts[i].name; i++) { @@ -668,18 +668,18 @@ vshCmddefHelp(const vshCmdDef *def) /* xgettext:c-format */ fmt =3D ((opt->flags & VSH_OFLAG_REQ) ? "<%s>" : _("[--%s ]")); - if (!(opt->flags & VSH_OFLAG_REQ_OPT)) + VIR_UNLESS ((opt->flags & VSH_OFLAG_REQ_OPT)) shortopt =3D true; break; case VSH_OT_STRING: /* xgettext:c-format */ fmt =3D _("[--%s ]"); - if (!(opt->flags & VSH_OFLAG_REQ_OPT)) + VIR_UNLESS ((opt->flags & VSH_OFLAG_REQ_OPT)) shortopt =3D true; break; case VSH_OT_DATA: fmt =3D ((opt->flags & VSH_OFLAG_REQ) ? "<%s>" : "[<%s>]"); - if (!(opt->flags & VSH_OFLAG_REQ_OPT)) + VIR_UNLESS ((opt->flags & VSH_OFLAG_REQ_OPT)) shortopt =3D true; break; case VSH_OT_ARGV: @@ -814,7 +814,7 @@ vshCommandOpt(const vshCmd *cmd, const char *name, vshC= mdOpt **opt, valid++; } =20 - if (!cmd->skipChecks) + VIR_UNLESS (cmd->skipChecks) assert(valid && (!needData || valid->type !=3D VSH_OT_BOOL)); =20 if (valid && valid->flags & VSH_OFLAG_REQ) @@ -1055,7 +1055,7 @@ vshCommandOptStringReq(vshControl *ctl, error =3D N_("Option argument is empty"); =20 if (error) { - if (!cmd->skipChecks) + VIR_UNLESS (cmd->skipChecks) vshError(ctl, _("Failed to get option '%s': %s"), name, _(erro= r)); return -1; } @@ -1278,7 +1278,7 @@ vshBlockJobOptionBandwidth(vshControl *ctl, return -1; } =20 - if (!bytes) + VIR_UNLESS (bytes) bw >>=3D 20; =20 *bandwidth =3D bw; @@ -1314,7 +1314,7 @@ vshCommandRun(vshControl *ctl, const vshCmd *cmd) after =3D g_get_real_time(); =20 /* try to automatically catch disconnections */ - if (!ret && + VIR_UNLESS (ret && ((last_error !=3D NULL) && (((last_error->code =3D=3D VIR_ERR_SYSTEM_ERROR) && (last_error->domain =3D=3D VIR_FROM_REMOTE)) || @@ -1323,7 +1323,7 @@ vshCommandRun(vshControl *ctl, const vshCmd *cmd) (last_error->code =3D=3D VIR_ERR_INVALID_CONN)))) disconnected++; =20 - if (!ret) + VIR_UNLESS (ret) vshReportError(ctl); =20 if (STREQ(cmd->def->name, "quit") || @@ -1375,7 +1375,7 @@ vshCommandParse(vshControl *ctl, vshCommandParser *pa= rser, vshCmd **partial) vshCmdOpt *first =3D NULL; const vshCmdDef *cmd =3D NULL; =20 - if (!partial) { + VIR_UNLESS (partial) { g_clear_pointer(&ctl->cmd, vshCommandFree); } =20 @@ -1416,8 +1416,8 @@ vshCommandParse(vshControl *ctl, vshCommandParser *pa= rser, vshCmd **partial) } while (tk =3D=3D VSH_TK_ARG); VIR_FREE(tkdata); break; - } else if (!(cmd =3D vshCmddefSearch(tkdata))) { - if (!partial) + } else VIR_UNLESS ((cmd =3D vshCmddefSearch(tkdata))) { + VIR_UNLESS (partial) vshError(ctl, _("unknown command: '%s'"), tkdata); goto syntaxError; /* ... or ignore this command only= ? */ } @@ -1443,7 +1443,7 @@ vshCommandParse(vshControl *ctl, vshCommandParser *pa= rser, vshCmd **partial) optstr =3D g_strdup(optstr + 1); } /* Special case 'help' to ignore all spurious options */ - if (!(opt =3D vshCmddefGetOption(ctl, cmd, tkdata + 2, + VIR_UNLESS ((opt =3D vshCmddefGetOption(ctl, cmd, tkdata += 2, &opts_seen, &opt_index, &optstr, partial =3D=3D NUL= L))) { VIR_FREE(optstr); @@ -1471,7 +1471,7 @@ vshCommandParse(vshControl *ctl, vshCommandParser *pa= rser, vshCmd **partial) if (parser->pos - parser->originalLine =3D=3D = parser->point - 1) arg->completeThis =3D true; =20 - if (!first) + VIR_UNLESS (first) first =3D arg; if (last) last->next =3D arg; @@ -1490,7 +1490,7 @@ vshCommandParse(vshControl *ctl, vshCommandParser *pa= rser, vshCmd **partial) } else { tkdata =3D NULL; if (optstr) { - if (!partial) + VIR_UNLESS (partial) vshError(ctl, _("invalid '=3D' after option --= %s"), opt->name); VIR_FREE(optstr); @@ -1505,10 +1505,10 @@ vshCommandParse(vshControl *ctl, vshCommandParser *= parser, vshCmd **partial) } else { get_data: /* Special case 'help' to ignore spurious data */ - if (!(opt =3D vshCmddefGetData(cmd, &opts_need_arg, + VIR_UNLESS ((opt =3D vshCmddefGetData(cmd, &opts_need_arg, &opts_seen)) && STRNEQ(cmd->name, "help")) { - if (!partial) + VIR_UNLESS (partial) vshError(ctl, _("unexpected data '%s'"), tkdata); goto syntaxError; } @@ -1524,13 +1524,13 @@ vshCommandParse(vshControl *ctl, vshCommandParser *= parser, vshCmd **partial) if (parser->pos - parser->originalLine =3D=3D parser->poin= t) arg->completeThis =3D true; =20 - if (!first) + VIR_UNLESS (first) first =3D arg; if (last) last->next =3D arg; last =3D arg; =20 - if (!partial) + VIR_UNLESS (partial) vshDebug(ctl, VSH_ERR_INFO, "%s: %s(%s): %s\n", cmd->name, opt->name, @@ -1568,7 +1568,7 @@ vshCommandParse(vshControl *ctl, vshCommandParser *pa= rser, vshCmd **partial) c->def =3D cmd; c->next =3D NULL; =20 - if (!partial && + VIR_UNLESS (partial && vshCommandCheckOpts(ctl, c, opts_required, opts_seen) < 0)= { vshCommandFree(c); goto syntaxError; @@ -1578,7 +1578,7 @@ vshCommandParse(vshControl *ctl, vshCommandParser *pa= rser, vshCmd **partial) vshCommandFree(*partial); *partial =3D c; } else { - if (!ctl->cmd) + VIR_UNLESS (ctl->cmd) ctl->cmd =3D c; if (clast) clast->next =3D c; @@ -1924,7 +1924,7 @@ vshTTYDisableInterrupt(vshControl *ctl G_GNUC_UNUSED) #ifndef WIN32 struct termios termset =3D ctl->termattr; =20 - if (!ctl->istty) + VIR_UNLESS (ctl->istty) return -1; =20 /* check if we need to set the terminal */ @@ -1946,7 +1946,7 @@ int vshTTYRestore(vshControl *ctl G_GNUC_UNUSED) { #ifndef WIN32 - if (!ctl->istty) + VIR_UNLESS (ctl->istty) return 0; =20 if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &ctl->termattr) < 0) @@ -1965,7 +1965,7 @@ vshTTYMakeRaw(vshControl *ctl G_GNUC_UNUSED, struct termios rawattr =3D ctl->termattr; =20 =20 - if (!ctl->istty) { + VIR_UNLESS (ctl->istty) { if (report_errors) { vshError(ctl, "%s", _("unable to make terminal raw: console isn't a tty")= ); @@ -2152,7 +2152,7 @@ vshEventWait(vshControl *ctl) assert(ctl->eventPipe[0] >=3D 0); while ((rv =3D read(ctl->eventPipe[0], &buf, 1)) < 0 && errno =3D=3D E= INTR); if (rv !=3D 1) { - if (!rv) + VIR_UNLESS (rv) errno =3D EPIPE; vshError(ctl, _("failed to determine loop exit status: %s"), g_strerror(errno)); @@ -2325,7 +2325,7 @@ vshAskReedit(vshControl *ctl, const char *msg, bool r= elax_avail) { int c =3D -1; =20 - if (!isatty(STDIN_FILENO)) + VIR_UNLESS (isatty(STDIN_FILENO)) return -1; =20 vshReportError(ctl); @@ -2384,7 +2384,7 @@ vshAskReedit(vshControl *ctl, void vshEditUnlinkTempfile(char *file) { - if (!file) + VIR_UNLESS (file) return; =20 ignore_value(unlink(file)); @@ -2402,7 +2402,7 @@ vshEditWriteToTempFile(vshControl *ctl, const char *d= oc) VIR_AUTOCLOSE fd =3D -1; =20 tmpdir =3D getenv("TMPDIR"); - if (!tmpdir) + VIR_UNLESS (tmpdir) tmpdir =3D "/tmp"; filename =3D g_strdup_printf("%s/virshXXXXXX.xml", tmpdir); fd =3D g_mkstemp_full(filename, O_RDWR | O_CLOEXEC, S_IRUSR | S_IWUSR); @@ -2446,9 +2446,9 @@ vshEditFile(vshControl *ctl, const char *filename) int errfd =3D STDERR_FILENO; =20 editor =3D getenv("VISUAL"); - if (!editor) + VIR_UNLESS (editor) editor =3D getenv("EDITOR"); - if (!editor) + VIR_UNLESS (editor) editor =3D DEFAULT_EDITOR; =20 /* Check that filename doesn't contain shell meta-characters, and @@ -2520,7 +2520,7 @@ vshTreePrintInternal(vshControl *ctl, root ? "" : "+- ", dev); =20 /* Update indent to show '|' or ' ' for child devices */ - if (!root) { + VIR_UNLESS (root) { virBufferAddChar(indent, devid =3D=3D lastdev ? ' ' : '|'); virBufferAddChar(indent, ' '); } @@ -2555,7 +2555,7 @@ vshTreePrintInternal(vshControl *ctl, if (nextlastdev =3D=3D -1 && devid =3D=3D lastdev) vshPrint(ctl, "%s\n", virBufferCurrentContent(indent)); =20 - if (!root) + VIR_UNLESS (root) virBufferTrimLen(indent, 2); =20 return 0; @@ -2634,10 +2634,10 @@ vshReadlineOptionsGenerator(const vshCmdDef *cmd, size_t ret_size =3D 0; g_auto(GStrv) ret =3D NULL; =20 - if (!cmd) + VIR_UNLESS (cmd) return NULL; =20 - if (!cmd->opts) + VIR_UNLESS (cmd->opts) return NULL; =20 for (list_index =3D 0; cmd->opts[list_index].name; list_index++) { @@ -2710,7 +2710,7 @@ vshCompleterFilter(char ***list, newList =3D g_new0(char *, list_len + 1); =20 for (i =3D 0; i < list_len; i++) { - if (!STRPREFIX((*list)[i], text)) { + VIR_UNLESS (STRPREFIX((*list)[i], text)) { g_clear_pointer(&(*list)[i], g_free); continue; } @@ -2737,7 +2737,7 @@ vshReadlineParse(const char *text, int state) * the very first call @state is zero which means we should * initialize those static variables above. On subsequent * calls @state is non zero. */ - if (!state) { + VIR_UNLESS (state) { g_autoptr(vshCmd) partial =3D NULL; const vshCmdDef *cmd =3D NULL; const vshCmdOptDef *opt =3D NULL; @@ -2768,7 +2768,7 @@ vshReadlineParse(const char *text, int state) =20 opt =3D vshReadlineCommandFindOpt(partial); =20 - if (!cmd) { + VIR_UNLESS (cmd) { list =3D vshReadlineCommandGenerator(); } else if (!opt || opt->type =3D=3D VSH_OT_BOOL) { list =3D vshReadlineOptionsGenerator(cmd, partial); @@ -2808,7 +2808,7 @@ vshReadlineParse(const char *text, int state) } =20 cleanup: - if (!ret) { + VIR_UNLESS (ret) { g_clear_pointer(&list, g_strfreev); list_index =3D 0; } @@ -3007,7 +3007,7 @@ vshInitDebug(vshControl *ctl) bool vshInit(vshControl *ctl, const vshCmdGrp *groups, const vshCmdDef *set) { - if (!ctl->hooks) { + VIR_UNLESS (ctl->hooks) { vshError(ctl, "%s", _("client hooks cannot be NULL")); return false; } @@ -3155,14 +3155,14 @@ cmdCd(vshControl *ctl, const vshCmd *cmd) const char *dir =3D NULL; g_autofree char *dir_malloced =3D NULL; =20 - if (!ctl->imode) { + VIR_UNLESS (ctl->imode) { vshError(ctl, "%s", _("cd: command valid only in interactive mode"= )); return false; } =20 if (vshCommandOptStringQuiet(ctl, cmd, "dir", &dir) <=3D 0) dir =3D dir_malloced =3D virGetUserDirectory(); - if (!dir) + VIR_UNLESS (dir) dir =3D "/"; =20 if (chdir(dir) =3D=3D -1) { @@ -3399,14 +3399,14 @@ cmdComplete(vshControl *ctl, const vshCmd *cmd) =20 vshReadlineInit(ctl); =20 - if (!(rl_line_buffer =3D virBufferContentAndReset(&buf))) + VIR_UNLESS ((rl_line_buffer =3D virBufferContentAndReset(&buf))) rl_line_buffer =3D g_strdup(""); =20 /* rl_point is current cursor position in rl_line_buffer. * In our case it's at the end of the whole line. */ rl_point =3D strlen(rl_line_buffer); =20 - if (!(matches =3D vshReadlineCompletion(arg, 0, 0))) + VIR_UNLESS ((matches =3D vshReadlineCompletion(arg, 0, 0))) return false; =20 for (iter =3D matches; *iter; iter++) { --=20 2.34.1 From nobody Thu May 9 02:37:02 2024 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=1648819671; cv=none; d=zohomail.com; s=zohoarc; b=kLCbJrw0XdQT8ISKluDOo82KiL1JveOhLrGE7Hu6H3nsVYowqmUOLI0x65bI73paLEhotu7fpD5SV+ek+1OASchdDAUDVlssjPLDsOZGG1vz7+TsFxNc2Nfo94QJida1CpUaaYHZ68+gc2BYKTOSFRyLZyz48GYcSbaF5L6WtxU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1648819671; 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=GdiPa6EVZLCgACac4GEObShbh8y8zmEdFiUKUJIuDYI=; b=jRqgPeFfPvrE+wlsmm/a+K+w4paioulGZCo86sotMaogU5ef+lreNuH4yzmCgOjgR3ZgK6t0TAjZ+bGkg/SffDopWXMIQXNotgELi7J38d7nAj1gHpAiHi+LU9rj2wtZUJekfmNAbRIpY2LVjNkg9a2CNzMXa7RXQ4EPXr1I7JA= 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 1648819671233266.1947098603158; Fri, 1 Apr 2022 06:27:51 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-213-UxqP_WMcM8yDWAMYGfUS5Q-1; Fri, 01 Apr 2022 09:27:46 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0853B8117B0; Fri, 1 Apr 2022 13:27:44 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id E594240CF8F4; Fri, 1 Apr 2022 13:27:43 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 7371E1947BBF; Fri, 1 Apr 2022 13:27:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D33771949761 for ; Fri, 1 Apr 2022 13:27:41 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id B2AE2C28104; Fri, 1 Apr 2022 13:27:41 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id 59D44C28103 for ; Fri, 1 Apr 2022 13:27:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1648819670; 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=GdiPa6EVZLCgACac4GEObShbh8y8zmEdFiUKUJIuDYI=; b=QKXxRHdsqeVDZr/JginqXwzxb4jE7q5uB7dAH7MSAlI2E57kev/hvIZnM2z+5ekqAZXrVR /dmuAKVe05zw8OdZ2FZkrvaJNqgUO3v0RwXuyFENkDnIgs8GFf62Ul8tblsgaOzw+7gpZ1 LcUEK4+At86PTwrvxiNNK+AITFYiijA= X-MC-Unique: UxqP_WMcM8yDWAMYGfUS5Q-1 X-Original-To: libvir-list@listman.corp.redhat.com From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 4/4] tools: use VIR_ELSIF more Date: Fri, 1 Apr 2022 15:27:36 +0200 Message-Id: <423e89c4f7c18a40633e683b31cd7745f976efc9.1648819564.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1648819673180100003 Nobody pronounces the 'e' anyway. Signed-off-by: J=C3=A1n Tomko --- tools/virsh-checkpoint.c | 4 +- tools/virsh-completer-domain.c | 2 +- tools/virsh-domain-monitor.c | 10 +-- tools/virsh-domain.c | 144 +++++++++++++++--------------- tools/virsh-host.c | 8 +- tools/virsh-interface.c | 2 +- tools/virsh-network.c | 12 +-- tools/virsh-pool.c | 6 +- tools/virsh-secret.c | 4 +- tools/virsh-snapshot.c | 18 ++-- tools/virsh.c | 6 +- tools/virt-admin.c | 6 +- tools/virt-host-validate-bhyve.c | 6 +- tools/virt-host-validate-ch.c | 2 +- tools/virt-host-validate-common.c | 12 +-- tools/virt-host-validate-qemu.c | 2 +- tools/vsh-table.c | 2 +- tools/vsh.c | 28 +++--- 18 files changed, 137 insertions(+), 137 deletions(-) diff --git a/tools/virsh-checkpoint.c b/tools/virsh-checkpoint.c index fd8cd8827f..9a2e11c7d6 100644 --- a/tools/virsh-checkpoint.c +++ b/tools/virsh-checkpoint.c @@ -166,7 +166,7 @@ virshParseCheckpointDiskspec(vshControl *ctl, for (i =3D 1; i < narray; i++) { if (!checkpoint && STRPREFIX(array[i], "checkpoint=3D")) checkpoint =3D array[i] + strlen("checkpoint=3D"); - else if (!bitmap && STRPREFIX(array[i], "bitmap=3D")) + VIR_ELSIF (!bitmap && STRPREFIX(array[i], "bitmap=3D")) bitmap =3D array[i] + strlen("bitmap=3D"); else goto cleanup; @@ -409,7 +409,7 @@ virshGetCheckpointParent(vshControl *ctl, /* API works, and virDomainCheckpointGetName will succeed */ *parent_name =3D g_strdup(virDomainCheckpointGetName(parent)); ret =3D 0; - } else if (last_error->code =3D=3D VIR_ERR_NO_DOMAIN_CHECKPOINT) { + } VIR_ELSIF (last_error->code =3D=3D VIR_ERR_NO_DOMAIN_CHECKPOINT) { /* API works, and we found a root with no parent */ ret =3D 0; } diff --git a/tools/virsh-completer-domain.c b/tools/virsh-completer-domain.c index 620a3a8ddb..852f1729bb 100644 --- a/tools/virsh-completer-domain.c +++ b/tools/virsh-completer-domain.c @@ -759,7 +759,7 @@ virshDomainVcpulistViaAgentCompleter(vshControl *ctl, =20 cpulist[i] =3D g_strdup_printf("%zu", j++); } - } else if (disable) { + } VIR_ELSIF (disable) { lastcpu =3D virBitmapLastSetBit(onlineVcpus); cpulist =3D g_new0(char *, virBitmapCountBits(onlineVcpus) + 1= ); for (i =3D 0; i < virBitmapCountBits(onlineVcpus); i++) { diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index e66383af05..ef8e6c8aa1 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -418,7 +418,7 @@ cmdDomblkinfoGet(const virDomainBlockInfo *info, *cap =3D g_strdup("-"); *alloc =3D g_strdup("-"); *phy =3D g_strdup("-"); - } else if (!human) { + } VIR_ELSIF (!human) { *cap =3D g_strdup_printf("%llu", info->capacity); *alloc =3D g_strdup_printf("%llu", info->allocation); *phy =3D g_strdup_printf("%llu", info->physical); @@ -815,7 +815,7 @@ cmdDomIfGetLink(vshControl *ctl, const vshCmd *cmd) vshError(ctl, _("Interface (dev: %s) not found."), iface); =20 return false; - } else if (ninterfaces > 1) { + } VIR_ELSIF (ninterfaces > 1) { vshError(ctl, _("multiple matching interfaces found")); return false; } @@ -865,7 +865,7 @@ cmdDomControl(vshControl *ctl, const vshCmd *cmd) vshPrint(ctl, "%s (%0.3fs)\n", virshDomainControlStateToString(info.state), info.stateTime / 1000.0); - } else if (info.state =3D=3D VIR_DOMAIN_CONTROL_ERROR && info.details = > 0) { + } VIR_ELSIF (info.state =3D=3D VIR_DOMAIN_CONTROL_ERROR && info.detail= s > 0) { vshPrint(ctl, "%s: %s\n", virshDomainControlStateToString(info.state), virshDomainControlErrorReasonToString(info.details)); @@ -1436,7 +1436,7 @@ cmdDomTime(vshControl *ctl, const vshCmd *cmd) if (rv < 0) { /* invalid integer format */ return false; - } else if (rv > 0) { + } VIR_ELSIF (rv > 0) { /* valid integer to set */ doSet =3D true; } @@ -1511,7 +1511,7 @@ virshDomainSorter(const void *a, const void *b) if (ida !=3D inactive && idb !=3D inactive) { if (ida > idb) return 1; - else if (ida < idb) + VIR_ELSIF (ida < idb) return -1; } =20 diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index bbebd8fd72..58d2cdb703 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -561,7 +561,7 @@ cmdAttachDiskFormatAddress(vshControl *ctl, _("expecting a pci:0000.00.00.00 or ccw:00.0.0000 add= ress.")); return -1; } - } else if (STRPREFIX((const char *)target, "sd")) { + } VIR_ELSIF (STRPREFIX((const char *)target, "sd")) { if (diskAddr.type !=3D VIRSH_ADDRESS_TYPE_SCSI && diskAddr.type !=3D VIRSH_ADDRESS_TYPE_USB && diskAddr.type !=3D VIRSH_ADDRESS_TYPE_SATA) { @@ -569,7 +569,7 @@ cmdAttachDiskFormatAddress(vshControl *ctl, _("expecting a scsi:00.00.00 or usb:00.00 or sata:00.= 00.00 address.")); return -1; } - } else if (STRPREFIX((const char *)target, "hd")) { + } VIR_ELSIF (STRPREFIX((const char *)target, "hd")) { if (diskAddr.type !=3D VIRSH_ADDRESS_TYPE_IDE) { vshError(ctl, "%s", _("expecting an ide:00.00.00 address.")); return -1; @@ -1422,7 +1422,7 @@ cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd) if ((rv =3D vshCommandOptScaledInt(ctl, cmd, #PARAM, &value, \ 1, ULLONG_MAX)) < 0) { \ goto interror; \ - } else if (rv > 0) { \ + } VIR_ELSIF (rv > 0) { \ if (virTypedParamsAddULLong(¶ms, &nparams, &maxparams, \ VIR_DOMAIN_BLOCK_IOTUNE_##CONST, \ value) < 0) \ @@ -1440,7 +1440,7 @@ cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd) #define VSH_ADD_IOTUNE(PARAM, CONST) \ if ((rv =3D vshCommandOptULongLong(ctl, cmd, #PARAM, &value)) < 0) { \ goto interror; \ - } else if (rv > 0) { \ + } VIR_ELSIF (rv > 0) { \ if (virTypedParamsAddULLong(¶ms, &nparams, &maxparams, \ VIR_DOMAIN_BLOCK_IOTUNE_##CONST, \ value) < 0) \ @@ -1609,7 +1609,7 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd) =20 if ((rv =3D vshCommandOptInt(ctl, cmd, "weight", &weight)) < 0) { goto cleanup; - } else if (rv > 0) { + } VIR_ELSIF (rv > 0) { if (weight <=3D 0) { vshError(ctl, _("Invalid value of %d for I/O weight"), weight); goto cleanup; @@ -1623,7 +1623,7 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd) if (rv < 0) { vshError(ctl, "%s", _("Unable to parse string parameter")); goto cleanup; - } else if (rv > 0) { + } VIR_ELSIF (rv > 0) { if (virTypedParamsAddString(¶ms, &nparams, &maxparams, VIR_DOMAIN_BLKIO_DEVICE_WEIGHT, device_weight) < 0) @@ -1634,7 +1634,7 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd) if (rv < 0) { vshError(ctl, "%s", _("Unable to parse string parameter")); goto cleanup; - } else if (rv > 0) { + } VIR_ELSIF (rv > 0) { if (virTypedParamsAddString(¶ms, &nparams, &maxparams, VIR_DOMAIN_BLKIO_DEVICE_READ_IOPS, device_riops) < 0) @@ -1645,7 +1645,7 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd) if (rv < 0) { vshError(ctl, "%s", _("Unable to parse string parameter")); goto cleanup; - } else if (rv > 0) { + } VIR_ELSIF (rv > 0) { if (virTypedParamsAddString(¶ms, &nparams, &maxparams, VIR_DOMAIN_BLKIO_DEVICE_WRITE_IOPS, device_wiops) < 0) @@ -1656,7 +1656,7 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd) if (rv < 0) { vshError(ctl, "%s", _("Unable to parse string parameter")); goto cleanup; - } else if (rv > 0) { + } VIR_ELSIF (rv > 0) { if (virTypedParamsAddString(¶ms, &nparams, &maxparams, VIR_DOMAIN_BLKIO_DEVICE_READ_BPS, device_rbps) < 0) @@ -1667,7 +1667,7 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd) if (rv < 0) { vshError(ctl, "%s", _("Unable to parse string parameter")); goto cleanup; - } else if (rv > 0) { + } VIR_ELSIF (rv > 0) { if (virTypedParamsAddString(¶ms, &nparams, &maxparams, VIR_DOMAIN_BLKIO_DEVICE_WRITE_BPS, device_wbps) < 0) @@ -2211,7 +2211,7 @@ cmdBlockcommit(vshControl *ctl, const vshCmd *cmd) } =20 vshPrintExtra(ctl, "\n%s", _("Successfully pivoted")); - } else if (finish) { + } VIR_ELSIF (finish) { if (virDomainBlockJobAbort(dom, path, abort_flags) < 0) { vshError(ctl, _("failed to finish job for disk %s"), path); goto cleanup; @@ -2542,7 +2542,7 @@ cmdBlockcopy(vshControl *ctl, const vshCmd *cmd) } =20 vshPrintExtra(ctl, "\n%s", _("Successfully pivoted")); - } else if (finish) { + } VIR_ELSIF (finish) { if (virDomainBlockJobAbort(dom, path, abort_flags) < 0) { vshError(ctl, _("failed to finish job for disk %s"), path); goto cleanup; @@ -4106,7 +4106,7 @@ cmdStart(vshControl *ctl, const vshCmd *cmd) if (rc < 0) { /* No managed save image to remove */ vshResetLibvirtError(); - } else if (rc > 0) { + } VIR_ELSIF (rc > 0) { if (virDomainManagedSaveRemove(dom, 0) < 0) { vshReportError(ctl); return false; @@ -4118,7 +4118,7 @@ cmdStart(vshControl *ctl, const vshCmd *cmd) /* Prefer older API unless we have to pass a flag. */ if (nfds > 0) { rc =3D virDomainCreateWithFiles(dom, nfds, fds, flags); - } else if (flags !=3D 0) { + } VIR_ELSIF (flags !=3D 0) { rc =3D virDomainCreateWithFlags(dom, flags); } else { rc =3D virDomainCreate(dom); @@ -5555,7 +5555,7 @@ virshGenFileName(vshControl *ctl, virDomainPtr dom, c= onst char *mime) =20 if (STREQ(mime, "image/x-portable-pixmap")) ext =3D ".ppm"; - else if (STREQ(mime, "image/png")) + VIR_ELSIF (STREQ(mime, "image/png")) ext =3D ".png"; /* add mime type here */ =20 @@ -5886,13 +5886,13 @@ cmdShutdown(vshControl *ctl, const vshCmd *cmd) mode =3D *tmp; if (STREQ(mode, "acpi")) { flags |=3D VIR_DOMAIN_SHUTDOWN_ACPI_POWER_BTN; - } else if (STREQ(mode, "agent")) { + } VIR_ELSIF (STREQ(mode, "agent")) { flags |=3D VIR_DOMAIN_SHUTDOWN_GUEST_AGENT; - } else if (STREQ(mode, "initctl")) { + } VIR_ELSIF (STREQ(mode, "initctl")) { flags |=3D VIR_DOMAIN_SHUTDOWN_INITCTL; - } else if (STREQ(mode, "signal")) { + } VIR_ELSIF (STREQ(mode, "signal")) { flags |=3D VIR_DOMAIN_SHUTDOWN_SIGNAL; - } else if (STREQ(mode, "paravirt")) { + } VIR_ELSIF (STREQ(mode, "paravirt")) { flags |=3D VIR_DOMAIN_SHUTDOWN_PARAVIRT; } else { vshError(ctl, _("Unknown mode %s value, expecting " @@ -5966,13 +5966,13 @@ cmdReboot(vshControl *ctl, const vshCmd *cmd) mode =3D *tmp; if (STREQ(mode, "acpi")) { flags |=3D VIR_DOMAIN_REBOOT_ACPI_POWER_BTN; - } else if (STREQ(mode, "agent")) { + } VIR_ELSIF (STREQ(mode, "agent")) { flags |=3D VIR_DOMAIN_REBOOT_GUEST_AGENT; - } else if (STREQ(mode, "initctl")) { + } VIR_ELSIF (STREQ(mode, "initctl")) { flags |=3D VIR_DOMAIN_REBOOT_INITCTL; - } else if (STREQ(mode, "signal")) { + } VIR_ELSIF (STREQ(mode, "signal")) { flags |=3D VIR_DOMAIN_REBOOT_SIGNAL; - } else if (STREQ(mode, "paravirt")) { + } VIR_ELSIF (STREQ(mode, "paravirt")) { flags |=3D VIR_DOMAIN_REBOOT_PARAVIRT; } else { vshError(ctl, _("Unknown mode %s value, expecting " @@ -6176,7 +6176,7 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd) if (rc =3D=3D 0) { if (virshDomainJobStatsToDomainJobInfo(params, nparams, &info) < 0) goto cleanup; - } else if (last_error->code =3D=3D VIR_ERR_NO_SUPPORT) { + } VIR_ELSIF (last_error->code =3D=3D VIR_ERR_NO_SUPPORT) { if (flags !=3D 0 || rawstats) { vshError(ctl, "%s", _("Optional flags or --rawstats are not supported by = the daemon")); @@ -6231,7 +6231,7 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd) VIR_DOMAIN_JOB_TIME_ELAPSED_NET, &value)) < 0) { goto save_error; - } else if (rc) { + } VIR_ELSIF (rc) { vshPrint(ctl, "%-17s %-12llu ms\n", _("Time elapsed w/o network:"), value); } @@ -6261,7 +6261,7 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd) VIR_DOMAIN_JOB_MEMORY_BPS, &value)) < 0) { goto save_error; - } else if (rc && value) { + } VIR_ELSIF (rc && value) { val =3D vshPrettyCapacity(value, &unit); vshPrint(ctl, "%-17s %-.3lf %s/s\n", _("Memory bandwidth:"), val, unit); @@ -6271,7 +6271,7 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd) VIR_DOMAIN_JOB_MEMORY_DIRTY_RATE, &value)) < 0) { goto save_error; - } else if (rc) { + } VIR_ELSIF (rc) { vshPrint(ctl, "%-17s %-12llu pages/s\n", _("Dirty rate:"), val= ue); } =20 @@ -6279,7 +6279,7 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd) VIR_DOMAIN_JOB_MEMORY_PAGE_SIZE, &value)) < 0) { goto save_error; - } else if (rc) { + } VIR_ELSIF (rc) { vshPrint(ctl, "%-17s %-12llu bytes\n", _("Page size:"), value); } =20 @@ -6287,7 +6287,7 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd) VIR_DOMAIN_JOB_MEMORY_ITERATION, &value)) < 0) { goto save_error; - } else if (rc) { + } VIR_ELSIF (rc) { vshPrint(ctl, "%-17s %-12llu\n", _("Iteration:"), value); } =20 @@ -6295,7 +6295,7 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd) VIR_DOMAIN_JOB_MEMORY_POSTCOPY_R= EQS, &value)) < 0) { goto save_error; - } else if (rc) { + } VIR_ELSIF (rc) { vshPrint(ctl, "%-17s %-12llu\n", _("Postcopy requests:"), valu= e); } } @@ -6312,7 +6312,7 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd) VIR_DOMAIN_JOB_DISK_BPS, &value)) < 0) { goto save_error; - } else if (rc && value) { + } VIR_ELSIF (rc && value) { val =3D vshPrettyCapacity(value, &unit); vshPrint(ctl, "%-17s %-.3lf %s/s\n", _("File bandwidth:"), val, unit); @@ -6323,21 +6323,21 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd) VIR_DOMAIN_JOB_MEMORY_CONSTANT, &value)) < 0) { goto save_error; - } else if (rc) { + } VIR_ELSIF (rc) { vshPrint(ctl, "%-17s %-12llu\n", _("Constant pages:"), value); } if ((rc =3D virTypedParamsGetULLong(params, nparams, VIR_DOMAIN_JOB_MEMORY_NORMAL, &value)) < 0) { goto save_error; - } else if (rc) { + } VIR_ELSIF (rc) { vshPrint(ctl, "%-17s %-12llu\n", _("Normal pages:"), value); } if ((rc =3D virTypedParamsGetULLong(params, nparams, VIR_DOMAIN_JOB_MEMORY_NORMAL_BYTES, &value)) < 0) { goto save_error; - } else if (rc) { + } VIR_ELSIF (rc) { val =3D vshPrettyCapacity(value, &unit); vshPrint(ctl, "%-17s %-.3lf %s\n", _("Normal data:"), val, unit); } @@ -6346,7 +6346,7 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd) VIR_DOMAIN_JOB_DOWNTIME, &value)) < 0) { goto save_error; - } else if (rc) { + } VIR_ELSIF (rc) { if (info.type =3D=3D VIR_DOMAIN_JOB_COMPLETED) { vshPrint(ctl, "%-17s %-12llu ms\n", _("Total downtime:"), value); @@ -6360,21 +6360,21 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd) VIR_DOMAIN_JOB_DOWNTIME_NET, &value)) < 0) goto save_error; - else if (rc) + VIR_ELSIF (rc) vshPrint(ctl, "%-17s %-12llu ms\n", _("Downtime w/o network:"), va= lue); =20 if ((rc =3D virTypedParamsGetULLong(params, nparams, VIR_DOMAIN_JOB_SETUP_TIME, &value)) < 0) goto save_error; - else if (rc) + VIR_ELSIF (rc) vshPrint(ctl, "%-17s %-12llu ms\n", _("Setup time:"), value); =20 if ((rc =3D virTypedParamsGetULLong(params, nparams, VIR_DOMAIN_JOB_COMPRESSION_CACHE, &value)) < 0) { goto save_error; - } else if (rc) { + } VIR_ELSIF (rc) { val =3D vshPrettyCapacity(value, &unit); vshPrint(ctl, "%-17s %-.3lf %s\n", _("Compression cache:"), val, u= nit); } @@ -6382,7 +6382,7 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd) VIR_DOMAIN_JOB_COMPRESSION_BYTES, &value)) < 0) { goto save_error; - } else if (rc) { + } VIR_ELSIF (rc) { val =3D vshPrettyCapacity(value, &unit); vshPrint(ctl, "%-17s %-.3lf %s\n", _("Compressed data:"), val, uni= t); } @@ -6390,21 +6390,21 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd) VIR_DOMAIN_JOB_COMPRESSION_PAGES, &value)) < 0) { goto save_error; - } else if (rc) { + } VIR_ELSIF (rc) { vshPrint(ctl, "%-17s %-13llu\n", _("Compressed pages:"), value); } if ((rc =3D virTypedParamsGetULLong(params, nparams, VIR_DOMAIN_JOB_COMPRESSION_CACHE_MIS= SES, &value)) < 0) { goto save_error; - } else if (rc) { + } VIR_ELSIF (rc) { vshPrint(ctl, "%-17s %-13llu\n", _("Compression cache misses:"), v= alue); } if ((rc =3D virTypedParamsGetULLong(params, nparams, VIR_DOMAIN_JOB_COMPRESSION_OVERFLOW, &value)) < 0) { goto save_error; - } else if (rc) { + } VIR_ELSIF (rc) { vshPrint(ctl, "%-17s %-13llu\n", _("Compression overflows:"), valu= e); } =20 @@ -6412,7 +6412,7 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd) VIR_DOMAIN_JOB_AUTO_CONVERGE_THROTTLE, &ivalue)) < 0) { goto save_error; - } else if (rc) { + } VIR_ELSIF (rc) { vshPrint(ctl, "%-17s %-13d\n", _("Auto converge throttle:"), ivalu= e); } =20 @@ -6420,7 +6420,7 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd) VIR_DOMAIN_JOB_DISK_TEMP_USED, &value)) < 0) { goto save_error; - } else if (rc) { + } VIR_ELSIF (rc) { val =3D vshPrettyCapacity(value, &unit); vshPrint(ctl, "%-17s %-.3lf %s\n", _("Temporary disk space use:"),= val, unit); } @@ -6429,7 +6429,7 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd) VIR_DOMAIN_JOB_DISK_TEMP_TOTAL, &value)) < 0) { goto save_error; - } else if (rc) { + } VIR_ELSIF (rc) { val =3D vshPrettyCapacity(value, &unit); vshPrint(ctl, "%-17s %-.3lf %s\n", _("Temporary disk space total:"= ), val, unit); } @@ -6437,7 +6437,7 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd) if ((rc =3D virTypedParamsGetString(params, nparams, VIR_DOMAIN_JOB_ER= RMSG, &svalue)) < 0) { goto save_error; - } else if (rc =3D=3D 1) { + } VIR_ELSIF (rc =3D=3D 1) { vshPrint(ctl, "%-17s %s\n", _("Error message:"), svalue); } =20 @@ -7972,7 +7972,7 @@ cmdCPUStats(vshControl *ctl, const vshCmd *cmd) =20 if ((rv =3D vshCommandOptInt(ctl, cmd, "start", &cpu)) < 0) { goto cleanup; - } else if (rv > 0) { + } VIR_ELSIF (rv > 0) { if (cpu < 0) { vshError(ctl, "%s", _("Invalid value for start CPU")); goto cleanup; @@ -7982,7 +7982,7 @@ cmdCPUStats(vshControl *ctl, const vshCmd *cmd) =20 if ((rv =3D vshCommandOptInt(ctl, cmd, "count", &show_count)) < 0) { goto cleanup; - } else if (rv > 0) { + } VIR_ELSIF (rv > 0) { if (show_count < 0) { vshError(ctl, "%s", _("Invalid value for number of CPUs to sho= w")); goto cleanup; @@ -8561,7 +8561,7 @@ cmdMetadata(vshControl *ctl, const vshCmd *cmd) vshPrintExtra(ctl, "%s\n", _("Metadata removed")); else vshPrintExtra(ctl, "%s\n", _("Metadata modified")); - } else if (edit) { + } VIR_ELSIF (edit) { #define EDIT_GET_XML \ virshDomainGetEditMetadata(ctl, dom, uri, flags) #define EDIT_NOT_CHANGED \ @@ -8787,7 +8787,7 @@ static int getSignalNumber(const char *signame) =20 if (STRPREFIX(p, "sig_")) p +=3D 4; - else if (STRPREFIX(p, "sig")) + VIR_ELSIF (STRPREFIX(p, "sig")) p +=3D 3; =20 return virshDomainProcessSignalTypeFromString(p); @@ -9036,7 +9036,7 @@ virshGetUpdatedMemoryXML(char **updatedMemoryXML, =20 if (nodeOpt) { xpath =3D g_strdup_printf("/domain/devices/memory[./target/node=3D= '%u']", node); - } else if (alias) { + } VIR_ELSIF (alias) { xpath =3D g_strdup_printf("/domain/devices/memory[./alias/@name=3D= '%s']", alias); } else { xpath =3D g_strdup("/domain/devices/memory"); @@ -9046,10 +9046,10 @@ virshGetUpdatedMemoryXML(char **updatedMemoryXML, if (nmems < 0) { vshSaveLibvirtError(); return -1; - } else if (nmems =3D=3D 0) { + } VIR_ELSIF (nmems =3D=3D 0) { vshError(ctl, _("no memory device found")); return -1; - } else if (nmems > 1) { + } VIR_ELSIF (nmems > 1) { vshError(ctl, _("multiple memory devices found, use --alias or --n= ode to select one")); return -1; } @@ -9696,7 +9696,7 @@ cmdDomSetLaunchSecState(vshControl * ctl, const vshCm= d * cmd) =20 if ((rv =3D vshCommandOptULongLong(ctl, cmd, "set-address", &setaddr))= < 0) { return false; - } else if (rv > 0) { + } VIR_ELSIF (rv > 0) { if (virTypedParamsAddULLong(¶ms, &nparams, &maxparams, VIR_DOMAIN_LAUNCH_SECURITY_SEV_SECRET_= SET_ADDRESS, setaddr) < 0) @@ -10183,7 +10183,7 @@ cmdQemuAgentCommand(vshControl *ctl, const vshCmd *= cmd) judge =3D vshCommandOptInt(ctl, cmd, "timeout", &timeout); if (judge < 0) goto cleanup; - else if (judge > 0) + VIR_ELSIF (judge > 0) judge =3D 1; if (judge && timeout < 1) { vshError(ctl, "%s", _("timeout must be positive")); @@ -10514,7 +10514,7 @@ cmdDomXMLToNative(vshControl *ctl, const vshCmd *cm= d) =20 if (dom) { xmlData =3D virDomainGetXMLDesc(dom, flags); - } else if (xmlFile) { + } VIR_ELSIF (xmlFile) { if (virFileReadAll(xmlFile, VSH_MAX_XML_FILE, &xmlData) < 0) return false; } else { @@ -11018,7 +11018,7 @@ doMigrate(void *opaque) =20 if ((rv =3D vshCommandOptInt(ctl, cmd, "comp-mt-level", &intOpt)) < 0)= { goto out; - } else if (rv > 0) { + } VIR_ELSIF (rv > 0) { if (virTypedParamsAddInt(¶ms, &nparams, &maxparams, VIR_MIGRATE_PARAM_COMPRESSION_MT_LEVEL, intOpt) < 0) @@ -11027,7 +11027,7 @@ doMigrate(void *opaque) =20 if ((rv =3D vshCommandOptInt(ctl, cmd, "comp-mt-threads", &intOpt)) < = 0) { goto out; - } else if (rv > 0) { + } VIR_ELSIF (rv > 0) { if (virTypedParamsAddInt(¶ms, &nparams, &maxparams, VIR_MIGRATE_PARAM_COMPRESSION_MT_THREADS, intOpt) < 0) @@ -11036,7 +11036,7 @@ doMigrate(void *opaque) =20 if ((rv =3D vshCommandOptInt(ctl, cmd, "comp-mt-dthreads", &intOpt)) <= 0) { goto out; - } else if (rv > 0) { + } VIR_ELSIF (rv > 0) { if (virTypedParamsAddInt(¶ms, &nparams, &maxparams, VIR_MIGRATE_PARAM_COMPRESSION_MT_DTHREADS, intOpt) < 0) @@ -11045,7 +11045,7 @@ doMigrate(void *opaque) =20 if ((rv =3D vshCommandOptULongLong(ctl, cmd, "comp-xbzrle-cache", &ull= Opt)) < 0) { goto out; - } else if (rv > 0) { + } VIR_ELSIF (rv > 0) { if (virTypedParamsAddULLong(¶ms, &nparams, &maxparams, VIR_MIGRATE_PARAM_COMPRESSION_XBZRLE_C= ACHE, ullOpt) < 0) @@ -11090,7 +11090,7 @@ doMigrate(void *opaque) =20 if ((rv =3D vshCommandOptInt(ctl, cmd, "auto-converge-initial", &intOp= t)) < 0) { goto out; - } else if (rv > 0) { + } VIR_ELSIF (rv > 0) { if (virTypedParamsAddInt(¶ms, &nparams, &maxparams, VIR_MIGRATE_PARAM_AUTO_CONVERGE_INITIAL, intOpt) < 0) @@ -11099,7 +11099,7 @@ doMigrate(void *opaque) =20 if ((rv =3D vshCommandOptInt(ctl, cmd, "auto-converge-increment", &int= Opt)) < 0) { goto out; - } else if (rv > 0) { + } VIR_ELSIF (rv > 0) { if (virTypedParamsAddInt(¶ms, &nparams, &maxparams, VIR_MIGRATE_PARAM_AUTO_CONVERGE_INCREMENT, intOpt) < 0) @@ -11108,7 +11108,7 @@ doMigrate(void *opaque) =20 if ((rv =3D vshCommandOptULongLong(ctl, cmd, "postcopy-bandwidth", &ul= lOpt)) < 0) { goto out; - } else if (rv > 0) { + } VIR_ELSIF (rv > 0) { if (virTypedParamsAddULLong(¶ms, &nparams, &maxparams, VIR_MIGRATE_PARAM_BANDWIDTH_POSTCOPY, ullOpt) < 0) @@ -11117,7 +11117,7 @@ doMigrate(void *opaque) =20 if ((rv =3D vshCommandOptInt(ctl, cmd, "parallel-connections", &intOpt= )) < 0) { goto out; - } else if (rv > 0) { + } VIR_ELSIF (rv > 0) { if (virTypedParamsAddInt(¶ms, &nparams, &maxparams, VIR_MIGRATE_PARAM_PARALLEL_CONNECTIONS, intOpt) < 0) @@ -11126,7 +11126,7 @@ doMigrate(void *opaque) =20 if ((rv =3D vshCommandOptULongLong(ctl, cmd, "bandwidth", &ullOpt)) < = 0) { goto out; - } else if (rv > 0) { + } VIR_ELSIF (rv > 0) { if (virTypedParamsAddULLong(¶ms, &nparams, &maxparams, VIR_MIGRATE_PARAM_BANDWIDTH, ullOpt) < 0) @@ -11312,7 +11312,7 @@ cmdMigrate(vshControl *ctl, const vshCmd *cmd) live_flag =3D true; if (vshCommandOptUInt(ctl, cmd, "timeout", &timeout) < 0) { goto cleanup; - } else if (timeout > 0 && !live_flag) { + } VIR_ELSIF (timeout > 0 && !live_flag) { vshError(ctl, "%s", _("migrate: Unexpected timeout for offline migration")); goto cleanup; @@ -11325,7 +11325,7 @@ cmdMigrate(vshControl *ctl, const vshCmd *cmd) if (timeout > 0) { if (timeoutAction =3D=3D VIRSH_MIGRATE_TIMEOUT_DEFAULT) timeoutAction =3D VIRSH_MIGRATE_TIMEOUT_SUSPEND; - } else if (timeoutAction) { + } VIR_ELSIF (timeoutAction) { vshError(ctl, "%s", _("migrate: Unexpected --timeout-* option without --timeo= ut")); goto cleanup; @@ -11771,9 +11771,9 @@ virshGetOneDisplay(vshControl *ctl, /* Then host name or IP */ if (!listen_addr && !sockpath) virBufferAddLit(&buf, "localhost"); - else if (!sockpath && strchr(listen_addr, ':')) + VIR_ELSIF (!sockpath && strchr(listen_addr, ':')) virBufferAsprintf(&buf, "[%s]", listen_addr); - else if (sockpath) + VIR_ELSIF (sockpath) virBufferAsprintf(&buf, "%s", sockpath); else virBufferAsprintf(&buf, "%s", listen_addr); @@ -12524,7 +12524,7 @@ virshFindDisk(const char *doc, (tmp =3D virXMLPropString(cur, "dir")) || (tmp =3D virXMLPropString(cur, "name"))) { } - } else if (virXMLNodeNameEqual(cur, "target")) { + } VIR_ELSIF (virXMLNodeNameEqual(cur, "target")) { tmp =3D virXMLPropString(cur, "dev"); } =20 @@ -12600,7 +12600,7 @@ virshUpdateDiskXML(xmlNodePtr disk_node, =20 if (!source && virXMLNodeNameEqual(tmp, "source")) source =3D tmp; - else if (!target_node && virXMLNodeNameEqual(tmp, "target")) + VIR_ELSIF (!target_node && virXMLNodeNameEqual(tmp, "target")) target_node =3D tmp; =20 /* @@ -12619,7 +12619,7 @@ virshUpdateDiskXML(xmlNodePtr disk_node, /* forcibly switch to empty file cdrom */ source_block =3D false; new_source =3D NULL; - } else if (!new_source) { + } VIR_ELSIF (!new_source) { vshError(NULL, _("New disk media source was not specified")); return NULL; } diff --git a/tools/virsh-host.c b/tools/virsh-host.c index c537db1516..bccfb8ecf3 100644 --- a/tools/virsh-host.c +++ b/tools/virsh-host.c @@ -785,7 +785,7 @@ cmdNodeCpuStats(vshControl *ctl, const vshCmd *cmd) if (i =3D=3D 0) { cpu_stats[field] =3D params[j].value; present[field] =3D true; - } else if (present[field]) { + } VIR_ELSIF (present[field]) { cpu_stats[field] =3D params[j].value - cpu_stats[field]; } } @@ -1488,7 +1488,7 @@ cmdNodeMemoryTune(vshControl *ctl, const vshCmd *cmd) =20 if ((rc =3D vshCommandOptUInt(ctl, cmd, "shm-pages-to-scan", &value)) = < 0) { goto cleanup; - } else if (rc > 0) { + } VIR_ELSIF (rc > 0) { if (virTypedParamsAddUInt(¶ms, &nparams, &maxparams, VIR_NODE_MEMORY_SHARED_PAGES_TO_SCAN, value) < 0) @@ -1497,7 +1497,7 @@ cmdNodeMemoryTune(vshControl *ctl, const vshCmd *cmd) =20 if ((rc =3D vshCommandOptUInt(ctl, cmd, "shm-sleep-millisecs", &value)= ) < 0) { goto cleanup; - } else if (rc > 0) { + } VIR_ELSIF (rc > 0) { if (virTypedParamsAddUInt(¶ms, &nparams, &maxparams, VIR_NODE_MEMORY_SHARED_SLEEP_MILLISECS, value) < 0) @@ -1506,7 +1506,7 @@ cmdNodeMemoryTune(vshControl *ctl, const vshCmd *cmd) =20 if ((rc =3D vshCommandOptUInt(ctl, cmd, "shm-merge-across-nodes", &val= ue)) < 0) { goto cleanup; - } else if (rc > 0) { + } VIR_ELSIF (rc > 0) { if (virTypedParamsAddUInt(¶ms, &nparams, &maxparams, VIR_NODE_MEMORY_SHARED_MERGE_ACROSS_NODE= S, value) < 0) diff --git a/tools/virsh-interface.c b/tools/virsh-interface.c index 2d65425a0d..3e13fcf85d 100644 --- a/tools/virsh-interface.c +++ b/tools/virsh-interface.c @@ -76,7 +76,7 @@ virshCommandOptInterfaceBy(vshControl *ctl, const vshCmd = *cmd, iface =3D virInterfaceLookupByName(priv->conn, n); =20 /* try it by MAC */ - } else if (is_mac && (flags & VIRSH_BYMAC)) { + } VIR_ELSIF (is_mac && (flags & VIRSH_BYMAC)) { vshDebug(ctl, VSH_ERR_DEBUG, "%s: <%s> trying as interface MAC\n", cmd->def->name, optname); iface =3D virInterfaceLookupByMACString(priv->conn, n); diff --git a/tools/virsh-network.c b/tools/virsh-network.c index a87c7b599e..fa8cde1c1e 100644 --- a/tools/virsh-network.c +++ b/tools/virsh-network.c @@ -768,13 +768,13 @@ cmdNetworkList(vshControl *ctl, const vshCmd *cmd G_G= NUC_UNUSED) _("yes") : _("no"), NULL) < 0) goto cleanup; - } else if (optUUID) { + } VIR_ELSIF (optUUID) { if (virNetworkGetUUIDString(network, uuid) < 0) { vshError(ctl, "%s", _("Failed to get network's UUID")); goto cleanup; } vshPrint(ctl, "%s\n", uuid); - } else if (optName) { + } VIR_ELSIF (optName) { vshPrint(ctl, "%s\n", virNetworkGetName(network)); } } @@ -1044,10 +1044,10 @@ cmdNetworkUpdate(vshControl *ctl, const vshCmd *cmd) else vshPrintExtra(ctl, _("Updated network %s persistent config"), virNetworkGetName(network)); - } else if (live) { + } VIR_ELSIF (live) { vshPrintExtra(ctl, _("Updated network %s live state"), virNetworkGetName(network)); - } else if (virNetworkIsActive(network)) { + } VIR_ELSIF (virNetworkIsActive(network)) { vshPrintExtra(ctl, _("Updated network %s live state"), virNetworkGetName(network)); } else { @@ -1429,7 +1429,7 @@ cmdNetworkDHCPLeases(vshControl *ctl, const vshCmd *c= md) =20 if (lease->type =3D=3D VIR_IP_ADDR_TYPE_IPV4) typestr =3D "ipv4"; - else if (lease->type =3D=3D VIR_IP_ADDR_TYPE_IPV6) + VIR_ELSIF (lease->type =3D=3D VIR_IP_ADDR_TYPE_IPV6) typestr =3D "ipv6"; =20 cidr_format =3D g_strdup_printf("%s/%d", lease->ipaddr, lease->pre= fix); @@ -1769,7 +1769,7 @@ cmdNetworkPortList(vshControl *ctl, const vshCmd *cmd) if (optTable) { if (vshTableRowAppend(table, uuid, NULL) < 0) goto cleanup; - } else if (optUUID) { + } VIR_ELSIF (optUUID) { vshPrint(ctl, "%s\n", uuid); } } diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c index 4026f9beb3..0273445ae9 100644 --- a/tools/virsh-pool.c +++ b/tools/virsh-pool.c @@ -386,15 +386,15 @@ virshBuildPoolXML(vshControl *ctl, virBufferAddLit(&buf, "\n", adapterWwnn, adapterWwpn); - } else if (adapterName) { + } VIR_ELSIF (adapterName) { virBufferAsprintf(&buf, "\n", adapterName); } diff --git a/tools/virsh-secret.c b/tools/virsh-secret.c index 0347a2e894..c5db56a90d 100644 --- a/tools/virsh-secret.c +++ b/tools/virsh-secret.c @@ -237,7 +237,7 @@ cmdSecretSetValue(vshControl *ctl, const vshCmd *cmd) vshError(ctl, _("Passing secret value as command-line argument is = insecure!")); secret_val =3D g_strdup(base64); secret_len =3D strlen(secret_val); - } else if (filename) { + } VIR_ELSIF (filename) { ssize_t read_ret; if ((read_ret =3D virFileReadAll(filename, 1024, &secret_val)) < 0= ) { vshSaveLibvirtError(); @@ -245,7 +245,7 @@ cmdSecretSetValue(vshControl *ctl, const vshCmd *cmd) } =20 secret_len =3D read_ret; - } else if (interactive) { + } VIR_ELSIF (interactive) { vshPrint(ctl, "%s", _("Enter new value for secret:")); fflush(stdout); =20 diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c index 3c0294ad68..2e4cdebda1 100644 --- a/tools/virsh-snapshot.c +++ b/tools/virsh-snapshot.c @@ -224,9 +224,9 @@ virshParseSnapshotMemspec(vshControl *ctl, virBuffer *b= uf, const char *str) for (i =3D 0; i < narray; i++) { if (!snapshot && STRPREFIX(array[i], "snapshot=3D")) snapshot =3D array[i] + strlen("snapshot=3D"); - else if (!file && STRPREFIX(array[i], "file=3D")) + VIR_ELSIF (!file && STRPREFIX(array[i], "file=3D")) file =3D array[i] + strlen("file=3D"); - else if (!file && *array[i] =3D=3D '/') + VIR_ELSIF (!file && *array[i] =3D=3D '/') file =3D array[i]; else goto cleanup; @@ -265,11 +265,11 @@ virshParseSnapshotDiskspec(vshControl *ctl, virBuffer= *buf, const char *str) for (i =3D 1; i < narray; i++) { if (!snapshot && STRPREFIX(array[i], "snapshot=3D")) snapshot =3D array[i] + strlen("snapshot=3D"); - else if (!driver && STRPREFIX(array[i], "driver=3D")) + VIR_ELSIF (!driver && STRPREFIX(array[i], "driver=3D")) driver =3D array[i] + strlen("driver=3D"); - else if (!stype && STRPREFIX(array[i], "stype=3D")) + VIR_ELSIF (!stype && STRPREFIX(array[i], "stype=3D")) stype =3D array[i] + strlen("stype=3D"); - else if (!file && STRPREFIX(array[i], "file=3D")) + VIR_ELSIF (!file && STRPREFIX(array[i], "file=3D")) file =3D array[i] + strlen("file=3D"); else goto cleanup; @@ -281,7 +281,7 @@ virshParseSnapshotDiskspec(vshControl *ctl, virBuffer *= buf, const char *str) if (stype) { if (STREQ(stype, "block")) { isFile =3D false; - } else if (STRNEQ(stype, "file")) { + } VIR_ELSIF (STRNEQ(stype, "file")) { vshError(ctl, _("Unknown storage type: '%s'"), stype); goto cleanup; } @@ -469,7 +469,7 @@ virshLookupSnapshot(vshControl *ctl, const vshCmd *cmd, =20 if (snapname) { *snap =3D virDomainSnapshotLookupByName(dom, snapname, 0); - } else if (current) { + } VIR_ELSIF (current) { *snap =3D virDomainSnapshotCurrent(dom, 0); } else { vshError(ctl, _("--%s or --current is required"), arg); @@ -565,7 +565,7 @@ cmdSnapshotEdit(vshControl *ctl, const vshCmd *cmd) edited_name =3D virDomainSnapshotGetName(edited); if (STREQ(name, edited_name)) { vshPrintExtra(ctl, _("Snapshot %s edited.\n"), name); - } else if (clone_okay) { + } VIR_ELSIF (clone_okay) { vshPrintExtra(ctl, _("Snapshot %s cloned to %s.\n"), name, edited_name); } else { @@ -1245,7 +1245,7 @@ virshSnapshotListCollect(vshControl *ctl, virDomainPt= r dom, virshDomainSnapshotFree); VIR_FREE(snaplist->snaps[i].parent); deleted++; - } else if (STREQ(snaplist->snaps[i].parent, fromname)) { + } VIR_ELSIF (STREQ(snaplist->snaps[i].parent, fromname)) { VIR_FREE(snaplist->snaps[i].parent); changed =3D true; } else { diff --git a/tools/virsh.c b/tools/virsh.c index bb80a1eb75..cc5e9d5a94 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -154,7 +154,7 @@ virshConnect(vshControl *ctl, const char *uri, bool rea= donly) err->code =3D=3D VIR_ERR_AUTH_UNAVAILABLE) { VIR_UNLESS ((pkagent =3D virPolkitAgentCreate())) goto cleanup; - } else if (err && err->domain =3D=3D VIR_FROM_POLKIT && + } VIR_ELSIF (err && err->domain =3D=3D VIR_FROM_POLKIT && err->code =3D=3D VIR_ERR_AUTH_FAILED) { authfail++; } else { @@ -215,7 +215,7 @@ virshReconnect(vshControl *ctl, const char *name, bool = readonly, bool force) ret =3D virConnectClose(priv->conn); if (ret < 0) vshError(ctl, "%s", _("Failed to disconnect from the hyperviso= r")); - else if (ret > 0) + VIR_ELSIF (ret > 0) vshError(ctl, "%s", _("One or more references were leaked afte= r " "disconnect from the hypervisor")); } @@ -406,7 +406,7 @@ virshDeinit(vshControl *ctl) ret =3D virConnectClose(priv->conn); if (ret < 0) vshError(ctl, "%s", _("Failed to disconnect from the hyperviso= r")); - else if (ret > 0) + VIR_ELSIF (ret > 0) vshError(ctl, "%s", _("One or more references were leaked afte= r " "disconnect from the hypervisor")); } diff --git a/tools/virt-admin.c b/tools/virt-admin.c index d162be0155..2f6b82a6fe 100644 --- a/tools/virt-admin.c +++ b/tools/virt-admin.c @@ -141,7 +141,7 @@ vshAdmDisconnect(vshControl *ctl) ret =3D virAdmConnectClose(priv->conn); if (ret < 0) vshError(ctl, "%s", _("Failed to disconnect from the admin server"= )); - else if (ret > 0) + VIR_ELSIF (ret > 0) vshError(ctl, "%s", _("One or more references were leaked after " "disconnect from the hypervisor")); priv->conn =3D NULL; @@ -491,7 +491,7 @@ cmdSrvThreadpoolSet(vshControl *ctl, const vshCmd *cmd) if ((rv =3D vshCommandOptUInt(ctl, cmd, NAME, &val)) < 0) { \ vshError(ctl, _("Unable to parse integer parameter '%s'"), NAME); \ goto cleanup; \ - } else if (rv > 0) { \ + } VIR_ELSIF (rv > 0) { \ if (virTypedParamsAddUInt(¶ms, &nparams, &maxparams, \ FIELD, val) < 0) \ goto save_error; \ @@ -899,7 +899,7 @@ cmdSrvClientsSet(vshControl *ctl, const vshCmd *cmd) if ((rv =3D vshCommandOptUInt(ctl, cmd, NAME, &val)) < 0) { \ vshError(ctl, _("Unable to parse integer parameter '%s'"), NAME); \ goto cleanup; \ - } else if (rv > 0) { \ + } VIR_ELSIF (rv > 0) { \ if (virTypedParamsAddUInt(¶ms, &nparams, &maxparams, \ FIELD, val) < 0) \ goto save_error; \ diff --git a/tools/virt-host-validate-bhyve.c b/tools/virt-host-validate-bh= yve.c index 2f0ec1e36c..16f345b3ed 100644 --- a/tools/virt-host-validate-bhyve.c +++ b/tools/virt-host-validate-bhyve.c @@ -60,11 +60,11 @@ int virHostValidateBhyve(void) =20 if (STREQ(stat.name, "vmm.ko")) vmm_loaded =3D true; - else if (STREQ(stat.name, "if_tap.ko")) + VIR_ELSIF (STREQ(stat.name, "if_tap.ko")) if_tap_loaded =3D true; - else if (STREQ(stat.name, "if_bridge.ko")) + VIR_ELSIF (STREQ(stat.name, "if_bridge.ko")) if_bridge_loaded =3D true; - else if (STREQ(stat.name, "nmdm.ko")) + VIR_ELSIF (STREQ(stat.name, "nmdm.ko")) nmdm_loaded =3D true; } =20 diff --git a/tools/virt-host-validate-ch.c b/tools/virt-host-validate-ch.c index 8b4bb88061..42a6e9110a 100644 --- a/tools/virt-host-validate-ch.c +++ b/tools/virt-host-validate-ch.c @@ -74,7 +74,7 @@ int virHostValidateCh(void) if (virHostValidateDeviceExists("CH", "/dev/kvm", VIR_HOST_VALIDAT= E_FAIL, kvmhint) < 0) ret =3D -1; - else if (virHostValidateDeviceAccessible("CH", "/dev/kvm", VIR_HOS= T_VALIDATE_FAIL, + VIR_ELSIF (virHostValidateDeviceAccessible("CH", "/dev/kvm", VIR_H= OST_VALIDATE_FAIL, _("Check /dev/kvm is worl= d writable or you are in " "a group that is allowe= d to access it")) < 0) ret =3D -1; diff --git a/tools/virt-host-validate-common.c b/tools/virt-host-validate-c= ommon.c index 25cd60888a..cb0a152ce9 100644 --- a/tools/virt-host-validate-common.c +++ b/tools/virt-host-validate-common.c @@ -344,7 +344,7 @@ int virHostValidateIOMMU(const char *hvname, =20 if (flags && virBitmapIsBitSet(flags, VIR_HOST_VALIDATE_CPU_FLAG_VMX)) isIntel =3D true; - else if (flags && virBitmapIsBitSet(flags, VIR_HOST_VALIDATE_CPU_FLAG_= SVM)) + VIR_ELSIF (flags && virBitmapIsBitSet(flags, VIR_HOST_VALIDATE_CPU_FLA= G_SVM)) isAMD =3D true; =20 if (isIntel) { @@ -358,7 +358,7 @@ int virHostValidateIOMMU(const char *hvname, "hardware platform"); return VIR_HOST_VALIDATE_FAILURE(level); } - } else if (isAMD) { + } VIR_ELSIF (isAMD) { if (access("/sys/firmware/acpi/tables/IVRS", F_OK) =3D=3D 0) { virHostMsgPass(); bootarg =3D "iommu=3Dpt iommu=3D1"; @@ -369,9 +369,9 @@ int virHostValidateIOMMU(const char *hvname, "hardware platform"); return VIR_HOST_VALIDATE_FAILURE(level); } - } else if (ARCH_IS_PPC64(arch)) { + } VIR_ELSIF (ARCH_IS_PPC64(arch)) { virHostMsgPass(); - } else if (ARCH_IS_S390(arch)) { + } VIR_ELSIF (ARCH_IS_S390(arch)) { g_autoptr(DIR) dir =3D NULL; =20 /* On s390x, we skip the IOMMU check if there are no PCI @@ -461,7 +461,7 @@ int virHostValidateSecureGuests(const char *hvname, =20 if (flags && virBitmapIsBitSet(flags, VIR_HOST_VALIDATE_CPU_FLAG_FACIL= ITY_158)) hasFac158 =3D true; - else if (flags && virBitmapIsBitSet(flags, VIR_HOST_VALIDATE_CPU_FLAG_= SEV)) + VIR_ELSIF (flags && virBitmapIsBitSet(flags, VIR_HOST_VALIDATE_CPU_FLA= G_SEV)) hasAMDSev =3D true; =20 virHostMsgCheck(hvname, "%s", _("for secure guest support")); @@ -496,7 +496,7 @@ int virHostValidateSecureGuests(const char *hvname, "support for IBM Secure Execution"); return VIR_HOST_VALIDATE_FAILURE(level); } - } else if (hasAMDSev) { + } VIR_ELSIF (hasAMDSev) { if (virFileReadValueString(&mod_value, "/sys/module/kvm_amd/parame= ters/sev") < 0) { virHostMsgFail(level, "AMD Secure Encrypted Virtualization not= " "supported by the currently used kernel"= ); diff --git a/tools/virt-host-validate-qemu.c b/tools/virt-host-validate-qem= u.c index b79c941153..a68e9564ab 100644 --- a/tools/virt-host-validate-qemu.c +++ b/tools/virt-host-validate-qemu.c @@ -81,7 +81,7 @@ int virHostValidateQEMU(void) VIR_HOST_VALIDATE_FAIL, kvmhint) <0) ret =3D -1; - else if (virHostValidateDeviceAccessible("QEMU", "/dev/kvm", + VIR_ELSIF (virHostValidateDeviceAccessible("QEMU", "/dev/kvm", VIR_HOST_VALIDATE_FAIL, _("Check /dev/kvm is worl= d writable or you are in " "a group that is allowe= d to access it")) < 0) diff --git a/tools/vsh-table.c b/tools/vsh-table.c index 67f5d24071..f60bba5810 100644 --- a/tools/vsh-table.c +++ b/tools/vsh-table.c @@ -242,7 +242,7 @@ vshTableSafeEncode(const char *s, size_t *width) *buf++ =3D *p; (*width)++; } - } else if (!iswprint(wc)) { + } VIR_ELSIF (!iswprint(wc)) { size_t i; for (i =3D 0; i < len; i++) { g_snprintf(buf, HEX_ENCODE_LENGTH + 1, "\\x%02x", p[i]= ); diff --git a/tools/vsh.c b/tools/vsh.c index ecd9d3fcb1..b3d74e32d2 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -1051,7 +1051,7 @@ vshCommandOptStringReq(vshControl *ctl, /* this should not be propagated here, just to be sure */ if (ret =3D=3D -1) error =3D N_("Mandatory option not present"); - else if (arg && !*arg->data && !(arg->def->flags & VSH_OFLAG_EMPTY_OK)) + VIR_ELSIF (arg && !*arg->data && !(arg->def->flags & VSH_OFLAG_EMPTY_O= K)) error =3D N_("Option argument is empty"); =20 if (error) { @@ -1431,9 +1431,9 @@ vshCommandParse(vshControl *ctl, vshCommandParser *pa= rser, vshCmd **partial) =20 vshCmddefOptParse(cmd, &opts_need_arg, &opts_required); VIR_FREE(tkdata); - } else if (data_only) { + } VIR_ELSIF (data_only) { goto get_data; - } else if (tkdata[0] =3D=3D '-' && tkdata[1] =3D=3D '-' && + } VIR_ELSIF (tkdata[0] =3D=3D '-' && tkdata[1] =3D=3D '-' && g_ascii_isalnum(tkdata[2])) { char *optstr =3D strchr(tkdata + 2, '=3D'); size_t opt_index =3D 0; @@ -1497,7 +1497,7 @@ vshCommandParse(vshControl *ctl, vshCommandParser *pa= rser, vshCmd **partial) goto syntaxError; } } - } else if (tkdata[0] =3D=3D '-' && tkdata[1] =3D=3D '-' && + } VIR_ELSIF (tkdata[0] =3D=3D '-' && tkdata[1] =3D=3D '-' && tkdata[2] =3D=3D '\0') { VIR_FREE(tkdata); data_only =3D true; @@ -1686,7 +1686,7 @@ vshCommandStringGetArg(vshControl *ctl, vshCommandPar= ser *parser, char **res, single_quote =3D !single_quote; p++; continue; - } else if (!single_quote && *p =3D=3D '\\') { /* escape */ + } VIR_ELSIF (!single_quote && *p =3D=3D '\\') { /* escape */ /* * The same as in shell, a \ in "" is an escaper, * but a \ in '' is not an escaper. @@ -1696,12 +1696,12 @@ vshCommandStringGetArg(vshControl *ctl, vshCommandP= arser *parser, char **res, if (report) vshError(ctl, "%s", _("dangling \\")); return VSH_TK_ERROR; - } else if (*p =3D=3D '\n') { + } VIR_ELSIF (*p =3D=3D '\n') { /* Elide backslash-newline entirely */ p++; continue; } - } else if (!single_quote && *p =3D=3D '"') { /* double quote */ + } VIR_ELSIF (!single_quote && *p =3D=3D '"') { /* double quote */ double_quote =3D !double_quote; p++; continue; @@ -2357,7 +2357,7 @@ vshAskReedit(vshControl *ctl, const char *msg, bool r= elax_avail) _("? - print this help"), NULL); continue; - } else if (c =3D=3D 'y' || c =3D=3D 'n' || c =3D=3D 'f' || + } VIR_ELSIF (c =3D=3D 'y' || c =3D=3D 'n' || c =3D=3D 'f' || (relax_avail && c =3D=3D 'i')) { break; } @@ -2770,9 +2770,9 @@ vshReadlineParse(const char *text, int state) =20 VIR_UNLESS (cmd) { list =3D vshReadlineCommandGenerator(); - } else if (!opt || opt->type =3D=3D VSH_OT_BOOL) { + } VIR_ELSIF (!opt || opt->type =3D=3D VSH_OT_BOOL) { list =3D vshReadlineOptionsGenerator(cmd, partial); - } else if (opt && opt->completer) { + } VIR_ELSIF (opt && opt->completer) { list =3D opt->completer(autoCompleteOpaque, partial, opt->completer_flags); @@ -2866,7 +2866,7 @@ vshReadlineInit(vshControl *ctl) if (virStrToLong_i(histsize_str, NULL, 10, &max_history) < 0) { vshError(ctl, _("Bad $%s value."), histsize_env); return -1; - } else if (max_history > HISTSIZE_MAX || max_history < 0) { + } VIR_ELSIF (max_history > HISTSIZE_MAX || max_history < 0) { vshError(ctl, _("$%s value should be between 0 " "and %d"), histsize_env, HISTSIZE_MAX); @@ -3123,7 +3123,7 @@ cmdHelp(vshControl *ctl, const vshCmd *cmd) if (def->flags & VSH_CMD_FLAG_ALIAS) def =3D vshCmddefSearch(def->alias); return vshCmddefHelp(def); - } else if ((grp =3D vshCmdGrpSearch(name))) { + } VIR_ELSIF ((grp =3D vshCmdGrpSearch(name))) { return vshCmdGrpHelp(ctl, grp); } else { vshError(ctl, _("command or command group '%s' doesn't exist"), na= me); @@ -3239,9 +3239,9 @@ cmdEcho(vshControl *ctl, const vshCmd *cmd) =20 if (xml) { virBufferEscapeString(&buf, "%s", curr); - } else if (shell) { + } VIR_ELSIF (shell) { virBufferEscapeShell(&buf, curr); - } else if (split) { + } VIR_ELSIF (split) { g_auto(GStrv) spl =3D NULL; GStrv n; =20 --=20 2.34.1