From nobody Fri Jun 16 07:19:45 2023 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Qj9XL2F6Fz4fZF8; Fri, 16 Jun 2023 07:19:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Qj9XL0fP3z47fn; Fri, 16 Jun 2023 07:19:46 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1686899986; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=4GUS4MVCj0+w4mufTNfH8BJ8nhWMzz/E/mEqrW8YOgk=; b=YAPRNjVkREjjGga+Paj+T2OKKmVAsD4m4bw3abCUotUSdsXKUrFHgkpzUGnwhn25sQV3PQ 0aMVJJmqpdgccBAgPLDtmcB6jrm3fUb+izremivYnf2i+9+RHNj3BMqlKORncx7DAMdo7h 6tnMvTRTJ2phppH6hS50s8BcXnbZIeW9WYqNLQ5TBWpB8afHIzORgWiR3wtOouG/XAYhTd F1RBkPhbntdMPUWjLmeivwclAgLSUy8ouneuOrbver2/j8J/v9QYpM9O4v5Hi46RrR06rm k2xTi217w73wItMinxbGtKHxwHbEU2cDGaY3eox41p3v5+vs5bjIH7ExNlqYQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1686899986; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=4GUS4MVCj0+w4mufTNfH8BJ8nhWMzz/E/mEqrW8YOgk=; b=KWwNPb08ILo9cUvWssQBkD9VHhzKTWY+qDtSOvS+CT2EtU6KJxklrThpD4RGppv+YSU+4E 5Dafto7/HZWA3fmQ77q6OBZ2Bx4/GhflZWpSqGFfMecWp03r+FXdDGPejqvgpZkrGk7iwM ECxy62fc89eICcEVjUlYxXCM4rx/KLfdOWdiTfrWlleTS0yfJ4MIT62xOOd6bZMbVE1rlt aIqfAXUjDxGYY6RXFhDpZ63bO+5Ro3zIxYJOlLrHNEJBQUnjKtRvivmEkBOWWW44tZ7Xp2 nfMeriddDXAGMkru69VI7VHo7iGrMYV3/9znrF3WTebHuzwkMJIpmgFYh+xYtw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1686899986; a=rsa-sha256; cv=none; b=ZlKvwXLiBr3AQ34A+h2juxWAhOrbBKg79Kx50F0jyLiQY1CxKidbwMnvmkm1pyEIQ/hITd gURQDEoHpmMBMheMt9jL4YBuYEVaCZzhepHtw2/X4ClfQGCdoMbu1N/o1azORpW5RKgI9V tdsg+cmB1c0W0FP+f51yXzaA+HXaZPRjMhBKUeaxzMWoPu8O7NEmRd+giOVdki9MgThvN4 GyJG5i913A4V868zhcYGZuaSt3jwDOPIXc6KsMqCyAlpaaV5MqNcnNqnIMWE/8GZYcXvO0 pxmUv4dP/o/XtE8buFpDf9sVLJqdOVzVW+TZYrHUW22nInhb6t73YswPsWwEwQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Qj9XK6sTTzKBd; Fri, 16 Jun 2023 07:19:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 35G7Jjj9034744; Fri, 16 Jun 2023 07:19:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 35G7JjS7034743; Fri, 16 Jun 2023 07:19:45 GMT (envelope-from git) Date: Fri, 16 Jun 2023 07:19:45 GMT Message-Id: <202306160719.35G7JjS7034743@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Alexander V. Chernikov" Subject: git: a3930cd46ce6 - main - ifconfig: use default (more rigid) WARNS level. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: melifaro X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a3930cd46ce6b3d6234044c5ed6970851ef3b967 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=a3930cd46ce6b3d6234044c5ed6970851ef3b967 commit a3930cd46ce6b3d6234044c5ed6970851ef3b967 Author: Alexander V. Chernikov AuthorDate: 2023-06-14 13:21:17 +0000 Commit: Alexander V. Chernikov CommitDate: 2023-06-16 07:19:22 +0000 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 --- sbin/ifconfig/Makefile | 1 - sbin/ifconfig/af_inet.c | 10 +++++----- sbin/ifconfig/af_inet6.c | 23 +++++++++++------------ sbin/ifconfig/af_link.c | 2 +- sbin/ifconfig/ifconfig.c | 5 ++--- sbin/ifconfig/ifconfig.h | 12 ++++++++++++ sbin/ifconfig/ifieee80211.c | 6 +++--- 7 files changed, 34 insertions(+), 25 deletions(-) diff --git a/sbin/ifconfig/Makefile b/sbin/ifconfig/Makefile index 9b9df6ab9f78..4b2f92b1597c 100644 --- a/sbin/ifconfig/Makefile +++ b/sbin/ifconfig/Makefile @@ -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 diff --git a/sbin/ifconfig/af_inet.c b/sbin/ifconfig/af_inet.c index 0c6ae253cbd4..83b605e8c4cb 100644 --- a/sbin/ifconfig/af_inet.c +++ b/sbin/ifconfig/af_inet.c @@ -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)); } diff --git a/sbin/ifconfig/af_inet6.c b/sbin/ifconfig/af_inet6.c index 1acfc28cad94..a0138e9b3de6 100644 --- a/sbin/ifconfig/af_inet6.c +++ b/sbin/ifconfig/af_inet6.c @@ -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"); } diff --git a/sbin/ifconfig/af_link.c b/sbin/ifconfig/af_link.c index e66266ece86b..17de87539d9a 100644 --- a/sbin/ifconfig/af_link.c +++ b/sbin/ifconfig/af_link.c @@ -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; diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index 24462f76e96c..f3d16fc052f6 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -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; diff --git a/sbin/ifconfig/ifconfig.h b/sbin/ifconfig/ifconfig.h index 49f907367b7a..c97ef447a3b3 100644 --- a/sbin/ifconfig/ifconfig.h +++ b/sbin/ifconfig/ifconfig.h @@ -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); +} diff --git a/sbin/ifconfig/ifieee80211.c b/sbin/ifconfig/ifieee80211.c index 480a8472f293..967385b2377d 100644 --- a/sbin/ifconfig/ifieee80211.c +++ b/sbin/ifconfig/ifieee80211.c @@ -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- */