summary refs log tree commit diff stats
path: root/util/qemu-option.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2020-04-15 09:49:22 +0200
committerMarkus Armbruster <armbru@redhat.com>2020-04-29 08:01:51 +0200
commit80a94855737622436a9b5cd25315b9c80d7e3ffa (patch)
tree79bf448d7dbb75080d05f94988181b3163943fbf /util/qemu-option.c
parent933d1527785fe839300459abb486905094d192a7 (diff)
downloadfocaccia-qemu-80a94855737622436a9b5cd25315b9c80d7e3ffa.tar.gz
focaccia-qemu-80a94855737622436a9b5cd25315b9c80d7e3ffa.zip
qemu-option: Fix has_help_option()'s sloppy parsing
has_help_option() uses its own parser.  It's inconsistent with
qemu_opts_parse(), as demonstrated by test-qemu-opts case
/qemu-opts/has_help_option.  Fix by reusing the common parser.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20200415074927.19897-5-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'util/qemu-option.c')
-rw-r--r--util/qemu-option.c39
1 files changed, 19 insertions, 20 deletions
diff --git a/util/qemu-option.c b/util/qemu-option.c
index d2956082bd..0abf26b61f 100644
--- a/util/qemu-option.c
+++ b/util/qemu-option.c
@@ -165,26 +165,6 @@ void parse_option_size(const char *name, const char *value,
     *ret = size;
 }
 
-bool has_help_option(const char *param)
-{
-    const char *p = param;
-    bool result = false;
-
-    while (*p && !result) {
-        char *value;
-
-        p = get_opt_value(p, &value);
-        if (*p) {
-            p++;
-        }
-
-        result = is_help_option(value);
-        g_free(value);
-    }
-
-    return result;
-}
-
 bool is_valid_option_list(const char *p)
 {
     char *value = NULL;
@@ -890,6 +870,25 @@ static char *opts_parse_id(const char *params)
     return NULL;
 }
 
+bool has_help_option(const char *params)
+{
+    const char *p;
+    char *name, *value;
+    bool ret;
+
+    for (p = params; *p;) {
+        p = get_opt_name_value(p, NULL, &name, &value);
+        ret = is_help_option(name);
+        g_free(name);
+        g_free(value);
+        if (ret) {
+            return true;
+        }
+    }
+
+    return false;
+}
+
 /**
  * Store options parsed from @params into @opts.
  * If @firstname is non-null, the first key=value in @params may omit