From nobody Mon Feb 9 13:59:43 2026 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) 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 1710157148936410.3941697388592; Mon, 11 Mar 2024 04:39:08 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id E730A1F72; Mon, 11 Mar 2024 07:39:07 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 3EB6E1E9B; Mon, 11 Mar 2024 07:32:02 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 60A5B1C16; Mon, 11 Mar 2024 07:31:07 -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 AE2E11CEC for ; Mon, 11 Mar 2024 07:31:06 -0400 (EDT) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-214-CpNZeT52NQmBl6m52uVsdA-1; Mon, 11 Mar 2024 07:31:03 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id 43E9B1C0513D for ; Mon, 11 Mar 2024 11:31:03 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.5]) by smtp.corp.redhat.com (Postfix) with ESMTP id B187E112132A for ; Mon, 11 Mar 2024 11:31:02 +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.8 required=5.0 tests=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 X-MC-Unique: CpNZeT52NQmBl6m52uVsdA-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 01/23] vsh: Always assume that command groups are used Date: Mon, 11 Mar 2024 12:30:38 +0100 Message-ID: <70b642c6fb43a9da4d105723e7be74223668da6f.1710156504.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: PRGI2MPWQBCM3W2GHD3DDUZOFEAOPBIP X-Message-ID-Hash: PRGI2MPWQBCM3W2GHD3DDUZOFEAOPBIP X-MailFrom: pkrempa@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: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1710157150758100001 None of the clients use the 'command set' approach and other pieces of code such as the command validator already assume that command groups are in use. Remove the unused 'command set' stuff. Signed-off-by: Peter Krempa --- tools/virsh.c | 2 +- tools/virt-admin.c | 2 +- tools/vsh.c | 38 +++++++------------------------------- tools/vsh.h | 2 +- 4 files changed, 10 insertions(+), 34 deletions(-) diff --git a/tools/virsh.c b/tools/virsh.c index 95ff63baeb..18cd279aba 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -878,7 +878,7 @@ main(int argc, char **argv) virFileActivateDirOverrideForProg(argv[0]); - if (!vshInit(ctl, cmdGroups, NULL)) + if (!vshInit(ctl, cmdGroups)) exit(EXIT_FAILURE); if (!virshParseArgv(ctl, argc, argv) || diff --git a/tools/virt-admin.c b/tools/virt-admin.c index aaf6edb9a9..f551b33c4b 100644 --- a/tools/virt-admin.c +++ b/tools/virt-admin.c @@ -1594,7 +1594,7 @@ main(int argc, char **argv) virFileActivateDirOverrideForProg(argv[0]); - if (!vshInit(ctl, cmdGroups, NULL)) + if (!vshInit(ctl, cmdGroups)) exit(EXIT_FAILURE); if (!vshAdmParseArgv(ctl, argc, argv) || diff --git a/tools/vsh.c b/tools/vsh.c index 65deaa77e8..0c41e9cfe8 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -56,7 +56,6 @@ vshControl *autoCompleteOpaque; * and only relies on static data accessible from the user-side callback */ const vshCmdGrp *cmdGroups; -const vshCmdDef *cmdSet; double @@ -572,8 +571,8 @@ vshCommandCheckOpts(vshControl *ctl, const vshCmd *cmd,= uint64_t opts_required, return -1; } -static const vshCmdDef * -vshCmdDefSearchGrp(const char *cmdname) +const vshCmdDef * +vshCmddefSearch(const char *cmdname) { const vshCmdGrp *g; const vshCmdDef *c; @@ -588,28 +587,6 @@ vshCmdDefSearchGrp(const char *cmdname) return NULL; } -static const vshCmdDef * -vshCmdDefSearchSet(const char *cmdname) -{ - const vshCmdDef *s; - - for (s =3D cmdSet; s->name; s++) { - if (STREQ(s->name, cmdname)) - return s; - } - - return NULL; -} - -const vshCmdDef * -vshCmddefSearch(const char *cmdname) -{ - if (cmdGroups) - return vshCmdDefSearchGrp(cmdname); - else - return vshCmdDefSearchSet(cmdname); -} - const vshCmdGrp * vshCmdGrpSearch(const char *grpname) { @@ -3012,20 +2989,19 @@ vshInitDebug(vshControl *ctl) * Initialize global data */ bool -vshInit(vshControl *ctl, const vshCmdGrp *groups, const vshCmdDef *set) +vshInit(vshControl *ctl, const vshCmdGrp *groups) { if (!ctl->hooks) { vshError(ctl, "%s", _("client hooks cannot be NULL")); return false; } - if (!groups && !set) { - vshError(ctl, "%s", _("command groups and command set cannot both = be NULL")); + if (!groups) { + vshError(ctl, "%s", _("command groups must be non-NULL")); return false; } cmdGroups =3D groups; - cmdSet =3D set; if (vshInitDebug(ctl) < 0 || (ctl->imode && vshReadlineInit(ctl) < 0)) @@ -3037,8 +3013,8 @@ vshInit(vshControl *ctl, const vshCmdGrp *groups, con= st vshCmdDef *set) bool vshInitReload(vshControl *ctl) { - if (!cmdGroups && !cmdSet) { - vshError(ctl, "%s", _("command groups and command are both NULL ru= n vshInit before reloading")); + if (!cmdGroups) { + vshError(ctl, "%s", _("command groups is NULL run vshInit before r= eloading")); return false; } diff --git a/tools/vsh.h b/tools/vsh.h index 2a1be29b1c..17d7f08dc9 100644 --- a/tools/vsh.h +++ b/tools/vsh.h @@ -310,7 +310,7 @@ void vshPrint(vshControl *ctl, const char *format, ...) G_GNUC_PRINTF(2, 3); void vshPrintExtra(vshControl *ctl, const char *format, ...) G_GNUC_PRINTF(2, 3); -bool vshInit(vshControl *ctl, const vshCmdGrp *groups, const vshCmdDef *se= t); +bool vshInit(vshControl *ctl, const vshCmdGrp *groups); bool vshInitReload(vshControl *ctl); void vshDeinit(vshControl *ctl); void vshDebug(vshControl *ctl, int level, const char *format, ...) --=20 2.44.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org