Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1408465 > unrolled thread

[PATCH] drbd: Replace if and BUG with BUG_ON

Started byAmitoj Kaur Chawla <amitoj1606@gmail.com>
First post2016-05-28 15:10 +0200
Last post2016-05-28 15:10 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH] drbd: Replace if and BUG with BUG_ON Amitoj Kaur Chawla <amitoj1606@gmail.com> - 2016-05-28 15:10 +0200

#1408465 — [PATCH] drbd: Replace if and BUG with BUG_ON

FromAmitoj Kaur Chawla <amitoj1606@gmail.com>
Date2016-05-28 15:10 +0200
Subject[PATCH] drbd: Replace if and BUG with BUG_ON
Message-ID<rDMa6-Tn-9@gated-at.bofh.it>
Replace if condition and BUG() with a BUG_ON having the conditional
expression of the if statement as argument.

The Coccinelle semantic patch used to make this change is as follows:
@ disable unlikely @ expression E,f; @@

(
  if (<+... f(...) ...+>) { BUG(); }
|
- if (unlikely(E)) { BUG(); }
+ BUG_ON(E);
)

@@ expression E,f; @@

(
  if (<+... f(...) ...+>) { BUG(); }
|
- if (E) { BUG(); }
+ BUG_ON(E);
)

Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
---
 drivers/block/drbd/drbd_state.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/block/drbd/drbd_state.c b/drivers/block/drbd/drbd_state.c
index 5a7ef78..154eb21 100644
--- a/drivers/block/drbd/drbd_state.c
+++ b/drivers/block/drbd/drbd_state.c
@@ -2160,8 +2160,7 @@ conn_set_state(struct drbd_connection *connection, union drbd_state mask, union
 			ns.disk = os.disk;
 
 		rv = _drbd_set_state(device, ns, flags, NULL);
-		if (rv < SS_SUCCESS)
-			BUG();
+		BUG_ON(rv < SS_SUCCESS);
 
 		ns.i = device->state.i;
 		ns_max.role = max_role(ns.role, ns_max.role);
-- 
1.9.1

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web