Re: [atishp04:ox_v5.14_working 4/13] arch/riscv/mm/init.c:714:83: warning: suggest braces around empty body in an 'if' statement

From: Alexandre Ghiti
Date: Fri Nov 05 2021 - 04:31:03 EST


On Fri, Nov 5, 2021 at 9:20 AM kernel test robot <lkp@xxxxxxxxx> wrote:
>
> tree: https://github.com/atishp04/linux ox_v5.14_working
> head: 9d2e326476c44eade0d6b7ee54c4eb8918d6aa94
> commit: 7c0cb480378b7fc7ccc693fc867c4d62c420732d [4/13] riscv: Implement sv48 support
> config: riscv-rv32_defconfig (attached as .config)
> compiler: riscv32-linux-gcc (GCC) 11.2.0
> reproduce (this is a W=1 build):
> wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> chmod +x ~/bin/make.cross
> # https://github.com/atishp04/linux/commit/7c0cb480378b7fc7ccc693fc867c4d62c420732d
> git remote add atishp04 https://github.com/atishp04/linux
> git fetch --no-tags atishp04 ox_v5.14_working
> git checkout 7c0cb480378b7fc7ccc693fc867c4d62c420732d
> # save the attached .config to linux build tree
> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross ARCH=riscv
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@xxxxxxxxx>
>
> All warnings (new ones prefixed by >>):
>
> arch/riscv/mm/init.c: In function 'create_fdt_early_page_table':
> >> arch/riscv/mm/init.c:714:83: warning: suggest braces around empty body in an 'if' statement [-Wempty-body]
> 714 | (uintptr_t)early_dtb_pmd, PUD_SIZE, PAGE_TABLE);
> | ^
>

Indeed, create_pud_mapping is an empty macro in 32-bit, I'll fix that
in the next version.

Thanks,

Alex

>
> vim +/if +714 arch/riscv/mm/init.c
>
> 696
> 697 /*
> 698 * Setup a 4MB mapping that encompasses the device tree: for 64-bit kernel,
> 699 * this means 2 PMD entries whereas for 32-bit kernel, this is only 1 PGDIR
> 700 * entry.
> 701 */
> 702 static void __init create_fdt_early_page_table(pgd_t *pgdir, uintptr_t dtb_pa)
> 703 {
> 704 #ifndef CONFIG_BUILTIN_DTB
> 705 uintptr_t pa = dtb_pa & ~(PMD_SIZE - 1);
> 706
> 707 create_pgd_mapping(early_pg_dir, DTB_EARLY_BASE_VA,
> 708 IS_ENABLED(CONFIG_64BIT) ? early_dtb_pgd_next : pa,
> 709 PGDIR_SIZE,
> 710 IS_ENABLED(CONFIG_64BIT) ? PAGE_TABLE : PAGE_KERNEL);
> 711
> 712 if (pgtable_l4_enabled)
> 713 create_pud_mapping(early_dtb_pud, DTB_EARLY_BASE_VA,
> > 714 (uintptr_t)early_dtb_pmd, PUD_SIZE, PAGE_TABLE);
> 715
> 716 if (IS_ENABLED(CONFIG_64BIT)) {
> 717 create_pmd_mapping(early_dtb_pmd, DTB_EARLY_BASE_VA,
> 718 pa, PMD_SIZE, PAGE_KERNEL);
> 719 create_pmd_mapping(early_dtb_pmd, DTB_EARLY_BASE_VA + PMD_SIZE,
> 720 pa + PMD_SIZE, PMD_SIZE, PAGE_KERNEL);
> 721 }
> 722
> 723 dtb_early_va = (void *)DTB_EARLY_BASE_VA + (dtb_pa & (PMD_SIZE - 1));
> 724 #else
> 725 /*
> 726 * For 64-bit kernel, __va can't be used since it would return a linear
> 727 * mapping address whereas dtb_early_va will be used before
> 728 * setup_vm_final installs the linear mapping. For 32-bit kernel, as the
> 729 * kernel is mapped in the linear mapping, that makes no difference.
> 730 */
> 731 dtb_early_va = kernel_mapping_pa_to_va(XIP_FIXUP(dtb_pa));
> 732 #endif
> 733
> 734 dtb_early_pa = dtb_pa;
> 735 }
> 736
>
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx