git: 8b6ccfb6c700 - main - multicast code: Quiet unused warnings for variables used for KTR traces.

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Wed, 06 Apr 2022 23:46:07 UTC
The branch main has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=8b6ccfb6c7006fb7ab5f1e6b00b67675f8ce147e

commit 8b6ccfb6c7006fb7ab5f1e6b00b67675f8ce147e
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2022-04-06 23:45:28 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2022-04-06 23:45:28 +0000

    multicast code: Quiet unused warnings for variables used for KTR traces.
    
    For nallow and nblock, move the variables under #ifdef KTR.
    
    For return values from functions logged in KTR traces, mark the
    variables as __unused rather than having to #ifdef the assignment of
    the function return value.
---
 sys/netinet/igmp.c  |  6 ++++++
 sys/netinet6/mld6.c | 10 +++++++---
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/sys/netinet/igmp.c b/sys/netinet/igmp.c
index 58d66ebafe64..61a83356a01c 100644
--- a/sys/netinet/igmp.c
+++ b/sys/netinet/igmp.c
@@ -3052,7 +3052,9 @@ igmp_v3_enqueue_filter_change(struct mbufq *mq, struct in_multi *inm)
 	struct mbuf		*m, *m0, *md;
 	in_addr_t		 naddr;
 	int			 m0srcs, nbytes, npbytes, off, rsrcs, schanged;
+#ifdef KTR
 	int			 nallow, nblock;
+#endif
 	uint8_t			 mode, now, then;
 	rectype_t		 crt, drt, nrt;
 
@@ -3072,8 +3074,10 @@ igmp_v3_enqueue_filter_change(struct mbufq *mq, struct in_multi *inm)
 	npbytes = 0;	/* # of bytes appended this packet */
 	rsrcs = 0;	/* # sources encoded in current record */
 	schanged = 0;	/* # nodes encoded in overall filter change */
+#ifdef KTR
 	nallow = 0;	/* # of source entries in ALLOW_NEW */
 	nblock = 0;	/* # of source entries in BLOCK_OLD */
+#endif
 	nims = NULL;	/* next tree node pointer */
 
 	/*
@@ -3197,8 +3201,10 @@ igmp_v3_enqueue_filter_change(struct mbufq *mq, struct in_multi *inm)
 					    "%s: m_append() failed", __func__);
 					return (-ENOMEM);
 				}
+#ifdef KTR
 				nallow += !!(crt == REC_ALLOW);
 				nblock += !!(crt == REC_BLOCK);
+#endif
 				if (++rsrcs == m0srcs)
 					break;
 			}
diff --git a/sys/netinet6/mld6.c b/sys/netinet6/mld6.c
index 1f79ef39e40e..15ad5196d205 100644
--- a/sys/netinet6/mld6.c
+++ b/sys/netinet6/mld6.c
@@ -1568,7 +1568,7 @@ mld_v2_process_group_timers(struct in6_multi_head *inmh,
 		 * immediate transmission.
 		 */
 		if (query_response_timer_expired) {
-			int retval;
+			int retval __unused;
 
 			retval = mld_v2_enqueue_group_record(qrq, inm, 0, 1,
 			    (inm->in6m_state == MLD_SG_QUERY_PENDING_MEMBER),
@@ -2702,10 +2702,10 @@ mld_v2_enqueue_filter_change(struct mbufq *mq, struct in6_multi *inm)
 	struct ip6_msource	*ims, *nims;
 	struct mbuf		*m, *m0, *md;
 	int			 m0srcs, nbytes, npbytes, off, rsrcs, schanged;
-	int			 nallow, nblock;
 	uint8_t			 mode, now, then;
 	rectype_t		 crt, drt, nrt;
 #ifdef KTR
+	int			 nallow, nblock;
 	char			 ip6tbuf[INET6_ADDRSTRLEN];
 #endif
 
@@ -2725,8 +2725,10 @@ mld_v2_enqueue_filter_change(struct mbufq *mq, struct in6_multi *inm)
 	nbytes = 0;	/* # of bytes appended to group's state-change queue */
 	rsrcs = 0;	/* # sources encoded in current record */
 	schanged = 0;	/* # nodes encoded in overall filter change */
+#ifdef KTR
 	nallow = 0;	/* # of source entries in ALLOW_NEW */
 	nblock = 0;	/* # of source entries in BLOCK_OLD */
+#endif
 	nims = NULL;	/* next tree node pointer */
 
 	/*
@@ -2847,8 +2849,10 @@ mld_v2_enqueue_filter_change(struct mbufq *mq, struct in6_multi *inm)
 					    "%s: m_append() failed", __func__);
 					return (-ENOMEM);
 				}
+#ifdef KTR
 				nallow += !!(crt == REC_ALLOW);
 				nblock += !!(crt == REC_BLOCK);
+#endif
 				if (++rsrcs == m0srcs)
 					break;
 			}
@@ -3006,7 +3010,7 @@ mld_v2_dispatch_general_query(struct mld_ifsoftc *mli)
 	struct ifmultiaddr	*ifma;
 	struct ifnet		*ifp;
 	struct in6_multi	*inm;
-	int			 retval;
+	int			 retval __unused;
 
 	NET_EPOCH_ASSERT();
 	IN6_MULTI_LIST_LOCK_ASSERT();