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


Groups > linux.kernel > #1408465

[PATCH] drbd: Replace if and BUG with BUG_ON

From Amitoj Kaur Chawla <amitoj1606@gmail.com>
Newsgroups linux.kernel
Subject [PATCH] drbd: Replace if and BUG with BUG_ON
Date 2016-05-28 15:10 +0200
Message-ID <rDMa6-Tn-9@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


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

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

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

csiph-web