git: ed4334af2457 - stable/13 - Fix unused variable warning in fwohci.c

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Sun, 24 Jul 2022 11:01:57 UTC
The branch stable/13 has been updated by dim:

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

commit ed4334af24570d0e6c2e106a89bd3d1cb353ca14
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2022-07-21 17:59:08 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2022-07-24 11:00:10 +0000

    Fix unused variable warning in fwohci.c
    
    With clang 15, the following -Werror warning is produced:
    
        sys/dev/firewire/fwohci.c:2762:23: error: variable 'pcnt' set but not used [-Werror,-Wunused-but-set-variable]
                int len, plen, hlen, pcnt, offset;
                                     ^
    
    The 'pcnt' variable is eventually used only in an #if 0'd block,
    obviously meant for debugging. Ensure that 'pcnt' is only declared and
    used when COUNT_PACKETS is defined, so the debugging can be easily
    turned on later, if desired.
    
    MFC after:      3 days
    
    (cherry picked from commit d7e0d962f39877b997454992a980f4122c6316e7)
---
 sys/dev/firewire/fwohci.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/sys/dev/firewire/fwohci.c b/sys/dev/firewire/fwohci.c
index 634c78e6afe8..a77a653fe5d7 100644
--- a/sys/dev/firewire/fwohci.c
+++ b/sys/dev/firewire/fwohci.c
@@ -2741,7 +2741,10 @@ fwohci_arcv(struct fwohci_softc *sc, struct fwohci_dbch *dbch, int count)
 	uint8_t *ld;
 	uint32_t stat, off, status, event;
 	u_int spd;
-	int len, plen, hlen, pcnt, offset;
+#ifdef COUNT_PACKETS
+	int pcnt;
+#endif
+        int len, plen, hlen, offset;
 	int s;
 	caddr_t buf;
 	int resCount;
@@ -2756,7 +2759,9 @@ fwohci_arcv(struct fwohci_softc *sc, struct fwohci_dbch *dbch, int count)
 
 	s = splfw();
 	db_tr = dbch->top;
+#ifdef COUNT_PACKETS
 	pcnt = 0;
+#endif
 	/* XXX we cannot handle a packet which lies in more than two buf */
 	fwdma_sync_multiseg_all(dbch->am, BUS_DMASYNC_POSTREAD);
 	fwdma_sync_multiseg_all(dbch->am, BUS_DMASYNC_POSTWRITE);
@@ -2922,7 +2927,9 @@ fwohci_arcv(struct fwohci_softc *sc, struct fwohci_dbch *dbch, int count)
 #endif
 				break;
 			}
+#ifdef COUNT_PACKETS
 			pcnt++;
+#endif
 			if (dbch->pdb_tr != NULL) {
 				fwohci_arcv_free_buf(sc, dbch, dbch->pdb_tr,
 				    off, 1);
@@ -2952,7 +2959,7 @@ out:
 		}
 		/* XXX make sure DMA is not dead */
 	}
-#if 0
+#ifdef COUNT_PACKETS
 	if (pcnt < 1)
 		printf("fwohci_arcv: no packets\n");
 #endif