examples/ip_pipeline: fix cpu cores parsing
authorMaciej Gajdzica <maciejx.t.gajdzica@intel.com>
Tue, 21 Jul 2015 14:39:00 +0000 (16:39 +0200)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Mon, 27 Jul 2015 13:59:58 +0000 (15:59 +0200)
This patch fixes parsing value of core variable in pipeline config.
Before not every combination of cores (c), sockets (s) and
hyperthreading (h) was parsed correctly.

Signed-off-by: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>
Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
examples/ip_pipeline/config_parse.c

index 361bf8a..c9b78f9 100644 (file)
@@ -386,14 +386,14 @@ parse_pipeline_core(uint32_t *socket,
                switch (type) {
                case 's':
                case 'S':
-                       if (s_parsed)
+                       if (s_parsed || c_parsed || h_parsed)
                                return -EINVAL;
                        s_parsed = 1;
                        next++;
                        break;
                case 'c':
                case 'C':
-                       if (c_parsed)
+                       if (c_parsed || h_parsed)
                                return -EINVAL;
                        c_parsed = 1;
                        next++;
@@ -423,7 +423,10 @@ parse_pipeline_core(uint32_t *socket,
                        num[num_len] = *next;
                }
 
-               if (num_len == 0 && type != 'h')
+               if (num_len == 0 && type != 'h' && type != 'H')
+                       return -EINVAL;
+
+               if (num_len != 0 && (type == 'h' || type == 'H'))
                        return -EINVAL;
 
                num[num_len] = '\0';
@@ -438,9 +441,6 @@ parse_pipeline_core(uint32_t *socket,
                case 'c':
                case 'C':
                        c = val;
-                       if (type == 'C' && *next != '\0')
-                               return -EINVAL;
-
                        break;
                case 'h':
                case 'H':