mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-18 10:35:20 +00:00
vsh: Add VSH_OT_NONE option type to catch programming errors
Add a check that the default 0 assignment will not mean that an option is considered to be VSH_OT_BOOL. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
e1666a088b
commit
3fcae7a028
@ -335,6 +335,11 @@ vshCmddefCheckInternals(vshControl *ctl,
|
|||||||
virBufferStrcat(&complbuf, opt->name, ", ", NULL);
|
virBufferStrcat(&complbuf, opt->name, ", ", NULL);
|
||||||
|
|
||||||
switch (opt->type) {
|
switch (opt->type) {
|
||||||
|
case VSH_OT_NONE:
|
||||||
|
vshError(ctl, "invalid type 'NONE' of option '%s' of command '%s'",
|
||||||
|
opt->name, cmd->name);
|
||||||
|
return -1;
|
||||||
|
|
||||||
case VSH_OT_BOOL:
|
case VSH_OT_BOOL:
|
||||||
if (opt->completer || opt->completer_flags) {
|
if (opt->completer || opt->completer_flags) {
|
||||||
vshError(ctl, "bool parameter '%s' of command '%s' has completer set",
|
vshError(ctl, "bool parameter '%s' of command '%s' has completer set",
|
||||||
@ -671,6 +676,7 @@ vshCmddefHelp(const vshCmdDef *def)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case VSH_OT_ALIAS:
|
case VSH_OT_ALIAS:
|
||||||
|
case VSH_OT_NONE:
|
||||||
/* aliases are intentionally undocumented */
|
/* aliases are intentionally undocumented */
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -713,6 +719,7 @@ vshCmddefHelp(const vshCmdDef *def)
|
|||||||
opt->name);
|
opt->name);
|
||||||
break;
|
break;
|
||||||
case VSH_OT_ALIAS:
|
case VSH_OT_ALIAS:
|
||||||
|
case VSH_OT_NONE:
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,6 +85,7 @@ typedef enum {
|
|||||||
* vshCmdOptType - command option type
|
* vshCmdOptType - command option type
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
VSH_OT_NONE = 0, /* cannary to catch programming errors */
|
||||||
VSH_OT_BOOL, /* optional boolean option */
|
VSH_OT_BOOL, /* optional boolean option */
|
||||||
VSH_OT_STRING, /* optional string option */
|
VSH_OT_STRING, /* optional string option */
|
||||||
VSH_OT_INT, /* optional or mandatory int option */
|
VSH_OT_INT, /* optional or mandatory int option */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user