]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
vsh: Replace 'VSH_OFLAG_EMPTY_OK' bitwise flag with a separate struct member
authorPeter Krempa <pkrempa@redhat.com>
Mon, 11 Mar 2024 12:17:50 +0000 (13:17 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 2 Apr 2024 12:24:30 +0000 (14:24 +0200)
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>
tools/virsh-domain-monitor.c
tools/virsh-domain.c
tools/virsh.c
tools/virt-admin.c
tools/vsh.c
tools/vsh.h

index 5531d3b737b7e9314215c2d3c5cd9f3768076faf..eec97b7d59fe5d96389786d9f2100070eb2f27f0 100644 (file)
@@ -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")
     },
index 91a9dfd96a385a3e8ad13a31dcb1ce66d326ab65..1ba38629ac1881abc6ab292c459c5b41cc3619cf 100644 (file)
@@ -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")
     },
index 890c96e5528fe51286a3128729f2669b5b3c8c47..0a586fd6393045aa42c139292c9aff016716a269 100644 (file)
@@ -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")
     },
index 04b417e9a87eec03d53c99d0f6328737a83b2815..9a10a4eb453e2c4d92fd362392f9fdacedb8306f 100644 (file)
@@ -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}
 };
index 1dac869413eeb902c8be8b9e6e723c0130f199f7..a12f0a635d71f39deaf636cebecc6d2673bf7b44 100644 (file)
@@ -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}
index 02c35488b97dc8f421bd4a4cea05774d20618ff0..1921645fca1cd07a513cb4c198b2598d90812d1f 100644 (file)
@@ -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 */