Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 21 Jul 2022 19:06:03 GMT
From:      Dimitry Andric <dim@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: d7e0d962f398 - main - Fix unused variable warning in fwohci.c
Message-ID:  <202207211906.26LJ63ei038015@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by dim:

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

commit d7e0d962f39877b997454992a980f4122c6316e7
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2022-07-21 17:59:08 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2022-07-21 19:05:50 +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
---
 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 9c95bff21ccb..9c182c6fa331 100644
--- a/sys/dev/firewire/fwohci.c
+++ b/sys/dev/firewire/fwohci.c
@@ -2759,7 +2759,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;
@@ -2774,7 +2777,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);
@@ -2940,7 +2945,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);
@@ -2970,7 +2977,7 @@ out:
 		}
 		/* XXX make sure DMA is not dead */
 	}
-#if 0
+#ifdef COUNT_PACKETS
 	if (pcnt < 1)
 		printf("fwohci_arcv: no packets\n");
 #endif



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202207211906.26LJ63ei038015>