mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
vsh: Replace 'VSH_OFLAG_EMPTY_OK' bitwise flag with a separate struct member
Replace the last bitwise flag with a separate member. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
8e39542a03
commit
4b44113d7b
@ -864,8 +864,8 @@ static const vshCmdOptDef opts_domblkstat[] = {
|
|||||||
VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE),
|
VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE),
|
||||||
{.name = "device",
|
{.name = "device",
|
||||||
.type = VSH_OT_STRING,
|
.type = VSH_OT_STRING,
|
||||||
.flags = VSH_OFLAG_EMPTY_OK,
|
|
||||||
.positional = true,
|
.positional = true,
|
||||||
|
.allowEmpty = true,
|
||||||
.completer = virshDomainDiskTargetCompleter,
|
.completer = virshDomainDiskTargetCompleter,
|
||||||
.help = N_("block device")
|
.help = N_("block device")
|
||||||
},
|
},
|
||||||
|
@ -422,7 +422,7 @@ static const vshCmdOptDef opts_attach_disk[] = {
|
|||||||
.type = VSH_OT_STRING,
|
.type = VSH_OT_STRING,
|
||||||
.positional = true,
|
.positional = true,
|
||||||
.required = true,
|
.required = true,
|
||||||
.flags = VSH_OFLAG_EMPTY_OK,
|
.allowEmpty = true,
|
||||||
.help = N_("source of disk device or name of network disk")
|
.help = N_("source of disk device or name of network disk")
|
||||||
},
|
},
|
||||||
{.name = "target",
|
{.name = "target",
|
||||||
@ -6838,7 +6838,7 @@ static const vshCmdOptDef opts_vcpupin[] = {
|
|||||||
{.name = "cpulist",
|
{.name = "cpulist",
|
||||||
.type = VSH_OT_STRING,
|
.type = VSH_OT_STRING,
|
||||||
.unwanted_positional = true,
|
.unwanted_positional = true,
|
||||||
.flags = VSH_OFLAG_EMPTY_OK,
|
.allowEmpty = true,
|
||||||
.completer = virshDomainCpulistCompleter,
|
.completer = virshDomainCpulistCompleter,
|
||||||
.help = N_("host cpu number(s) to set, or omit option to query")
|
.help = N_("host cpu number(s) to set, or omit option to query")
|
||||||
},
|
},
|
||||||
@ -7047,7 +7047,7 @@ static const vshCmdOptDef opts_emulatorpin[] = {
|
|||||||
{.name = "cpulist",
|
{.name = "cpulist",
|
||||||
.type = VSH_OT_STRING,
|
.type = VSH_OT_STRING,
|
||||||
.unwanted_positional = true,
|
.unwanted_positional = true,
|
||||||
.flags = VSH_OFLAG_EMPTY_OK,
|
.allowEmpty = true,
|
||||||
.completer = virshDomainCpulistCompleter,
|
.completer = virshDomainCpulistCompleter,
|
||||||
.help = N_("host cpu number(s) to set, or omit option to query")
|
.help = N_("host cpu number(s) to set, or omit option to query")
|
||||||
},
|
},
|
||||||
|
@ -246,7 +246,7 @@ static const vshCmdOptDef opts_connect[] = {
|
|||||||
{.name = "name",
|
{.name = "name",
|
||||||
.type = VSH_OT_STRING,
|
.type = VSH_OT_STRING,
|
||||||
.positional = true,
|
.positional = true,
|
||||||
.flags = VSH_OFLAG_EMPTY_OK,
|
.allowEmpty = true,
|
||||||
.completer = virshCompleteEmpty,
|
.completer = virshCompleteEmpty,
|
||||||
.help = N_("hypervisor connection URI")
|
.help = N_("hypervisor connection URI")
|
||||||
},
|
},
|
||||||
|
@ -255,7 +255,7 @@ static const vshCmdOptDef opts_connect[] = {
|
|||||||
{.name = "name",
|
{.name = "name",
|
||||||
.type = VSH_OT_STRING,
|
.type = VSH_OT_STRING,
|
||||||
.positional = true,
|
.positional = true,
|
||||||
.flags = VSH_OFLAG_EMPTY_OK,
|
.allowEmpty = true,
|
||||||
.help = N_("daemon's admin server connection URI")
|
.help = N_("daemon's admin server connection URI")
|
||||||
},
|
},
|
||||||
{.name = NULL}
|
{.name = NULL}
|
||||||
@ -961,7 +961,7 @@ static const vshCmdOptDef opts_daemon_log_filters[] = {
|
|||||||
.type = VSH_OT_STRING,
|
.type = VSH_OT_STRING,
|
||||||
.positional = true,
|
.positional = true,
|
||||||
.help = N_("redefine the existing set of logging filters"),
|
.help = N_("redefine the existing set of logging filters"),
|
||||||
.flags = VSH_OFLAG_EMPTY_OK
|
.allowEmpty = true
|
||||||
},
|
},
|
||||||
{.name = NULL}
|
{.name = NULL}
|
||||||
};
|
};
|
||||||
@ -1044,7 +1044,7 @@ static const vshCmdOptDef opts_daemon_log_outputs[] = {
|
|||||||
.type = VSH_OT_STRING,
|
.type = VSH_OT_STRING,
|
||||||
.positional = true,
|
.positional = true,
|
||||||
.help = N_("redefine the existing set of logging outputs"),
|
.help = N_("redefine the existing set of logging outputs"),
|
||||||
.flags = VSH_OFLAG_EMPTY_OK
|
.allowEmpty = true
|
||||||
},
|
},
|
||||||
{.name = NULL}
|
{.name = NULL}
|
||||||
};
|
};
|
||||||
|
@ -1030,7 +1030,7 @@ vshCommandOptStringQuiet(vshControl *ctl G_GNUC_UNUSED, const vshCmd *cmd,
|
|||||||
if ((ret = vshCommandOpt(cmd, name, &arg, true)) <= 0)
|
if ((ret = vshCommandOpt(cmd, name, &arg, true)) <= 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (!*arg->data && !(arg->def->flags & VSH_OFLAG_EMPTY_OK))
|
if (!arg->def->allowEmpty && *arg->data == '\0')
|
||||||
return -1;
|
return -1;
|
||||||
*value = arg->data;
|
*value = arg->data;
|
||||||
return 1;
|
return 1;
|
||||||
@ -1069,7 +1069,7 @@ vshCommandOptStringReq(vshControl *ctl,
|
|||||||
/* this should not be propagated here, just to be sure */
|
/* this should not be propagated here, just to be sure */
|
||||||
if (ret == -1)
|
if (ret == -1)
|
||||||
error = N_("Mandatory option not present");
|
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");
|
error = N_("Option argument is empty");
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
@ -3394,7 +3394,7 @@ const vshCmdOptDef opts_complete[] = {
|
|||||||
{.name = "string",
|
{.name = "string",
|
||||||
.type = VSH_OT_ARGV,
|
.type = VSH_OT_ARGV,
|
||||||
.positional = true,
|
.positional = true,
|
||||||
.flags = VSH_OFLAG_EMPTY_OK,
|
.allowEmpty = true,
|
||||||
.help = N_("partial string to autocomplete")
|
.help = N_("partial string to autocomplete")
|
||||||
},
|
},
|
||||||
{.name = NULL}
|
{.name = NULL}
|
||||||
|
@ -98,7 +98,6 @@ typedef enum {
|
|||||||
*/
|
*/
|
||||||
enum {
|
enum {
|
||||||
VSH_OFLAG_NONE = 0, /* without flags */
|
VSH_OFLAG_NONE = 0, /* without flags */
|
||||||
VSH_OFLAG_EMPTY_OK = (1 << 1), /* empty string option allowed */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* forward declarations */
|
/* forward declarations */
|
||||||
@ -140,6 +139,7 @@ struct _vshCmdOptDef {
|
|||||||
bool unwanted_positional;
|
bool unwanted_positional;
|
||||||
|
|
||||||
unsigned int flags; /* flags */
|
unsigned int flags; /* flags */
|
||||||
|
bool allowEmpty; /* allow empty string */
|
||||||
const char *help; /* non-NULL help string; or for VSH_OT_ALIAS
|
const char *help; /* non-NULL help string; or for VSH_OT_ALIAS
|
||||||
* the name of a later public option */
|
* the name of a later public option */
|
||||||
vshCompleter completer; /* option completer */
|
vshCompleter completer; /* option completer */
|
||||||
|
Loading…
Reference in New Issue
Block a user