git: 63e8ce61d72a - stable/12 - Fix unused variable warning in sctp_timer.c

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Fri, 29 Jul 2022 18:48:14 UTC
The branch stable/12 has been updated by dim:

URL: https://cgit.FreeBSD.org/src/commit/?id=63e8ce61d72a01da4f74f560e993ecafcd914e10

commit 63e8ce61d72a01da4f74f560e993ecafcd914e10
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2022-07-25 20:06:28 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2022-07-29 18:35:36 +0000

    Fix unused variable warning in sctp_timer.c
    
    With clang 15, the following -Werror warning is produced:
    
        sys/netinet/sctp_timer.c:510:6: error: variable 'recovery_cnt' set but not used [-Werror,-Wunused-but-set-variable]
                int recovery_cnt = 0;
                    ^
    
    The 'recovery_cnt' variable is only used when INVARIANTS is undefined.
    Ensure it is only declared and set in that case.
    
    MFC after:      3 days
    
    (cherry picked from commit 5bfd8cf3691381c19296d76d7944d6c1df5f4a75)
---
 sys/netinet/sctp_timer.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sys/netinet/sctp_timer.c b/sys/netinet/sctp_timer.c
index b5f84bcf3665..c9cd64961c8c 100644
--- a/sys/netinet/sctp_timer.c
+++ b/sys/netinet/sctp_timer.c
@@ -494,7 +494,9 @@ sctp_mark_all_for_resend(struct sctp_tcb *stcb,
 	unsigned int cnt_mk;
 	uint32_t orig_flight, orig_tf;
 	uint32_t tsnlast, tsnfirst;
+#ifndef INVARIANTS
 	int recovery_cnt = 0;
+#endif
 
 
 	/* none in flight now */
@@ -553,10 +555,10 @@ start_again:
 			/* Strange case our list got out of order? */
 			SCTP_PRINTF("Our list is out of order? last_acked:%x chk:%x\n",
 			    (unsigned int)stcb->asoc.last_acked_seq, (unsigned int)chk->rec.data.tsn);
-			recovery_cnt++;
 #ifdef INVARIANTS
 			panic("last acked >= chk on sent-Q");
 #else
+			recovery_cnt++;
 			SCTP_PRINTF("Recover attempts a restart cnt:%d\n", recovery_cnt);
 			sctp_recover_sent_list(stcb);
 			if (recovery_cnt < 10) {