All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm/zsmalloc: replace if (cond) BUG() with BUG_ON()
@ 2020-12-12  3:26 ` Alex Shi
  0 siblings, 0 replies; 21+ messages in thread
From: Alex Shi @ 2020-12-12  3:26 UTC (permalink / raw)
  Cc: Minchan Kim, Nitin Gupta, Sergey Senozhatsky, Andrew Morton,
	linux-mm, linux-kernel

coccinelle reports some warning:
WARNING: Use BUG_ON instead of if condition followed by BUG.

It could be fixed by BUG_ON().

Reported-by: abaci@linux.alibaba.com
Signed-off-by: Alex Shi <alex.shi@linux.alibaba.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Nitin Gupta <ngupta@vflare.org>
Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org
---
 mm/zsmalloc.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index 7289f502ffac..1ea0605dbe94 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -1988,8 +1988,7 @@ static int zs_page_migrate(struct address_space *mapping, struct page *newpage,
 		head = obj_to_head(page, addr);
 		if (head & OBJ_ALLOCATED_TAG) {
 			handle = head & ~OBJ_ALLOCATED_TAG;
-			if (!testpin_tag(handle))
-				BUG();
+			BUG_ON(!testpin_tag(handle));
 
 			old_obj = handle_to_obj(handle);
 			obj_to_location(old_obj, &dummy, &obj_idx);
@@ -2036,8 +2035,8 @@ static int zs_page_migrate(struct address_space *mapping, struct page *newpage,
 		head = obj_to_head(page, addr);
 		if (head & OBJ_ALLOCATED_TAG) {
 			handle = head & ~OBJ_ALLOCATED_TAG;
-			if (!testpin_tag(handle))
-				BUG();
+			BUG_ON(!testpin_tag(handle));
+
 			unpin_tag(handle);
 		}
 	}
-- 
2.29.GIT


^ permalink raw reply related	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2021-01-07 17:45 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-12  3:26 [PATCH] mm/zsmalloc: replace if (cond) BUG() with BUG_ON() Alex Shi
2020-12-12  3:26 ` Alex Shi
2020-12-12  3:26 ` [PATCH] mm/mmap: " Alex Shi
2020-12-12  3:26   ` Alex Shi
2020-12-12  3:52   ` Alex Shi
2020-12-12  3:52     ` Alex Shi
2021-01-06  4:28     ` Hugh Dickins
2021-01-06  4:28       ` Hugh Dickins
2021-01-06  8:40       ` Alex Shi
2021-01-06 19:46       ` Andrew Morton
2021-01-06 20:09         ` Andrea Arcangeli
2021-01-06 20:18           ` Hugh Dickins
2021-01-06 20:18             ` Hugh Dickins
2021-01-06 20:42             ` Andrew Morton
2021-01-07 17:28             ` Vlastimil Babka
2021-01-07 17:36               ` Andrea Arcangeli
2021-01-07 17:45                 ` Vlastimil Babka
2021-01-06 20:10         ` Hugh Dickins
2021-01-06 20:10           ` Hugh Dickins
2021-01-07  8:33           ` Michal Hocko
2020-12-21 16:41 ` [PATCH] mm/zsmalloc: " Minchan Kim

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.