From 23f98d5bcd11f457e6508b074944a5ef18a260ba Mon Sep 17 00:00:00 2001 From: Brad House Date: Fri, 8 Dec 2023 15:22:04 -0500 Subject: [PATCH] use IF_NAMESIZE instead of IFNAMSIZ to avoid warning --- src/lib/ares__iface_ips.c | 12 +++++------- src/lib/ares__iface_ips.h | 2 +- src/lib/ares_update_servers.c | 10 +++------- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/lib/ares__iface_ips.c b/src/lib/ares__iface_ips.c index 9c4181a3..91210af6 100644 --- a/src/lib/ares__iface_ips.c +++ b/src/lib/ares__iface_ips.c @@ -24,8 +24,7 @@ * SPDX-License-Identifier: MIT */ #include "ares_setup.h" -#include "ares.h" -#include "ares_private.h" + #ifdef USE_WINSOCK # include @@ -57,9 +56,8 @@ # include #endif -#ifndef IFNAMSIZ -# define IFNAMSIZ 64 -#endif +#include "ares.h" +#include "ares_private.h" static ares_status_t ares__iface_ips_enumerate(ares__iface_ips_t *ips, const char *name); @@ -555,7 +553,7 @@ const char *ares__if_indextoname(unsigned int index, char *name, size_t name_len) { #ifdef HAVE_IF_INDEXTONAME - if (name_len < IFNAMSIZ) { + if (name_len < IF_NAMESIZE) { return NULL; } return if_indextoname(index, name); @@ -565,7 +563,7 @@ const char *ares__if_indextoname(unsigned int index, char *name, size_t i; const char *ptr = NULL; - if (name_len < IFNAMSIZ) { + if (name_len < IF_NAMESIZE) { goto done; } diff --git a/src/lib/ares__iface_ips.h b/src/lib/ares__iface_ips.h index 3edc3bc6..61ff736a 100644 --- a/src/lib/ares__iface_ips.h +++ b/src/lib/ares__iface_ips.h @@ -130,7 +130,7 @@ unsigned int ares__if_nametoindex(const char *name); * * \param[in] index Interface index (> 0) * \param[in] name Buffer to hold name - * \param[in] name_len Length of provided buffer, must be at least IFNAMSIZ + * \param[in] name_len Length of provided buffer, must be at least IF_NAMESIZE * \return NULL on failure, or pointer to name on success */ const char *ares__if_indextoname(unsigned int index, char *name, diff --git a/src/lib/ares_update_servers.c b/src/lib/ares_update_servers.c index 5f27e57d..dd24fbfd 100644 --- a/src/lib/ares_update_servers.c +++ b/src/lib/ares_update_servers.c @@ -54,16 +54,12 @@ #include "ares_inet_net_pton.h" #include "ares_private.h" -#ifndef IFNAMSIZ -# define IFNAMSIZ 64 -#endif - typedef struct { struct ares_addr addr; unsigned short tcp_port; unsigned short udp_port; - char ll_iface[IFNAMSIZ]; + char ll_iface[IF_NAMESIZE]; unsigned int ll_scope; } ares_sconfig_t; @@ -351,8 +347,8 @@ static ares_status_t ares__sconfig_linklocal(ares_sconfig_t *s, unsigned int ll_scope = 0; if (ares_str_isnum(ll_iface)) { - char ifname[IFNAMSIZ] = ""; - ll_scope = (unsigned int)atoi(ll_iface); + char ifname[IF_NAMESIZE] = ""; + ll_scope = (unsigned int)atoi(ll_iface); if (ares__if_indextoname(ll_scope, ifname, sizeof(ifname)) == NULL) { DEBUGF(fprintf(stderr, "Interface %s for ipv6 Link Local not found\n", ll_iface));