Skip to content

Commit 4fdae9f

Browse files
committed
hook/comm: don't ignore fscanf return
Signed-off-by: Brian Barrett <bbarrett@amazon.com>
1 parent 20721c1 commit 4fdae9f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

ompi/mca/hook/comm_method/hook_comm_method_fns.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,13 +545,17 @@ ompi_report_comm_methods(int called_from_location) // 1 = from init, 2 = from fi
545545
fp = fopen(mca_hook_comm_method_fakefile, "r");
546546
for (i=0; i<nleaderranks; ++i) {
547547
for (k=0; k<nleaderranks; ++k) {
548-
fscanf(fp, "%d", &setting);
548+
if (fscanf(fp, "%d", &setting) != 1) {
549+
break;
550+
}
549551
// let -1 mean "use existing (real) setting"
550552
if (setting != -1) {
551553
method[i * nleaderranks + k] = setting;
552554
}
553555
}
554-
fscanf(fp, "\n");
556+
if (fscanf(fp, "\n") != 0) {
557+
break;
558+
}
555559
}
556560
fclose(fp);
557561
}

0 commit comments

Comments
 (0)