git: 05ea7a3e5e74 - main - net80211: fix -Wunused-but-set-variable warnings

From: Bjoern A. Zeeb <bz_at_FreeBSD.org>
Date: Wed, 24 Nov 2021 17:44:11 UTC
The branch main has been updated by bz:

URL: https://cgit.FreeBSD.org/src/commit/?id=05ea7a3e5e748547a0229efa80be0e71eaf84f52

commit 05ea7a3e5e748547a0229efa80be0e71eaf84f52
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2021-11-24 17:36:48 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2021-11-24 17:39:19 +0000

    net80211: fix -Wunused-but-set-variable warnings
    
    Put the offending variables under the appropriate #ifdefs
    (mostly IEEE80211_DEBUG, in one case IEEE80211_SUPPORT_SUPERG, and
    in two cases under __notyet__ to revisit why these had been left
    there but not used).
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      10 days
---
 sys/net80211/ieee80211_adhoc.c      |  5 ++++-
 sys/net80211/ieee80211_crypto_wep.c |  8 +++++---
 sys/net80211/ieee80211_hostap.c     | 16 +++++++++++++++-
 sys/net80211/ieee80211_ht.c         | 21 ++++++++++++++++-----
 sys/net80211/ieee80211_output.c     |  6 ++++++
 sys/net80211/ieee80211_sta.c        |  7 ++++++-
 6 files changed, 52 insertions(+), 11 deletions(-)

diff --git a/sys/net80211/ieee80211_adhoc.c b/sys/net80211/ieee80211_adhoc.c
index 150515222268..57e46dd5ad0b 100644
--- a/sys/net80211/ieee80211_adhoc.c
+++ b/sys/net80211/ieee80211_adhoc.c
@@ -1009,7 +1009,6 @@ ahdemo_recv_mgmt(struct ieee80211_node *ni, struct mbuf *m0,
 {
 	struct ieee80211vap *vap = ni->ni_vap;
 	struct ieee80211com *ic = ni->ni_ic;
-	struct ieee80211_frame *wh;
 
 	/*
 	 * Process management frames when scanning; useful for doing
@@ -1018,7 +1017,11 @@ ahdemo_recv_mgmt(struct ieee80211_node *ni, struct mbuf *m0,
 	if (ic->ic_flags & IEEE80211_F_SCAN)
 		adhoc_recv_mgmt(ni, m0, subtype, rxs, rssi, nf);
 	else {
+#ifdef IEEE80211_DEBUG
+		struct ieee80211_frame *wh;
+
 		wh = mtod(m0, struct ieee80211_frame *);
+#endif
 		switch (subtype) {
 		case IEEE80211_FC0_SUBTYPE_ASSOC_REQ:
 		case IEEE80211_FC0_SUBTYPE_ASSOC_RESP:
diff --git a/sys/net80211/ieee80211_crypto_wep.c b/sys/net80211/ieee80211_crypto_wep.c
index 797de006cdf2..164157559cb2 100644
--- a/sys/net80211/ieee80211_crypto_wep.c
+++ b/sys/net80211/ieee80211_crypto_wep.c
@@ -241,11 +241,8 @@ wep_decap(struct ieee80211_key *k, struct mbuf *m, int hdrlen)
 {
 	struct wep_ctx *ctx = k->wk_private;
 	struct ieee80211vap *vap = ctx->wc_vap;
-	struct ieee80211_frame *wh;
 	const struct ieee80211_rx_stats *rxs;
 
-	wh = mtod(m, struct ieee80211_frame *);
-
 	rxs = ieee80211_get_rx_params_ptr(m);
 
 	if ((rxs != NULL) && (rxs->c_pktflags & IEEE80211_RX_F_IV_STRIP))
@@ -258,6 +255,11 @@ wep_decap(struct ieee80211_key *k, struct mbuf *m, int hdrlen)
 	 */
 	if ((k->wk_flags & IEEE80211_KEY_SWDECRYPT) &&
 	    !wep_decrypt(k, m, hdrlen)) {
+#ifdef IEEE80211_DEBUG
+		struct ieee80211_frame *wh;
+
+		wh = mtod(m, struct ieee80211_frame *);
+#endif
 		IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_CRYPTO, wh->i_addr2,
 		    "%s", "WEP ICV mismatch on decrypt");
 		vap->iv_stats.is_rx_wepfail++;
diff --git a/sys/net80211/ieee80211_hostap.c b/sys/net80211/ieee80211_hostap.c
index 4fa9c6a72145..f3a85848fc84 100644
--- a/sys/net80211/ieee80211_hostap.c
+++ b/sys/net80211/ieee80211_hostap.c
@@ -997,7 +997,7 @@ hostap_auth_shared(struct ieee80211_node *ni, struct ieee80211_frame *wh,
 {
 	struct ieee80211vap *vap = ni->ni_vap;
 	uint8_t *challenge;
-	int allocbs, estatus;
+	int estatus;
 
 	KASSERT(vap->iv_state == IEEE80211_S_RUN, ("state %d", vap->iv_state));
 
@@ -1070,17 +1070,26 @@ hostap_auth_shared(struct ieee80211_node *ni, struct ieee80211_frame *wh,
 	}
 	switch (seq) {
 	case IEEE80211_AUTH_SHARED_REQUEST:
+	{
+#ifdef IEEE80211_DEBUG
+		bool allocbs;
+#endif
+
 		if (ni == vap->iv_bss) {
 			ni = ieee80211_dup_bss(vap, wh->i_addr2);
 			if (ni == NULL) {
 				/* NB: no way to return an error */
 				return;
 			}
+#ifdef IEEE80211_DEBUG
 			allocbs = 1;
+#endif
 		} else {
 			if ((ni->ni_flags & IEEE80211_NODE_AREF) == 0)
 				(void) ieee80211_ref_node(ni);
+#ifdef IEEE80211_DEBUG
 			allocbs = 0;
+#endif
 		}
 		/*
 		 * Mark the node as referenced to reflect that it's
@@ -1120,6 +1129,7 @@ hostap_auth_shared(struct ieee80211_node *ni, struct ieee80211_frame *wh,
 			return;
 		}
 		break;
+	}
 	case IEEE80211_AUTH_SHARED_RESPONSE:
 		if (ni == vap->iv_bss) {
 			IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_AUTH,
@@ -2299,7 +2309,9 @@ hostap_recv_mgmt(struct ieee80211_node *ni, struct mbuf *m0,
 
 	case IEEE80211_FC0_SUBTYPE_DEAUTH:
 	case IEEE80211_FC0_SUBTYPE_DISASSOC: {
+#ifdef IEEE80211_DEBUG
 		uint16_t reason;
+#endif
 
 		if (vap->iv_state != IEEE80211_S_RUN ||
 		    /* NB: can happen when in promiscuous mode */
@@ -2312,7 +2324,9 @@ hostap_recv_mgmt(struct ieee80211_node *ni, struct mbuf *m0,
 		 *	[2] reason
 		 */
 		IEEE80211_VERIFY_LENGTH(efrm - frm, 2, return);
+#ifdef IEEE80211_DEBUG
 		reason = le16toh(*(uint16_t *)frm);
+#endif
 		if (subtype == IEEE80211_FC0_SUBTYPE_DEAUTH) {
 			vap->iv_stats.is_rx_deauth++;
 			IEEE80211_NODE_STAT(ni, rx_deauth);
diff --git a/sys/net80211/ieee80211_ht.c b/sys/net80211/ieee80211_ht.c
index fc10e07cc4fc..e680db5faa52 100644
--- a/sys/net80211/ieee80211_ht.c
+++ b/sys/net80211/ieee80211_ht.c
@@ -2351,7 +2351,7 @@ ieee80211_addba_response(struct ieee80211_node *ni,
 	int status, int baparamset, int batimeout)
 {
 	struct ieee80211vap *vap = ni->ni_vap;
-	int bufsiz, tid;
+	int bufsiz;
 
 	/* XXX locking */
 	addba_stop_timeout(tap);
@@ -2360,7 +2360,9 @@ ieee80211_addba_response(struct ieee80211_node *ni,
 		/* XXX override our request? */
 		tap->txa_wnd = (bufsiz == 0) ?
 		    IEEE80211_AGGR_BAWMAX : min(bufsiz, IEEE80211_AGGR_BAWMAX);
+#ifdef __notyet__
 		tid = _IEEE80211_MASKSHIFT(baparamset, IEEE80211_BAPS_TID);
+#endif
 		tap->txa_flags |= IEEE80211_AGGR_RUNNING;
 		tap->txa_attempts = 0;
 		/* TODO: this should be a vap flag */
@@ -2486,16 +2488,20 @@ ht_recv_action_ba_addba_response(struct ieee80211_node *ni,
 	struct ieee80211_tx_ampdu *tap;
 	uint8_t dialogtoken, policy;
 	uint16_t baparamset, batimeout, code;
-	int tid, bufsiz;
-	int amsdu;
+	int tid;
+#ifdef IEEE80211_DEBUG
+	int amsdu, bufsiz;
+#endif
 
 	dialogtoken = frm[2];
 	code = le16dec(frm+3);
 	baparamset = le16dec(frm+5);
 	tid = _IEEE80211_MASKSHIFT(baparamset, IEEE80211_BAPS_TID);
+#ifdef IEEE80211_DEBUG
 	bufsiz = _IEEE80211_MASKSHIFT(baparamset, IEEE80211_BAPS_BUFSIZ);
-	policy = _IEEE80211_MASKSHIFT(baparamset, IEEE80211_BAPS_POLICY);
 	amsdu = !! _IEEE80211_MASKSHIFT(baparamset, IEEE80211_BAPS_AMSDU);
+#endif
+	policy = _IEEE80211_MASKSHIFT(baparamset, IEEE80211_BAPS_POLICY);
 	batimeout = le16dec(frm+7);
 
 	tap = &ni->ni_tx_ampdu[tid];
@@ -2563,11 +2569,16 @@ ht_recv_action_ba_delba(struct ieee80211_node *ni,
 	struct ieee80211com *ic = ni->ni_ic;
 	struct ieee80211_rx_ampdu *rap;
 	struct ieee80211_tx_ampdu *tap;
-	uint16_t baparamset, code;
+	uint16_t baparamset;
+#ifdef IEEE80211_DEBUG
+	uint16_t code;
+#endif
 	int tid;
 
 	baparamset = le16dec(frm+2);
+#ifdef IEEE80211_DEBUG
 	code = le16dec(frm+4);
+#endif
 
 	tid = _IEEE80211_MASKSHIFT(baparamset, IEEE80211_DELBAPS_TID);
 
diff --git a/sys/net80211/ieee80211_output.c b/sys/net80211/ieee80211_output.c
index 4f9e9614f732..9b1898df7b10 100644
--- a/sys/net80211/ieee80211_output.c
+++ b/sys/net80211/ieee80211_output.c
@@ -126,10 +126,12 @@ ieee80211_vap_pkt_send_dest(struct ieee80211vap *vap, struct mbuf *m,
 	struct ifnet *ifp = vap->iv_ifp;
 	int mcast;
 	int do_ampdu = 0;
+#ifdef IEEE80211_SUPPORT_SUPERG
 	int do_amsdu = 0;
 	int do_ampdu_amsdu = 0;
 	int no_ampdu = 1; /* Will be set to 0 if ampdu is active */
 	int do_ff = 0;
+#endif
 
 	if ((ni->ni_flags & IEEE80211_NODE_PWR_MGT) &&
 	    (m->m_flags & M_PWR_SAV) == 0) {
@@ -187,12 +189,14 @@ ieee80211_vap_pkt_send_dest(struct ieee80211vap *vap, struct mbuf *m,
 	 */
 	do_ampdu = ((ni->ni_flags & IEEE80211_NODE_AMPDU_TX) &&
 	    (vap->iv_flags_ht & IEEE80211_FHT_AMPDU_TX));
+#ifdef IEEE80211_SUPPORT_SUPERG
 	do_amsdu = ((ni->ni_flags & IEEE80211_NODE_AMSDU_TX) &&
 	    (vap->iv_flags_ht & IEEE80211_FHT_AMSDU_TX));
 	do_ff =
 	    ((ni->ni_flags & IEEE80211_NODE_HT) == 0) &&
 	    ((ni->ni_flags & IEEE80211_NODE_VHT) == 0) &&
 	    (IEEE80211_ATH_CAP(vap, ni, IEEE80211_NODE_FF));
+#endif
 
 	/*
 	 * Check if A-MPDU tx aggregation is setup or if we
@@ -246,9 +250,11 @@ ieee80211_vap_pkt_send_dest(struct ieee80211vap *vap, struct mbuf *m,
 			 * have also set or cleared the amsdu-in-ampdu txa_flags
 			 * combination so we can correctly do A-MPDU + A-MSDU.
 			 */
+#ifdef IEEE80211_SUPPORT_SUPERG
 			no_ampdu = (! IEEE80211_AMPDU_RUNNING(tap)
 			    || (IEEE80211_AMPDU_NACKED(tap)));
 			do_ampdu_amsdu = IEEE80211_AMPDU_RUNNING_AMSDU(tap);
+#endif
 		}
 	}
 
diff --git a/sys/net80211/ieee80211_sta.c b/sys/net80211/ieee80211_sta.c
index 7ea6187332b1..9e103f6877c4 100644
--- a/sys/net80211/ieee80211_sta.c
+++ b/sys/net80211/ieee80211_sta.c
@@ -1569,7 +1569,10 @@ sta_recv_mgmt(struct ieee80211_node *ni, struct mbuf *m0, int subtype,
 				int ix = aid / NBBY;
 				int min = tim->tim_bitctl &~ 1;
 				int max = tim->tim_len + min - 4;
-				int tim_ucast = 0, tim_mcast = 0;
+				int tim_ucast = 0;
+#ifdef __notyet__
+				int tim_mcast = 0;
+#endif
 
 				/*
 				 * Only do this for unicast traffic in the TIM
@@ -1582,6 +1585,7 @@ sta_recv_mgmt(struct ieee80211_node *ni, struct mbuf *m0, int subtype,
 					tim_ucast = 1;
 				}
 
+#ifdef __notyet__
 				/*
 				 * Do a separate notification
 				 * for the multicast bit being set.
@@ -1589,6 +1593,7 @@ sta_recv_mgmt(struct ieee80211_node *ni, struct mbuf *m0, int subtype,
 				if (tim->tim_bitctl & 1) {
 					tim_mcast = 1;
 				}
+#endif
 
 				/*
 				 * If the TIM indicates there's traffic for