From nobody Sat Nov 23 17:49:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1724078351063934.4974029526276; Mon, 19 Aug 2024 07:39:11 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id E87C2167B; Mon, 19 Aug 2024 10:39:09 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 040471607; Mon, 19 Aug 2024 10:38:39 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 471F3BFA; Mon, 19 Aug 2024 10:38:36 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id C60D5B24 for ; Mon, 19 Aug 2024 10:38:35 -0400 (EDT) Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-610-mIZoB5o8MvO4w_buWMPJCA-1; Mon, 19 Aug 2024 10:38:33 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BBAD01955BEE for ; Mon, 19 Aug 2024 14:38:32 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.3.102]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id EEED31955BF8 for ; Mon, 19 Aug 2024 14:38:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724078315; h=from:from: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; bh=cWRFt41lGCNMVZHDiWBPOAvNIMVV8zJ2K0JKf3mZmoE=; b=CjC6rmZjZcIBkspRi4gDJFx+fYh7y1b8tRkYWNF0FQKn6y13DCIUZAc9GhJ3SU3qx1HoH9 lGF2V003PHvIb6EyhWs69Xg+ZxQ7p4fA3jMusiQi+ceoWrEGZSoWaj8z2FxS1ZNmA9zd5U 9jAnFDGNbUxwFzj04Wl8qp5YSKQwm4w= X-MC-Unique: mIZoB5o8MvO4w_buWMPJCA-1 From: Michal Privoznik To: devel@lists.libvirt.org Subject: [PATCH 1/2] virsh: Simplify vshTableRowAppend() calling in cmdList(), part one Date: Mon, 19 Aug 2024 16:38:27 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: OUTL7MT77B4PITJJG367UJUGB4GWRJGL X-Message-ID-Hash: OUTL7MT77B4PITJJG367UJUGB4GWRJGL X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1724078352785116600 Content-Type: text/plain; charset="utf-8"; x-default="true" All calls to vshTableRowAppend() inside of cmdList() share couple of same arguments: domain ID, domain name and domain state. While the first one is stored in a variable and then passed to all vshTableRowAppend() calls, the others are passed as a function call. Switch the latter to variables too. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- tools/virsh-domain-monitor.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index 37184baa69..80b6857fad 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -1889,6 +1889,9 @@ cmdList(vshControl *ctl, const vshCmd *cmd) ignore_value(virStrcpyStatic(id_buf, "-")); =20 if (optTable) { + const char *domName =3D virDomainGetName(dom); + const char *stateStr =3D NULL; + state =3D virshDomainState(ctl, dom, NULL); =20 /* Domain could've been removed in the meantime */ @@ -1896,8 +1899,11 @@ cmdList(vshControl *ctl, const vshCmd *cmd) continue; =20 if (managed && state =3D=3D VIR_DOMAIN_SHUTOFF && - virDomainHasManagedSaveImage(dom, 0) > 0) - state =3D -2; + virDomainHasManagedSaveImage(dom, 0) > 0) { + stateStr =3D _("saved"); + } else { + stateStr =3D virshDomainStateToString(state); + } =20 if (optTitle && !optUUID) { g_autofree char *title =3D NULL; @@ -1905,9 +1911,7 @@ cmdList(vshControl *ctl, const vshCmd *cmd) if (!(title =3D virshGetDomainDescription(ctl, dom, true, = 0))) goto cleanup; if (vshTableRowAppend(table, id_buf, - virDomainGetName(dom), - state =3D=3D -2 ? _("saved") - : virshDomainStateToString(state), + domName, stateStr, title, NULL) < 0) goto cleanup; } else if (optUUID && !optTitle) { @@ -1916,9 +1920,7 @@ cmdList(vshControl *ctl, const vshCmd *cmd) goto cleanup; } if (vshTableRowAppend(table, id_buf, - virDomainGetName(dom), - state =3D=3D -2 ? _("saved") - : virshDomainStateToString(state), + domName, stateStr, uuid, NULL) < 0) goto cleanup; } else if (optUUID && optTitle) { @@ -1931,16 +1933,12 @@ cmdList(vshControl *ctl, const vshCmd *cmd) goto cleanup; } if (vshTableRowAppend(table, id_buf, - virDomainGetName(dom), - state =3D=3D -2 ? _("saved") - : virshDomainStateToString(state), + domName, stateStr, title, uuid, NULL) < 0) goto cleanup; } else { if (vshTableRowAppend(table, id_buf, - virDomainGetName(dom), - state =3D=3D -2 ? _("saved") - : virshDomainStateToString(state), + domName, stateStr, NULL) < 0) goto cleanup; } --=20 2.44.2