From nobody Thu May 15 09:36:22 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1510840180773696.1435805325011; Thu, 16 Nov 2017 05:49:40 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0C049686AA; Thu, 16 Nov 2017 13:49:39 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C2E46614D8; Thu, 16 Nov 2017 13:49:38 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 777811800BDC; Thu, 16 Nov 2017 13:49:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vAGDnapg014120 for ; Thu, 16 Nov 2017 08:49:36 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1DA7360460; Thu, 16 Nov 2017 13:49:36 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 98D3660486 for ; Thu, 16 Nov 2017 13:49:35 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 16 Nov 2017 14:49:27 +0100 Message-Id: <767fbbf566cabe976970443ce5e21c0167a2c9ee.1510840039.git.mprivozn@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/3] vsh: Make self-test more robust X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 16 Nov 2017 13:49:39 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" There are couple of limitations when it comes to option types and flags for the options. For instance, VSH_OT_STRING cannot have VSH_OFLAG_REQ set (commit c7543a728). For some reason this is checked in vshCmddefHelp() but not in vshCmddefCheckInternals(). Signed-off-by: Michal Privoznik Reviewed-by: Erik Skultety --- tools/vsh.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/tools/vsh.c b/tools/vsh.c index 10a65c39f..75568353d 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -363,12 +363,15 @@ vshCmddefCheckInternals(const vshCmdDef *cmd) =20 if (i > 63) return -1; /* too many options */ - if (opt->type =3D=3D VSH_OT_BOOL) { + + switch (opt->type) { + case VSH_OT_STRING: + case VSH_OT_BOOL: if (opt->flags & VSH_OFLAG_REQ) return -1; /* bool options can't be mandatory */ - continue; - } - if (opt->type =3D=3D VSH_OT_ALIAS) { + break; + + case VSH_OT_ALIAS: { size_t j; char *name =3D (char *)opt->help; /* cast away const */ char *p; @@ -391,10 +394,22 @@ vshCmddefCheckInternals(const vshCmdDef *cmd) } if (!cmd->opts[j].name) return -1; /* alias option must map to a later option name= */ - continue; } - if (opt->type =3D=3D VSH_OT_ARGV && cmd->opts[i + 1].name) - return -1; /* argv option must be listed last */ + break; + case VSH_OT_ARGV: + if (cmd->opts[i + 1].name) + return -1; /* argv option must be listed last */ + break; + + case VSH_OT_DATA: + if (!(opt->flags & VSH_OFLAG_REQ)) + return -1; /* OT_DATA should always be required. */ + break; + + case VSH_OT_INT: + /* nada */ + break; + } } return 0; } --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list