Skip to content

Commit e9e89e5

Browse files
authored
Merge pull request #3245 from hjelmn/auto_bool
mca/base: accept y and n for bool and auto bool enumerator
2 parents 462342d + 676cfe2 commit e9e89e5

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

opal/mca/base/mca_base_var_enum.c

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Copyright (c) 2004-2005 The Regents of the University of California.
1212
* All rights reserved.
1313
* Copyright (c) 2008-2013 Cisco Systems, Inc. All rights reserved.
14-
* Copyright (c) 2012-2015 Los Alamos National Security, LLC. All rights
14+
* Copyright (c) 2012-2017 Los Alamos National Security, LLC. All rights
1515
* reserved.
1616
* Copyright (c) 2017 Research Organization for Information Science
1717
* and Technology (RIST). All rights reserved.
@@ -70,18 +70,20 @@ static int mca_base_var_enum_bool_vfs (mca_base_var_enum_t *self, const char *st
7070
int *value)
7171
{
7272
char *tmp;
73-
int v;
73+
long v;
7474

7575
/* skip whitespace */
7676
string_value += strspn (string_value, " \t\n\v\f\r");
7777

7878
v = strtol (string_value, &tmp, 10);
7979
if (*tmp != '\0') {
8080
if (0 == strcmp (string_value, "true") || 0 == strcmp (string_value, "t") ||
81-
0 == strcmp (string_value, "enabled") || 0 == strcmp (string_value, "yes")) {
81+
0 == strcmp (string_value, "enabled") || 0 == strcmp (string_value, "yes") ||
82+
0 == strcmp (string_value, "y")) {
8283
v = 1;
8384
} else if (0 == strcmp (string_value, "false") || 0 == strcmp (string_value, "f") ||
84-
0 == strcmp (string_value, "disabled") || 0 == strcmp (string_value, "no")) {
85+
0 == strcmp (string_value, "disabled") || 0 == strcmp (string_value, "no") ||
86+
0 == strcmp (string_value, "n")) {
8587
v = 0;
8688
} else {
8789
return OPAL_ERR_VALUE_OUT_OF_BOUNDS;
@@ -105,7 +107,7 @@ static int mca_base_var_enum_bool_sfv (mca_base_var_enum_t *self, const int valu
105107

106108
static int mca_base_var_enum_bool_dump (mca_base_var_enum_t *self, char **out)
107109
{
108-
*out = strdup ("0: f|false|disabled|no, 1: t|true|enabled|yes");
110+
*out = strdup ("0: f|false|disabled|no|n, 1: t|true|enabled|yes|y");
109111
return *out ? OPAL_SUCCESS : OPAL_ERR_OUT_OF_RESOURCE;
110112
}
111113

@@ -146,18 +148,20 @@ static int mca_base_var_enum_auto_bool_vfs (mca_base_var_enum_t *self, const cha
146148
int *value)
147149
{
148150
char *tmp;
149-
int v;
151+
long v;
150152

151153
/* skip whitespace */
152154
string_value += strspn (string_value, " \t\n\v\f\r");
153155

154156
v = strtol (string_value, &tmp, 10);
155157
if (*tmp != '\0') {
156158
if (0 == strcasecmp (string_value, "true") || 0 == strcasecmp (string_value, "t") ||
157-
0 == strcasecmp (string_value, "enabled") || 0 == strcasecmp (string_value, "yes")) {
159+
0 == strcasecmp (string_value, "enabled") || 0 == strcasecmp (string_value, "yes") ||
160+
0 == strcasecmp (string_value, "y")) {
158161
v = 1;
159162
} else if (0 == strcasecmp (string_value, "false") || 0 == strcasecmp (string_value, "f") ||
160-
0 == strcasecmp (string_value, "disabled") || 0 == strcasecmp (string_value, "no")) {
163+
0 == strcasecmp (string_value, "disabled") || 0 == strcasecmp (string_value, "no") ||
164+
0 == strcasecmp (string_value, "n")) {
161165
v = 0;
162166
} else if (0 == strcasecmp (string_value, "auto")) {
163167
v = -1;
@@ -171,7 +175,7 @@ static int mca_base_var_enum_auto_bool_vfs (mca_base_var_enum_t *self, const cha
171175
} else if (v < -1) {
172176
*value = -1;
173177
} else {
174-
*value = v;
178+
*value = (int) v;
175179
}
176180

177181
return OPAL_SUCCESS;
@@ -195,7 +199,7 @@ static int mca_base_var_enum_auto_bool_sfv (mca_base_var_enum_t *self, const int
195199

196200
static int mca_base_var_enum_auto_bool_dump (mca_base_var_enum_t *self, char **out)
197201
{
198-
*out = strdup ("-1: auto, 0: f|false|disabled|no, 1: t|true|enabled|yes");
202+
*out = strdup ("-1: auto, 0: f|false|disabled|no|n, 1: t|true|enabled|yes|y");
199203
return *out ? OPAL_SUCCESS : OPAL_ERR_OUT_OF_RESOURCE;
200204
}
201205

0 commit comments

Comments
 (0)