diff --git a/opal/mca/base/help-mca-base.txt b/opal/mca/base/help-mca-base.txt index 8cc849a3fb..a5ff1e6143 100644 --- a/opal/mca/base/help-mca-base.txt +++ b/opal/mca/base/help-mca-base.txt @@ -35,3 +35,21 @@ The %s component was not found! This means that this component is either not installed, or unable to be used on your system. +[framework-param:too-many-negates] +MCA framework parameters can only take a single negation operator +("^"), and it must be at the beginning of the value. The following +value violates this rule: + + %s + +When used, the negation operator sets the "exclusive" behavior mode, +meaning that it will exclude all specified components (and implicitly +include all others). If the negation operator is not specified, the +"inclusive" mode is assumed, meaning that all specified components +will be included (and implicitly exclude all others). + +For example, "^a,b" specifies the exclusive behavior and means "use +all components *except* a and b", while "c,d" specifies the inclusive +behavior and means "use *only* components c and d." + +You cannot mix inclusive and exclusive behavior. diff --git a/opal/mca/base/mca_base_components_open.c b/opal/mca/base/mca_base_components_open.c index 3abda53c0e..8c30515546 100644 --- a/opal/mca/base/mca_base_components_open.c +++ b/opal/mca/base/mca_base_components_open.c @@ -159,8 +159,7 @@ static int parse_requested(int mca_param, bool *include_mode, char ***requested_component_names) { int i; - char *requested; - char *tmp; + char *requested, *requested_orig; *requested_component_names = NULL; *include_mode = true; @@ -173,22 +172,39 @@ static int parse_requested(int mca_param, bool *include_mode, if (NULL == requested || 0 == strlen(requested)) { return OPAL_SUCCESS; } - *requested_component_names = opal_argv_split(requested, ','); + requested_orig = requested; - /* Are we including or excluding? */ + /* Are we including or excluding? We only allow the negate + character to be the *first* character of the value (but be nice + and allow any number of negate characters in the beginning). */ - for (i = 0; NULL != (*requested_component_names)[i]; ++i) { - if (negate == *((*requested_component_names)[i])) { - tmp = strdup((*requested_component_names)[i] + 1); - free((*requested_component_names)[i]); - (*requested_component_names)[i] = tmp; - - *include_mode = false; - } + while (negate == requested[0] && '\0' != requested[0]) { + *include_mode = false; + ++requested; } + /* Double check to ensure that the user did not specify the negate + character anywhere else in the value. */ + + i = 0; + while ('\0' != requested[i]) { + if (negate == requested[i]) { + opal_show_help("help-mca-base.txt", + "framework-param:too-many-negates", + true, requested_orig); + free(requested_orig); + return OPAL_ERROR; + } + ++i; + } + + /* Split up the value into individual component names */ + + *requested_component_names = opal_argv_split(requested, ','); + /* All done */ + free(requested_orig); return OPAL_SUCCESS; }