Skip to content

Commit 2f9d1d2

Browse files
committed
coll/tuned: Correct bound-check
Correct bounds-check on collective id, which was previously off by one. Fixes Coverity issues 1646445, 16464444, and 1646440.
1 parent 7fc5ab0 commit 2f9d1d2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ompi/mca/coll/tuned/coll_tuned_component.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ mca_coll_tuned_module_construct(mca_coll_tuned_module_t *module)
304304

305305
int coll_tuned_alg_from_str(int collective_id, const char *alg_name, int *alg_value) {
306306
int rc;
307-
if (collective_id > COLLCOUNT || collective_id < 0) { return OPAL_ERROR; };
307+
if (collective_id >= COLLCOUNT || collective_id < 0) { return OPAL_ERROR; };
308308
rc = coll_tuned_algorithm_enums[collective_id]->value_from_string(
309309
coll_tuned_algorithm_enums[collective_id],
310310
alg_name, alg_value );
@@ -314,7 +314,7 @@ int coll_tuned_alg_from_str(int collective_id, const char *alg_name, int *alg_va
314314
/* return the enum's value and string. caller's responsibility to free alg_string if NULL was not provided. */
315315
int coll_tuned_alg_to_str(int collective_id, int alg_value, char **alg_string) {
316316
int rc;
317-
if (collective_id > COLLCOUNT || collective_id < 0) { return OPAL_ERROR; };
317+
if (collective_id >= COLLCOUNT || collective_id < 0) { return OPAL_ERROR; };
318318
rc = coll_tuned_algorithm_enums[collective_id]->string_from_value(
319319
coll_tuned_algorithm_enums[collective_id],
320320
alg_value, alg_string );
@@ -326,7 +326,7 @@ int coll_tuned_alg_register_options(int collective_id, mca_base_var_enum_t *opti
326326
/* use the same enum used for mca parameters to allow tuning files to use
327327
algorithm names rather than just numbers.*/
328328
if (!options) { return OPAL_ERROR; }
329-
if (collective_id > COLLCOUNT || collective_id < 0) {
329+
if (collective_id >= COLLCOUNT || collective_id < 0) {
330330
return OPAL_ERROR;
331331
}
332332

0 commit comments

Comments
 (0)