mirror of
https://github.com/freebsd/freebsd-src
synced 2024-07-22 02:37:15 +00:00
ifconfig: use default (more rigid) WARNS level.
It helps catch more errors at compile time. Reviewed by: kp Differential Revision: https://reviews.freebsd.org/D40536 MFC after: 2 weeks
This commit is contained in:
parent
f414f37e38
commit
a3930cd46c
|
@ -80,7 +80,6 @@ CFLAGS+=-DWITHOUT_NETLINK
|
|||
MAN= ifconfig.8
|
||||
|
||||
CFLAGS+= -Wall -Wmissing-prototypes -Wcast-qual -Wwrite-strings -Wnested-externs
|
||||
WARNS?= 2
|
||||
|
||||
HAS_TESTS=
|
||||
SUBDIR.${MK_TESTS}+= tests
|
||||
|
|
|
@ -105,20 +105,20 @@ in_status(if_ctx *ctx __unused, const struct ifaddrs *ifa)
|
|||
{
|
||||
struct sockaddr_in *sin, null_sin = {};
|
||||
|
||||
sin = (struct sockaddr_in *)ifa->ifa_addr;
|
||||
sin = satosin(ifa->ifa_addr);
|
||||
if (sin == NULL)
|
||||
return;
|
||||
|
||||
print_addr(sin);
|
||||
|
||||
if (ifa->ifa_flags & IFF_POINTOPOINT) {
|
||||
sin = (struct sockaddr_in *)ifa->ifa_dstaddr;
|
||||
sin = satosin(ifa->ifa_dstaddr);
|
||||
if (sin == NULL)
|
||||
sin = &null_sin;
|
||||
printf(" --> %s", inet_ntoa(sin->sin_addr));
|
||||
}
|
||||
|
||||
sin = (struct sockaddr_in *)ifa->ifa_netmask;
|
||||
sin = satosin(ifa->ifa_netmask);
|
||||
if (sin == NULL)
|
||||
sin = &null_sin;
|
||||
if (f_inet != NULL && strcmp(f_inet, "cidr") == 0) {
|
||||
|
@ -139,7 +139,7 @@ in_status(if_ctx *ctx __unused, const struct ifaddrs *ifa)
|
|||
printf(" netmask 0x%lx", (unsigned long)ntohl(sin->sin_addr.s_addr));
|
||||
|
||||
if (ifa->ifa_flags & IFF_BROADCAST) {
|
||||
sin = (struct sockaddr_in *)ifa->ifa_broadaddr;
|
||||
sin = satosin(ifa->ifa_broadaddr);
|
||||
if (sin != NULL && sin->sin_addr.s_addr != 0)
|
||||
printf(" broadcast %s", inet_ntoa(sin->sin_addr));
|
||||
}
|
||||
|
@ -202,7 +202,7 @@ static struct sockaddr_in *sintab[] = {
|
|||
};
|
||||
|
||||
static void
|
||||
in_copyaddr(if_ctx *ctx, int to, int from)
|
||||
in_copyaddr(if_ctx *ctx __unused, int to, int from)
|
||||
{
|
||||
memcpy(sintab[to], sintab[from], sizeof(struct sockaddr_in));
|
||||
}
|
||||
|
|
|
@ -299,7 +299,7 @@ in6_status(if_ctx *ctx, const struct ifaddrs *ifa)
|
|||
u_int32_t flags6;
|
||||
struct in6_addrlifetime lifetime;
|
||||
|
||||
sin = (struct sockaddr_in6 *)ifa->ifa_addr;
|
||||
sin = satosin6(ifa->ifa_addr);
|
||||
if (sin == NULL)
|
||||
return;
|
||||
|
||||
|
@ -328,7 +328,7 @@ in6_status(if_ctx *ctx, const struct ifaddrs *ifa)
|
|||
print_addr(sin);
|
||||
|
||||
if (ifa->ifa_flags & IFF_POINTOPOINT) {
|
||||
sin = (struct sockaddr_in6 *)ifa->ifa_dstaddr;
|
||||
sin = satosin6(ifa->ifa_dstaddr);
|
||||
/*
|
||||
* some of the interfaces do not have valid destination
|
||||
* address.
|
||||
|
@ -337,16 +337,16 @@ in6_status(if_ctx *ctx, const struct ifaddrs *ifa)
|
|||
print_p2p(sin);
|
||||
}
|
||||
|
||||
sin = (struct sockaddr_in6 *)ifa->ifa_netmask;
|
||||
sin = satosin6(ifa->ifa_netmask);
|
||||
if (sin == NULL)
|
||||
sin = &null_sin;
|
||||
print_mask(prefix(&sin->sin6_addr, sizeof(struct in6_addr)));
|
||||
|
||||
print_flags(flags6);
|
||||
|
||||
if (((struct sockaddr_in6 *)(ifa->ifa_addr))->sin6_scope_id)
|
||||
if ((satosin6(ifa->ifa_addr))->sin6_scope_id)
|
||||
printf(" scopeid 0x%x",
|
||||
((struct sockaddr_in6 *)(ifa->ifa_addr))->sin6_scope_id);
|
||||
(satosin6(ifa->ifa_addr))->sin6_scope_id);
|
||||
|
||||
if (ip6lifetime && (lifetime.ia6t_preferred || lifetime.ia6t_expire)) {
|
||||
struct timespec now;
|
||||
|
@ -510,7 +510,7 @@ static struct sockaddr_in6 *sin6tab[] = {
|
|||
};
|
||||
|
||||
static void
|
||||
in6_copyaddr(if_ctx *ctx, int to, int from)
|
||||
in6_copyaddr(if_ctx *ctx __unused, int to, int from)
|
||||
{
|
||||
memcpy(sin6tab[to], sin6tab[from], sizeof(struct sockaddr_in6));
|
||||
}
|
||||
|
@ -675,15 +675,14 @@ in6_status_tunnel(if_ctx *ctx)
|
|||
static void
|
||||
in6_set_tunnel(if_ctx *ctx, struct addrinfo *srcres, struct addrinfo *dstres)
|
||||
{
|
||||
struct in6_aliasreq in6_addreq;
|
||||
struct in6_aliasreq in6_req = {};
|
||||
|
||||
memset(&in6_addreq, 0, sizeof(in6_addreq));
|
||||
strlcpy(in6_addreq.ifra_name, ctx->ifname, sizeof(in6_addreq.ifra_name));
|
||||
memcpy(&in6_addreq.ifra_addr, srcres->ai_addr, srcres->ai_addr->sa_len);
|
||||
memcpy(&in6_addreq.ifra_dstaddr, dstres->ai_addr,
|
||||
strlcpy(in6_req.ifra_name, ctx->ifname, sizeof(in6_req.ifra_name));
|
||||
memcpy(&in6_req.ifra_addr, srcres->ai_addr, srcres->ai_addr->sa_len);
|
||||
memcpy(&in6_req.ifra_dstaddr, dstres->ai_addr,
|
||||
dstres->ai_addr->sa_len);
|
||||
|
||||
if (ioctl_ctx(ctx, SIOCSIFPHYADDR_IN6, &in6_addreq) < 0)
|
||||
if (ioctl_ctx(ctx, SIOCSIFPHYADDR_IN6, &in6_req) < 0)
|
||||
warn("SIOCSIFPHYADDR_IN6");
|
||||
}
|
||||
|
||||
|
|
|
@ -120,7 +120,7 @@ link_status(if_ctx *ctx, const struct ifaddrs *ifa)
|
|||
int rc, sock_hw;
|
||||
static const u_char laggaddr[6] = {0};
|
||||
|
||||
sdl = (struct sockaddr_dl *) ifa->ifa_addr;
|
||||
sdl = satosdl(ifa->ifa_addr);
|
||||
if (sdl == NULL || sdl->sdl_alen == 0)
|
||||
return;
|
||||
|
||||
|
|
|
@ -811,7 +811,7 @@ list_interfaces_ioctl(if_ctx *ctx)
|
|||
if (args->ifname != NULL && strcmp(args->ifname, ifa->ifa_name) != 0)
|
||||
continue;
|
||||
if (ifa->ifa_addr->sa_family == AF_LINK)
|
||||
sdl = (const struct sockaddr_dl *) ifa->ifa_addr;
|
||||
sdl = satosdl_c(ifa->ifa_addr);
|
||||
else
|
||||
sdl = NULL;
|
||||
if (cp != NULL && strcmp(cp, ifa->ifa_name) == 0 && !args->namesonly)
|
||||
|
@ -1737,8 +1737,7 @@ print_description(if_ctx *ctx)
|
|||
* specified, show only it; otherwise, show them all.
|
||||
*/
|
||||
static void
|
||||
status(if_ctx *ctx, const struct sockaddr_dl *sdl,
|
||||
struct ifaddrs *ifa)
|
||||
status(if_ctx *ctx, const struct sockaddr_dl *sdl __unused, struct ifaddrs *ifa)
|
||||
{
|
||||
struct ifaddrs *ift;
|
||||
int s, old_s;
|
||||
|
|
|
@ -314,3 +314,15 @@ satosin(struct sockaddr *sa)
|
|||
{
|
||||
return ((struct sockaddr_in *)(void *)sa);
|
||||
}
|
||||
|
||||
static inline struct sockaddr_dl *
|
||||
satosdl(struct sockaddr *sa)
|
||||
{
|
||||
return ((struct sockaddr_dl *)(void *)sa);
|
||||
}
|
||||
|
||||
static inline const struct sockaddr_dl *
|
||||
satosdl_c(const struct sockaddr *sa)
|
||||
{
|
||||
return ((const struct sockaddr_dl *)(const void *)sa);
|
||||
}
|
||||
|
|
|
@ -196,7 +196,7 @@ static struct ieee80211_txparams_req txparams;
|
|||
static int gottxparams = 0;
|
||||
static struct ieee80211_channel curchan;
|
||||
static int gotcurchan = 0;
|
||||
static struct ifmediareq *ifmr;
|
||||
static struct ifmediareq *global_ifmr;
|
||||
static int htconf = 0;
|
||||
static int gothtconf = 0;
|
||||
|
||||
|
@ -239,7 +239,7 @@ getchaninfo(if_ctx *ctx)
|
|||
if (get80211(ctx, IEEE80211_IOC_CHANINFO, chaninfo,
|
||||
IEEE80211_CHANINFO_SIZE(MAXCHAN)) < 0)
|
||||
err(1, "unable to get channel information");
|
||||
ifmr = ifmedia_getstate(ctx);
|
||||
global_ifmr = ifmedia_getstate(ctx);
|
||||
gethtconf(ctx);
|
||||
getvhtconf(ctx);
|
||||
}
|
||||
|
@ -317,7 +317,7 @@ promote(unsigned int i)
|
|||
* the socket descriptor down to here so we can make
|
||||
* the ifmedia_getstate call ourselves.
|
||||
*/
|
||||
int chanmode = ifmr != NULL ? IFM_MODE(ifmr->ifm_current) : IFM_AUTO;
|
||||
int chanmode = global_ifmr != NULL ? IFM_MODE(global_ifmr->ifm_current) : IFM_AUTO;
|
||||
|
||||
/* when ambiguous promote to ``best'' */
|
||||
/* NB: we abitrarily pick HT40+ over HT40- */
|
||||
|
|
Loading…
Reference in a new issue