]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
accel: use g_strsplit for parsing accelerator names
authorDaniel P. Berrangé <berrange@redhat.com>
Mon, 16 Apr 2018 11:17:41 +0000 (12:17 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 8 May 2018 22:13:38 +0000 (00:13 +0200)
Instead of re-using the get_opt_name() method from QemuOpts to split a
string on ':', just use g_strsplit().

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-Id: <20180416111743.8473-2-berrange@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
accel/accel.c
include/qemu/option.h
util/qemu-option.c

index 9cfab115d02ac31f9df8220ffdd2ff0d720052b4..966b2d8f536ce6065f677c0a5188781deb1adf3e 100644 (file)
@@ -70,8 +70,8 @@ static int accel_init_machine(AccelClass *acc, MachineState *ms)
 
 void configure_accelerator(MachineState *ms)
 {
-    const char *accel, *p;
-    char buf[10];
+    const char *accel;
+    char **accel_list, **tmp;
     int ret;
     bool accel_initialised = false;
     bool init_failed = false;
@@ -83,13 +83,10 @@ void configure_accelerator(MachineState *ms)
         accel = "tcg";
     }
 
-    p = accel;
-    while (!accel_initialised && *p != '\0') {
-        if (*p == ':') {
-            p++;
-        }
-        p = get_opt_name(buf, sizeof(buf), p, ':');
-        acc = accel_find(buf);
+    accel_list = g_strsplit(accel, ":", 0);
+
+    for (tmp = accel_list; !accel_initialised && tmp && *tmp; tmp++) {
+        acc = accel_find(*tmp);
         if (!acc) {
             continue;
         }
@@ -107,6 +104,7 @@ void configure_accelerator(MachineState *ms)
             accel_initialised = true;
         }
     }
+    g_strfreev(accel_list);
 
     if (!accel_initialised) {
         if (!init_failed) {
index 306fdb5f7ada52c5e0230882fb243075c0bbc72e..1cfe5cbc2d34e30569988ed46e1e5a35609d196b 100644 (file)
@@ -28,7 +28,6 @@
 
 #include "qemu/queue.h"
 
-const char *get_opt_name(char *buf, int buf_size, const char *p, char delim);
 const char *get_opt_value(char *buf, int buf_size, const char *p);
 
 void parse_option_size(const char *name, const char *value,
index d0756fda58d8ae89a54bdfc0b55fee408c85fd61..baca40fb9463936b0d5b63408d99acdd65fc42bf 100644 (file)
@@ -49,7 +49,8 @@
  * The return value is the position of the delimiter/zero byte after the option
  * name in p.
  */
-const char *get_opt_name(char *buf, int buf_size, const char *p, char delim)
+static const char *get_opt_name(char *buf, int buf_size, const char *p,
+                                char delim)
 {
     char *q;