git: 957c5a9a4dda - stable/13 - Fix unused variable warning in mmu_radix.c

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Sun, 21 Aug 2022 11:29:12 UTC
The branch stable/13 has been updated by dim:

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

commit 957c5a9a4dda013ca8775922b24fb6ab0e418f77
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2022-08-15 18:42:51 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2022-08-21 11:13:32 +0000

    Fix unused variable warning in mmu_radix.c
    
    With clang 15, the following -Werror warning is produced:
    
        sys/powerpc/aim/mmu_radix.c:5409:22: error: variable 'freed' set but not used [-Werror,-Wunused-but-set-variable]
                int allfree, field, freed, 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 3446738e8deb6d475f88ca16fbb7b11473d17010)
---
 sys/powerpc/aim/mmu_radix.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/sys/powerpc/aim/mmu_radix.c b/sys/powerpc/aim/mmu_radix.c
index b9311e999588..097cc4be23dc 100644
--- a/sys/powerpc/aim/mmu_radix.c
+++ b/sys/powerpc/aim/mmu_radix.c
@@ -5369,7 +5369,10 @@ mmu_radix_remove_pages(pmap_t pmap)
 	struct rwlock *lock;
 	int64_t bit;
 	uint64_t inuse, bitmask;
-	int allfree, field, freed, idx;
+	int allfree, field, idx;
+#ifdef PV_STATS
+	int freed;
+#endif
 	boolean_t superpage;
 	vm_paddr_t pa;
 
@@ -5388,7 +5391,9 @@ mmu_radix_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) {
@@ -5505,7 +5510,9 @@ mmu_radix_remove_pages(pmap_t pmap)
 					}
 				}
 				pmap_unuse_pt(pmap, pv->pv_va, ptel3e, &free);
+#ifdef PV_STATS
 				freed++;
+#endif
 			}
 		}
 		PV_STAT(atomic_add_long(&pv_entry_frees, freed));