From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============3846339923203140195==" MIME-Version: 1.0 From: kernel test robot Subject: [PATCH] RISC-V: fix bugon.cocci warnings Date: Fri, 17 Jul 2020 22:43:08 +0800 Message-ID: <20200717144308.GA116177@f2f7d3bee6c7> In-Reply-To: <202007172235.Fu1yWDZQ%lkp@intel.com> List-Id: To: kbuild@lists.01.org --===============3846339923203140195== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable CC: kbuild-all(a)lists.01.org TO: Atish Patra CC: Paul Walmsley CC: Palmer Dabbelt CC: Albert Ou CC: Anup Patel CC: Zong Li CC: Mike Rapoport CC: Kefeng Wang CC: Yash Shah CC: linux-riscv(a)lists.infradead.org From: kernel test robot arch/riscv/mm/init.c:258:3-6: WARNING: Use BUG_ON instead of if condition f= ollowed by BUG. Please make sure the condition has no side effects (see conditional BUG_ON = definition in include/asm-generic/bug.h) Use BUG_ON instead of a if condition followed by BUG. Semantic patch information: This makes an effort to find cases where BUG() follows an if condition on an expression and replaces the if condition and BUG() with a BUG_ON having the conditional expression of the if statement as argument. Generated by: scripts/coccinelle/misc/bugon.cocci Fixes: 4f1b8699833b ("RISC-V: Implement late mapping page table allocation = functions") Signed-off-by: kernel test robot --- tree: https://github.com/atishp04/linux uefi_riscv_5.9_v3 head: 6704b94c1a532f3c8d8fcdb9db87313a87350ec8 commit: 4f1b8699833b26397b5667e74d8bce5f12c487eb [16/22] RISC-V: Implement = late mapping page table allocation functions :::::: branch date: 15 hours ago :::::: commit date: 15 hours ago Please take the patch only if it's a positive warning. Thanks! init.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -254,8 +254,7 @@ static phys_addr_t __init alloc_pte(uint BUG_ON(!mmu_enabled); if (late_mapping) { vaddr =3D __get_free_page(GFP_KERNEL); - if (!vaddr || !pgtable_pte_page_ctor(virt_to_page(vaddr))) - BUG(); + BUG_ON(!vaddr || !pgtable_pte_page_ctor(virt_to_page(vaddr))); return __pa(vaddr); } else return memblock_phys_alloc(PAGE_SIZE, PAGE_SIZE); --===============3846339923203140195==--