use IF_NAMESIZE instead of IFNAMSIZ to avoid warning

pull/657/head
Brad House 1 year ago
parent dcd63acdb6
commit 23f98d5bcd
  1. 12
      src/lib/ares__iface_ips.c
  2. 2
      src/lib/ares__iface_ips.h
  3. 8
      src/lib/ares_update_servers.c

@ -24,8 +24,7 @@
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
*/ */
#include "ares_setup.h" #include "ares_setup.h"
#include "ares.h"
#include "ares_private.h"
#ifdef USE_WINSOCK #ifdef USE_WINSOCK
# include <winsock2.h> # include <winsock2.h>
@ -57,9 +56,8 @@
# include <netinet/in.h> # include <netinet/in.h>
#endif #endif
#ifndef IFNAMSIZ #include "ares.h"
# define IFNAMSIZ 64 #include "ares_private.h"
#endif
static ares_status_t ares__iface_ips_enumerate(ares__iface_ips_t *ips, static ares_status_t ares__iface_ips_enumerate(ares__iface_ips_t *ips,
const char *name); const char *name);
@ -555,7 +553,7 @@ const char *ares__if_indextoname(unsigned int index, char *name,
size_t name_len) size_t name_len)
{ {
#ifdef HAVE_IF_INDEXTONAME #ifdef HAVE_IF_INDEXTONAME
if (name_len < IFNAMSIZ) { if (name_len < IF_NAMESIZE) {
return NULL; return NULL;
} }
return if_indextoname(index, name); return if_indextoname(index, name);
@ -565,7 +563,7 @@ const char *ares__if_indextoname(unsigned int index, char *name,
size_t i; size_t i;
const char *ptr = NULL; const char *ptr = NULL;
if (name_len < IFNAMSIZ) { if (name_len < IF_NAMESIZE) {
goto done; goto done;
} }

@ -130,7 +130,7 @@ unsigned int ares__if_nametoindex(const char *name);
* *
* \param[in] index Interface index (> 0) * \param[in] index Interface index (> 0)
* \param[in] name Buffer to hold name * \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 * \return NULL on failure, or pointer to name on success
*/ */
const char *ares__if_indextoname(unsigned int index, char *name, const char *ares__if_indextoname(unsigned int index, char *name,

@ -54,16 +54,12 @@
#include "ares_inet_net_pton.h" #include "ares_inet_net_pton.h"
#include "ares_private.h" #include "ares_private.h"
#ifndef IFNAMSIZ
# define IFNAMSIZ 64
#endif
typedef struct { typedef struct {
struct ares_addr addr; struct ares_addr addr;
unsigned short tcp_port; unsigned short tcp_port;
unsigned short udp_port; unsigned short udp_port;
char ll_iface[IFNAMSIZ]; char ll_iface[IF_NAMESIZE];
unsigned int ll_scope; unsigned int ll_scope;
} ares_sconfig_t; } ares_sconfig_t;
@ -351,7 +347,7 @@ static ares_status_t ares__sconfig_linklocal(ares_sconfig_t *s,
unsigned int ll_scope = 0; unsigned int ll_scope = 0;
if (ares_str_isnum(ll_iface)) { if (ares_str_isnum(ll_iface)) {
char ifname[IFNAMSIZ] = ""; char ifname[IF_NAMESIZE] = "";
ll_scope = (unsigned int)atoi(ll_iface); ll_scope = (unsigned int)atoi(ll_iface);
if (ares__if_indextoname(ll_scope, ifname, sizeof(ifname)) == NULL) { if (ares__if_indextoname(ll_scope, ifname, sizeof(ifname)) == NULL) {
DEBUGF(fprintf(stderr, "Interface %s for ipv6 Link Local not found\n", DEBUGF(fprintf(stderr, "Interface %s for ipv6 Link Local not found\n",

Loading…
Cancel
Save