Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions contrib/build-mca-comps-outside-of-tree/btl_tcp2_endpoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ static void mca_btl_tcp2_endpoint_send_handler(int sd, short flags, void* user);

void mca_btl_tcp_endpoint_dump(mca_btl_base_endpoint_t* btl_endpoint, const char* msg)
{
char src[64], dst[64], *status;
char src[INET_ADDRSTRLEN], dst[INET_ADDRSTRLEN], *status;
int sndbuf, rcvbuf, nodelay, flags = -1;
#if OPAL_ENABLE_IPV6
struct sockaddr_storage inaddr;
Expand All @@ -144,7 +144,7 @@ void mca_btl_tcp_endpoint_dump(mca_btl_base_endpoint_t* btl_endpoint, const char
}
}
#else
sprintf(src, "%s", inet_ntoa(inaddr.sin_addr));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change the size of the src and dst char arrays to be INET_ADDRSTRLEN instead of 64.

inet_ntop(AF_INET, &inaddr.sin_addr, src, sizeof(src));
#endif
getpeername(btl_endpoint->endpoint_sd, (struct sockaddr*)&inaddr, &addrlen);
#if OPAL_ENABLE_IPV6
Expand All @@ -156,7 +156,7 @@ void mca_btl_tcp_endpoint_dump(mca_btl_base_endpoint_t* btl_endpoint, const char
}
}
#else
sprintf(dst, "%s", inet_ntoa(inaddr.sin_addr));
inet_ntop(AF_INET, &inaddr.sin_addr, dst, sizeof(dst));
#endif

if((flags = fcntl(btl_endpoint->endpoint_sd, F_GETFL, 0)) < 0) {
Expand Down
16 changes: 0 additions & 16 deletions contrib/openmpi-valgrind.supp
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,6 @@
#
###############################################################

# inet_ntoa on linux mallocs a static buffer. We can't free
# it, so we have to live with it
{
linux_inet_ntoa
Memcheck:Leak
fun:malloc
fun:inet_ntoa
}
{
linux_inet_ntoa_thread
Memcheck:Leak
fun:calloc
fun:pthread_setspecific
fun:inet_ntoa
}


###############################################################
#
Expand Down
12 changes: 10 additions & 2 deletions opal/mca/btl/tcp/btl_tcp_endpoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,11 @@ void mca_btl_tcp_endpoint_dump(int level, const char *fname, int lineno, const c
}
}
# else
used += snprintf(&outmsg[used], DEBUG_LENGTH - used, "%s -", inet_ntoa(inaddr.sin_addr));
{
char ep_addr[INET_ADDRSTRLEN];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a fan of this double copy, but it's outside the critical path.

inet_ntop(AF_INET, &inaddr.sin_addr, ep_addr, sizeof(ep_addr));
used += snprintf(&outmsg[used], DEBUG_LENGTH - used, "%s -", ep_addr);
}
if (used >= DEBUG_LENGTH)
goto out;
# endif
Expand All @@ -184,7 +188,11 @@ void mca_btl_tcp_endpoint_dump(int level, const char *fname, int lineno, const c
}
}
# else
used += snprintf(&outmsg[used], DEBUG_LENGTH - used, " %s", inet_ntoa(inaddr.sin_addr));
{
char ep_addr[INET_ADDRSTRLEN];
inet_ntop(AF_INET, &inaddr.sin_addr, ep_addr, sizeof(ep_addr));
used += snprintf(&outmsg[used], DEBUG_LENGTH - used, " %s", ep_addr);
}
if (used >= DEBUG_LENGTH)
goto out;
# endif
Expand Down
12 changes: 8 additions & 4 deletions opal/mca/btl/usnic/btl_usnic_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -1564,10 +1564,14 @@ static int create_ep(opal_btl_usnic_module_t *module, struct opal_btl_usnic_chan
} else {
str = "UNKNOWN";
}
opal_output_verbose(15, USNIC_OUT,
"btl:usnic:create_ep:%s: new usnic local endpoint channel %s: %s:%d",
module->linux_device_name, str, inet_ntoa(sin->sin_addr),
ntohs(sin->sin_port));
{
char ep_addr[INET_ADDRSTRLEN];
inet_ntop(AF_INET, &sin->sin_addr, ep_addr, sizeof(ep_addr));
opal_output_verbose(15, USNIC_OUT,
"btl:usnic:create_ep:%s: new usnic local endpoint channel %s: %s:%d",
module->linux_device_name, str, ep_addr,
ntohs(sin->sin_port));
}

return OPAL_SUCCESS;
}
Expand Down
6 changes: 5 additions & 1 deletion opal/util/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,11 @@ char *opal_net_get_hostname(const struct sockaddr *addr)
}
return name;
# else
return inet_ntoa(((struct sockaddr_in *) addr)->sin_addr);
{
static char ntop_buf[INET_ADDRSTRLEN];
inet_ntop(AF_INET, &((struct sockaddr_in *) addr)->sin_addr, ntop_buf, sizeof(ntop_buf));
return ntop_buf;
}
# endif
}

Expand Down
Loading