[PATCH linux-5.15.y] RISC-V: Fix up a cherry-pick warning in setup_vm_final()

Palmer Dabbelt palmer at rivosinc.com
Sat Apr 29 15:43:31 PDT 2023


This triggers a -Wdeclaration-after-statement as the code has changed a
bit since upstream.  It might be better to hoist the whole block up, but
this is a smaller change so I went with it.

arch/riscv/mm/init.c:755:16: warning: mixing declarations and code is a C99 extension [-Wdeclaration-after-statement]
            unsigned long idx = pgd_index(__fix_to_virt(FIX_FDT));
                          ^
    1 warning generated.

Reported-by: kernel test robot <lkp at intel.com>
Link: https://lore.kernel.org/oe-kbuild-all/202304300429.SXZOA5up-lkp@intel.com/
Signed-off-by: Palmer Dabbelt <palmer at rivosinc.com>
---
I haven't even build tested this one, but it looks simple enough that I figured
I'd just send it.  Be warned, though: I broke glibc and missed a merged
conflict yesterday...
---
 arch/riscv/mm/init.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index e800d7981e99..8d67f43f1865 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -717,6 +717,7 @@ static void __init setup_vm_final(void)
 	uintptr_t va, map_size;
 	phys_addr_t pa, start, end;
 	u64 i;
+	unsigned long idx;
 
 	/**
 	 * MMU is enabled at this point. But page table setup is not complete yet.
@@ -735,7 +736,7 @@ static void __init setup_vm_final(void)
 	 * directly in swapper_pg_dir in addition to the pgd entry that points
 	 * to fixmap_pte.
 	 */
-	unsigned long idx = pgd_index(__fix_to_virt(FIX_FDT));
+	idx = pgd_index(__fix_to_virt(FIX_FDT));
 
 	set_pgd(&swapper_pg_dir[idx], early_pg_dir[idx]);
 #endif
-- 
2.40.0




More information about the linux-riscv mailing list