Skip to content

Replace deprecated inet_ntoa() with inet_ntop()#13763

Open
geokoko wants to merge 3 commits intoopen-mpi:mainfrom
geokoko:replace-inet_ntoa-with-inet_ntop
Open

Replace deprecated inet_ntoa() with inet_ntop()#13763
geokoko wants to merge 3 commits intoopen-mpi:mainfrom
geokoko:replace-inet_ntoa-with-inet_ntop

Conversation

@geokoko
Copy link

@geokoko geokoko commented Mar 14, 2026

inet_ntoa() is deprecated according to Linux man pages and is on Fedora's rpminspect forbidden functions list (badfuncs). All occurrences are replaced with inet_ntop(), which writes to a caller-provided buffer instead of returning a pointer to an internal static buffer.

Also removed two inet_ntoa valgrind leak suppressions in contrib/openmpi-valgrind.supp that are no longer needed.

Files changed:

  • opal/util/net.c
  • opal/mca/btl/tcp/btl_tcp_endpoint.c
  • opal/mca/btl/usnic/btl_usnic_module.c
  • contrib/build-mca-comps-outside-of-tree/btl_tcp2_endpoint.c
  • contrib/openmpi-valgrind.supp

Fixes #13759

geokoko added 2 commits March 14, 2026 03:39
inet_ntoa() is deprecated according to Linux man pages and is also on Fedora's rpminspect forbidden functions list. Replacing all occurences with inet_ntop(), which writes to a caller-provided buffer.

Signed-off-by: geokoko <71934918+geokoko@users.noreply.github.com>
Signed-off-by: geokoko <71934918+geokoko@users.noreply.github.com>
bosilca
bosilca previously approved these changes Mar 18, 2026
}
}
#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.

# 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.

…2_endpoint.c

Signed-off-by: geokoko <71934918+geokoko@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use of deprecated inet_ntoa

2 participants