Skip to content

Commit a651f26

Browse files
committed
Merge pull request #1690 from hjelmn/flag_enum
mca/base: fix typo in flag enumeration
2 parents e7d46b9 + 37e9e2c commit a651f26

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

opal/mca/base/mca_base_var.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ static int var_set_from_string (mca_base_var_t *var, char *src)
688688
case MCA_BASE_VAR_TYPE_BOOL:
689689
case MCA_BASE_VAR_TYPE_SIZE_T:
690690
ret = int_from_string(src, var->mbv_enumerator, &int_value);
691-
if (OPAL_ERR_VALUE_OUT_OF_BOUNDS == ret ||
691+
if (OPAL_SUCCESS != ret ||
692692
(MCA_BASE_VAR_TYPE_INT == var->mbv_type && ((int) int_value != (int64_t) int_value)) ||
693693
(MCA_BASE_VAR_TYPE_UNSIGNED_INT == var->mbv_type && ((unsigned int) int_value != int_value))) {
694694
if (var->mbv_enumerator) {

opal/mca/base/mca_base_var_enum.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -494,21 +494,28 @@ static int enum_value_from_string_flag (mca_base_var_enum_t *self, const char *s
494494

495495
bool found = false, conflict = false;
496496
for (int j = 0 ; j < count ; ++j) {
497-
if ((is_int && (value == flag_enum->enum_flags[i].flag)) ||
498-
0 == strcasecmp (flags[i], flag_enum->enum_flags[i].string)) {
497+
if ((is_int && (value & flag_enum->enum_flags[j].flag)) ||
498+
0 == strcasecmp (flags[i], flag_enum->enum_flags[j].string)) {
499499
found = true;
500500

501-
if (flag & flag_enum->enum_flags[i].conflicting_flag) {
501+
if (flag & flag_enum->enum_flags[j].conflicting_flag) {
502502
conflict = true;
503503
} else {
504-
flag |= flag_enum->enum_flags[i].flag;
504+
flag |= flag_enum->enum_flags[j].flag;
505505
}
506506

507-
break;
507+
if (is_int) {
508+
value &= ~flag_enum->enum_flags[j].flag;
509+
if (0 == value) {
510+
break;
511+
}
512+
} else {
513+
break;
514+
}
508515
}
509516
}
510517

511-
if (!found || conflict) {
518+
if (!found || conflict || (is_int && value)) {
512519
opal_argv_free (flags);
513520
return !found ? OPAL_ERR_VALUE_OUT_OF_BOUNDS : OPAL_ERR_BAD_PARAM;
514521
}

0 commit comments

Comments
 (0)