|
| 1 | +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ |
1 | 2 | /* |
2 | 3 | * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana |
3 | 4 | * University Research and Technology |
|
11 | 12 | * All rights reserved. |
12 | 13 | * Copyright (c) 2006-2013 Cisco Systems, Inc. All rights reserved. |
13 | 14 | * Copyright (c) 2008 Mellanox Technologies. All rights reserved. |
14 | | - * Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights |
| 15 | + * Copyright (c) 2012-2015 Los Alamos National Security, LLC. All rights |
15 | 16 | * reserved. |
16 | 17 | * Copyright (c) 2014 Intel, Inc. All rights reserved |
17 | 18 | * Copyright (c) 2014-2015 Research Organization for Information Science |
@@ -345,25 +346,20 @@ static int parse_line(parsed_section_values_t *sv) |
345 | 346 |
|
346 | 347 | /* Next we get the value */ |
347 | 348 | val = btl_openib_ini_yylex(); |
348 | | - if (BTL_OPENIB_INI_PARSE_SINGLE_WORD == val || |
349 | | - BTL_OPENIB_INI_PARSE_VALUE == val) { |
350 | | - value = strdup(btl_openib_ini_yytext); |
351 | | - |
352 | | - /* Now we need to see the newline */ |
353 | | - val = btl_openib_ini_yylex(); |
354 | | - if (BTL_OPENIB_INI_PARSE_NEWLINE != val && |
355 | | - BTL_OPENIB_INI_PARSE_DONE != val) { |
356 | | - opal_show_help("help-mpi-btl-openib.txt", "ini file:expected newline", true); |
357 | | - free(value); |
358 | | - return OPAL_ERROR; |
359 | | - } |
| 349 | + if (BTL_OPENIB_INI_PARSE_SINGLE_WORD != val && BTL_OPENIB_INI_PARSE_VALUE != val) { |
| 350 | + return OPAL_ERROR; |
360 | 351 | } |
361 | 352 |
|
| 353 | + value = strdup(btl_openib_ini_yytext); |
| 354 | + |
| 355 | + /* Now we need to see the newline */ |
| 356 | + val = btl_openib_ini_yylex(); |
| 357 | + |
362 | 358 | /* If we did not get EOL or EOF, something is wrong */ |
363 | | - else if (BTL_OPENIB_INI_PARSE_DONE != val && |
364 | | - BTL_OPENIB_INI_PARSE_NEWLINE != val) { |
365 | | - opal_show_help("help-mpi-btl-openib.txt", "ini file:expected newline", true); |
366 | | - return OPAL_ERROR; |
| 359 | + if (BTL_OPENIB_INI_PARSE_NEWLINE != val && BTL_OPENIB_INI_PARSE_DONE != val) { |
| 360 | + opal_show_help("help-mpi-btl-openib.txt", "ini file:expected newline", true); |
| 361 | + free(value); |
| 362 | + return OPAL_ERROR; |
367 | 363 | } |
368 | 364 |
|
369 | 365 | /* Ok, we got a good parse. Now figure out what it is and save |
@@ -621,19 +617,7 @@ static int save_section(parsed_section_values_t *s) |
621 | 617 | */ |
622 | 618 | int opal_btl_openib_ini_intify(char *str) |
623 | 619 | { |
624 | | - while (isspace(*str)) { |
625 | | - ++str; |
626 | | - } |
627 | | - |
628 | | - /* If it's hex, use sscanf() */ |
629 | | - if (strlen(str) > 3 && 0 == strncasecmp("0x", str, 2)) { |
630 | | - unsigned int i; |
631 | | - sscanf(str, "%X", &i); |
632 | | - return (int) i; |
633 | | - } |
634 | | - |
635 | | - /* Nope -- just decimal, so use atoi() */ |
636 | | - return atoi(str); |
| 620 | + return strtol (str, NULL, 0); |
637 | 621 | } |
638 | 622 |
|
639 | 623 |
|
@@ -676,13 +660,13 @@ int opal_btl_openib_ini_intify_list(char *value, uint32_t **values, int *len) |
676 | 660 | /* Iterate over the values and save them */ |
677 | 661 | str = value; |
678 | 662 | comma = strchr(str, ','); |
679 | | - do { |
| 663 | + while (NULL != comma) { |
680 | 664 | *comma = '\0'; |
681 | 665 | (*values)[*len] = (uint32_t) opal_btl_openib_ini_intify(str); |
682 | 666 | ++(*len); |
683 | 667 | str = comma + 1; |
684 | 668 | comma = strchr(str, ','); |
685 | | - } while (NULL != comma); |
| 669 | + } |
686 | 670 | /* Get the last value (i.e., the value after the last |
687 | 671 | comma, because it won't have been snarfed in the |
688 | 672 | loop) */ |
|
0 commit comments