Skip to contentSkip to conversation

arch/sparc: fix unused variable warning

PATCH In review [email protected] 4 participants 7 messages Jan 7 – Feb 2 SPARC + UltraSPARC (sparc/sparc64)

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 arch/sparc: fix unused variable warning

From: Alex Shi <[email protected]>

arch/sparc/mm/init_64.c: In function 'arch_hugetlb_valid_size':
arch/sparc/mm/init_64.c:361:24: warning: variable 'hv_pgsz_idx' set but not used [-Wunused-but-set-variable]

     361 |         unsigned short hv_pgsz_idx;
         |                        ^~~~~~~~~~~
Cc Matthew Wilcox <[email protected]>
Cc Lorenzo Stoakes <[email protected]>
Cc Qi Zheng <[email protected]>
Cc Dave Hansen <[email protected]>
Cc Zi Yan <[email protected]>
Cc Kevin Brodsky <[email protected]>
Cc Mike Rapoport <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Andreas Larsson <[email protected]>
Cc David S. Miller <[email protected]>
---
 arch/sparc/mm/init_64.c | 6 ------
 1 file changed, 6 deletions(-)
arch/sparc/mm/init_64.c +0 -6
index df9f7c444c39..ba19d23d4040 100644
@@ -358,30 +358,24 @@ static void __init pud_huge_patch(void)
 bool __init arch_hugetlb_valid_size(unsigned long size)
 {
 	unsigned int hugepage_shift = ilog2(size);
-	unsigned short hv_pgsz_idx;
 	unsigned int hv_pgsz_mask;
 
 	switch (hugepage_shift) {
 	case HPAGE_16GB_SHIFT:
 		hv_pgsz_mask = HV_PGSZ_MASK_16GB;
-		hv_pgsz_idx = HV_PGSZ_IDX_16GB;
 		pud_huge_patch();
 		break;
 	case HPAGE_2GB_SHIFT:
 		hv_pgsz_mask = HV_PGSZ_MASK_2GB;
-		hv_pgsz_idx = HV_PGSZ_IDX_2GB;
 		break;
 	case HPAGE_256MB_SHIFT:
 		hv_pgsz_mask = HV_PGSZ_MASK_256MB;
-		hv_pgsz_idx = HV_PGSZ_IDX_256MB;
 		break;
 	case HPAGE_SHIFT:
 		hv_pgsz_mask = HV_PGSZ_MASK_4MB;
-		hv_pgsz_idx = HV_PGSZ_IDX_4MB;
 		break;
 	case HPAGE_64K_SHIFT:
 		hv_pgsz_mask = HV_PGSZ_MASK_64K;
-		hv_pgsz_idx = HV_PGSZ_IDX_64K;
 		break;
 	default:
 		hv_pgsz_mask = 0;
Signature · 1 line
2.43.0
#1 lore raw
Quoted 6 lines · On Wed, Jan 07, 2026 at 06:41:44PM +0800, [email protected] wrote:

From: Alex Shi <[email protected]>

arch/sparc/mm/init_64.c: In function 'arch_hugetlb_valid_size':

   arch/sparc/mm/init_64.c:361:24: warning: variable 'hv_pgsz_idx' set but not used [-Wunused-but-set-variable]
     361 |         unsigned short hv_pgsz_idx;
         |                        ^~~~~~~~~~~

Looks like it's been unused since introduction in c7d9f77d33a7 ?

As such, why cc all these people who have absolutely nothing to do with it? Use your brain, not a stupid script.

Quoted 55 lines
Cc Matthew Wilcox <[email protected]>
Cc Lorenzo Stoakes <[email protected]>
Cc Qi Zheng <[email protected]>
Cc Dave Hansen <[email protected]>
Cc Zi Yan <[email protected]>
Cc Kevin Brodsky <[email protected]>
Cc Mike Rapoport <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Andreas Larsson <[email protected]>
Cc David S. Miller <[email protected]>
---
 arch/sparc/mm/init_64.c | 6 ------
 1 file changed, 6 deletions(-)
arch/sparc/mm/init_64.c +0 -6
index df9f7c444c39..ba19d23d4040 100644
@@ -358,30 +358,24 @@ static void __init pud_huge_patch(void)
 bool __init arch_hugetlb_valid_size(unsigned long size)
 {
 	unsigned int hugepage_shift = ilog2(size);
-	unsigned short hv_pgsz_idx;
 	unsigned int hv_pgsz_mask;
 
 	switch (hugepage_shift) {
 	case HPAGE_16GB_SHIFT:
 		hv_pgsz_mask = HV_PGSZ_MASK_16GB;
-		hv_pgsz_idx = HV_PGSZ_IDX_16GB;
 		pud_huge_patch();
 		break;
 	case HPAGE_2GB_SHIFT:
 		hv_pgsz_mask = HV_PGSZ_MASK_2GB;
-		hv_pgsz_idx = HV_PGSZ_IDX_2GB;
 		break;
 	case HPAGE_256MB_SHIFT:
 		hv_pgsz_mask = HV_PGSZ_MASK_256MB;
-		hv_pgsz_idx = HV_PGSZ_IDX_256MB;
 		break;
 	case HPAGE_SHIFT:
 		hv_pgsz_mask = HV_PGSZ_MASK_4MB;
-		hv_pgsz_idx = HV_PGSZ_IDX_4MB;
 		break;
 	case HPAGE_64K_SHIFT:
 		hv_pgsz_mask = HV_PGSZ_MASK_64K;
-		hv_pgsz_idx = HV_PGSZ_IDX_64K;
 		break;
 	default:
 		hv_pgsz_mask = 0;
Signature · 1 line
2.43.0
#2 lore raw
Quoted 11 lines · Matthew Wilcox
Quoted 6 lines · On Wed, Jan 07, 2026 at 06:41:44PM +0800,[email protected] wrote:

From: Alex Shi<[email protected]>

arch/sparc/mm/init_64.c: In function 'arch_hugetlb_valid_size':
arch/sparc/mm/init_64.c:361:24: warning: variable 'hv_pgsz_idx' set but not used [-Wunused-but-set-variable]
361 | unsigned short hv_pgsz_idx;
| ^~~~~~~~~~~

Looks like it's been unused since introduction in c7d9f77d33a7 ?

As such, why cc all these people who have absolutely nothing to do with it? Use your brain, not a stupid script.

Thanks for the feedback, Matthew. You're right—the script was too aggressive for such a localized fix.

I used 'scripts/get_maintainer.pl' without enough manual filtering. Besides '--nogit-fallback', are there specific parameters or workflows you recommend to keep the CC list lean for trivial cleanups like this?

I'll be more surgical with the CC list on the next version.

Thanks!

#3 lore raw
In reply to Matthew Wilcox
Quoted 11 lines · Matthew Wilcox
Quoted 6 lines · On Wed, Jan 07, 2026 at 06:41:44PM +0800,[email protected] wrote:

From: Alex Shi<[email protected]>

arch/sparc/mm/init_64.c: In function 'arch_hugetlb_valid_size':
arch/sparc/mm/init_64.c:361:24: warning: variable 'hv_pgsz_idx' set but not used [-Wunused-but-set-variable]
361 | unsigned short hv_pgsz_idx;
| ^~~~~~~~~~~

Looks like it's been unused since introduction in c7d9f77d33a7 ?

As such, why cc all these people who have absolutely nothing to do with it? Use your brain, not a stupid script.

Thanks for the feedback, Matthew. You're right—the script was too aggressive for such a localized fix.

I used scripts/get_maintainer.pl without enough manual filtering. Are there specific parameters or workflows you recommend to keep the CC list lean for trivial cleanups like this?

I'll be more surgical with the CC list on the next version.

Thanks
Alex

maintainer
#4 lore raw
In reply to [email protected]
Quoted 8 lines · On 2026-01-07 11:41, [email protected] wrote:

From: Alex Shi <[email protected]>

arch/sparc/mm/init_64.c: In function 'arch_hugetlb_valid_size':

   arch/sparc/mm/init_64.c:361:24: warning: variable 'hv_pgsz_idx' set but not used [-Wunused-but-set-variable]
     361 |         unsigned short hv_pgsz_idx;
         |                        ^~~~~~~~~~~

Did the kernel test robot also suggest a "Closes:" line as well? If so, please also add that.

Quoted 12 lines
Cc Matthew Wilcox <[email protected]>
Cc Lorenzo Stoakes <[email protected]>
Cc Qi Zheng <[email protected]>
Cc Dave Hansen <[email protected]>
Cc Zi Yan <[email protected]>
Cc Kevin Brodsky <[email protected]>
Cc Mike Rapoport <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Andreas Larsson <[email protected]>
Cc David S. Miller <[email protected]>
Quoted 1 line

---

It's helpful if you put changes between versions in between --- lines here.

Quoted 28 lines
 arch/sparc/mm/init_64.c | 6 ------
 1 file changed, 6 deletions(-)
arch/sparc/mm/init_64.c +0 -4
index df9f7c444c39..ba19d23d4040 100644
@@ -358,30 +358,24 @@ static void __init pud_huge_patch(void)
 bool __init arch_hugetlb_valid_size(unsigned long size)
 {
 	unsigned int hugepage_shift = ilog2(size);
-	unsigned short hv_pgsz_idx;
 	unsigned int hv_pgsz_mask;
 
 	switch (hugepage_shift) {
 	case HPAGE_16GB_SHIFT:
 		hv_pgsz_mask = HV_PGSZ_MASK_16GB;
-		hv_pgsz_idx = HV_PGSZ_IDX_16GB;
 		pud_huge_patch();
 		break;
 	case HPAGE_2GB_SHIFT:
 		hv_pgsz_mask = HV_PGSZ_MASK_2GB;
-		hv_pgsz_idx = HV_PGSZ_IDX_2GB;
 		break;
 	case HPAGE_256MB_SHIFT:
 		hv_pgsz_mask = HV_PGSZ_MASK_256MB;
-		hv_pgsz_idx = HV_PGSZ_IDX_256MB;
 		break;

arch/sparc/mm/init_64.c static void __init pud_huge_patch(void) · line 381

Quoted 10 lines
arch/sparc/mm/init_64.c +0 -2
 	case HPAGE_SHIFT:
 		hv_pgsz_mask = HV_PGSZ_MASK_4MB;
-		hv_pgsz_idx = HV_PGSZ_IDX_4MB;
 		break;
 	case HPAGE_64K_SHIFT:
 		hv_pgsz_mask = HV_PGSZ_MASK_64K;
-		hv_pgsz_idx = HV_PGSZ_IDX_64K;
 		break;
 	default:
 		hv_pgsz_mask = 0;

Other than the potentially missing Closes: line, LGTM.

Thanks,
Andreas

maintainer
#5 lore raw
Quoted 1 line

Other than the potentially missing Closes: line, LGTM.

Oh, and also, please use "sparc64:" instead of "arch/sparc:" in the subject. No need for "arch/" and this change is only for sparc64.

Thanks,
Andreas

#6 lore raw
In reply to Andreas Larsson
Quoted 9 lines · Andreas Larsson <[email protected]> 于2026年1月27日周二 00:44写道:
Quoted 7 lines · On 2026-01-07 11:41, [email protected] wrote:

From: Alex Shi <[email protected]>

arch/sparc/mm/init_64.c: In function 'arch_hugetlb_valid_size':

   arch/sparc/mm/init_64.c:361:24: warning: variable 'hv_pgsz_idx' set but not used [-Wunused-but-set-variable]
     361 |         unsigned short hv_pgsz_idx;
         |                        ^~~~~~~~~~~
Quoted 4 lines
Quoted 1 line

Did the kernel test robot also suggest a "Closes:" line as well? If so, please also add that.

No, I found this issue in a lkp report for my testing code on sparc. In that report, lkp just focus on my another issue.

Quoted 15 lines
Quoted 13 lines
Cc Matthew Wilcox <[email protected]>
Cc Lorenzo Stoakes <[email protected]>
Cc Qi Zheng <[email protected]>
Cc Dave Hansen <[email protected]>
Cc Zi Yan <[email protected]>
Cc Kevin Brodsky <[email protected]>
Cc Mike Rapoport <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Andreas Larsson <[email protected]>
Cc David S. Miller <[email protected]>
Quoted 1 line

---

Quoted 2 lines

It's helpful if you put changes between versions in between --- lines here.

Thanks for suggestion, will do it in next version.

Thanks
Alex