Skip to content

Commit

Permalink
hmem: Fix two compilation warnings
Browse files Browse the repository at this point in the history
1. iface_filter_array is already the pointer
to the array, drop the & when passing it to ofi_hmem_set_iface_filter
2. copy the const iface_filter_str to iface_filter_str_copy before
passing to strtok, which will modify the iface_filter_str_copy.

Signed-off-by: Shi Jin <sjina@amazon.com>
  • Loading branch information
shijin-aws committed Oct 31, 2023
1 parent 6db3137 commit 9caab31
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/hmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -545,13 +545,14 @@ void ofi_hmem_set_iface_filter(const char* iface_filter_str, bool* filter)
"neuron",
"synapseai"
};
char *iface_filter_str_copy = strdup(iface_filter_str);

memset(filter, false, sizeof(bool) * ARRAY_SIZE(hmem_ops));

/* always enable system hmem interface */
filter[FI_HMEM_SYSTEM] = true;

entry = strtok(iface_filter_str, token);
entry = strtok(iface_filter_str_copy, token);
while (entry != NULL) {
for (iface = 0; iface < ARRAY_SIZE(hmem_ops); iface++) {
if (!strcasecmp(iface_labels[iface], entry)) {
Expand Down Expand Up @@ -584,7 +585,7 @@ void ofi_hmem_init(void)

if (hmem_filter) {
if (strlen(hmem_filter) != 0) {
ofi_hmem_set_iface_filter(hmem_filter, &iface_filter_array);
ofi_hmem_set_iface_filter(hmem_filter, iface_filter_array);
filter_hmem_ifaces = true;
} else {
FI_WARN(&core_prov, FI_LOG_CORE,
Expand Down

0 comments on commit 9caab31

Please sign in to comment.