[PATCH v2] arch/sparc: fix unused variable warning

alexs@kernel.org posted 1 patch 1 month ago
arch/sparc/mm/init_64.c | 6 ------
1 file changed, 6 deletions(-)
[PATCH v2] arch/sparc: fix unused variable warning
Posted by alexs@kernel.org 1 month ago
From: Alex Shi <alexs@kernel.org>

   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;
         |                        ^~~~~~~~~~~

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Alex Shi <alexs@kernel.org>
Cc: sparclinux@vger.kernel.org
Cc: Matthew Wilcox  <willy@infradead.org>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Qi Zheng <zhengqi.arch@bytedance.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Zi Yan <ziy@nvidia.com>
Cc: Kevin Brodsky <kevin.brodsky@arm.com>
Cc: Mike Rapoport  <rppt@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andreas Larsson <andreas@gaisler.com>
Cc: David S. Miller <davem@davemloft.net>
---
 arch/sparc/mm/init_64.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
index df9f7c444c39..ba19d23d4040 100644
--- a/arch/sparc/mm/init_64.c
+++ b/arch/sparc/mm/init_64.c
@@ -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;
-- 
2.43.0
Re: [PATCH v2] arch/sparc: fix unused variable warning
Posted by Andreas Larsson 1 week, 5 days ago
On 2026-01-07 11:41, alexs@kernel.org wrote:
> From: Alex Shi <alexs@kernel.org>
> 
>    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;
>          |                        ^~~~~~~~~~~
> 
> Reported-by: kernel test robot <lkp@intel.com>

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

> Signed-off-by: Alex Shi <alexs@kernel.org>
> Cc: sparclinux@vger.kernel.org
> Cc: Matthew Wilcox  <willy@infradead.org>
> Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
> Cc: Qi Zheng <zhengqi.arch@bytedance.com>
> Cc: Dave Hansen <dave.hansen@linux.intel.com>
> Cc: Zi Yan <ziy@nvidia.com>
> Cc: Kevin Brodsky <kevin.brodsky@arm.com>
> Cc: Mike Rapoport  <rppt@kernel.org>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Andreas Larsson <andreas@gaisler.com>
> Cc: David S. Miller <davem@davemloft.net>
> ---

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

>  arch/sparc/mm/init_64.c | 6 ------
>  1 file changed, 6 deletions(-)
> 
> diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
> index df9f7c444c39..ba19d23d4040 100644
> --- a/arch/sparc/mm/init_64.c
> +++ b/arch/sparc/mm/init_64.c
> @@ -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;

Other than the potentially missing Closes: line, LGTM.

Thanks,
Andreas
Re: [PATCH v2] arch/sparc: fix unused variable warning
Posted by Alex Shi 6 days, 4 hours ago
Andreas Larsson <andreas@gaisler.com> 于2026年1月27日周二 00:44写道:
>
> On 2026-01-07 11:41, alexs@kernel.org wrote:
> > From: Alex Shi <alexs@kernel.org>
> >
> >    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;
> >          |                        ^~~~~~~~~~~
> >
> > Reported-by: kernel test robot <lkp@intel.com>
>
> 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.

>
> > Signed-off-by: Alex Shi <alexs@kernel.org>
> > Cc: sparclinux@vger.kernel.org
> > Cc: Matthew Wilcox  <willy@infradead.org>
> > Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
> > Cc: Qi Zheng <zhengqi.arch@bytedance.com>
> > Cc: Dave Hansen <dave.hansen@linux.intel.com>
> > Cc: Zi Yan <ziy@nvidia.com>
> > Cc: Kevin Brodsky <kevin.brodsky@arm.com>
> > Cc: Mike Rapoport  <rppt@kernel.org>
> > Cc: Andrew Morton <akpm@linux-foundation.org>
> > Cc: Andreas Larsson <andreas@gaisler.com>
> > Cc: David S. Miller <davem@davemloft.net>
> > ---
>
> It's helpful if you put changes between versions in between --- lines
> here.

Thanks for suggestion, will do it in next version.

Thanks
Alex
Re: [PATCH v2] arch/sparc: fix unused variable warning
Posted by Andreas Larsson 1 week, 5 days ago
> 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
Re: [PATCH v2] arch/sparc: fix unused variable warning
Posted by Matthew Wilcox 1 month ago
On Wed, Jan 07, 2026 at 06:41:44PM +0800, alexs@kernel.org wrote:
> From: Alex Shi <alexs@kernel.org>
> 
>    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.

> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Alex Shi <alexs@kernel.org>
> Cc: sparclinux@vger.kernel.org
> Cc: Matthew Wilcox  <willy@infradead.org>
> Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
> Cc: Qi Zheng <zhengqi.arch@bytedance.com>
> Cc: Dave Hansen <dave.hansen@linux.intel.com>
> Cc: Zi Yan <ziy@nvidia.com>
> Cc: Kevin Brodsky <kevin.brodsky@arm.com>
> Cc: Mike Rapoport  <rppt@kernel.org>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Andreas Larsson <andreas@gaisler.com>
> Cc: David S. Miller <davem@davemloft.net>
> ---
>  arch/sparc/mm/init_64.c | 6 ------
>  1 file changed, 6 deletions(-)
> 
> diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
> index df9f7c444c39..ba19d23d4040 100644
> --- a/arch/sparc/mm/init_64.c
> +++ b/arch/sparc/mm/init_64.c
> @@ -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;
> -- 
> 2.43.0
>
Re: [PATCH v2] arch/sparc: fix unused variable warning
Posted by Alex Shi 1 month ago

On 2026/1/7 22:46, Matthew Wilcox wrote:
> On Wed, Jan 07, 2026 at 06:41:44PM +0800,alexs@kernel.org wrote:
>> From: Alex Shi<alexs@kernel.org>
>>
>>     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
Re: [PATCH v2] arch/sparc: fix unused variable warning
Posted by Alex Shi 1 month ago

On 2026/1/7 22:46, Matthew Wilcox wrote:
> On Wed, Jan 07, 2026 at 06:41:44PM +0800,alexs@kernel.org wrote:
>> From: Alex Shi<alexs@kernel.org>
>>
>>     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!