[PATCH linux-next] arch/nios2/mm/ioremap.c: fix bugon.cocci warnings

From: CGEL
Date: Sun Aug 22 2021 - 21:53:21 EST


From: Jing Yangyang <jing.yangyang@xxxxxxxxxx>

Use BUG_ON instead of a if condition followed by BUG.

Generated by: scripts/coccinelle/misc/bugon.cocci

Reported-by: Zeal Robot <zealci@xxxxxxxxxx>
Signed-off-by: Jing Yangyang <jing.yangyang@xxxxxxxxxx>
---
arch/nios2/mm/ioremap.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/arch/nios2/mm/ioremap.c b/arch/nios2/mm/ioremap.c
index fe821ef..67f73c1 100644
--- a/arch/nios2/mm/ioremap.c
+++ b/arch/nios2/mm/ioremap.c
@@ -32,8 +32,7 @@ static inline void remap_area_pte(pte_t *pte, unsigned long address,
end = address + size;
if (end > PMD_SIZE)
end = PMD_SIZE;
- if (address >= end)
- BUG();
+ BUG_ON(address >= end);
pfn = PFN_DOWN(phys_addr);
do {
if (!pte_none(*pte)) {
@@ -58,8 +57,7 @@ static inline int remap_area_pmd(pmd_t *pmd, unsigned long address,
if (end > PGDIR_SIZE)
end = PGDIR_SIZE;
phys_addr -= address;
- if (address >= end)
- BUG();
+ BUG_ON(address >= end);
do {
pte_t *pte = pte_alloc_kernel(pmd, address);

@@ -83,8 +81,7 @@ static int remap_area_pages(unsigned long address, unsigned long phys_addr,
phys_addr -= address;
dir = pgd_offset(&init_mm, address);
flush_cache_all();
- if (address >= end)
- BUG();
+ BUG_ON(address >= end);
do {
p4d_t *p4d;
pud_t *pud;
--
1.8.3.1