From nobody Mon May 20 01:44:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1605188829; cv=none; d=zohomail.com; s=zohoarc; b=krOizVp4YjulGwIf2k7OsMCSDeFcfNsaj1zvy9O2wAh9NgOFzIJBmdRq3iDievw77CjG284reYMBDsIVHGDwnOLeRKEYDmC3eQs6iwnMIp/v3pMZbYhLM71tIXtWzZOBKdRQX/m75qqocHSR9CC9mg53PukL/nwW0/DHyq4mF+4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605188829; 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=4vaF2OoaZNtRzcnJ0683Vab/tY5s4cdVMaAS+mLJKVs=; b=Y0/zHRQBCptF0OHh03tagsQVXSFvxMgPUCc74akvoWuVOy8oINbmOCqno5CeWIc9wgf8I5+NWNvJXfR2VBsDJ/PkcqTLjHH0jf6/YY2XPEo312PNtkiBxSPSblde/VM9GRRevsAGgewXvJyQvO/r+uW992Xi0as6pcuAb5b/xn8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1605188829523690.6507132582811; Thu, 12 Nov 2020 05:47:09 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-238-uPA0R5GpMziMU96HSe9pwQ-1; Thu, 12 Nov 2020 08:47:05 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id F11898018A4; Thu, 12 Nov 2020 13:46:59 +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 CFB416EF52; Thu, 12 Nov 2020 13:46:59 +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 980B8180B657; Thu, 12 Nov 2020 13:46:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0ACDhEbn012307 for ; Thu, 12 Nov 2020 08:43:14 -0500 Received: by smtp.corp.redhat.com (Postfix) id 535EE75135; Thu, 12 Nov 2020 13:43:14 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id A98867513E for ; Thu, 12 Nov 2020 13:43:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605188828; 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=4vaF2OoaZNtRzcnJ0683Vab/tY5s4cdVMaAS+mLJKVs=; b=XcU4GfurDMYyLMUcxKa/EIHLfv1cAazz+UbMBQ6tUCUiqJKtLdyMxiY8F8+24shuhWV2Y3 xn/hF29QAWHpGFDWTRBTCPrGzzFB3BycYOFJNtfhYcw5UbsU1X3iq6/hJGb2XYlKbVeaR3 pueCYrHYmJh5lwAAx0bGMGYi9Yc6Eo4= X-MC-Unique: uPA0R5GpMziMU96HSe9pwQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 1/8] tools: vsh: Unexport vshCmddefHelp Date: Thu, 12 Nov 2020 14:42:58 +0100 Message-Id: <0c33a7f1b66d0f02024e4eac7c7325a44e03450e.1605188395.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tools/vsh.c | 2 +- tools/vsh.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/vsh.c b/tools/vsh.c index ca92bcd78c..e5ecc38f73 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -600,7 +600,7 @@ vshCmdGrpHelp(vshControl *ctl, const vshCmdGrp *grp) return true; } -bool +static bool vshCmddefHelp(vshControl *ctl, const vshCmdDef *def) { const char *desc =3D NULL; diff --git a/tools/vsh.h b/tools/vsh.h index 5583fef9cc..0c5584891d 100644 --- a/tools/vsh.h +++ b/tools/vsh.h @@ -248,7 +248,6 @@ void vshCloseLogFile(vshControl *ctl); const char *vshCmddefGetInfo(const vshCmdDef *cmd, const char *info); const vshCmdDef *vshCmddefSearch(const char *cmdname); -bool vshCmddefHelp(vshControl *ctl, const vshCmdDef *def); const vshCmdGrp *vshCmdGrpSearch(const char *grpname); bool vshCmdGrpHelp(vshControl *ctl, const vshCmdGrp *grp); --=20 2.28.0 From nobody Mon May 20 01:44:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1605188626; cv=none; d=zohomail.com; s=zohoarc; b=T0bKzcMgkNhYzD1sulsyuphxaTCsyKL2rX5hEfHvkGyzSmSXQIYzc2Zj5u+uFpTce0BrwtReDJPU5ES1f819w+rCKPTHyYXV7lSOIbTWn4YiKUSmfIQYiCf1Wll+L/NcLPfvFWf3FcNUbuY3TDYgxHJt8nIgWy4mcBZGfJ8Tc20= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605188626; 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=lCAAXe4CTnIYT1znRUET+gLl2SFzTrPXGIJh5Hb1l3I=; b=mFXs5HHjs5wYCXy/d+mVs6ltomScxytC6nwF7eNaN+kOXL7oElMFF7udj+eZWWcCt+F1LdqQ10oujW0ajaqQW4vBjQ7IrsBAqKylZ4Z4yyzTFJbqZ4D6Dm9Ph8NnE142VKar1kE0zokk19N37zd/AMHl/F3y2eVIeVsx9mcw4TU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1605188626250925.4409215624374; Thu, 12 Nov 2020 05:43:46 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-177-FJ64H_uIPgKuUOna6UuJ8g-1; Thu, 12 Nov 2020 08:43:42 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BAD538018A4; Thu, 12 Nov 2020 13:43:36 +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 9921975135; Thu, 12 Nov 2020 13:43:36 +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 60712181A06E; Thu, 12 Nov 2020 13:43:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0ACDhHeL012324 for ; Thu, 12 Nov 2020 08:43:17 -0500 Received: by smtp.corp.redhat.com (Postfix) id A96607513C; Thu, 12 Nov 2020 13:43:17 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id DD85275138 for ; Thu, 12 Nov 2020 13:43:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605188625; 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=lCAAXe4CTnIYT1znRUET+gLl2SFzTrPXGIJh5Hb1l3I=; b=Xn8BcwiiFIUVu0ZRnW4tRu2lgAGK4EDSbdCFwNgZNhqWftfkcfwyKHuECnTYiz33l9fCa/ hAxUin+wCkUGiLdc4JLuXm0/1jTkvIo4w3h1VOp6Ma8mRfS75mtwJa/yh0/23Tx9cOK2fN 34qey7F9F7OCvn0P9qAkE2bb3a98lXA= X-MC-Unique: FJ64H_uIPgKuUOna6UuJ8g-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 2/8] tools: vshCmddefCheckInternals: Add parameter name to error message Date: Thu, 12 Nov 2020 14:42:59 +0100 Message-Id: <2b8e14f9089bc7d77257cea9d6d1f5f51e2cb6a8.1605188395.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" If a parameter definition is invalid we can include the name of the parameter for simpler debugging. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tools/vsh.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tools/vsh.c b/tools/vsh.c index e5ecc38f73..d1e795bbc1 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -307,8 +307,8 @@ vshCmddefCheckInternals(vshControl *ctl, case VSH_OT_STRING: case VSH_OT_BOOL: if (opt->flags & VSH_OFLAG_REQ) { - vshError(ctl, _("command '%s' misused VSH_OFLAG_REQ"), - cmd->name); + vshError(ctl, _("parameter '%s' of command '%s' misused VS= H_OFLAG_REQ"), + opt->name, cmd->name); return -1; /* neither bool nor string options can be manda= tory */ } break; @@ -319,8 +319,8 @@ vshCmddefCheckInternals(vshControl *ctl, char *p; if (opt->flags || !opt->help) { - vshError(ctl, _("command '%s' has incorrect alias option"), - cmd->name); + vshError(ctl, _("parameter '%s' of command '%s' has incorr= ect alias option"), + opt->name, cmd->name); return -1; /* alias options are tracked by the original na= me */ } if ((p =3D strchr(name, '=3D'))) @@ -334,30 +334,30 @@ vshCmddefCheckInternals(vshControl *ctl, VIR_FREE(name); /* If alias comes with value, replacement must not be bool= */ if (cmd->opts[j].type =3D=3D VSH_OT_BOOL) { - vshError(ctl, _("command '%s' has mismatched alias typ= e"), - cmd->name); + vshError(ctl, _("alias '%s' of command '%s' has mismat= ched alias type"), + opt->name, cmd->name); return -1; } } if (!cmd->opts[j].name) { - vshError(ctl, _("command '%s' has missing alias option"), - cmd->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= */ } } break; case VSH_OT_ARGV: if (cmd->opts[i + 1].name) { - vshError(ctl, _("command '%s' does not list argv option la= st"), - cmd->name); + vshError(ctl, _("parameter '%s' of command '%s' must be li= sted last"), + opt->name, cmd->name); return -1; /* argv option must be listed last */ } break; case VSH_OT_DATA: if (!(opt->flags & VSH_OFLAG_REQ)) { - vshError(ctl, _("command '%s' has non-required VSH_OT_DATA= "), - cmd->name); + 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. */ } break; --=20 2.28.0 From nobody Mon May 20 01:44:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1605188830; cv=none; d=zohomail.com; s=zohoarc; b=XD6Jhh4GeyilbVMfKbktsCqx1I3Ifth1uX1nrydUdCLj7pr2sWd250LAiWYvkAS3oJbldVkky5N3R3J8MfuEJ6IenFtE/j+eznPFYFL1528YJ4uSEBgvhBGsJtW585x32hI8deTRxlIYlYnet9OJZIVOwq7lwi0hZlIAxPObNzM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605188830; 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=AoGDmw/q0YJ5a038Rgd929I8ZYEVZystf9w7vXYx7FI=; b=n1qVCOg3FYyWb4MzcMWIt32nA6logcSDiOjeo6rseXQnn8ePAe9tniLXZsMpkajbkua40mDl8QEj3+//vkZ+t+XJqGQJl6vIEgL+ANDa9DJoEmRflCLhcm3Rz3VWr4stH+vSTTl42XyIVoEMbjxq3Mvq6hgXY3oGPBWLllRMhpU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1605188830985811.4604337331085; Thu, 12 Nov 2020 05:47:10 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-372-6OGVYiegNI-fC7wnI5nidQ-1; Thu, 12 Nov 2020 08:47:07 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C9064186DD4D; Thu, 12 Nov 2020 13:47:02 +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 A78375D9E8; Thu, 12 Nov 2020 13:47:02 +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 6E6DD181A050; Thu, 12 Nov 2020 13:47:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0ACDhJcT012332 for ; Thu, 12 Nov 2020 08:43:19 -0500 Received: by smtp.corp.redhat.com (Postfix) id F2A1255766; Thu, 12 Nov 2020 13:43:18 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4D62A7F8C8 for ; Thu, 12 Nov 2020 13:43:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605188829; 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=AoGDmw/q0YJ5a038Rgd929I8ZYEVZystf9w7vXYx7FI=; b=DJDDclELLm+DWwYGnGKk8Tun2xoZJO9TZiNGGrVjK7Uf3Ycp4yikROLZWPLAwhLLeIwAXw exh9XV55YmghnrABiGU5QyFKFQlmqSP3O3bUnpri3yIYYu1NmqvaeCd/NCLRJI6GswvOjl bSgL+u5TCVlAAqxAnb/M5pwilj0gjsg= X-MC-Unique: 6OGVYiegNI-fC7wnI5nidQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 3/8] tools: vshCmddefCheckInternals: Port mandatory options check from vshCmddefOptParse Date: Thu, 12 Nov 2020 14:43:00 +0100 Message-Id: <654c8ab8033e571c15b24574e46952eab0b595db.1605188395.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" 'vshCmddefCheckInternals' is the go-to place for all checks related to the definition of parameters for commands, but the check that all mandatory parameters must be ordered before optional parameters was still only in vshCmddefOptParse. Adding a non-compliant option would not be caught by our test suite as 'virsh self-test' doesn't call vshCmddefOptParse. Re-implement the check in vshCmddefCheckInternals. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tools/vsh.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tools/vsh.c b/tools/vsh.c index d1e795bbc1..28c7533a25 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -276,6 +276,7 @@ vshCmddefCheckInternals(vshControl *ctl, { size_t i; const char *help =3D NULL; + bool seenOptionalOption =3D false; /* in order to perform the validation resolve the alias first */ if (cmd->flags & VSH_CMD_FLAG_ALIAS) { @@ -311,6 +312,8 @@ vshCmddefCheckInternals(vshControl *ctl, opt->name, cmd->name); return -1; /* neither bool nor string options can be manda= tory */ } + + seenOptionalOption =3D true; break; case VSH_OT_ALIAS: { @@ -360,9 +363,25 @@ vshCmddefCheckInternals(vshControl *ctl, opt->name, cmd->name); return -1; /* OT_DATA should always be required. */ } + + if (seenOptionalOption) { + vshError(ctl, _("parameter '%s' of command '%s' must be li= sted before optional parameters"), + opt->name, cmd->name); + return -1; /* mandatory options must be listed first */ + } break; case VSH_OT_INT: + if (opt->flags & VSH_OFLAG_REQ) { + if (seenOptionalOption) { + vshError(ctl, _("parameter '%s' of command '%s' must b= e listed before optional parameters"), + opt->name, cmd->name); + return -1; /* mandatory options must be listed first = */ + } + } else { + seenOptionalOption =3D true; + } + break; } } --=20 2.28.0 From nobody Mon May 20 01:44:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1605188835; cv=none; d=zohomail.com; s=zohoarc; b=Z0Ie2Ncjo6355EdBQIo/LwVsbxqSZZ6R1QfrdJnHynQSgvDiluwEb+qhyUE2lvOxoGRmTTUEtrVSvof7G5faxbqpYsBf5lgafYJlqYFcLAClikjOuHmAGlz60089SpNTUNITBPDbOOjTjtrDxnwid7b+MiImap9rdr7o+zSM4cg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605188835; 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=depEI6wYSOIKD2riX/cSvKA7DoxQALt7L+QWYtPGYdc=; b=EL3ignsrAsFIDfP8GtbdsA1YIKfXq9Wz4F7q1mw7u85UfHdieXmbyPUakwLjmCXQ1d7x8YjDPOT3bWZ7ZDEVJSgKhMmtRUhSYPwtCybKJ4tx5sYUVzE1SrU8PTg61jOCwMFYuRdjTtvwxlvvkct7XJiHV0kGySZN9e/LHsb0poI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1605188835349585.1156012261085; Thu, 12 Nov 2020 05:47:15 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-139-q4gNBPHpNqivUEf-9DtUXA-1; Thu, 12 Nov 2020 08:47:12 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BA43E1006CA9; Thu, 12 Nov 2020 13:47:05 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 97F8B55766; Thu, 12 Nov 2020 13:47:05 +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 61F235810C; Thu, 12 Nov 2020 13:47:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0ACDhKof012341 for ; Thu, 12 Nov 2020 08:43:20 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3B7CB55766; Thu, 12 Nov 2020 13:43:20 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7375375132 for ; Thu, 12 Nov 2020 13:43:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605188834; 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=depEI6wYSOIKD2riX/cSvKA7DoxQALt7L+QWYtPGYdc=; b=QD9UP6G8WRDoOwFXTpsBp1fTOjUsgYfkV5tCe/XhOag5pL2w0vVSI89hn7Yd47Q5c5OknZ uopluLST1U3DCPriWOCMTBFl4WlEOQKkykeOy1tAFFkVOPIE32GIhOeQyrRRgdjJPobZqG AsqJdu89EcZz+3mG0fvalO/3h0jbs8s= X-MC-Unique: q4gNBPHpNqivUEf-9DtUXA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 4/8] tools: cmdSelfTest: Drop misleading comment Date: Thu, 12 Nov 2020 14:43:01 +0100 Message-Id: <49dc09f917dbab6e0363319bfb864200acec5279.1605188395.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" We no longer print help for every command to validate the args. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tools/vsh.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/tools/vsh.c b/tools/vsh.c index 28c7533a25..cf4ddc1c2c 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -3324,9 +3324,6 @@ const vshCmdInfo info_selftest[] =3D { {.name =3D NULL} }; -/* Prints help for every command. - * That runs vshCmddefOptParse which validates - * the per-command options structure. */ bool cmdSelfTest(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED) --=20 2.28.0 From nobody Mon May 20 01:44:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1605188613; cv=none; d=zohomail.com; s=zohoarc; b=aVHKgQ2bJ9BlGIG5zlOq/dBEQVL+xupXiRKdAWbJHan9kQZFii3TrukhGW4hdhGc2qEM53MDgLCcrpV/b5Tj9B0wGm1WUpmip4s7cCwUEgnkyvdWewWg0QLL8yrtpqmLePVGJ698d/VaYeNeB8aeOeJZwaqImCgF5EtdvPHt1hI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605188613; 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=xYU7pVLy/vEmEh4gHiGhwuhnsyyk0u2+SxBCx3pPRyM=; b=CK611Yql6pAhPPriG7iSHBqaG0skpZtNoSjVAt70hZsF+e3QMalVAshgaVVhqKjDLZpqdeqPKI+2tSl0C9Bp0d1sMcLqOXQ8EOlBWmLRIyNeuK4UCQ47yxAM1uRhuZb6G+5dw3bMBktEyiyXToU4/NlY16tofIoBM9lRoRz/7Lc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1605188613281663.9750623417275; Thu, 12 Nov 2020 05:43:33 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-410-9-6v-xpnMyOEfmH6ApdXww-1; Thu, 12 Nov 2020 08:43:30 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0564218B6472; Thu, 12 Nov 2020 13:43:25 +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 D544575139; Thu, 12 Nov 2020 13:43:24 +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 65EE9181A06B; Thu, 12 Nov 2020 13:43:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0ACDhLfF012352 for ; Thu, 12 Nov 2020 08:43:21 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7B37A75135; Thu, 12 Nov 2020 13:43:21 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id C27E255766 for ; Thu, 12 Nov 2020 13:43:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605188612; 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=xYU7pVLy/vEmEh4gHiGhwuhnsyyk0u2+SxBCx3pPRyM=; b=b0iEcNlbJAB8Qzb9m95ZbGw+rYwW8OZYtTARlnarndbOJcixyYDUVyTBWSgc/XdU8u6OCd Rx6P5RZOM+we7hTrL+L1aF2VteuNx3DsF3vsrQ/s2hq1c8Suk9ZXhjc5eUTli51ngDkzYn QhqZ0rdhkblOw4co+AtPj+MRtBcKHg0= X-MC-Unique: 9-6v-xpnMyOEfmH6ApdXww-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 5/8] tools: vshCmddefOptParse: Remove 'optional' command validation Date: Thu, 12 Nov 2020 14:43:02 +0100 Message-Id: <6766b37fcdbe52d03d295e30cf1d8e3a26b384ec.1605188395.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Since vshCmddefCheckInternals now has this check we no longer need it in vshCmddefOptParse. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tools/vsh.c | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/tools/vsh.c b/tools/vsh.c index cf4ddc1c2c..f92759f219 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -399,7 +399,6 @@ vshCmddefOptParse(const vshCmdDef *cmd, uint64_t *opts_= need_arg, uint64_t *opts_required) { size_t i; - bool optional =3D false; *opts_need_arg =3D 0; *opts_required =3D 0; @@ -410,30 +409,17 @@ vshCmddefOptParse(const vshCmdDef *cmd, uint64_t *opt= s_need_arg, for (i =3D 0; cmd->opts[i].name; i++) { const vshCmdOptDef *opt =3D &cmd->opts[i]; - if (opt->type =3D=3D VSH_OT_BOOL) { - optional =3D true; + if (opt->type =3D=3D VSH_OT_BOOL) continue; - } - - if (opt->flags & VSH_OFLAG_REQ_OPT) { - if (opt->flags & VSH_OFLAG_REQ) - *opts_required |=3D 1ULL << i; - else - optional =3D true; - continue; - } if (opt->type =3D=3D VSH_OT_ALIAS) continue; /* skip the alias option */ - *opts_need_arg |=3D 1ULL << i; - if (opt->flags & VSH_OFLAG_REQ) { - if (optional && opt->type !=3D VSH_OT_ARGV) - return -1; /* mandatory options must be listed first */ + if (!(opt->flags & VSH_OFLAG_REQ_OPT)) + *opts_need_arg |=3D 1ULL << i; + + if (opt->flags & VSH_OFLAG_REQ) *opts_required |=3D 1ULL << i; - } else { - optional =3D true; - } } return 0; --=20 2.28.0 From nobody Mon May 20 01:44:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1605188628; cv=none; d=zohomail.com; s=zohoarc; b=Rzy3u67JMpUZnCM4DXJoEhHyNAhBMFi7rLpsg8P0p6LXJh7I5R7eFwt0H35NKKZFGJomvZfrKrZADDkeaS+yoABrMOZiIGK7TQ+LkS9kK3dZO9aiEfrV5vDizViQiQPrFPkkAUagsXSvlGSVGw7aAKHkLVPu5aM6WczxJ/iiuuA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605188628; 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=jCfDzenyw+H5TjGsfn8VXOyEZq75ono1iMrgVH7ltck=; b=eF3V7hyZ6kmeThR3Rc0CYRemHUGJfD9y6AtA+8Ui1Y22eNoepsrZYBHeCgBs0byqcSImUwXqXrq/8wqZhNNXsy0fTvBxQFG4tqlPH4eYD+1pidMfFvICx7JjHV6wlR3XtyMLD6PFhM9kAav61v/kMXN+EPR/GRQh18GNDZAYVHU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1605188628588933.1048252461989; Thu, 12 Nov 2020 05:43:48 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-62-_yENGGQiPjmvKnm4p8Ds7g-1; Thu, 12 Nov 2020 08:43:45 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C77281017DC8; Thu, 12 Nov 2020 13:43: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 A56291002C26; Thu, 12 Nov 2020 13:43:39 +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 44C40181A07E; Thu, 12 Nov 2020 13:43:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0ACDhPFB012369 for ; Thu, 12 Nov 2020 08:43:25 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0A0A255766; Thu, 12 Nov 2020 13:43:25 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6D5F675141 for ; Thu, 12 Nov 2020 13:43:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605188627; 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=jCfDzenyw+H5TjGsfn8VXOyEZq75ono1iMrgVH7ltck=; b=g+hl2YkuJLN0fCgQuU3EYyADPh/s2EFBYtDSgDfNPYWNnT6Ubsr23vbbFclAFf7zanG3Oc 25w2w5ikW9aSZSe4S6aAputCW7qGpH/F2L+DEgV+9657N9czvlN/9Oq0glTiciZDoxD7nK BkdqfTAZjq63jVABfoWCiVAnqOrfm8o= X-MC-Unique: _yENGGQiPjmvKnm4p8Ds7g-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 6/8] tools: vshCmddefHelp: Don't call vshCmddefOptParse Date: Thu, 12 Nov 2020 14:43:03 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The help formatter called vshCmddefOptParse just for validation purposes. Since vshCmddefOptParse no longer validates the command itself and we don't need the bitmaps returned by it we can drop the call entirely. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tools/vsh.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/tools/vsh.c b/tools/vsh.c index f92759f219..2de940277e 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -606,20 +606,12 @@ vshCmdGrpHelp(vshControl *ctl, const vshCmdGrp *grp) } static bool -vshCmddefHelp(vshControl *ctl, const vshCmdDef *def) +vshCmddefHelp(const vshCmdDef *def) { const char *desc =3D NULL; char buf[256]; - uint64_t opts_need_arg; - uint64_t opts_required; bool shortopt =3D false; /* true if 'arg' works instead of '--opt arg'= */ - if (vshCmddefOptParse(def, &opts_need_arg, &opts_required)) { - vshError(ctl, _("internal error: bad options in command: '%s'"), - def->name); - return false; - } - fputs(_(" NAME\n"), stdout); fprintf(stdout, " %s - %s\n", def->name, _(vshCmddefGetInfo(def, "help"))); @@ -3113,7 +3105,7 @@ cmdHelp(vshControl *ctl, const vshCmd *cmd) if ((def =3D vshCmddefSearch(name))) { if (def->flags & VSH_CMD_FLAG_ALIAS) def =3D vshCmddefSearch(def->alias); - return vshCmddefHelp(ctl, def); + return vshCmddefHelp(def); } else if ((grp =3D vshCmdGrpSearch(name))) { return vshCmdGrpHelp(ctl, grp); } else { --=20 2.28.0 From nobody Mon May 20 01:44:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1605188627; cv=none; d=zohomail.com; s=zohoarc; b=JDNQorOtVPm1U2fNLL1+TyrvIVzR6mqIW0mOcuPsx9zYDTKhAzDa5u0/dL/GdQvqAqWLDUO5Rb5dOEXfdOCISATtrIdFQY1a0u3NIaccyZFBhhzlUkZR7JYzFkg26BGJf1u8sZiqvij2CDGHQ/rWxTgQJNjFUq/TnW3sJ3uBZRs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605188627; 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=Fut62sPR//YLgw37ILRnooQir7SQGH8UIV4h4G5POZw=; b=NaTB/6mF1Zh6NjiL0jlBbQOiIQ60g3S6xvu595SloHHaiR8pGbIHhCV+Ew6/sgK4ZMEW1si/KfCJIgaPZK6PugyINavq4Y2zr7m2PZn+jS33YxfaM2nme68DQ3ynrU7Zfz7UAosO3jY02rNYs0jgFi0qI4KMTvY10cZT1rKlnQk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1605188627241835.0406648753142; Thu, 12 Nov 2020 05:43:47 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-279-ZT5YaXQ6PMGfVdrRUP7Lfw-1; Thu, 12 Nov 2020 08:43:43 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 85A4018B9EC1; Thu, 12 Nov 2020 13:43:37 +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 605885C1A3; Thu, 12 Nov 2020 13:43:37 +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 217EF181A07B; Thu, 12 Nov 2020 13:43:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0ACDhZoB012393 for ; Thu, 12 Nov 2020 08:43:35 -0500 Received: by smtp.corp.redhat.com (Postfix) id 926F475135; Thu, 12 Nov 2020 13:43:35 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id E91EB7513C for ; Thu, 12 Nov 2020 13:43:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605188626; 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=Fut62sPR//YLgw37ILRnooQir7SQGH8UIV4h4G5POZw=; b=ETvg6hbV659plHWU7mmUK6HrEexRVKIf0stWO5sKjLzz+v1I0yU59Eox4+AWAIDf4207OT qfNjoL89fSgfeJcliT3j6U0ZmoJSZVpnv7lRa1D+QQgcI0fgESprJjGAdQrYkI7myqIT9t p/A56oMQWpcAuUL68Tv7ZdAn4h73+Ts= X-MC-Unique: ZT5YaXQ6PMGfVdrRUP7Lfw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 7/8] tools: vshCmddefOptParse: Remove return value Date: Thu, 12 Nov 2020 14:43:04 +0100 Message-Id: <3d655b7b59da9377be180f3af3cc0c9b6221b208.1605188395.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The function can't fail so there's no need to return a value or check it in the callers. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tools/vsh.c | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/tools/vsh.c b/tools/vsh.c index 2de940277e..badd37c08e 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -389,13 +389,11 @@ vshCmddefCheckInternals(vshControl *ctl, } /* Parse the options associated with @cmd, i.e. test whether options are - * required or need an argument. - * - * Returns -1 on error or 0 on success, filling the caller-provided bitmaps - * which keep track of required options and options needing an argument. + * required or need an argument and fill the appropriate caller-provided b= itmaps */ -static int -vshCmddefOptParse(const vshCmdDef *cmd, uint64_t *opts_need_arg, +static void +vshCmddefOptParse(const vshCmdDef *cmd, + uint64_t *opts_need_arg, uint64_t *opts_required) { size_t i; @@ -404,7 +402,7 @@ vshCmddefOptParse(const vshCmdDef *cmd, uint64_t *opts_= need_arg, *opts_required =3D 0; if (!cmd->opts) - return 0; + return; for (i =3D 0; cmd->opts[i].name; i++) { const vshCmdOptDef *opt =3D &cmd->opts[i]; @@ -421,8 +419,6 @@ vshCmddefOptParse(const vshCmdDef *cmd, uint64_t *opts_= need_arg, if (opt->flags & VSH_OFLAG_REQ) *opts_required |=3D 1ULL << i; } - - return 0; } static vshCmdOptDef helpopt =3D { @@ -1388,14 +1384,8 @@ vshCommandParse(vshControl *ctl, vshCommandParser *p= arser, vshCmd **partial) tkdata =3D g_strdup(cmd->alias); cmd =3D vshCmddefSearch(tkdata); } - if (vshCmddefOptParse(cmd, &opts_need_arg, - &opts_required) < 0) { - if (!partial) - vshError(ctl, - _("internal error: bad options in command= : '%s'"), - tkdata); - goto syntaxError; - } + + vshCmddefOptParse(cmd, &opts_need_arg, &opts_required); VIR_FREE(tkdata); } else if (data_only) { goto get_data; --=20 2.28.0 From nobody Mon May 20 01:44:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1605188709; cv=none; d=zohomail.com; s=zohoarc; b=hDHpS95QZNKgzFTPCzchE+gref4YvujfI8nWpTKkqlV+RFaNaZVQQ+NvRgww655hIwmR1zvKwtwcX6ySfkFworW6wayDG/blragONzDI1ePwWN9rpPDSGJrHnpQ3T8zFzCq9tv2w1URWbgQ1Va74MoKVAIoFvxyYXQ6F+xF80AA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605188709; 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=ofnKfqtrpTSf7cx9dz74tTSEX9OQEometgPANbB202Y=; b=ZxPnQaFgotAzg8PWgsIcpswiJGClzAuMTpVlxK3j6JZsMmtddH6bP0sKCUwX3emcO7XQNqEV3MxVLZcc/xdPPxVLvR80FU27eGUXuJgTLh/7ria3agvR6o1XZBwqhKN8LJjEKzeULhZSA7t6QDNrJK2baPpf3xpeaed5JYGgrUQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1605188709917473.9519981703314; Thu, 12 Nov 2020 05:45:09 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-207-WvaUlJ-VMVuDWBytoplojw-1; Thu, 12 Nov 2020 08:43:48 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 86AF3AF069; Thu, 12 Nov 2020 13:43:40 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5AD975C1A3; Thu, 12 Nov 2020 13:43:40 +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 236509982; Thu, 12 Nov 2020 13:43:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0ACDhdVX012412 for ; Thu, 12 Nov 2020 08:43:39 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1476275139; Thu, 12 Nov 2020 13:43:39 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7294855766 for ; Thu, 12 Nov 2020 13:43:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605188708; 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=ofnKfqtrpTSf7cx9dz74tTSEX9OQEometgPANbB202Y=; b=HzlUhUxxRPFN6ivjL4vXAt1DBpU/GTTON6WHOj/YALalAoYE0hRVjwpd46pGEHZEmog404 UbEZhIphcTRiIWyAVffQiI5xk4JyaDYdcJqh8d6Rgi2UkWSgWDIkBmrqlLQmnaSx7rPZ2j d5zo1kIcW7oAYdcGn2r9kJkq6NcZK6U= X-MC-Unique: WvaUlJ-VMVuDWBytoplojw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 8/8] tools: virsh: Reset error when keepalive registration fails Date: Thu, 12 Nov 2020 14:43:05 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" We try to enable keepalive oportunistically. If it's not supported by the connection driver and it was not explicitly requested we keep the error object set and can report it in some cases accidentally: Reviewed-by: J=C3=A1n Tomko --- stdout --- TEST: /home/pipo/libvirt/tests/virsh-self-test ! 1 FAILED --- stderr --- error: parameter 'target' of command 'attach-disk' must be listed before op= tional parameters error: this function is not supported by the connection driver: virConnectS= etKeepAlive ------- Clear the stored libvirt error. Signed-off-by: Peter Krempa --- tools/virsh.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/virsh.c b/tools/virsh.c index 954778b626..a6bfbbbb87 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -176,6 +176,7 @@ virshConnect(vshControl *ctl, const char *uri, bool rea= donly) } vshDebug(ctl, VSH_ERR_INFO, "%s", _("Failed to setup keepalive on connection\n")); + vshResetLibvirtError(); } cleanup: --=20 2.28.0