Patchwork [RFC,06/19] i386: cpu: extract the full feature list before parsing it

login
register
mail settings
Submitter Eduardo Habkost
Date Aug. 3, 2012, 2:59 a.m.
Message ID <1343962766-22024-7-git-send-email-ehabkost@redhat.com>
Download mbox | patch
Permalink /patch/174855/
State New
Headers show

Comments

Eduardo Habkost - Aug. 3, 2012, 2:59 a.m.
The parsing of the feature list string will be moved to a separate
function, so first extract the full feature list, then parse it.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 target-i386/cpu.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Patch

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 154a01f..7af80a0 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1086,6 +1086,8 @@  static int cpu_x86_build_from_name(x86_def_t *x86_cpu_def,
     char *last;
     char *s = g_strdup(cpu_model);
     char *featurestr, *name = strtok_r(s, ",", &last);
+    char *featlist = strtok_r(NULL, "", &last);
+
     /* Features to be added*/
     uint32_t plus_features = 0, plus_ext_features = 0;
     uint32_t plus_ext2_features = 0, plus_ext3_features = 0;
@@ -1116,7 +1118,7 @@  static int cpu_x86_build_from_name(x86_def_t *x86_cpu_def,
         &plus_ext_features, &plus_ext2_features, &plus_ext3_features,
         &plus_kvm_features, &plus_svm_features);
 
-    featurestr = strtok_r(NULL, ",", &last);
+    featurestr = featlist ? strtok_r(featlist, ",", &last) : NULL;
 
     while (featurestr) {
         char *val;