git: 7a1f289bd294 - main - Fix unused variable warning in amd64's pmap.c

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Tue, 26 Jul 2022 20:10:03 UTC
The branch main has been updated by dim:

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

commit 7a1f289bd2949e5867c7f0396c35f02f179dc8bd
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2022-07-26 19:53:08 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2022-07-26 20:08:10 +0000

    Fix unused variable warning in amd64's pmap.c
    
    With clang 15, the following -Werror warning is produced:
    
        sys/amd64/amd64/pmap.c:8274:22: error: variable 'freed' set but not used [-Werror,-Wunused-but-set-variable]
                int allfree, field, freed, i, idx;
                                    ^
    
    The 'freed' variable is only used when PV_STATS is defined. Ensure it is
    only declared and set in that case.
    
    MFC after:      3 days
---
 sys/amd64/amd64/pmap.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c
index f35a8c4c789c..893774357629 100644
--- a/sys/amd64/amd64/pmap.c
+++ b/sys/amd64/amd64/pmap.c
@@ -8271,7 +8271,10 @@ pmap_remove_pages(pmap_t pmap)
 	struct rwlock *lock;
 	int64_t bit;
 	uint64_t inuse, bitmask;
-	int allfree, field, freed, i, idx;
+	int allfree, field, i, idx;
+#ifdef PV_STATS
+	int freed;
+#endif
 	boolean_t superpage;
 	vm_paddr_t pa;
 
@@ -8305,7 +8308,9 @@ pmap_remove_pages(pmap_t pmap)
 	PMAP_LOCK(pmap);
 	TAILQ_FOREACH_SAFE(pc, &pmap->pm_pvchunk, pc_list, npc) {
 		allfree = 1;
+#ifdef PV_STATS
 		freed = 0;
+#endif
 		for (field = 0; field < _NPCM; field++) {
 			inuse = ~pc->pc_map[field] & pc_freemask[field];
 			while (inuse != 0) {
@@ -8426,7 +8431,9 @@ pmap_remove_pages(pmap_t pmap)
 					}
 				}
 				pmap_unuse_pt(pmap, pv->pv_va, ptepde, &free);
+#ifdef PV_STATS
 				freed++;
+#endif
 			}
 		}
 		PV_STAT(counter_u64_add(pv_entry_frees, freed));