Skip to content

Commit ceb3b86

Browse files
authored
Merge pull request #510 from sydidelot/putenv
Fix wrong usage of putenv()
2 parents f731f31 + 8d852f5 commit ceb3b86

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/ior.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ static void DestroyTests(IOR_test_t *tests_head)
511511
*/
512512
static void DistributeHints(MPI_Comm com)
513513
{
514-
char hint[MAX_HINTS][MAX_STR], fullHint[MAX_STR], hintVariable[MAX_STR];
514+
char hint[MAX_HINTS][MAX_STR], fullHint[MAX_STR], hintVariable[MAX_STR], hintValue[MAX_STR];
515515
int hintCount = 0, i;
516516

517517
if (rank == 0) {
@@ -537,9 +537,10 @@ static void DistributeHints(MPI_Comm com)
537537
"cannot broadcast hints");
538538
strcpy(fullHint, hint[i]);
539539
strcpy(hintVariable, strtok(fullHint, "="));
540+
strcpy(hintValue, strtok(NULL, "="));
540541
if (getenv(hintVariable) == NULL) {
541542
/* doesn't exist in this task's environment; better set it */
542-
if (putenv(hint[i]) != 0)
543+
if (setenv(hintVariable, hintValue, 1) != 0)
543544
WARN("cannot set environment variable");
544545
}
545546
}

0 commit comments

Comments
 (0)