[dpdk-dev,v3,3/4] eal: fix tail blank check in --lcores argument

Message ID 1469618756-144196-1-git-send-email-wei.dai@intel.com (mailing list archive)
State Accepted, archived
Headers

Commit Message

Wei Dai July 27, 2016, 11:25 a.m. UTC
  the tail blank after a group of lcore or cpu set
will make check of its end character fail.
for example: --lcores '(0-3)@(0-3)   ,(4-5)@(4-5)',
the next character after cpu set (0-3) is not ','
or '\0', which fail the check in eal_parse_lcores( ).

Fixes: 53e54bf81700 ("eal: new option --lcores for cpu assignment")

Signed-off-by: Wei Dai <wei.dai@intel.com>
---
 lib/librte_eal/common/eal_common_options.c | 7 +++++++
 1 file changed, 7 insertions(+)
  

Comments

Ferruh Yigit July 28, 2016, 3:18 p.m. UTC | #1
On 7/27/2016 12:25 PM, Wei Dai wrote:
> the tail blank after a group of lcore or cpu set
> will make check of its end character fail.
> for example: --lcores '(0-3)@(0-3)   ,(4-5)@(4-5)',
> the next character after cpu set (0-3) is not ','
> or '\0', which fail the check in eal_parse_lcores( ).
> 
> Fixes: 53e54bf81700 ("eal: new option --lcores for cpu assignment")
> 
> Signed-off-by: Wei Dai <wei.dai@intel.com>

Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
  

Patch

diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c
index 217d08b..1a1bab3 100644
--- a/lib/librte_eal/common/eal_common_options.c
+++ b/lib/librte_eal/common/eal_common_options.c
@@ -530,6 +530,13 @@  eal_parse_set(const char *input, uint16_t set[], unsigned num)
 		str = end + 1;
 	} while (*end != '\0' && *end != ')');
 
+	/*
+	 * to avoid failure that tail blank makes end character check fail
+	 * in eal_parse_lcores( )
+	 */
+	while (isblank(*str))
+		str++;
+
 	return str - input;
 }