Skip to content

Commit d32033c

Browse files
wckzhangWilliam Zhang
authored andcommitted
opal/params: Change color string initialization
The way that color string was initialized caused problems as the pointer to opal_var_dump_color_string became (nil) after re-entering this path after performing mca_base_var_register. Signed-off-by: William Zhang <wilzhang@amazon.com>
1 parent 3722992 commit d32033c

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

opal/runtime/opal_params_core.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,7 @@ int opal_max_thread_in_progress = 1;
8787

8888
static bool opal_register_util_done = false;
8989

90-
/* Basic color options: 30=black, 31=red, 32=green,
91-
* 33=yellow, 34=blue, 35=magenta, 36=cyan, 37=white
92-
* https://en.wikipedia.org/wiki/ANSI_escape_code#Colors */
93-
static char *opal_var_dump_color_string = "name=34,value=32,valid_values=36";
90+
static char *opal_var_dump_color_string = NULL;
9491

9592
static char *opal_var_dump_color_keys[OPAL_VAR_DUMP_COLOR_KEY_COUNT] = {
9693
[OPAL_VAR_DUMP_COLOR_VAR_NAME] = "name",
@@ -258,6 +255,10 @@ int opal_register_util_params(void)
258255
return OPAL_ERR_OUT_OF_RESOURCE;
259256
}
260257

258+
/* Basic color options: 30=black, 31=red, 32=green,
259+
* 33=yellow, 34=blue, 35=magenta, 36=cyan, 37=white
260+
* https://en.wikipedia.org/wiki/ANSI_escape_code#Colors */
261+
opal_var_dump_color_string = "name=34,value=32,valid_values=36";
261262
ret = mca_base_var_register("opal", "opal", NULL, "var_dump_color", string,
262263
MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, OPAL_INFO_LVL_2, MCA_BASE_VAR_SCOPE_READONLY,
263264
&opal_var_dump_color_string);
@@ -434,13 +435,15 @@ static int parse_color_string(char *color_string, char **key_names,
434435
values_out[k] = NULL;
435436
}
436437

437-
tokens = opal_argv_split(color_string, ',');
438-
if (NULL == tokens) {
439-
return_code = OPAL_ERR_OUT_OF_RESOURCE;
440-
goto end;
438+
if (NULL != color_string) {
439+
tokens = opal_argv_split(color_string, ',');
440+
if (NULL == tokens) {
441+
return_code = OPAL_ERR_OUT_OF_RESOURCE;
442+
goto end;
443+
}
441444
}
442445

443-
for (int i = 0; tokens[i] != NULL; i++) {
446+
for (int i = 0; tokens && tokens[i] != NULL; i++) {
444447
kv = opal_argv_split(tokens[i], '=');
445448
if (NULL == kv) {
446449
return_code = OPAL_ERR_OUT_OF_RESOURCE;

0 commit comments

Comments
 (0)