Skip to content

Commit

Permalink
Removing trailing comma for environment vars such as OMP_PLACES.
Browse files Browse the repository at this point in the history
  • Loading branch information
eleon committed Jul 22, 2020
1 parent df581c2 commit 267b83e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ endif
PROGS = main

## HWLOC_XML_VERBOSE=1
## HWLOC_XMLFILE=topo-xml/lassen-hw2.xml
## ./mpibind_v0.14.1
## HWLOC_XMLFILE=../topo-xml/coral-lassen.xml ./main

all: $(PROGS) $(MPIBIND_SONAME) $(MPIBIND_LIB)

Expand Down
9 changes: 7 additions & 2 deletions src/mpibind.c
Original file line number Diff line number Diff line change
Expand Up @@ -1389,7 +1389,7 @@ void mpibind_print_mapping(mpibind_t *handle)
*/
int mpibind_set_env_vars(mpibind_t *handle)
{
int i, v, nc, val;
int i, v, nc, val, end;
char *str;
int nvars = 4;
char *vars[] = {"OMP_NUM_THREADS",
Expand Down Expand Up @@ -1445,11 +1445,16 @@ int mpibind_set_env_vars(mpibind_t *handle)
nc += snprintf(str+nc, LONG_STR_SIZE-nc, "%d,", val);
} hwloc_bitmap_foreach_end();
}

/* Strip the last comma */
end = strlen(str) - 1;
if (str[end] == ',')
str[end] = '\0';
}
}

/* Store the names of the vars in its own array
so that callers can retrieve it easily */
so that callers can retrieve them easily */
handle->names = calloc(nvars, sizeof(char *));
for (v=0; v<nvars; v++) {
handle->names[v] = malloc(SHORT_STR_SIZE);
Expand Down

0 comments on commit 267b83e

Please sign in to comment.