From nobody Mon Feb 9 12:11:18 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 1710511510814334.92127096265335; Fri, 15 Mar 2024 07:05:10 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 9C7E91EFB; Fri, 15 Mar 2024 10:05:09 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id C6A811B11; Fri, 15 Mar 2024 09:46:22 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 837A8179C; Fri, 15 Mar 2024 09:45:34 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 CEF451BC9 for ; Fri, 15 Mar 2024 09:44:51 -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-255-bmydWqXNMkeIGGm2AdG81A-1; Fri, 15 Mar 2024 09:44:50 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (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 EEC281C2CEC1 for ; Fri, 15 Mar 2024 13:44:49 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.5]) by smtp.corp.redhat.com (Postfix) with ESMTP id 67475C15771 for ; Fri, 15 Mar 2024 13:44:49 +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: bmydWqXNMkeIGGm2AdG81A-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 27/28] vsh: Replace 'VSH_OFLAG_EMPTY_OK' bitwise flag with a separate struct member Date: Fri, 15 Mar 2024 14:44:22 +0100 Message-ID: <79262171d399665d6df93ee085a2b2195e0b984d.1710510137.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: 32JGPXE44UZQROUWFIUEQF2QY67OP7AD X-Message-ID-Hash: 32JGPXE44UZQROUWFIUEQF2QY67OP7AD 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: 1710511511554100001 Replace the last bitwise flag with a separate member. Signed-off-by: Peter Krempa --- tools/virsh-domain-monitor.c | 2 +- tools/virsh-domain.c | 6 +++--- tools/virsh.c | 2 +- tools/virt-admin.c | 6 +++--- tools/vsh.c | 6 +++--- tools/vsh.h | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index 5531d3b737..eec97b7d59 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -864,8 +864,8 @@ static const vshCmdOptDef opts_domblkstat[] =3D { VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE), {.name =3D "device", .type =3D VSH_OT_STRING, - .flags =3D VSH_OFLAG_EMPTY_OK, .positional =3D true, + .allowEmpty =3D true, .completer =3D virshDomainDiskTargetCompleter, .help =3D N_("block device") }, diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 91a9dfd96a..1ba38629ac 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -422,7 +422,7 @@ static const vshCmdOptDef opts_attach_disk[] =3D { .type =3D VSH_OT_STRING, .positional =3D true, .required =3D true, - .flags =3D VSH_OFLAG_EMPTY_OK, + .allowEmpty =3D true, .help =3D N_("source of disk device or name of network disk") }, {.name =3D "target", @@ -6838,7 +6838,7 @@ static const vshCmdOptDef opts_vcpupin[] =3D { {.name =3D "cpulist", .type =3D VSH_OT_STRING, .unwanted_positional =3D true, - .flags =3D VSH_OFLAG_EMPTY_OK, + .allowEmpty =3D true, .completer =3D virshDomainCpulistCompleter, .help =3D N_("host cpu number(s) to set, or omit option to query") }, @@ -7047,7 +7047,7 @@ static const vshCmdOptDef opts_emulatorpin[] =3D { {.name =3D "cpulist", .type =3D VSH_OT_STRING, .unwanted_positional =3D true, - .flags =3D VSH_OFLAG_EMPTY_OK, + .allowEmpty =3D true, .completer =3D virshDomainCpulistCompleter, .help =3D N_("host cpu number(s) to set, or omit option to query") }, diff --git a/tools/virsh.c b/tools/virsh.c index 890c96e552..0a586fd639 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -246,7 +246,7 @@ static const vshCmdOptDef opts_connect[] =3D { {.name =3D "name", .type =3D VSH_OT_STRING, .positional =3D true, - .flags =3D VSH_OFLAG_EMPTY_OK, + .allowEmpty =3D true, .completer =3D virshCompleteEmpty, .help =3D N_("hypervisor connection URI") }, diff --git a/tools/virt-admin.c b/tools/virt-admin.c index 9a29a67999..ce60077672 100644 --- a/tools/virt-admin.c +++ b/tools/virt-admin.c @@ -255,7 +255,7 @@ static const vshCmdOptDef opts_connect[] =3D { {.name =3D "name", .type =3D VSH_OT_STRING, .positional =3D true, - .flags =3D VSH_OFLAG_EMPTY_OK, + .allowEmpty =3D true, .help =3D N_("daemon's admin server connection URI") }, {.name =3D NULL} @@ -961,7 +961,7 @@ static const vshCmdOptDef opts_daemon_log_filters[] =3D= { .type =3D VSH_OT_STRING, .positional =3D true, .help =3D N_("redefine the existing set of logging filters"), - .flags =3D VSH_OFLAG_EMPTY_OK + .allowEmpty =3D true }, {.name =3D NULL} }; @@ -1044,7 +1044,7 @@ static const vshCmdOptDef opts_daemon_log_outputs[] = =3D { .type =3D VSH_OT_STRING, .positional =3D true, .help =3D N_("redefine the existing set of logging outputs"), - .flags =3D VSH_OFLAG_EMPTY_OK + .allowEmpty =3D true }, {.name =3D NULL} }; diff --git a/tools/vsh.c b/tools/vsh.c index 1dac869413..a12f0a635d 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -1030,7 +1030,7 @@ vshCommandOptStringQuiet(vshControl *ctl G_GNUC_UNUSE= D, const vshCmd *cmd, if ((ret =3D vshCommandOpt(cmd, name, &arg, true)) <=3D 0) return ret; - if (!*arg->data && !(arg->def->flags & VSH_OFLAG_EMPTY_OK)) + if (!arg->def->allowEmpty && *arg->data =3D=3D '\0') return -1; *value =3D arg->data; return 1; @@ -1069,7 +1069,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)) + else if (arg && *arg->data =3D=3D '\0' && !arg->def->allowEmpty) error =3D N_("Option argument is empty"); if (error) { @@ -3394,7 +3394,7 @@ const vshCmdOptDef opts_complete[] =3D { {.name =3D "string", .type =3D VSH_OT_ARGV, .positional =3D true, - .flags =3D VSH_OFLAG_EMPTY_OK, + .allowEmpty =3D true, .help =3D N_("partial string to autocomplete") }, {.name =3D NULL} diff --git a/tools/vsh.h b/tools/vsh.h index 02c35488b9..1921645fca 100644 --- a/tools/vsh.h +++ b/tools/vsh.h @@ -98,7 +98,6 @@ typedef enum { */ enum { VSH_OFLAG_NONE =3D 0, /* without flags */ - VSH_OFLAG_EMPTY_OK =3D (1 << 1), /* empty string option allowed */ }; /* forward declarations */ @@ -140,6 +139,7 @@ struct _vshCmdOptDef { bool unwanted_positional; unsigned int flags; /* flags */ + bool allowEmpty; /* allow empty string */ const char *help; /* non-NULL help string; or for VSH_OT_ALI= AS * the name of a later public option */ vshCompleter completer; /* option completer */ --=20 2.44.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org