git: 1fcaea242a7b - stable/13 - Fix unused variable warning in amd64's pmap.c

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

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

commit 1fcaea242a7b31eb6b449f00c98cb69faa156c12
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2022-07-26 19:53:08 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2022-07-29 18:30:00 +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
    
    (cherry picked from commit 7a1f289bd2949e5867c7f0396c35f02f179dc8bd)
---
 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 79e61de490ae..5288cd7fbfef 100644
--- a/sys/amd64/amd64/pmap.c
+++ b/sys/amd64/amd64/pmap.c
@@ -8152,7 +8152,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;
 
@@ -8186,7 +8189,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) {
@@ -8307,7 +8312,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));