From b22becea6dff84d7deb97ecc7ae5a4a615867af3 Mon Sep 17 00:00:00 2001 From: Brian Barrett Date: Mon, 1 Nov 2004 14:18:30 +0000 Subject: [PATCH] * fix portability stupidity in ifislocal() * clarify comment for addrtoname This commit was SVN r3455. --- src/util/if.c | 7 +++---- src/util/if.h | 10 ++++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/util/if.c b/src/util/if.c index d68e4da498..705600f8e0 100644 --- a/src/util/if.c +++ b/src/util/if.c @@ -517,15 +517,14 @@ int ompi_ifindextoname(int if_index, char* if_name, int length) return OMPI_ERROR; } - +#define ADDRLEN 100 bool ompi_ifislocal(char *hostname) { - const int len = 100; - char addrname[len - 1]; + char addrname[ADDRLEN - 1]; int ret; - ret = ompi_ifaddrtoname(hostname, addrname, len); + ret = ompi_ifaddrtoname(hostname, addrname, ADDRLEN); if (OMPI_SUCCESS == ret) return true; return false; diff --git a/src/util/if.h b/src/util/if.h index 6106cf660e..5467e1624e 100644 --- a/src/util/if.h +++ b/src/util/if.h @@ -24,16 +24,18 @@ extern "C" { * @param if_addr (OUT) Interface address buffer * @param size (IN) Interface address buffer size */ -OMPI_DECLSPEC int ompi_ifnametoaddr(const char* if_name, struct sockaddr*, int); +OMPI_DECLSPEC int ompi_ifnametoaddr(const char* if_name, + struct sockaddr* if_addr, int size); /** * Lookup an interface by address and return its name. * - * @param if_name (IN) Interface address - * @param if_addr (OUT) Interface name buffer + * @param if_addr (IN) Interface address (hostname or dotted-quad) + * @param if_name (OUT) Interface name buffer * @param size (IN) Interface name buffer size */ -OMPI_DECLSPEC int ompi_ifaddrtoname(const char* if_addr, char* if_name, int); +OMPI_DECLSPEC int ompi_ifaddrtoname(const char* if_addr, + char* if_name, int size); /** * Lookup an interface by name and return its kernel index.