Replace the last bitwise flag with a separate member. Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- 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[] = { VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE), {.name = "device", .type = VSH_OT_STRING, - .flags = VSH_OFLAG_EMPTY_OK, .positional = true, + .allowEmpty = true, .completer = virshDomainDiskTargetCompleter, .help = 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[] = { .type = VSH_OT_STRING, .positional = true, .required = true, - .flags = VSH_OFLAG_EMPTY_OK, + .allowEmpty = true, .help = N_("source of disk device or name of network disk") }, {.name = "target", @@ -6838,7 +6838,7 @@ static const vshCmdOptDef opts_vcpupin[] = { {.name = "cpulist", .type = VSH_OT_STRING, .unwanted_positional = true, - .flags = VSH_OFLAG_EMPTY_OK, + .allowEmpty = true, .completer = virshDomainCpulistCompleter, .help = N_("host cpu number(s) to set, or omit option to query") }, @@ -7047,7 +7047,7 @@ static const vshCmdOptDef opts_emulatorpin[] = { {.name = "cpulist", .type = VSH_OT_STRING, .unwanted_positional = true, - .flags = VSH_OFLAG_EMPTY_OK, + .allowEmpty = true, .completer = virshDomainCpulistCompleter, .help = 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[] = { {.name = "name", .type = VSH_OT_STRING, .positional = true, - .flags = VSH_OFLAG_EMPTY_OK, + .allowEmpty = true, .completer = virshCompleteEmpty, .help = 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[] = { {.name = "name", .type = VSH_OT_STRING, .positional = true, - .flags = VSH_OFLAG_EMPTY_OK, + .allowEmpty = true, .help = N_("daemon's admin server connection URI") }, {.name = NULL} @@ -961,7 +961,7 @@ static const vshCmdOptDef opts_daemon_log_filters[] = { .type = VSH_OT_STRING, .positional = true, .help = N_("redefine the existing set of logging filters"), - .flags = VSH_OFLAG_EMPTY_OK + .allowEmpty = true }, {.name = NULL} }; @@ -1044,7 +1044,7 @@ static const vshCmdOptDef opts_daemon_log_outputs[] = { .type = VSH_OT_STRING, .positional = true, .help = N_("redefine the existing set of logging outputs"), - .flags = VSH_OFLAG_EMPTY_OK + .allowEmpty = true }, {.name = 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_UNUSED, const vshCmd *cmd, if ((ret = vshCommandOpt(cmd, name, &arg, true)) <= 0) return ret; - if (!*arg->data && !(arg->def->flags & VSH_OFLAG_EMPTY_OK)) + if (!arg->def->allowEmpty && *arg->data == '\0') return -1; *value = arg->data; return 1; @@ -1069,7 +1069,7 @@ vshCommandOptStringReq(vshControl *ctl, /* this should not be propagated here, just to be sure */ if (ret == -1) error = N_("Mandatory option not present"); - else if (arg && !*arg->data && !(arg->def->flags & VSH_OFLAG_EMPTY_OK)) + else if (arg && *arg->data == '\0' && !arg->def->allowEmpty) error = N_("Option argument is empty"); if (error) { @@ -3394,7 +3394,7 @@ const vshCmdOptDef opts_complete[] = { {.name = "string", .type = VSH_OT_ARGV, .positional = true, - .flags = VSH_OFLAG_EMPTY_OK, + .allowEmpty = true, .help = N_("partial string to autocomplete") }, {.name = 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 = 0, /* without flags */ - VSH_OFLAG_EMPTY_OK = (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_ALIAS * the name of a later public option */ vshCompleter completer; /* option completer */ -- 2.44.0 _______________________________________________ Devel mailing list -- devel@xxxxxxxxxxxxxxxxx To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx